5.
Linear Diophantine equations
Linear Diophantine Equations
In the third century, Diophantus of Alexandria
wrote a book called Arithmetic, consisiting of
computational problems which can today be
formulated as polynomial equations in one or more
variables with integer coefficients; all the solutions
to these equations were meant to be positive
integers (or sometimes, rational numbers).
(It is important to note that these equations were
not algebraicalgebraic notation and symbolic
methods were not to be invented for some 700 years
after Diophantus; also, there was a long history of
similar problem solving known to Babylonian
mathematics many centuries before Diophantus.)
From the tradition of Diophantus, we call any
equation whose solutions are meant to be integers a
Diophantine equation. A very important class of
Diophantine equations are of linear type, and the
simplest nontrivial equation of this type has the
form
Given integers a, b, c, find integers x, y so that
ax + by = c.
5. Linear Diophantine equations
Our discussion of how gcd(a, b) takes the form
ax + by for a suitable choice of x, y suggests that c
must be related to (a, b). This is indeed the case.
Brahmaguptas Theorem Given integers a, b, c,
the Diophantine equation
(*)
ax + by = c
has no integer solutions unless (a, b)|c, in which
case the solutions to (*) are the same as those to
a
b
c
x+
y=
.
(a,b)
(a,b)
(a,b)
(**)
Moreover, if x = x0, y = y0 is any one solution to (**),
then all solutions to (**) have the form
x = x0 +
b
a
k, y = y 0
k for any integer k.
(a,b)
(a,b)
Proof If (*) has a solution, then since (a, b) divides
the left side of the equation, it must divide the
right: (a, b)|c. When this condition holds, dividing
through (*) by (a, b) yields (**), so both equations
have the same set of solutions. Putting
a
b
c
a =
, b =
, c =
,
(a,b)
(a,b)
(a,b)
5. Linear Diophantine equations
note that since a and b are relatively prime, we
can, by the extended Euclidean algorithm, find
integers X, Y so that aX + bY = 1. It follows that
x0 = cX , y0 = cY satisfy (**). Thus, (**) is solvable.
If x = x0, y = y0 is any one solution to (**) and
x = x1, y = y1 is
another, then subtracting these two
equations gives the relation a(x 0 x1 ) = b( y0 y1 ).
And since a and b have no common factors, we
conclude that a | (y 0 y1 ). It follows that y1 = y0 ka
and so also x1 = x0 + kb . //
In light of the extended Euclidean algorithm, the
theorem
suggests how to compute the solution set
to a Diophantine equation ax +by = c. We illustrate
with an example of a problem of Eulers:
A farmer lays out the sum of 1770 crowns in purchasing horses
and oxen. He pays 31 crowns for each horse and 21 crowns for
each ox. How many horses and oxen did the farmer buy?
With x = number of horses and y = number of oxen,
the problem becomes one of solving the
Diophantine equation 31x + 21y = 1770. Since
(31,21) = 1, we compute, by the extended Euclidean
algorithm:
5. Linear Diophantine equations
31 1 0
21 0 1 1
10 1 1 2
1 2 3
whence 1 = 231 + 3 21 and, by multiplying
through by 1770, we get 1770 = 3540 31+ 5310 21.
Therefore,x0 = 3540, y0 = 5310 is one solution.
The entire solution set must have the form
x = 3540 + 21k, y = 5310 31k
where k is any integer.
interesting to consider the geometric
It is
interpretation of this solution. Since the
equation is a Diophantine one, all solutions are
representable as points of the integer lattice in the
plane that lie on the line 31x +21y =1770.
To solve Eulers problem, we must restrict
attention to positive integer solutions of x and y.
(Diophantus, for one, does this in his Arithmetic.)
From the general solution, it is a simple
introduction of the necessary inequality conditions
that resolves this additional twist to the problem.
In Eulers problem, it proceeds as follows:
5. Linear Diophantine equations
3540 + 21k 0
21k 3540
k 168.57...
5310 31k 0
5310 31k
171.29... k
Consequently, since k must be an integer, we must
have k = 169, 170, or 171, leading to precisely three
positive solutions:
(x,y) = (9,71) = (30,40) = (51,9).
Thus, the farmer purchased either 9 horses and 71
oxen; 30 horses and 40 oxen; or 51 horses and 9
oxen.