Linear equations for which only integer solutions are sought.
IntuitionIntuition: paying an exact amount with two coin values
Suppose you only have 3-đồng coins and 5-đồng coins and want to pay exactly 8 đồng. You need whole numbers of each coin, so you are really solving 3x+5y=8 for integers x,y≥0 — and indeed x=1,y=1 works since 3+5=8. The general question "for which integers a,b,c does ax+by=c have an integer solution, and how do we find all of them?" is the theory of linear Diophantine equations.
A line of slope $-0.6$ and intercept $1.6$, with lattice points marked where it passes through integer coordinates.
The line 3x+5y=8 rewritten as y=−0.6x+1.6: integer solutions are exactly the lattice points the line passes through.
SchoolDefinition and the divisibility criterion
Definition: Linear Diophantine equation in two unknowns
An equation ax+by=c with integers a,b,c and (a,b)=(0,0), for which we seek solutions (x,y) with x,y∈Z, is called a linear Diophantine equation.
ax+by=ca,b,c∈Z,(a,b)=(0,0)
Not every choice of a,b,c gives a solvable equation: 2x+4y=7 has none, since the left side is always even. The precise criterion involves d=gcd(a,b): the equation has an integer solution if and only if d∣c.
d=gcd(a,b)∣c⟺∃x,y∈Z:ax+by=c
Solvability of ax+by=c
Condition
Solvable?
Solution set
d∣c
Yes
Infinite family: x=x0+dbt,y=y0−dat
d∤c
No
Empty set ∅
AdvancedTheorems and proofs (going beyond the curriculum)
For integers a,b not both 0, there exist integers u,v such that au+bv=gcd(a,b).
Why is it true?
It shows the greatest common divisor is not just the "biggest shared factor" but is actually reachable as an integer combination of a and b — the key fact that makes the solvability criterion for ax+by=c work.
Proof
Consider the set S={au+bv:u,v∈Z}∩Z>0 of all strictly positive integer combinations of a and b. Since a,b are not both 0, S is nonempty (it contains ∣a∣ or ∣b∣), so by the well-ordering principle S has a least element d=au0+bv0>0.
We show d∣a: divide a=qd+r with 0≤r<d. Then r=a−qd=a−q(au0+bv0)=a(1−qu0)+b(−qv0) is itself an integer combination of a,b. If r>0 then r would belong to S and be smaller than d, contradicting minimality; so r=0, i.e. d∣a. The identical argument with b in place of a shows d∣b.
Since d is a common divisor of a and b, d≤gcd(a,b). Conversely, any common divisor e of a and b divides au0+bv0=d, so e≤d; taking e=gcd(a,b) gives gcd(a,b)≤d.
Combining both inequalities, d=gcd(a,b), and by construction d=au0+bv0, which is exactly Bézout's identity with u=u0,v=v0.
ax+by=c has an integer solution if and only if d∣c where d=gcd(a,b); when it does, and (x0,y0) is one solution, every integer solution is exactly x=x0+dbt,y=y0−dat(t∈Z).
Why is it true?
It completely closes the problem: one divisibility check decides solvability, and once you have any single solution, a one-parameter family via t hands you every other solution — no guessing required.
Proof
(⇒) If (x,y) is an integer solution, then d=gcd(a,b) divides both ax and by, hence divides ax+by=c. So d∣c is necessary.
(⇐) Suppose d∣c, say c=de. By Bézout's identity there exist u0,v0 with au0+bv0=d. Multiplying by e gives a(u0e)+b(v0e)=de=c, so (x0,y0)=(u0e,v0e) is an integer solution. This proves solvability.
Now fix any solution (x0,y0) and let (x,y) be any other solution. Subtracting ax0+by0=c from ax+by=c gives a(x−x0)+b(y−y0)=0, i.e. a(x−x0)=−b(y−y0). Dividing through by d: da(x−x0)=−db(y−y0), and since gcd(a/d,b/d)=1, the factor db must divide x−x0 (a standard consequence of coprimality: if p∣mn and gcd(p,m)=1 then p∣n). So x−x0=dbt for some integer t, and substituting back gives y−y0=−dat.
Conversely, for any integer t, substituting x=x0+dbt,y=y0−dat into ax+by gives ax0+by0+t(dab−dab)=c+0=c, confirming every such pair is indeed a solution. Hence the solution set is exactly x=x0+dbt,y=y0−dat(t∈Z).
AdvancedReal-World Applications and Worked Examples
Solving ax+by=c is not just a classroom exercise: the extended Euclidean algorithm that produces the Bézout coefficients is exactly what finds a modular inverse in RSA key generation, and the same lattice-point reasoning underlies how computer graphics algorithms (like Bresenham's line drawing) decide which integer pixels a line passes through.
Example: Solving 3x+5y=8 completely
Find all integer solutions of 3x+5y=8, and the one with the smallest nonnegative x.
Solution
Run the Euclidean algorithm: 5=1⋅3+2, 3=1⋅2+1, 2=2⋅1+0, so gcd(3,5)=1, which divides 8, so solutions exist.
Back-substitute: 1=3−1⋅2=3−1⋅(5−1⋅3)=2⋅3−1⋅5. Multiplying by 8: 2⋅3⋅8−1⋅5⋅8=8⋅1, i.e. 3⋅16+5⋅(−8)=8, giving one solution (x0,y0)=(16,−8).
By the general solution theorem with d=1, every solution is x=16+5t,y=−8−3t for t∈Z. Choosing t=−3 gives x=16−15=1,y=−8+9=1, matching the coin example.
Among all t, x=16+5t≥0 first fails to hold for t≤−4 (giving x=−4), so the smallest nonnegative x is at t=−3: (x,y)=(1,1).
Example: RSA key generation: finding a modular inverse
In RSA with public exponent e=7 and φ(n)=40, find the private exponent d satisfying 7d≡1(mod40).
Solution
The congruence 7d≡1(mod40) is equivalent to the linear Diophantine equation 7d−40k=1 for some integer k.
Euclidean algorithm: 40=5⋅7+5, 7=1⋅5+2, 5=2⋅2+1, 2=2⋅1+0, so gcd(7,40)=1, confirming an inverse exists.
Back-substitute: 1=5−2⋅2=5−2⋅(7−1⋅5)=3⋅5−2⋅7=3⋅(40−5⋅7)−2⋅7=3⋅40−17⋅7. So 7⋅(−17)+40⋅3=1, giving d≡−17(mod40).
Reducing to the standard range: d≡−17+40=23(mod40). Checking: 7×23=161=4×40+1, confirming d=23 is the correct RSA private exponent for this toy key.
Which condition on d=gcd(a,b) decides whether ax+by=c has an integer solution?
Bézout's identity guarantees the existence of which integers?
If (x0,y0) solves ax+by=c with d=gcd(a,b), the general solution is x=x0+dbt and y= ?
The extended Euclidean algorithm used to solve linear Diophantine equations is also the standard method for computing which cryptographic quantity?