The Euclidean Algorithm and Linear Combinations, Study notes of Algorithms and Programming

The Euclidean Algorithm, which is a method to find the greatest common divisor (GCD) of two integers, as well as a specific pair of numbers r,s such that ra + sb = (a,b). a definition of GCD, Theorem 1.2, and a worksheet with warm-up exercises and solutions. It also explores the relationship between (a,b), (b,r), and common divisors of a, b, and r. useful for students studying number theory and algebra.

Typology: Study notes

2021/2022

Uploaded on 05/11/2023

ambau
ambau 🇺🇸

4.5

(11)

250 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Math 412. Worksheet on The Euclidean Algorithm.
Professors Jack Jeffries and Karen E. Smith
DEFI NI TI ON : The greatest common divisor or GCD of two integers a, b is the largest integer
dsuch that d|aand d|b. We often write (a, b)for the GCD of aand b.
THE OR EM 1.2: Let aand bbe integers, and assume that aand bare not both zero. There exist
r, s Zsuch that ra +sb = (a, b).
The Euclidean algorithm is a method to find the GCD of two integers, as well as a specific
pair of numbers r, s such that ra +sb = (a, b). We will say that an expression of the form
ra +sb with r, s Zis a linear combination of aand b.
A. WARMU P:
(1) List all factors1of 18? List all factors of 24. Find (18,24).
(2) For aZ, what is (a, a)? What is (a, 7a)? If a > 0, what is the GCD of aand 0?
ANSWER:
(1) The factors of 18 are 1,±2,±3,±6,±9,±18}.
The factors of 24 are 1,±2,±3,±4,±6,±8,±12,±24}. The GCD is 6.
(2) (a, a) = |a|,(a, 7a) = |a|and (a, 0) = |a|.
B. Suppose we had two numbers aand b, and we did the division algorithm to get a=bq +r
for some q, r Z.
(1) Show that if dis a common divisor of band r, then dis a common divisor of aand b.
What does this say about the relationship between (a, b)and (b, r)?
(2) Show that if dis a common divisor of aand b, then dis a common divisor of band r.
What does this say about the relationship between (b, r)and (a, b)?
(3) Show that (a, b)=(b, r).
(4) How might (3) make the computation of (a, b)easier?
ANSWER:
(1) Let dbe a common factor of band r. So there exist k1, k2Zsuch that b=dk1and r=dk2.
Substitute a=bq +r=dk1q+dk2=d(k1q+k2). Since k1q+k2Z, we have d|a. Thus dis
a common factor of aand b. We conclude that (b, r)(a, b)since the greatest common factor of b
and ris at least some common factor of aand b, but not necessarily the greatest.
(2) Let dbe a common factor of band a. So there exist k1, k2Zsuch that b=dk1and ra =dk2.
Substitute r=abq =dk1dk2q=d(k1k2q). So similarly, d|r. Thus dis a common factor
of rand b. By a similar argument, we conclude that (b, r)(a, b)
(3) This follows from (1) and (2), since both (b, r)(a, b)and (b, r)(a, b).
(4) The integers aand bmay have an out-of-control number of digits, but assuming (without loss of
generality) that a>b, then we know that the pair b, r will be “smaller”. So instead we can compute
the GCD (b, r), which is the same as the one we started with (a, b).
1Factor is another word for divisor. Completely synonymous.
pf2

Partial preview of the text

Download The Euclidean Algorithm and Linear Combinations and more Study notes Algorithms and Programming in PDF only on Docsity!

Math 412. Worksheet on The Euclidean Algorithm.

Professors Jack Jeffries and Karen E. Smith

DEFINITION: The greatest common divisor or GCD of two integers a, b is the largest integer

d such that d|a and d|b. We often write (a, b) for the GCD of a and b.

THEOREM 1.2: Let a and b be integers, and assume that a and b are not both zero. There exist

r, s ∈ Z such that ra + sb = (a, b).

The Euclidean algorithm is a method to find the GCD of two integers, as well as a specific

pair of numbers r, s such that ra + sb = (a, b). We will say that an expression of the form

ra + sb with r, s ∈ Z is a linear combination of a and b.

A. WARMUP:

(1) List all factors^1 of 18? List all factors of 24. Find (18, 24).

(2) For a ∈ Z, what is (a, a)? What is (a, 7 a)? If a > 0 , what is the GCD of a and 0?

ANSWER:

