18 - The extended Euclidean algorithm

In class practice

An (integral) linear combination of two integers a and b is a number of the form ax+by where x,y∈Z.
a=13, b=3, 13(1)+3(−2)=7

n=qd+r
r=n−qd

Theorem: Let a and b be integers, not both equal to 0. The smallest positive integral linear combination of a and b is GCD(a,b).

Outline of proof:
Let s be the set of positive integral linear combinations of a and b. Not both 0. Let a,b∈Z. At least one is in S. By the theorem, S has a least element. Call it s. By the division algorithm:

r=a−qs

0≤r≤s.

d=GCD(a,b).

r=a−qs=a−q(ax+by)=a(1−qx)+b(−qy)

Therefore r∈S or r=0. Since r<s and s is the least element, r∉S. Thus r=0.

=> a = qs
=> s | a
Similar s | b. So s is a common divisor s≥d.

d∣a and d∣b. Therefore, d∣ax+by for any x,y∈Z.
Thus
d∣s
d≤s
So d=s since s≤d. Thus the GCD is the smallest positive integral linear combination of a and b.

GCD(512, 314)

512 = 1(314) + 198
314 = 1(198) + 116
198 = 1(116) + 82
116 = 1(82) + 34
82 = 2(34) + 14
34 = 2(14) + 6
14 = 2(6) + 2
6 = 3(2) + 0
198 = 512 - 1(314)
116 = 314 - 1(198)
82 = 198 - 1(116)
34 = 116 - 1(82)
14 - 82 - 2(34)
6 = 34 - 2(14)
2 = 14 - 2(6)
2=14−2(6)=14−2(34−(2)14)=5(14)+(−2)⋅34=(5)⋅(82−(2)⋅34)+(−2)⋅34=5(82)+(−12)34=5(82)+(−12)(116−1(82))=(−12)⋅116+(17)⋅82=(−12)⋅116+(17)(198−1(116))=(17)⋅198+(−29)⋅116=(−29)⋅314+46(198)=(−29)314+(46)(512−(1)314)=(46)512+(−75)314

E 18.9
GCD(221, 136) = 17
221 = 1(136) + 85
136 = 1(85) + 51
85 = 1(51) + 34
51 = 1(34) + 17
34 = 2(17) + 0

Remainders:
85 = 221 - 1(36)
51 = 136 - 1(85)
34 = 85 - 1(51)
17 = 51 - 1(34)

17=51−1(85−1(51))=2(51)−1(85)=2(136−1(85))−1(85)=2(136)−3(85)=2(136)−3(221−1(136))17=5(136)−3(221)

Let a,b∈Z. GCD(a, b) = 1 iff ax+by=1 for some x,y.

Def GCD(a,b)=1, we say a and b are relatively prime.

Theorem. Let a,b,c∈Z. If a∣bc and GCD(a,b)=1 then a∣c. If a∣C and b∣c and GCD(a,b)=1 then ab∣c.



HW 18

E 18.1
a) GCD(15, 27)
27 = 1(15) + 12
15 = 1(12) + 3
12 = 4(3) + 0
GCD = 3

Remainders:
12 = 27 - 1(15)
3 = 15 - 1(12)

Linear Combination of GCD

3=15−1(27−1(15))=2(15)+1(−27)

b) GCD(29, 23)
29 = 1(23) + 6
23 = 3(6) + 5
6 = 1(5) + 1
5 = 5(1) + 0
GCD = 1

Remainders
6 = 29 - 1(23)
5 = 23 - 3(6)
1 = 6 - 1(5)

Linear combination of the GCD

1=6−1(23−3(6))=4(6)−1(23)=4(29−1(23))−1(23)=4(29)−5(23)=4(29)+5(−23)

c) GCD(91, 133)
133 = 1(91) + 42
91 = 2(42) + 7
42 = 6(7) + 0
GCD = 7

Remainders:
42 = 133 - 1(91)
7 = 91 - 2(42)

Linear combination:

7=91−2(133−1(91))=3(91)−2(133)=3(91)+2(−133)

d)
GCD(221, 377)
377 = 1(221) + 156
221 = 1(156) + 65
156 = 2(65) + 26
65 = 2(26) + 13
26 = 2(13) + 0
GCD = 13

Remainders:
156 = 377 - 1(221)
65 = 221 - 1(156)
26 = 156 - 2(65)
13 = 65 - 2(26)

Linear combination:

13=65−2(156−2(65))=5(65)−2(156)=5(221−1(156))−2(156)=5(221)−7(156)=5(221)−7(377−1(221))=12(221)−7(377)=12(221)+7(−377)

E 18.2
Proof.

Let a,n∈Z. Assume that GCD(a,n)=1. We aim to prove that there is some b such that ab≡1 (mod n) or in other words ab−1=nk for some b,k∈Z. By theorem 18.10, we see that 1=ab+nk since GCD(a,n)=1. Solving for nk yields ab−1=nk which satisfies the definition of modulus. Thus ab≡1 (mod) n. ◻

E 18.3
a)
Proof.
Let a,b∈Z, b≠0. Let d=GCD(a,b).
We aim to prove GCD(a,bd)=1.

Since d is the greatest common divisor of a and b, we can write a=dm and b=dn, where m and n are integers. Since d divides a and b, it also divides any linear combination of a and b. Therefore, we have:

bd=dnd=n

Now, we show that GCD(a,n)=1. Suppose there exists a common divisor c of a and n such that c>1. Then, c divides both a and n, so it must also divide b. However, this contradicts the fact that d=GCD(a,b). Therefore, GCD(a,n)=1, which completes the proof. ◻

