The Extended Euclidean Algorithm and the Fundamental Theorem

advertisement
CS4390/5390 Fall 2013 Shirley Moore, Instructor September 19 Class The Extended Euclidean Algorithm and the Fundamental Theorem of Arithmetic €
€
Theorem 1. Let a and b be integers with greatest common divisor d. Then there exist integers s and t such that d = sa + tb. Proof. We will show that the conclusion is true for all of the remainders, not just d. Clearly the conclusion is true for r0 = a since a = 1⋅ a + 0⋅ b and for r1 = b since b = 0⋅ a +1⋅ b . Consider rk+1 for k > 1. Assume the conclusion is true for preceding remainders, so that there exist integers sk −1 and t k −1 such that rk −1 = sk −1a + t k −1b and integers sk and tk such that rk = sk a +€t k b . Recall equation (1) from last class, which can be rearranged to rk +1 = rk −1 − qk rk . Then €
€
€
rk+1 = (sk −1a + tk −1b) − qk (sk a + tk b) €
= (sk −1 − qk sk )a + (tk −1 − qk tk )b
€
QED Exercise 1. Now let’s try it. Fill in the following table. Remainders Quotients s t r0 = a = 97 s0 = 1 t0 = 0 r1 = b = 18 q1 = 5 s1 = 0 t1 = 1 Write down your observations. Exercise 2. Write and test a MATLAB function called EXTENDED_EUCLID that inputs integers a and b and returns s and t such that sa + tb = gcd(a,b). Exercise 3. Write and test a MATLAB function called FULL_EXTENDED_EUCLID that inputs integers a and b and returns the remainder, quotient, s, and t sequences (or modify your function from Exercise 2 to have this option). 1 €
Corollary to Theorem 1. If d divides mn and d is relatively prime to m, then d divides n. Proof. Because d divides mn, mn = du for some integer u. Because d and m are relatively prime, gcd(d,m) = 1 and by Theorem 1, there exist integers s and t such that 1 = sd + tm. Multiplying each side by n and replacing mn by du, we obtain n = nsd + ntm = nsd + dut = d(ns + ut). Since ns + ut is an integer, d divides n. QED We are now in a position to prove the Fundamental Theorem of Arithmetic, which states that there exists a unique prime factorization for every positive integer. It is easy to show by induction that every positive integer has a prime factorization. But to prove the factorization is unique, we need the gcd machinery we have just built. Theorem 2 (Fundamental Theorem of Arithmetic). Every positive integer can be factored into primes, and the factorization is unique except for order. Proof by induction. The base case is 2. 2 is prime and can be factored in only one way: 2. Now suppose every integer less than n has a unique prime factorization. Let n = p1 p2  pr = q1q2 qs where the pi and qj are primes that are not necessarily distinct, but where the second factorization is not simply a reordering of the first. If p1 were equal to any of the qj, then we could divide each product by p1 to get a positive integer smaller than n with a non-­‐unique prime factorization. So p1 is relatively prime to each qj. Since p1 divides n, it must divide q1q2 qs . Since p1 is relatively prime to q1, by the Corollary to Theorem 1, it must divide q2q3 qs . But p1 is also relatively prime to q2, so it divides q3q4 qs . Continuing in this manner, we find that p1 divides qs, a contradiction since qs is prime. QED €
€
€
2 
Download