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,yZ.
a=13, b=3, 13(1)+3(2)=7

n=qd+r
r=nqd

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,bZ. At least one is in S. By the theorem, S has a least element. Call it s. By the division algorithm:

r=aqs

0rs.

d=GCD(a,b).

r=aqs=aq(ax+by)=a(1qx)+b(qy)

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

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

da and db. Therefore, dax+by for any x,yZ.
Thus
ds
ds
So d=s since sd. 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=142(6)=142(34(2)14)=5(14)+(2)34=(5)(82(2)34)+(2)34=5(82)+(12)34=5(82)+(12)(1161(82))=(12)116+(17)82=(12)116+(17)(1981(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=511(851(51))=2(51)1(85)=2(1361(85))1(85)=2(136)3(85)=2(136)3(2211(136))17=5(136)3(221)

Let a,bZ. 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,cZ. If abc and GCD(a,b)=1 then ac. If aC and bc and GCD(a,b)=1 then abc.



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=151(271(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=61(233(6))=4(6)1(23)=4(291(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=912(1331(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=652(1562(65))=5(65)2(156)=5(2211(156))2(156)=5(221)7(156)=5(221)7(3771(221))=12(221)7(377)=12(221)+7(377)

E 18.2
Proof.

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

E 18.3
a)
Proof.
Let a,bZ, b0. 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,bZ, b0. 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

cd 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, cd per Theorem 18.5.

Since we have cd and dc, it follows that c=d.

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

(=>) We work directly. Assume dn. Thus n=dk for some kZ. Since d=GCD(a,b), per Theorem 18.5, d=ax+by for some x,yZ. 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,fZ.

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 dn if and only if n is a linear combination of a and b.

E 18.5
Proof.
Let a,b,nZ. Assume that GCD(a,b)=1. We aim to prove that if ca and db then GCD(c,d) = 1. We work directly. Since GCD(a,b)=1, 1=ax+by for some x,yZ. Assume that c|a and d|b. Thus a=mc and b=nd for some m,nZ. 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,bZ, 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,yZ

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 b0 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=rs, where both fractions are in lowest terms, meaning GCD(r,s)=GCD(r,s)=1.

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

Since r and s are relatively prime, as are r and s, the numerators rs and rs are also relatively prime to their respective denominators, or in other words, GCD(rs,ss)=1 and GCD(rs,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=rs.

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

Now that it is established that s=s, the equation rs=rs 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,bZ.
Let d=GCD(a,b).
Let a=ad and b=bd, 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 ad and bd respectively, we have

abd=adbdd=abd2d=abd

abd is clearly a multiple of both a=ad and b=bd as it contains both as factors.

Let m be any common multiple of a=ad and b=bd. Then, m=adb1=bda1=dab1=dba1 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=ak and a1=bk for some integer k.

Substituting back into the equation m=dab1=dba1, we get

m=da(ak)=db(bk)=d2a2k=d2b2k=abd2k

Dividing by k on both sides, we get:

mk=abd2=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.