Section 4.1 Solving Linear Congruences
As we saw in a previous lecture, finding a solution to the linear Diophantine equation
is equivalent to solving the congruence
In all of the previous examples (from homework and class) we had \(a\) and \(n\) coprime. This is nice, because as previously seen, this is sufficient to give a solution to any linear Diophantine equation of the form \(ax-ny = b,\) since surely \(1\vert b.\) But what if \(\gcd(a,n) = d \gt 1?\) Does the equivalence \(ax\equiv b\pmod{n}\) have a solution? Is it unique? Before we answer these questions we give some definitions to formalise our discussion.
Definition 4.1.1.
An equation of the form \(ax \equiv b \pmod{n}\) is called a linear congruence.
It is also convenient to think of two congruent solutions as "equal", and two that are not congruent as "different". Thus, when we refer to the number of solutions to a linear congruence, we mean the number of incongruent solutions satisfying the congruence.
Theorem 4.1.2.
The linear congruence \(ax \equiv b \pmod{n}\) has a solution if and only if \(d\vert b,\) where \(d = \gcd(a, n).\) If \(d\vert b,\) then it has \(d\) mutually incongruent solutions modulo \(n.\)
Proof.
Since we know that solving \(ax \equiv b \pmod{n}\) is equivalent to solving \(ax-ny = b,\) we have by comparison that \(ax \equiv b \pmod{n}\) has a solution if and only if \(d\vert b,\) where \(d = \gcd(a, n).\) Also we know that if the linear Diophantine is solvable and \(x_0, y_0\) is a solution, then all other solutions are given by
where \(t\in\mathbb{Z}.\)
Since we are only interested in the solution of the congruence and not the equation, we consider only the solution for \(x.\) We shall show that of all of the solutions \(x = x_0 +\frac{n}{d}t\) for \(t\in\mathbb{Z},\) the only incongruent ones are
Suppose it happened that two solutions were congruent; that is,
where \(0 \leq t_1 \lt t_2 \leq d-1.\) Then we would have
But since \(\gcd(\frac{n}{d}, n) = \frac{n}{d},\) so that
which is impossible since \(0 \leq t_1 \lt t_2 \leq d-1\) shows that \(n \nmid t_1-t_2.\) Thus our list of solutions are pairwise incongruent.
To see that any solution is congruent to one on our list, suppose that \(x_0+\frac{n}{d}t\) is some solution. Using the Division Algorithm, we may we may write \(t = qd + r,\) where \(0 \leq r \lt d.\) Now
where \(x_0 +\frac{n}{d}r\) is one of the solutions on our list.
Corollary 4.1.3.
If \(\gcd(a, n) = 1,\) then the linear congruence \(ax \equiv b\pmod{n}\) has a unique solution modulo \(n.\)
Example 4.1.4.
Consider the equivalence \(2x = 2 \pmod{4}.\) Since
there are \(2\) incongruent solutions modulo \(4.\) We easily see that \(x = 1\) is a solution. All solutions are of the form \(x = 1 + 2t\) for \(t = 0, 1.\) Thus the other solution is \(x = 3.\) So the two incongruent solutions modulo \(4\) are
To consider a more complicated example we use the following lemma.
Lemma 4.1.5.
If \(ca \equiv cb \pmod{n},\) then \(a \equiv b \pmod{\frac{n}{d}},\) where \(d =\gcd(c, n).\)
Proof.
Homework problem.
Example 4.1.6.
Consider the equivalence \(9x = 21 \pmod{30}.\) Since
there are \(3\) incongruent solutions modulo \(30.\) Finding a first solution to this congruence is a little more tricky than the earlier example.
Using the preceding lemma we know that we may solve \(3x \equiv 7 \pmod{10}\) instead. Now multiplying by \(7\) gives this congruence as \(21x \equiv 49\pmod{10}\) so that \(x \equiv 9 \pmod{10}\) is a solution. So the solution to our original congruence are those integers of the form
where \(t = 0, 1, 2.\) Thus we have the solutions