b)
Let a,b∈Z, b≠0. Let d=GCD(a,b). We work directly. Assume c is a positive common divisor of a and b, and c=ax+by. We aim to prove c=d

c≤d since c is also a common divisor of a and b but possibly not larger than d.

Per our assumption, given that c is a common divisor of a and b and c=ax+by, c≥d per Theorem 18.5.

Since we have c≤d and d≤c, it follows that c=d. ◻

E 18.4
Let a,b,n∈Z, and fix d=GCD(a,b). We aim to prove that d∣n iff n is a linear combination of a and b.

(=>) We work directly. Assume d∣n. Thus n=dk for some k∈Z. Since d=GCD(a,b), per Theorem 18.5, d=ax+by for some x,y∈Z. We find

n=d(ax+by)=a(dx)+b(dy)

Thus n is a linear combination of a and b.
(<=) We work directly. Assume n is a linear combination of a and b. Then n=ax+by for some x,y in Z.

Because d is the greatest common divisor of a and b, we can say a=de and b=df for some e,f∈Z.

Substituting a and b into our expression for n gives:

n=ax+by=dex+dfy=d(ex+fy)

This demonstrates that d divides n, as ex+fy is an integer.

Therefore, we have proven that d∣n if and only if n is a linear combination of a and b. ◻

E 18.5
Proof.
Let a,b,n∈Z. Assume that GCD(a,b)=1. We aim to prove that if c∣a and d∣b then GCD(c,d) = 1. We work directly. Since GCD(a,b)=1, 1=ax+by for some x,y∈Z. Assume that c|a and d|b. Thus a=mc and b=nd for some m,n∈Z. We find

ax+by=1(mc)x+(nd)y=1c(mx)+d(ny)=1

Since (mx) and (ny) are integers, c and d are linear combinations of 1. Per Theorem 18.5, if we can write 1 as a linear combination of c and d, GCD(c, d) = 1 since 1 is the smallest possible positive integer linear combination of two integers. ◻

E 18.6
a) Let a,b∈Z, not both zero. Let d=GCD(a,b). We want to show that GCD(ad,bd)=1. Since d divides both a and b, ad and bd are integers.

By the definition of GCD, we have:

d=ax+by for some x,y∈Z

Dividing by d on both sides:

1=(ad)x+(bd)y

From Theorem 18.10, 1 = GCD(ad, bd). ◻

b)
Fix d=GCD(a,b).

Let r=ad and s=bd. By definition, r and s are integers.

Using part (a) of the proof, we have established that GCD(ad,bd)=GCD(r,s)=1.

Therefore, any rational number ab can be represented as a fraction rs such that GCD(r,s)=1. ◻

c)
Proof.

We know that b≠0 as given, but we don't know whether b is positive or negative. d=GCD(a,b) will always be positive, so we need to redefine s to be positive regardless of the sign of b.

We can modify the definitions as follows:

  1. If b>0, let r=ad and s=bd.
  2. If b<0, let r=−ad and s=−bd.

In either case, we guarantee that s>0, since d>0 and b is either positive (by definition 1) or negative (which then gets multiplied by -1 in definition 2). ◻

d)
Proof.

We have that rs=r′s′, where both fractions are in lowest terms, meaning GCD(r,s)=GCD(r′,s′)=1.

Assume by way of contradiction that s≠s′. Then, both rs and r′s′ could be multiplied to get a common denominator ss′, resulting in rs′ss′=r′sss′.

Since r and s are relatively prime, as are r′ and s′, the numerators rs′ and r′s are also relatively prime to their respective denominators, or in other words, GCD(rs′,ss′)=1 and GCD(r′s,ss′)=1.

But we already have two fractions that are equal and have the same denominator ss′, and both have their numerator and denominator relatively prime. This implies that the numerators are equal, i.e., rs′=r′s.

Now suppose that s>s′. Then rs′=r′s<rs, which is a contradiction. Similarly, if s<s′, then rs′=r′s>rs, which is also a contradiction. Therefore, we must have s=s′.

Now that it is established that s=s′, the equation rs=r′s′ simplifies to r=r′. ◻

E 18.7
a) LCM(12, 18) = 36
b) LCM(21, 35) = 105
c)

Proof.
We aim to prove LCM(a, b) = abd.
Let a,b∈Z.
Let d=GCD(a,b).
Let a=a′d and b=b′d, where a′ and b′ are integers. Since d is the greatest common divisor of a and b, it follows that gcd(a′,b′)=1 per exercise 18.6.

We want to first show that abd is a common multiple of both a and b.
Substituting a and b with a′d and b′d respectively, we have

abd=a′d⋅b′dd=a′b′d2d=a′b′d

a′b′d is clearly a multiple of both a=a′d and b=b′d as it contains both as factors.

Let m be any common multiple of a=a′d and b=b′d. Then, m=a′db1=b′da1=da′b1=db′a1 for some integers a1 and b1. As gcd(a′,b′)=1, we know that a′ divides b1 and b′ divides a1. So we can write b1=a′k and a1=b′k for some integer k.

Substituting back into the equation m=da′b1=db′a1, we get

m=da′(a′k)=db′(b′k)=d2a′2k=d2b′2k=a′b′d2k

Dividing by k on both sides, we get:

mk=a′b′d2=abd

Since k is an integer and m is a common multiple of a and b, mk is also a common multiple of a and b.

Therefore, abd divides every other positive common multiple of a and b.

Hence, abd is the least common multiple of a and b. ◻