(1) The factors of 18 are {± 1 , ± 2 , ± 3 , ± 6 , ± 9 , ± 18 }. The factors of 24 are {± 1 , ± 2 , ± 3 , ± 4 , ± 6 , ± 8 , ± 12 , ± 24 }. The GCD is 6. (2) (a, a) = |a|, (a, 7 a) = |a| and (a, 0) = |a|.

B. Suppose we had two numbers a and b, and we did the division algorithm to get a = bq + r

for some q, r ∈ Z.

(1) Show that if d is a common divisor of b and r, then d is a common divisor of a and b.

What does this say about the relationship between (a, b) and (b, r)?

(2) Show that if d is a common divisor of a and b, then d is a common divisor of b and r.

What does this say about the relationship between (b, r) and (a, b)?

(3) Show that (a, b) = (b, r).

(4) How might (3) make the computation of (a, b) easier?

ANSWER:

(1) Let d be a common factor of b and r. So there exist k 1 , k 2 ∈ Z such that b = dk 1 and r = dk 2. Substitute a = bq + r = dk 1 q + dk 2 = d(k 1 q + k 2 ). Since k 1 q + k 2 ∈ Z, we have d|a. Thus d is a common factor of a and b. We conclude that (b, r) ≤ (a, b) since the greatest common factor of b and r is at least some common factor of a and b, but not necessarily the greatest. (2) Let d be a common factor of b and a. So there exist k 1 , k 2 ∈ Z such that b = dk 1 and ra = dk 2. Substitute r = a − bq = dk 1 − dk 2 q = d(k 1 − k 2 q). So similarly, d|r. Thus d is a common factor of r and b. By a similar argument, we conclude that (b, r) ≥ (a, b) (3) This follows from (1) and (2), since both (b, r) ≥ (a, b) and (b, r) ≤ (a, b). (4) The integers a and b may have an out-of-control number of digits, but assuming (without loss of generality) that a > b, then we know that the pair b, r will be “smaller”. So instead we can compute the GCD (b, r), which is the same as the one we started with (a, b).

(^1) Factor is another word for divisor. Completely synonymous.

C. Consider the following computation, which you can assume is accurate:

(i) 524 = 148 · 3 + 80 0 ≤ 80 < 148

(ii) 148 = 80 · 1 + 68 0 ≤ 68 < 80

(iii) 80 = 68 · 1 + 12 0 ≤ 12 < 68

(iv) 68 = 12 · 5 + 8 0 ≤ 8 < 12

(v) 12 = 8 · 1 + 4 0 ≤ 4 < 8

(vi) 8 = 4 · 2 + 0

(1) What is going on on each individual line?

(2) How does each line relate to the previous one?

(3) Prove that

ANSWER: This shows several applications of the technique in B. We use repeated instances of the division algorithm to replace each pair (a, b) with a more manageable pair (b, r) where b is the smaller of the two original integers and r is the remainder upon dividing the larger by the smaller. We keep doing this until the remainder becomes 0. This eventually tells us that the GCD is of 524 and 148 is 4.

D. The computation above is an example of the Euclidean algorithm applied to 524 and 148.

Use the Euclidean algorithm to find (1003, 456).

ANSWER:

1003 =2 × 456 + 91 so (1003, 456) = (456, 91). 456 =91 × 5 + 1 so (456, 91) = (91, 1). 91 =91 × 1 + 0 so (91, 1) = (1, 0) = 1

So (1003, 456) = 1. Note that we could have stopped one step earlier, since obviously (91, 1) = 1.

E. Let’s return to the example in part 3.

(1) Use equation (i) to express 80 as a linear combination of 524 and 148.

(2) Use equation (ii) to express 68 as a linear combination of 148 and 80. Use this and the

previous part to express 68 as a linear combination of 524 and 148.

(3) Express 12 as a linear combination of 524 and 148.

(4) Express 4 = (524, 148) as a linear combination of 524 and 148.

ANSWER:

(1) 80 = 524 − 3 × 148.

(2) 68 = 148 − 80. So 68 = 148 − (524 − 3 × 148) = −524 + 4 × 148 (3) 12 = 80 − 68 = 524 − 3 × 148 − (−524 + 4 × 148) = 2 × 524 − 7 × 148 (4) 4 = 12 − 8 = 12 − (68 − 5 × 12) = −68 + 6 × 12 = −(−524 + 4 × 148) + 6 × (2 × 524 − 7 × 148) = 13 × 524 − 46 × 148

F. Express (1003, 456) as a linear combination of 1003 and 456.

ANSWER: 1 = − 5 × 1003 + 11 × 456