Section 4.3 Solving Congruences
Objectives
- Determine if an integer has a multiplicative inverse, and find it if it exists.
- Solve linear congruences by using properties of congruence and/or finding the multiplicative inverse.
Video: Solving Congruences
When we are asked to solve for \(x\) in an equation like \(2x^2 + 4 = 36\text{,}\) we know that we need to look for all values of \(x\) that satisfy that equation (\(x = \pm 4\)). What if we are asked to solve for \(x\) given a congruence?
Example 4.3.1. Solving for \(x\).
Solve for \(x\) in the congruence \(2x \equiv 4 \Mod{9}\text{.}\)
Before looking at the solution, try it yourself first! What value(s) of \(x\) will satisfy the congruence?
We need to find all values of \(x\) so that \(9 \mid (2x - 4)\text{,}\) or \(9 \mid 2(x-2)\text{.}\)
Since \(\gcd(2,9) = 1\text{,}\) by Checkpoint 1.3.13 we have \(9 \mid (x-2)\text{,}\) which means \(x \equiv 2 \Mod{9}\text{.}\)
Note that this is no different from applying Proposition 4.2.15 directly: since \(\gcd(2,9) = 1\text{,}\) we can safely divide both sides by 2 to obtain \(x \equiv 2 \Mod{9}\text{.}\)
This means that the congruence class \([2]\) is the solution to \(2x \equiv 4 \Mod{9}\text{,}\) or that all integers in \(\{\ldots,-16,-7,2,11,\ldots\}\) satisfy the congruence.
The final answer in the above example is typical of solutions to congruences: since we are working modulo \(n\text{,}\) answers will be congruence classes from \(\{[0],[1],\ldots,[n-1]\}\text{.}\) Hence when asked to solve for \(x\) given a congruence, you should express your answer as a congruence class (\([2]\)), or as a statement of congruence like \(x \equiv 2 \Mod{9}\text{,}\) which makes the modulus explicit.
Example 4.3.2. Solve for \(x\).
Solve the congruence
and express your answer using congruence classes of the original modulus.
We can apply Proposition 4.2.15 here to divide through by 2, and we get
Modulo 10, this is the same as
So the original congruence has two solutions in \(\{[0],[1],\ldots,[9]\}\text{,}\) namely \([3]\) and \([8]\text{.}\)
Checkpoint 4.3.3. Solve Each Congruence.
Solve each congruence for \(x\text{,}\) paying special attention to your usage of Proposition 4.2.15.
- \(\displaystyle 3x \equiv 9 \Mod{10}\)
- \(\displaystyle 5x + 2 \equiv 27 \Mod{15}\)
- \(\displaystyle -11x - 3 \equiv 30 \Mod{7}\)
Checkpoint 4.3.4. Solve Another One.
Proposition 4.2.15 cannot be used to solve the congruence
since we cannot divide both sides by 2.
Solve the congruence by trial-and-error.
There are only 7 congruence classes to check, since we are working modulo 7.
Video: Multiplicative Inverses
We've seen that dividing both sides by a constant is not always possible. Recall instead that in the real numbers, division by a nonzero number \(x\) is the same as multiplication by its reciprocal \(\frac{1}{x}\text{.}\) The number \(\frac{1}{x}\) is sometimes called the inverse of \(x\) since they ‘cancel’ each other out when multplied together.
We define a similar concept for modular arithmetic.
Definition 4.3.5. Multiplicative Inverse.
Given natural numbers \(a, n\) such that \(\gcd(a,n) = 1\text{,}\) the number \(b\) is called a multiplicative inverse of \(a\) modulo \(n\) if
We can denote this inverse as \(a^{-1} = b\text{,}\) or by \(a^{-1} \Mod{n}\) to make the modulus explicit.
In Definition 4.3.5 we are really saying that any number in \([b]\) is a multiplicative inverse of \(a\) modulo \(n\text{,}\) though we will usually be interested in finding that specific inverse that is also in the set \(\{0,1,\ldots,n-1\}\text{.}\) This can now be used when solving congruences of the form
where \(a \nmid b\text{.}\) Instead of dividing both sides by \(a\) (which can't always be done), we multiply both sides by the inverse of \(a\text{.}\)
Checkpoint 4.3.6. Checkpoint 4.3.4 Again.
Show that modulo 7, any number in \([4]\) is a multiplicative inverse of 2. Then use this fact to solve the congruence
from Checkpoint 4.3.4.
You may have noticed that in Definition 4.3.5 we required that \(\gcd(a,n) = 1\) holds. Without this condition, could one still obtain an inverse of \(a\) modulo \(n\text{?}\) Before expanding the next exercise try exploring this idea with pairs of values of \(a\) and \(n\) that aren't relatively prime.
Checkpoint 4.3.7. When does \(a\) have an Inverse Modulo \(n\text{?}\)
Let \(a, n \in \mathbb{N}\text{.}\) Prove that \(a\) has an inverse modulo \(n\) if and only if \(\gcd(a,n) = 1\text{.}\)
Prove both directions separately. Theorem 1.3.7 will be useful in both cases.
For brevity, we make use of the following terminology for integers that have inverses under a particular modulus.
Definition 4.3.8. Unit Modulo \(n\).
If \(a,n \in \mathbb{N}\) such that \(a\) has an inverse modulo \(n\text{,}\) then \(a\) is said to be a unit modulo \(n\).Checkpoint 4.3.9. The Multiplicative Inverse is Unique.
Given \(a, n \in \mathbb{N}\) such that \(\gcd(a,n) = 1\text{,}\) prove that the multiplicative inverse of \(a\) modulo \(n\) is unique (up to congruence class).
Assume that \(c\) and \(d\) are both multiplicative inverses of \(a\) modulo \(n\text{.}\) Show that \(c \equiv d \Mod{n}\text{.}\)
Checkpoint 4.3.10. Uniqueness of Solutions.
Use the previous exercise to argue that
has a unique solution (up to congruence class) if \(\gcd(a,n) = 1\text{.}\)
Does the converse hold? That is, if we know that
has a unique solution, can we conclude that \(\gcd(a,n) = 1\text{?}\)
Checkpoint 4.3.11. Solve These Congruences.
Solve the congruences:
- \(\displaystyle 5x - 7 \equiv 9 \Mod{11}\)
- \(\displaystyle 3 - 2x \equiv 3 - 5x \Mod{7}\)
- \(\displaystyle 21x + 35 \equiv 9 \Mod{19}\)
Checkpoint 4.3.12. How Many Solutions?
Since \(\gcd(6,16) \gt 1\text{,}\) the number 6 has no multiplicative inverse modulo 16. Solve the congruences
and
How many solutions do you get for each one (modulo 16)?