Skip to main content
Logo image

Section 4.4 Bézout’s Identity

The following theorem follows from the Euclidean Algorithm (Algorithm 4.17) and Theorem 3.20.
The values s and t from Theorem 4.25 are called the cofactors of a and b. To find s and t for any a and b, we would use repeated substitutions on the results of the Euclidean Algorithm (Algorithm 4.17). This works because the algorithm connects a and b to the gcd(a,b) by a series of related equations.
When gcd(a,b)=amodb, we can easily find the values of s and t from Theorem 4.25. In this course we limit our computations to this case. We demonstrate this in the following examples.

Example 4.26. Bézout’s identity for gcd(28,12).

We find values for s and t from Theorem 4.25 for a:=28 and b:=12.
First, we compute the gcd(28,12) using the Euclidean Algorithm (Algorithm 4.17). In the table we give the values of the variables at the end of step (1) in each iteration of the loop.
step r a b
Input 28 12
(1) 28mod12=4 12 4
(1) 12mod4=0 1 0
Output 4
So the gcd(28,12)=28mod12=4. To find s and t with (s28)+(t12)=gcd(28,12)=4 we need
  • the remainder from the first iteration of the loop r:=amodb=28mod12=4 and
  • the quotient q:=adivb=28div12=2.
Now we can write a in the form a=bq+r:
28=122+4
We write a=(bq)+r in slightly more complicated way, namely as (1a)=(qb)+r. Solving (1a)=(qb)+r for r we get (1a)(qb)=r. To bring this into the desired form (sa)+(tb)=gcd(a,b) we write (qb) as +((q)b) and obtain
(1a)+((q)b)=r
Plugging in our values for a, b, q, and r we obtain
(128)+((2)12)=4
So s=1 and t=2.
The cofactors s and t are not unique. Using the numbers from this example, the values s=5 and t=12 would also have been a solution since then
(s28)+(t12)(528)+(1212)=140+144=4.

Problem 4.27. Bézout’s identity for gcd(5,2).

Find integers s and t such that s5+t2=gcd(5,2).
Solution.
Although it is easy to see that the greatest common divisor of 5 and 2 is 1, we need some of the intermediate result from the Euclidean algorithm to find s and t. Following the Euclidean algorithm (Algorithm 4.17) for the input values a:=5 and b:=2 we get:
step r a b
Input 5 2
(1) 5mod2=1 2 1
(1) 2mod1=0 1 0
Output 1
We have confirmed that gcd(5,2)=1. Since the Euclidean algorithm terminated after 2 iterations we can use the same trick as in Example 4.26. We get
r:=5mod2=1
and
q:=5div2=2
Plugging these into the formula
(1a)+((q)b)=r
we get
(15)+((2)2)=1.
We read of the values s:=1 and t:=2. Note that t=(5div2).
In Checkpoint 4.28 work through a similar example.

Checkpoint 4.28. Find the cofactors.

Let a:=780 and b:=96.
Follow these step to compute the greatest common divisor of a and b and the integers s and t such that (sa)+(tb)=gcd(a,b).
First we compute gcd(a,b) using the Euclidean algorithm.
In addition to the remainder we also compute the quotient.
Let a1:=b= and let b1:=amodb= and let q1:=a div b=
Let a2:=b1= and let b2:=a1modb1=
We have computed gcd(780,96)=a2=b1=.
Now write a=(bq1)+b1:
=( )+
Rearranging the values, write b1=(1a)+((q1)b) :
=(1 )+()
Read off the values of s and t. Recall that b1=gcd(a,b).
With s= and t= we have gcd(a,b)=(sa)+(tb).
The pattern observed in the solution of the problem and Checkpoint 4.28 can be generalized. We obtain the following theorem.
The condition gcd(a,b)=amodb in Theorem 4.29 means that in the Euclidean algorithm the instructions in the repeat until loop are only executed twice.
We apply Theorem 4.29 in the solution of a problem.

Problem 4.30. Find s and t such that s63+t14=gcd(63,14).

For a=63 and b=14 find integers s and t such that sa+tb=gcd(a,b).
Solution.
We find the greatest common divisor of 63 and 14 using the Euclidean Algorithm.
  1. 63mod14=7
  2. 14mod7=0
So the Euclidean Algorithm ends after running through the loop twice and returns gcd(63,14)=7. By Theorem 4.29. we have s=1 and t=(63div14)=4.
We check whether the result is correct:
163+(4)14=63+(56)=7.
Apply Theorem 4.29 in the solution of Checkpoint 4.31.

Checkpoint 4.31. Find the cofactors.

Compute the greatest common divisor of a:=10 and b:=3 and the integers s and t such that (sa)+(tb)=gcd(a,b).
We have gcd(10,3)=. Now find the numbers s and t whose existence is guaranteed by Bezout’s identity.
With s= and t= we have (sa)+(tb)=gcd(a,b).
In the video in Figure 4.32 we summarize the results from above and give some additional examples.
Figure 4.32. Bézout’s Identity by Matt Farmer and Stephen Steward