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.

4.1. GCD IN ONE VARIABLE 123<br />

Figure 4.6: Algorithm 15<br />

Algorithm 15 (Modular GCD (Alternative small prime version))<br />

Input: A, B polynomials in Z[x].<br />

Output: G := gcd(A, B), A ′ , B ′ with A = A ′ G, B = B ′ G.<br />

M :=Landau_Mignotte_bound(A, B);<br />

g := gcd(lc(A), lc(B));<br />

p := find_prime(g);<br />

[D, A ′ , B ′ ] := modular_gcd_c<strong>of</strong>actors(A, B, p);<br />

if deg(D) = 0 then return [1,A,B]<br />

D := gD # g is our guess at the leading coefficient <strong>of</strong> the g.c.d.<br />

N := p; # N is the modulus we will be constructing<br />

while N < 2M repeat<br />

p := find_prime(g);<br />

[C, A 1 , B 1 ] := modular_gcd_c<strong>of</strong>actors(A, B, p);<br />

if deg(C) = deg(D)<br />

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

A ′ := Algorithm 40(A 1 , A ′ , p, N);<br />

B ′ := Algorithm 40(B 1 , B ′ , p, N);<br />

N := pN;<br />

else if deg(C) < deg(D)<br />

# C proves that D is based on primes <strong>of</strong> bad reduction<br />

if deg(C) = 0 then return [1,A,B]<br />

D := C; A ′ = A 1 ; B ′ = B 1 ;<br />

N := p;<br />

else #D proves that p is <strong>of</strong> bad reduction, so we ignore it<br />

if gA = DA ′ and gB = DB ′<br />

then G := pp(D) gcd(cont(A), cont(B)); # Theorem 5<br />

A ′ := A ′ /lc(G); B ′ := B ′ /lc(G); # Fix leading coefficients<br />

return [G, A ′ , B ′ ]<br />

else all primes must have been bad, and we start again

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

Saved successfully!

Ooh no, something went wrong!