88. A constructive proof of Bézout’s Lemma

The preceding proof of Bézout’s Lemma does not tell us how to calculate the integers $a$ and $b$ for which $am + bn = \mathrm{GCD}(m,n)$. For example, see how fast you can find integers $a$ and $b$ for which $13a + 21b = 1$. (See Exercise 107.3.4.)

We now give a modification of the Euclidean algorithm which constructs integers $a$ and $b$ for which $\mathrm{GCD}(m,n) = am + bn$. The Euclidean algorithm is given as program 65.1, page 93, based on Theorem 65.1, which says that for any integers $m$ and $n$, $\mathrm{GCD}(m,n) = \mathrm{GCD}(n, m \operatorname{mod} n)$. Program 65.1 starts with $M$ and $N$ and repeatedly replaces $N$ by $M \operatorname{mod} N$ and $M$ by $N$. The last value of $N$ before it becomes 0 is the GCD. This lemma shows how being an integral linear combination is preserved by that process:

88.1 Lemma

Let $m$ and $n$ be positive integers.

B.1 The integers $m$ and $n$ are integral linear combinations of $m$ and $n$.

B.2 If $u$ and $v$ are integral linear combinations of $m$ and $n$ and $v \neq 0$, then $u \operatorname{mod} v$ is also an integral linear combination of $m$ and $n$.

Proof B.1 is trivial: $m = 1 \times m + 0 \times n$ and $n = 0 \times m + 1 \times n$. As for B.2, suppose $u = wm + xn$ and $v = ym + zn$. Let $u = qv + r$ with $0 \leq r < v$, so $r = u \operatorname{mod} v$. Then

$$r = u - qv = wm + xn - q(ym + zn) = (w - qy)m + (x - qz)n$$

so $r$ is an integral linear combination of $m$ and $n$, too.

88.2 A method for calculating the Bézout coefficients

We now describe a method for calculating the Bézout coefficients based on Lemma 88.1. Given positive integers $m$ and $n$ with $d = \mathrm{GCD}(m,n)$, we calculate integers $a$ and $b$ for which $am + bn = d$ as follows: Make a table with columns labeled $u$, $v$, $w$ and $w = am + bn$.

  1. Put $u = m$, $v = n$, $w = m \operatorname{mod} n$ in the first row, and in the last column put the equation $w = m - (m \operatorname{div} n)n$. Note that this equation expresses $m \operatorname{mod} n$ in the form $am + bn$ (here $a = 1$ and $b = -m \operatorname{div} n$).

  2. Make each succeeding row $u'$, $v'$, $w'$, $w' = a'm + b'n$ by setting $u' = v$ (the entry under $v$ in the preceding row), $v' = w$ and $w' = v \operatorname{mod} w$, and solving for $a'$ and $b'$ by using the equation $w' = u' - (u' \operatorname{div} v')v'$ and the equations in the preceding rows. Note that the entry in the last column always expresses $w$ in terms of the original $m$ and $n$, not in terms of the $u$ and $v$ in that row.

  3. Continue this process until the entry under $w$ is $\mathrm{GCD}(m,n)$ (this always happens because the first three columns in the process constitute the Euclidean algorithm).

88.2.1 Example The following table shows the calculation of integers $a$ and $b$ for which $100a + 36b = 4$.

$$\begin{array}{rrrl} u & v & w & \\ 100 & 36 & 28 & 28 = 100 - 2 \cdot 36 \quad \text{Note that } 100 \operatorname{div} 36 = 2 \\ 36 & 28 & 8 & 8 = 36 - 28 = 36 - (100 - 2 \cdot 36) = 3 \cdot 36 - 100 \\ 28 & 8 & 4 & 4 = 28 - 3 \cdot 8 = 100 - 2 \cdot 36 - 3(3 \cdot 36 - 100) = 4 \cdot 100 - 11 \cdot 36 \end{array}$$

so that $a = 4$, $b = -11$.

88.3 Constructive and nonconstructive

The two proofs we have given for Theorem 87.2 illustrate a common phenomenon in mathematics. The first proof is nonconstructive; it shows that the requisite integers $a$ and $b$ exist but does not tell you how to get them. The second proof is constructive; it is more complicated but gives an explicit way of constructing $a$ and $b$.

88.3.1 Exercise Express $a$ as an integral linear combination of $b$ and $c$, or explain why this cannot be done.

$$\begin{array}{rrr} a & b & c \\ 2 & 12 & 16 \\ 4 & 12 & 16 \\ 2 & 26 & 30 \\ 4 & 26 & 30 \\ -2 & 26 & 30 \\ 1 & 51 & 100 \end{array}$$

(Answer on page 247.)

88.3.2 Exercise Express 1 as an integral linear combination of 13 and 21.

88.3.3 Exercise (M. Leitman) Suppose $a$, $b$, $m$ and $n$ are integers. Prove that if $m$ and $n$ are relatively prime and $am + bn = e$, then there are integers $a'$ and $b'$ for which $a'm + b'n = e + 1$. (Answer on page 247.)

88.3.4 Exercise Prove without using the Fundamental Theorem of Arithmetic that if $\mathrm{GCD}(m,n) = 1$ and $m \mid nr$ then $m \mid r$. (Use Bézout’s Lemma, page 128.)

88.3.5 Exercise Suppose that $a$, $b$ and $c$ are positive integers for which $c = 12a - 8b$. Show that $\mathrm{GCD}(a,b) \leq \frac{c}{4}$.

88.3.6 Exercise Prove that the following rule of inference is valid (use Bézout’s Lemma, page 128).

$$e \mid m, e \mid n \vdash e \mid \mathrm{GCD}(m,n)$$

(It follows that the statement “$e \leq d$” in Rule (85.2) can be replaced by “$e \mid d$”.)

88.3.7 Exercise (hard) Prove that if $d$ is an integral linear combination of $m$ and $n$ then there are an infinite number of different pairs of integers $a$ and $b$ for which $d = am + bn$.

88.3.8 Exercise Use Bézout’s Lemma (page 128) to prove Corollary 64.2 on page 90 without using the Fundamental Theorem of Arithmetic.

Pages 128–130 of the book (PDF).