10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9.5 Large-integer multiplication 473<br />

It is natural to ask whether there exist extended forms of such recursivegcd<br />

algorithms, along the lines, say, of Algorithm 2.1.4 or Algorithm 9.4.3, to<br />

effect asymptotically fast modular inversion. The answer is yes, as explained<br />

in [Stehlé and Zimmermann 2004] and [Cesari 1998].<br />

9.5 Large-integer multiplication<br />

When numbers have, say, hundreds or thousands (even millions) of decimal<br />

digits, there are modern methods for multiplication. In practice, one finds<br />

that the classical “grammar-school” methods just cannot effect multiplication<br />

in certain desired ranges. This is because, of course, the bit complexity of<br />

grammar-school multiply of two size-N numbers is O ln 2 N . It turns out that<br />

by virtue of modern transform and convolution techniques, this complexity<br />

can be brought down to<br />

O(ln N(ln ln N)(lnlnlnN)),<br />

as we discuss in more detail later in this section.<br />

The art of large-integer arithmetic has, especially in modern times,<br />

sustained many revisions. Just as with the fast Fourier transform (FFT)<br />

engineering literature itself, there seems to be no end to the publication of<br />

new approaches, new optimizations, and new applications for computational<br />

number theory. The forest is sufficiently thick that we have endeavored in<br />

this section to render an overview rather than an encyclopedic account of this<br />

rich and exotic field. An interesting account of multiplication methods from<br />

a theoretical point of view is [Bernstein 1997], and modern implementations<br />

are discussed, with historical references, in [Crandall 1994b, 1996a].<br />

9.5.1 Karatsuba and Toom–Cook methods<br />

The classical multiplication methods can be applied on parts of integers to<br />

speed up large-integer multiplication, as observed by Karatsuba. His recursive<br />

scheme assumes that numbers be represented in split form<br />

x = x0 + x1W,<br />

with x0,x1 ∈ [0,W − 1], which is equivalent to base-W representation, except<br />

that here the base will be about half the size of x itself. Note that x is<br />

therefore a “size-W 2 ” integer. For two integers x, y of this approximate size,<br />

the Karatsuba relation is<br />

where<br />

xy =<br />

t + u<br />

2<br />

− v + t − u<br />

2 W + vW 2 , (9.17)<br />

t =(x0 + x1)(y0 + y1),<br />

u =(x0 − x1)(y0 − y1),<br />

v = x1y1,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!