<<

The Euclidean Investigation Module MATH 558: Introductory Modern

In this module, we introduce and study the , a remarkably fast, systematic way of finding the greatest common of any two positive . The backbone of Euclidean Algorithm is repeated use of the Algorithm, which is just a formal way of writing out the and when dividing one by another:

The . Let a and b be integers, where a > 0. Then there exist unique integers q and r, where 0 ≤ r < a, such that b = aq + r.

Here, we are “dividing” the integer b by a; perhaps unsurprisingly, we call q the quotient, and r the remainder. For instance, a = 5 “goes into” b = 17 three times with two “left over,” so the conclusion of the Division Algorithm can be written out simply as 17 = 5 · 3 + 2 just as we computed 5)17 in grade school. Notice that q = 3 and r = 2 here. Of course, the 17 = 5 · 2 + 7 and 17 = 5 · 4 + (−3) also hold, but the “” 7 and −3 do not satisfy the requirement that 0 ≤ r < 5. Indeed, the Division Algorithm states that there is only one remainder in this range!

0. For each pair of integers a, b below, find q and r as in the Division Algorithm.

(a) a = 11, b = 64. () a = 101, b = 0. (b) a = 64, b = 11. (d) a = 3, b = −11.

1. What does the remainder r equal whenever a divides b? Prove it!

This problem shows that the Division Algorithm is closely related to the notion of an integer dividing another. This will eventually help us apply the Division Algorithm iteratively to compute greatest common . To start, consider the following lemma:

Lemma. Given integers a, b, q, and r, suppose that

b = aq + r.

If d is an integer for which d | a and d | b, then d | r.

Do you think this lemma is true? Use your work in Problem 0 to investigate its statement. MATH 558: Modern Algebra 2

2. Prove the lemma by following these steps: (a) Write out, using equations, what the hypotheses d | a and d | b, and the conclusion, d | r, mean. Specify which values in your equations are integers! (b) Plug your results from (a) into the b = aq + r. (c) Solve for r in the resulting equation. Can you show the desired conclusion? Make sure to justify that certain value(s), if necessary, are integers!

Now that you’ve proved the lemma, let’s use it! It says, in particular, that if we apply the Division Algorithm to positive integers a < b (why is this assumption natural?), then then every common divisor of a and b is also a divisor of the remainder r. Remarkably, we can extend this to show that the of b and a coincides with a and r, i.e., the GCD of the highlighted values in b = aq + r is the same as in b = aq + r.

3. Given a, b, q, r ∈ Z such that b = aq + r, use the lemma to prove that any common divisor of a and b is a common divisor of a and r; then explain why (a, b) = (a, r).

Factor each integer a and b into a of primes, and use your answer to find (a, b). Record your answers for later (you don’t need to turn in these ). • a = 24 and b = 60. • a = 156 and b = 198. • a = 5 159 and b = 455. (Use a and your own cleverness!) As the integers get larger, did you notice that it becomes harder and harder to compute GCDs “by hand”? In fact, when we submit an online payment using our credit card , the security depends on the computational difficulty of factoring large integers! Thus, your work in Problem 3, which allows one to replace the problem of finding the GCD of two integers with two smaller integers, is beneficial. This idea leads to the following algorithm:

The Euclidean Algorithm. Given positive integers a and b for which a < b, apply the Division Algorithm successively:

b = aq + r where 0 ≤ r < a

a = rq1 + r1 where 0 ≤ r1 < r

r = r1q2 + r2 where 0 ≤ r2 < r1

r1 = r2q3 + r3 where 0 ≤ r3 < r2

r2 = r3q4 + r4 where 0 ≤ r4 < r3 . .

rn−1 = rnqn+1 + rn+1 where 0 ≤ rn+1 < rn . .

Then the greatest common divisor of a and b equals the last nonzero remainder. MATH 558: Modern Algebra 3

Example (Applying the Euclidean Algorithm). Recall that you found (5 159, 455) by hand earlier. (It was a pain, right?) Let’s apply the Euclidean Al- gorithm instead. Since it is always the larger integer, we take b = 5 159, and then a = 455. Applying the Division Algorithm to a and b, we first write

5 159 = 455 · 11 + 154. (1)

Next, we replace b with a, and a with the remainder; i.e., shift the underlined in blue left, into the spots that are underlined in red (we do nothing with the quotient!):

455 = 154 · 2 + 147. (2)

Shifting again, we replace the leftmost integers with 154 and 147, respectively:

