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.

2.3. GREATEST COMMON DIVISORS 49<br />

a 4 = −3722432068x − 8393738634,<br />

a 5 = 1954124052188.<br />

Here the numbers are much smaller, and indeed it can be proved that the<br />

coefficient growth is only linear in the step number. a 2 has a content <strong>of</strong> 3,<br />

which the primitive p.r.s. would eliminate, but this content in fact disappears<br />

later. Similarly a 3 has a content <strong>of</strong> 5, which again disappears later. Hence we<br />

have the following result.<br />

Theorem 6 Let R be a g.c.d. domain. Then there is an algorithm to calculate<br />

the g.c.d. <strong>of</strong> polynomials in R[x]. If the original coefficients have length bounded<br />

by B, the length at the i-th step is bounded by iB.<br />

This algorithm is the best method known <strong>for</strong> calculating the g.c.d., <strong>of</strong> all those<br />

based on Euclid’s algorithm applied to polynomials with integer coefficients. In<br />

chapter 4 we shall see that if we go beyond these limits, it is possible to find<br />

better algorithms <strong>for</strong> this calculation.<br />

2.3.3 The Extended Euclidean Algorithm<br />

We can in fact do more with the Euclidean algorithm. Consider the following<br />

variant <strong>of</strong> Algorithm 1, where we have added a few extra lines, marked (*),<br />

manipulating (a, b), (c, d) and (e, e ′ ).<br />

Algorithm 4 (Extended Euclidean)<br />

Input: f, g ∈ K[x].<br />

Output: h ∈ K[x] a greatest common divisor <strong>of</strong> f and g, and c, d ∈ K[x] such<br />

that cf + dg = h.<br />

i := 1;<br />

if deg(f) < deg(g)<br />

then a 0 := g; a 1 := f;<br />

(*) a := 1; d := 1; b := c := 0<br />

else a 0 := f; a 1 := g;<br />

(*) c := 1; b := 1; a := d := 0<br />

while a i ≠ 0 do<br />

(*) #Loop invariant: a i = af + bg; a i−1 = cf + dg;<br />

a i+1 = rem(a i−1 , a i );<br />

q i :=the corresponding quotient: #a i+1 = a i−1 − q i a i<br />

(*) e := c − q i a; e ′ := d − q i b; #a i+1 = ef + e ′ g<br />

i := i + 1;<br />

(*) (c, d) = (a, b);<br />

(*) (a, b) = (e, e ′ )<br />

return (a i−1 , c, d);<br />

The comments essentially <strong>for</strong>m the pro<strong>of</strong> <strong>of</strong> correctness. In particular, if f and<br />

g are relatively prime, there exist c and d such that<br />

cf + dg = 1 : (2.10)

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

Saved successfully!

Ooh no, something went wrong!