A Diophantine equation is an equation where only integer solutions count. The simplest kind is linear: $ax + by = c$. Graphed, it is a straight line; the question is which points on it have whole-number coordinates. Bézout's identity answers it completely.
Theorem. Let $d = \gcd(a, b)$, with $a$ and $b$ not both $0$. The equation $ax + by = c$ has an integer solution exactly when $d \mid c$. If $(x_0, y_0)$ is one solution, then all solutions are $$x = x_0 + \frac{b}{d}\,t, \qquad y = y_0 - \frac{a}{d}\,t, \qquad t \in \mathbb{Z}.$$
Why it works
Worked example: All solutions
- $d = \gcd(12, 18) = 6$, and $6 \mid 30$, so solutions exist.
- Bézout: $12 \cdot (-1) + 18 \cdot 1 = 6$. Multiply by $30/6 = 5$: $x_0 = -5$, $y_0 = 5$.
- Steps: $b/d = 18/6 = 3$ and $a/d = 12/6 = 2$. So $x = -5 + 3t$, $y = 5 - 2t$.
- Check $t = 2$: $(1, 1)$, and $12 + 18 = 30$.
Answer: $x = -5 + 3t$, $y = 5 - 2t$ for every integer $t$.
Worked example: No solution
- $\gcd(6, 9) = 3$, so $6x + 9y$ is always a multiple of $3$.
- $3 \nmid 20$, so no integers $x$, $y$ work.
Answer: No solution.
Worked example: Stamps
- Solve $5x + 8y = 100$ with $x, y \ge 0$. One solution is $(20, 0)$.
- $d = 1$, so all solutions are $x = 20 + 8t$, $y = -5t$.
- $y \ge 0$ needs $t \le 0$; $x \ge 0$ needs $t \ge -2.5$. So $t = 0, -1, -2$.
- That gives $(20, 0)$, $(12, 5)$ and $(4, 10)$.
Answer: Three ways.
Geometrically, the solutions are the lattice points on the line $ax + by = c$. Since the line has slope $-a/b = -(a/d)/(b/d)$ in lowest terms, moving from one lattice point to the next means going $b/d$ across and $a/d$ down, and no smaller step lands on a lattice point.
Common mistake
Key idea