2.5.9 · D3Number Theory (Intermediate)

Worked examples — Bézout's identity

2,551 words12 min readBack to topic

Before anything else, recall the single equation everything on this page serves:


The scenario matrix

Every Bézout problem falls into one of these cells. The examples below are tagged with the cell they cover.

# Cell (case class) What is unusual Covered by
C1 Both positive, the "standard" run Ex 1
C2 Coprime pair, answer must equal Ex 2
C3 One number divides the other Euclid stops in one line Ex 3
C4 A negative input signs of coefficients flip Ex 4
C5 One input is zero degenerate — no algorithm needed Ex 5
C6 Modular inverse (why we care) rephrasing Ex 6
C7 Word problem (jugs of water) translate story → equation Ex 7
C8 Exam twist: solve with scale + shift a solution Ex 8

The tools we lean on: the Euclidean algorithm (repeated division to find the GCD), back-substitution (the extended version that also returns ), and the shift rule for generating all solutions. Each is why-justified as it appears.


Example 1 — C1: both positive, GCD bigger than 1

Figure — Bézout's identity

The figure shows what "smallest positive combination" means: mark every value on the number line and the nearest one above zero lands exactly on .


Example 2 — C2: a coprime pair (GCD = 1)


Example 3 — C3: one number divides the other


Example 4 — C4: a negative input


Example 5 — C5: one input is zero (degenerate)


Example 6 — C6: modular inverse (why coprimality matters)


Example 7 — C7: word problem (two water jugs)


Example 8 — C8: exam twist, solve with

Figure — Bézout's identity

The figure plots the solution pairs for several : they land on a straight line of step — the lattice of all Diophantine solutions.


Recall Which cell am I in? (quick decision table)

Is one input ? ::: Cell C5 — the non-zero number is the GCD; the other coefficient is free. Does one number divide the other exactly? ::: Cell C3 — Euclid ends in one line; use style. Is ? ::: Cell C2/C6 — you can reach ; the coefficient of is 's modular inverse. Is there a negative input? ::: Cell C4 — solve with absolute values, then push the sign into the variable. Right-hand side isn't the GCD? ::: Cell C8 — check , scale by , then shift by .