Introduction
In this lesson (and the next), we will explore linear Diophantine
equations. For this lesson, we will focus on what these equations
are, when a solution exists, and how to find a solution when one exists.
In the lesson two weeks from now, we will explore how to find all
solutions to linear Diophantine equations, and also look at finding
solutions under various constraints.
Diophantine
Equations
A Diophantine equation, named after
Diophantus of Alexandria, is a polynomial equation with integer
coefficients that is intended to be solved with integer solutions.
One Diophantine equation you’ve likely seen is Positive integer
solutions to this Diophantine equation (for example, , , ) correspond to right-angled triangles
with integer side lengths.
Another famous Diophantine equation is where is an integer . It has been shown that this
Diophantine equation has no solution where , , and are positive integers. This was first
stated by the mathematician Fermat in the 1600s, but was not proven
until 1994 by the mathematician Andrew Wiles.
Linear
Diophantine Equations
In this lesson, we’re going to focus on linear Diophantine
equations. A (two-variable) linear Diophantine
equation is an equation of the form where , , and are given integers and we are
interested in solving for integers and .
Example 1
Sara needs to buy a large
coffee. She only has quarters and dimes, and the cashier insists that
she pay with exact change. Is there a combination of quarters and dimes
that will total ?
Solution:
We need to solve the equation , where and are integers. Since and represent the number of quarters and
dimes, respectively, that Sara uses, notice that it makes sense that we
are only interested in integer solutions to this equation. Further, we
should also ensure that and are not negative.
By using systematic guess and check, we can come up with the
following possible solutions:
and , or and , or and , or and
There are no other solutions. Can you see why?
Example 2
A robot can move backwards or forwards with big steps ( cm) or small steps ( cm). Is there a series of moves that
the robot can make to end up cm
ahead of where it started?
Solution:
We need to solve the equation , where and are integers.
Using guess and check, we find one (of many) solutions to be and . That is, if the robot takes big steps forward and small steps backward, it will end up
cm ahead of where it
started.
There are many other solutions. Can you find another solution?
It is not always easy to find a solution to a linear Diophantine
equation by trial-and-error.
For example, trial-and-error could be time consuming if we used that
technique to find integers and
that satisfy the linear
Diophantine equation
Main Question for this Lesson
Given three integers , , and , how can we find a solution to , where and are integers?
Be careful! There may not be an integer solution! In this lesson, we
will determine conditions on ,
, and that guarantee an integer solution to
the equation , and learn a
method for finding such a solution, in the case where one exists.
When does a
solution exist?
Consider the linear Diophantine equation If we divide both sides by , the equation becomes
Stop and Think
Before reading further, can you see a problem with it being true that
?
Since we are told is a
linear Diophantine equation, a solution must have both and being integers. If and are both integers, must also be an integer, but is not an integer! Therefore,
the equation cannot have
any integer solutions.
In general, we have the following result:
Necessary Condition for Solutions
If is an integer that divides
both and , but does not divide , then the linear Diophantine equation
has no solutions.
Exercise 1
Does the linear Diophantine equation have a solution?
Exercise 1 Solution
Since divides and , but does not divide , this linear Diophantine equation has
no solution.
If we’re going to discuss whether or not we can solve the linear
Diophantine equation for
integers and , it appears as though we’ll need to
investigate common divisors of and .
GCDs and
the Euclidean Algorithm
Suppose and are integers. If is an integer that divides both and , we call a common
divisor of and
. The largest integer that divides
both and is called the greatest
common divisor of
and , denoted .
Example 3
What is ?
Solution:
Let’s list the positive divisors of each.
Positive divisors of : , , , , , , , , ,
Positive divisors of : , , , , ,
Since the largest divisor that they have in common is , .
Finding by factoring
and may be very time consuming if and are large.
For example, try to calculate or by factoring.
Instead, we will use a method that does not require us to find a
single divisor of or . The first step is the
division algorithm.
The Division Algorithm
Let and be integers with . There are unique integers (the quotient) and (the remainder) such that
For example, suppose and
. We can write , so and . Notice that it is also true that
and ; however, neither
nor satisfy the requirement that they are
and also . So, it turns out that and are the unique and satisfying the division algorithm when
and .
Example 4
For and , calculate and from the division algorithm.
,
,
,
Solution:
, so , .
, so , .
, so , .
Now that we know how to find
and in the division algorithm, we
are ready to learn an important fact that will help us calculate
greatest common divisors more efficiently.
Important Fact
If , then .
As we saw above, when and
, we have and . Notice that and . So the important fact holds,
since .
Similarly, in Example , we saw
that when and , we have and . Notice that and . So the important fact holds,
since . Note
that for any positive
integer , since is divisible by every positive
integer.
Exercise 2
For and , verify that the important fact
holds.
,
,
Exercise 2 Solution
We saw in Example that
. Thus, and . Notice that and . Since , the important fact
holds.
We saw in Example that
. Thus, and . Notice that and . Since , the important fact
holds.
How can we use the important fact to calculate greatest common
divisors more efficiently? We will iterate the division algorithm and
apply the important fact each time.
Example 5
Calculate .
Solution:
Since , we have
and from the division algorithm. Thus,
by the important fact, we know .
Now, let’s repeat this process on and .
Since, , we have and from the division algorithm. Thus, by
the important fact, we know .
Now, let’s repeat this process on
and .
Since, , we have and from the division algorithm. Thus, by
the important fact, we know .
Thus, we can conclude that
This method of repeatedly using the division algorithm along with the
important fact to find the greatest common divisor of two integers is
called the Euclidean algorithm.
The Euclidean Algorithm
Input: Positive integers and
.
Step 1: Arrange and so that .
Step 2: Write , with .
Step 3: If , then stop! If , then go back to Step , this time with the pair .
Step 4: The last non-zero remainder if such an exists, or else output .
The greatest common divisor of the two integers will be equal to the
last non-zero remainder that is seen in the Euclidean algorithm. When
working through this algorithm, we will use the fact that , for any positive integer
.
Let’s work through another example to convince ourselves that this
algorithm will always output .
Example 6
Calculate using
the Euclidean algorithm.
Solution:
Here we will apply the Euclidean algorithm to the pair . We will keep track of what
is happening with the gcd on the right-hand side.
Euclidean Algorithm Step |
GCD Equality |
As , set and |
|
Write () |
|
Write () |
|
Write () |
|
Write () |
|
From the gcd equalities on the right hand side, we see that .
Stop and Think
Since , the integers get
smaller after each iteration of the division algorithm, and so this
procedure must eventually stop. Can you convince yourself that you will
always reach a remainder of zero, and that the output will always be
?
Exercise 3
Calculate using
the Euclidean algorithm.
Exercise 3 Solution
As , set and |
|
Write () |
|
Write () |
|
Write () |
|
Write () |
|
Write () |
|
From the gcd equalities on the right hand side we see that .
Using
the Euclidean algorithm to solve linear Diophantine equations
As we’ll see in our next example, the Euclidean algorithm not only
finds , but by working
backwards, we can actually use it to solve linear Diophantine
equations!
Example 7
Find integers and such that .
Solution:
As we saw in Example , the
Euclidean algorithm gives And so . Notice that this is
the value of in the equation. We
can exploit this fact by tracing our steps in the Euclidean algorithm
and working backwards as follows:
From : Substituting for using :
Simplifying: Substituting for using : Simplifying: That is, . Therefore, one
solution is , . Check!
Exercise 4
Find integers and such that .
Exercise 4 Solution
From Exercise , the Euclidean
algorithm gives And so we have . Notice that this is our
value of in the equation. Working
backwards, from equation we
have: Substituting for using :
Simplifying: Substituting for using : Simplifying: Substituting for using :
Simplifying: That is, . Therefore, one solution is , . Check!
We now have a strategy to find integers and such that when : We can work backwards
through our steps in the Euclidean algorithm, starting with the line
where , as we saw in
Example . But what if we need to
solve , where is not equal to ?
Example 8
Find integers and such that .
Solution:
Notice that .
From the Example , we know that
.
Multiplying the entire equation by gives Thus, there is a
solution, namely , . Check!
From Example , we can see that
if divides , then we can use a solution to to find a solution to
the equation . What if
does not divide ?
Example 9
Find integers and such that .
Solution:
Suppose that integers and
that satisfy the above equation.
Since , we can
factor out of the left hand side
of the equation: But since and are integers, this last equality is
impossible!
Therefore, there is no solution to the linear Diophantine equation
.
From Example , we can see that
if does not divide , then the equation does not have a solution where
and are integers.
The following theorem summarizes what we have observed about
solutions to linear Diophantine equations.
Theorem
The linear Diophantine equation has a solution if and only if divides .
Using the Euclidean algorithm and working backwards, we can find
integers and such that
Once we have found and such that , we can multiply this
solution by to
get a solution to .
Exercise 5
Find integers and such that .
Exercise 5 Solution
From Exercise , we know that
. Since , we know divides and so this linear Diophantine
equation has a solution.
From Exercise , we know that
and so
multiplying the entire equation by gives Thus, , is a solution. Check!
Exercise 6
Find integers and such that .
Exercise 6 Solution
Since , and
does not divide , there is no solution to this linear
Diophantine equation.