154 = 147 · 1 +7 , (3)

and finally, 147 =7 · 21 + 0. Since the remainder is zero, we see that the last nonzero remainder we 7. Hence, we conclude that the greatest common divisor of 5 159 and 455 is 7. Is this what you found earlier? Which method did you find to be faster? More straighforward?

Now, why does the Euclidean Algorithm actually compute the GCD of a and b? Well the condition in the Division Algorithm on the remainder tells us that

a > r > r1 > r2 > ···

are all nonnegative integers, so eventually one remainder must be zero and the chain must terminate by the Principle of Infinite Descent–there is no infinite descending chain of natural numbers–which is equivalent to the Well-ordering Principle (see homework problem 2.34!). Suppose that rn 6= 0, while rn+1 = 0. Then Problem 3, applied, iteratively, tells us that

(a, b) = (a, r) = (r, r1) = (r1, r2) = ··· = (rn, rn+1) = (rn, 0) = rn.

and (a, b) is certainly the last nonzero remainder! Notice that to prove the string of inequal- ities above carefully (instead of using our “and so on and so forth” idea), we would need to apply the Principle of . Think about how this would go!

4. Explain why (rn, 0) = rn above. 5. Use the Euclidean Algorithm to compute (a, b), showing all your steps: (a) a = 1001 and b = 1309. (b) a = 89 and b = 144.

Next, we turn to an useful theorem, which can be justified via the Euclidean Algorithm: MATH 558: Modern Algebra 4

B´ezout’stheorem. Given any two integers a and b, let d denote their greatest com- mon divisor. Then there exist integers x and y such that

ax + by = d.

We often refer to the equation in the conclusion of B´ezout’stheorem as B´ezout’sidentity.

6. Use “guess and check” to find x, y in B´ezout’sIdentity given the values of a, b. (a) a = 5, b = 8 (b) a = 12, b = 20 (c) a = −100, b = 14

In the first two problems above, both a, b are positive, yet one of x, y is negative. Think about why this is the case! The Euclidean Algorithm allows us to create an algorithm for finding the values of x, y in B´ezout’sidentity, often called the Extended Euclidean Algorithm (EEA). We’ll explain it through an example, using the integers a = 455 and b = 5 159 from our above example.

Example (Extended Euclidean Algorithm). Let’s again take a = 455 and b = 5 159; we found that (5 159, 455) = 7 in our earlier example. Our goal is to find integers x and y for which B´ezout’sidentity holds:

5 159x + 455y = 7.

To begin the EEA, start with equation (3) in our example, and solve for 7, the GCD:

7 = 154 − 147 · 1.

Notice that we are writing 7 in terms of the integers underlined in (3). We don’t want to expand! Instead, we solve for the remainder, 147 in (2), i.e., 147 = 455 − 154 · 2, and substitute this for 147 in the equation above:

7 = 154 − (455 − 154 · 2) · 1.

We then expand, writing the right-hand side as the sum of multiples of the integers underlined in red in equation (2):

7 = 154 − 455 + 154 · 2 = 154 · 3 + 455 · (−1).

Finally, we continue this process using (1):

7 = (5 159 − 455 · 11) · 3 + 455 · (−1) = 5 159 · 3 + 455 · (−33 + −1) = 5 159 · 3 + 455 · (−34)

So that x = 3 and y = −34 is a solution! MATH 558: Modern Algebra 5

Now that we have seen an example of applying the EEA, let’s try it out!

7. For each pair a, b, perform the EEA to find the values for x, y in B´ezout’sTheorem, applied to a, b.. (a) a, b from Problem 5(a) (b) a, b from Problem 5(b) (c) a = 100, b = 101.

Now that we have a handle on the EEA, maybe it is clearer to see that it can help us prove B´ezout’sTheorem. Given any two integers a, b, we can first find (a, b) by performing the Euclidean Algorithm and getting equations

b = aq + r where 0 ≤ r < a

a = rq1 + r1 where 0 ≤ r1 < r

r = r1q2 + r2 where 0 ≤ r2 < r1

r1 = r2q3 + r3 where 0 ≤ r3 < r2

r2 = r3q4 + r4 where 0 ≤ r4 < r3 . .

rn−1 = rnqn+1 + rn+1 where 0 ≤ rn+1 < rn . .

Since this algorithm must terminate, resulting in a zero remainder, we can use the second- to-last equation to solve for the GCD of a and b. Then substituting the values of the remainder of the other equations, from bottom to top, we can find appropriate x and y!