Linear Congruences - Article
Linear Congruences - Article
Linear Congruences - Article
ax ≡ b (mod m)
Are these the ONLY solutions? No. In fact, any integer which is congruent
to either 4 or 9 mod 10 is also a solution. You should check this for yourself
now.
This means that although the congruence 6x ≡ 4 (mod 10) had infinitely
many integer solutions, the solutions fall into congruence classes, and there
are only two of those: [4]10 and [9]10 .
Whenever a linear congruence has any solutions, it has infinitely many. The
solutions fall into congruence classes, and there are only a finite number of
congruence classes that solve the congruence.
Here is the key observation which enables us to solve linear congruences.
1
By definition of congruence, ax ≡ b (mod m) iff ax − b is divisible by m.
Hence, ax ≡ b (mod m) iff ax − b = my, for some integer y. Rearranging
the equation to the equivalent form ax − my = b we arrive at the following
result.
Since we already know how to solve linear diophantine equations, this means
we can apply that knowledge to solve linear congruences.
Comment. Later in this lecture we will see that all the solutions can be
joined together to form a single congruence class mod m/d.
x = x0 + (m/d)t, y = y0 + (a/d)t
where (x0 , y0 ) is any particular solution (obtained from the Euclidean algo-
rithm, for instance).
2
Notice that we could write this as: x ≡ 4, 9 (mod 10). This congruence
describes exactly the same set of integers as the union of the congruence
classes [4]10 , [9]10 .
Even better: we can write the complete solution as: x ≡ 4 (mod 5). This
single congruence describes the set of all integer solutions, as you should
check. In other words, we have
Example. Let’s solve 230x ≡ 1081 (mod 12167). We start by applying the
Euclidean algorithm to compute d = gcd(230, 12167) = 23. Since d | 1081
there are solutions. The extended Euclidean algorithm gives the particular
solution (s0 , t0 ) = (53, 1) to the diophantine equation 230s − 12167t = 23,
and scaling by 47 = 1081/23 we get the particular solution (x0 , y0 ) =
(2491, 47) to the diophantine equation 230x − 12167y = 1081. So x0 = 2491
solves the original given congruence. In this case, m/d = 529. Thus, with
m = 12167, the set of residue classes
Thus with m = 12167 we get solutions [a]m for a = 2491, 3020, 3549, 4078,
4607, 5136, 5665, 6194, 6723, 7252, 7781, 8310, 8839, 9368, 9897, 10426,
10955, 11484, 12013, 12542, 13071, 13600, 14129 and no others.
We can also say that (still with m = 12167) we get solutions [a]m for a =
2491, 3020, 3549, 4078, 4607, 5136, 5665, 6194, 6723, 7252, 7781, 8310, 8839,
9368, 9897, 10426, 10955, 11484, 12013, 375, 904, 1433, 1962.
This is because 12542 ≡ 375, 13071 ≡ 904, 13600 ≡ 1433, and 14129 ≡ 1962
(mod m).
When dealing with congruence classes, we can always replace any represen-
tative by another one!
3
The examples suggest a simpler method to solve a linear congruence, which
should always produce a single congruence class mod m/d (assuming d | m).
Example. Suppose we are given the congruence 11x ≡ 15 (mod 20). Ob-
serve that d = gcd(11, 20) = 1. Thus 11x ≡ 15 (mod 20) has a unique
solution class. Observe that 11 · 11 ≡ 1 (mod 20), so [11]20 · [11]20 = [1]20
and [11]−1
20 = [11]20 . This tells us that we can solve the given congruence
simply by multiplying both sides by 11 and reducing numbers mod 20. Here
we go:
This proves that x = [5]20 is the unique solution to the given congruence
11x ≡ 15 (mod 20).
4
small enough then trial and error works pretty well to find an inverse, since
there are few possibilities to check.
Example. Let’s again solve 230x ≡ 1081 (mod 12167) (which we solved
earlier) using this new approach. We start by applying the Euclidean algo-
rithm to compute d = gcd(230, 12167) = 23. Next, we reduce the congruence
to the equivalent congruence 10x ≡ 47 (mod 529) by dividing by d. We now
have gcd(10, 529) = 1, so we can solve by multiplying by 10−1 mod 529. We
can find the inverse by finding any solution to the diophantine equation
10x − 529y = 1 and then throwing away y. For instance, the extended
Euclidean algorithm gives (x, y) = (53, 1) so 10−1 ≡ 53 mod 529.
You should verify for yourself that the union of the congruence classes [a]m
for a = 2491, 3020, 3549, 4078, 4607, 5136, 5665, 6194, 6723, 7252, 7781,
8310, 8839, 9368, 9897, 10426, 10955, 11484, 12013, 375, 904, 1433, 1962
(which we got before) gives exactly the same set of integers as the single
congruence class [375]529 .