10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

9.6. Use the identity (9.4) to write a program that calculates any product<br />

xy for each of x, y having at most 15 binary bits, using only table lookups,<br />

add/subtracts, shifts, and involving no more than 2 21 bits of table storage.<br />

(Hint: The identity of the text can be used after one computes a certain lookup<br />

table.)<br />

9.7. Modify the binary divide algorithm (9.1.3) so that the value x mod N<br />

is also returned. Note that one could just use equation (9.5), but there is a<br />

way to use the local variables of the algorithm itself, and avoid the multiply<br />

by N.<br />

9.8. Prove that Arazi’s prescription (Algorithm 9.1.4) for simple modular<br />

multiplication indeed returns the value (xy) modN.<br />

9.9. Work out an algorithm similar to Algorithm 9.1.3 for bases B =2 k ,for<br />

k>1. Can this be done without explicit multiplies?<br />

9.10. Prove Theorem 9.2.1. Then prove an extension: that the difference<br />

y/R − (xR −1 )modN is one of {0,N,2N,...,(1 + ⌊x/(RN)⌋)N}.<br />

9.11. Prove Theorem 9.2.4. Then develop and prove a corollary for powering,<br />

of which equation (9.8) would be the special case of cubing.<br />

9.12. In using the Montgomery rules, one has to precompute the residue<br />

N ′ =(−N −1 )modR. In the case that R =2 s and N is odd, show that the<br />

Newton iteration (9.10) with a set at −N, with initial value −N mod 8, and<br />

the iteration thought of as a congruence modulo R, quickly converges to N ′ .<br />

In particular, show how the earlier iterates can be performed modulo smaller<br />

powers of 2, so that the total work involved, assuming naive multiplication and<br />

squaring, can be effected with about 4/3 ofans-bit multiply and about 1/3 of<br />

an s-bit square operation. Since part of each product involved is obliterated<br />

by the mod reduction, show how the work involved can be reduced further.<br />

Contrast this method with a traditional inverse calculation.<br />

9.13. We have indicated that Newton iterations, while efficient, involve<br />

adroit choices of initial values. For the reciprocation of real numbers, equation<br />

(9.10), describe rigorously the range of initial guesses for a given positive real<br />

a, such that the Newton iteration indeed causes x to converge to 1/a.<br />

9.14. We have observed that with Newton iteration one may “divide using<br />

multiplication alone.” It turns out that one may also take square roots in the<br />

same spirit. Consider the coupled Newton iteration<br />

x = y =1;<br />

do {<br />

x = x/2+(1+a)y/2;<br />

y =2y − xy 2 ;<br />

y =2y − xy 2 ;<br />

}

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

Saved successfully!

Ooh no, something went wrong!