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.

524 Chapter 9 FAST ALGORITHMS FOR LARGE-INTEGER ARITHMETIC<br />

algorithm that inputs x, y and requires only four internal variables to calculate<br />

the inverse of x.<br />

9.32. Can Algorithm 9.4.4 be generalized to composite p?<br />

9.33. Prove that Algorithms 9.4.4 and 9.4.5 work. For the latter algorithm,<br />

it may help to observe how one inverts a pure power of two modulo a Mersenne<br />

prime.<br />

9.34. In the spirit of the special-case mod Algorithm 9.2.13, which relied<br />

heavily on bit shifting, recast Algorithm 9.4.5 to indicate the actual shifts<br />

required in the various steps. In particular, not only the mod operation but<br />

multiplication by a power of two is especially simple for Mersenne prime<br />

moduli, so use these simplifications to rewrite the algorithm.<br />

9.35. CanoneperformagcdontwonumberseachofsizeN in polynomial<br />

time (i.e., time proportional to some power lg α N), using a polynomial number<br />

of parallelized processors (i.e., lg β N of them)? An interesting reference is<br />

[Cesari 1998], where it is explained that it is currently unknown whether such<br />

a scheme is possible.<br />

9.36. Write out a clear algorithm for a full integer multiplication using the<br />

Karatsuba method. Make sure to show the recursive nature of the method,<br />

and also to handle properly the problem of carry, which must be addressed<br />

when any final digits overflow the base size.<br />

9.37. Show that a Karatsuba-like recursion on the (D =3)Toom–Cook<br />

method (i.e., recursion on Algorithm 9.5.2) yields integer multiplication of<br />

two size-N numbers in what is claimed in the text, namely, O((ln N) ln 5/ ln 3 )<br />

word multiplies. (All of this assumes that we count neither additions nor the<br />

constant multiplies as they would arise in every recursive [Reconstruction]<br />

step of Algorithm 9.5.2.)<br />

9.38. Recast the [Initialize] step of Algorithm 9.5.2 so that the ri,si can be<br />

most efficiently calculated.<br />

9.39. We have seen that an acyclic convolution of length N can be effected<br />

in 2N −1 multiplies (aside from multiplications by constants; e.g., a term such<br />

as 4x can be done with left-shift alone, no explicit multiply). It turns out that<br />

a cyclic convolution can be effected in 2N − d(N) multiplies, where d is the<br />

standard divisor function (the number of divisors of n), while a negacyclic can<br />

be effected in 2N − 1 multiplies. (These wonderful results are due chiefly to<br />

S. Winograd; see the older but superb collection [McClellan and Rader 1979].)<br />

Here are some explicit related problems:<br />

(1) Show that two complex numbers a + bi, c + di may be multiplied via only<br />

three real multiplies.<br />

(2) Work out an algorithm that performs a length-4 negacyclic in nine<br />

multiplies, but with all constant mul or div operations being by powers of

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

Saved successfully!

Ooh no, something went wrong!