19.07.2014 Views

Contents - Student subdomain for University of Bath

Contents - Student subdomain for University of Bath

Contents - Student subdomain for University of Bath

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

122 CHAPTER 4. MODULAR METHODS<br />

Figure 4.5: “Early termination” g.c.d. code<br />

then D ′ := D<br />

D := Algorithm 40(C, D, p, N);<br />

if D = D ′ #We may have found the answer<br />

then E := pp(D);<br />

if E divides A and B<br />

then return E;<br />

# Otherwise this was a false alert, and we continue as normal.<br />

4.1.5 Computing the g.c.d.: early success<br />

While Algorithm 14 will detect a g.c.d. <strong>of</strong> 1 early, it will otherwise compute as<br />

far as the Landau–Mignotte bound if the g.c.d. is not 1. While this may be<br />

necessary, it would be desirable to terminate earlier if we have already found<br />

the g.c.d. This is easily done by replacing the line<br />

then D := Algorithm 40(C, D, p, N);<br />

by the code in Figure 4.5. We should note that we return an E which divides<br />

the inputs, and is derived from modular images, and there<strong>for</strong>e has to be the<br />

greatest common divisor by Corollary 10.<br />

4.1.6 An alternative correctness check<br />

So far we have suggested computing the putative g.c.d. G, then checking that<br />

it really divides both, and relying on Corollary 10 to say that G is there<strong>for</strong>e a<br />

greatest common divisor. An alternative approach is to compute the co-factors,<br />

i.e. A ′ such that A = A ′ G and B ′ such that B = B ′ G at the same time, and<br />

use these as the check. So let us assume that modular gcd c<strong>of</strong>actors returns<br />

a triple [G, A ′ , B ′ ] modulo p. The Algorithm (15) is given in Figure 4.6, and the<br />

diagram in Figure 4.4 is still relevant.<br />

Observation 5 It is tempting to conjecture that we do not need to make both<br />

the multiplication checks at the end, but this is false: consider A = H, B =<br />

H + 3p 1 · · · p k , when the algorithm will find H as the putative g.c.d., since the<br />

Landau–Mignotte bound will ignore the large extra term in B, and only the<br />

multiplication check <strong>for</strong> B will detect this.<br />

Observation 6 Early termination can perfectly well be applied to this variant:<br />

at any time gA = DA ′ and gB = DB ′ over the integers, we can finish.<br />

Observation 7 We have presented this material as if there were a choice between<br />

one large prime (Algorithm 13) and several small ones (Algorithms 14,<br />

15). In practice, <strong>of</strong> course, a computer regards all numbers less than 32 bits (and

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

Saved successfully!

Ooh no, something went wrong!