Solving Linear
Congruences
Learn how to solve equations of the form \( ax \equiv b \pmod{m} \) using modular inverses and the Extended Euclidean Algorithm.
What Is a Congruence?
We say \( a \equiv b \pmod{m} \) if \( m \) divides \( a - b \). In other words, \( a \) and \( b \) leave the same remainder when divided by \( m \).
What Is a Linear Congruence?
A linear congruence is an equation of the form:
where \( a, b, m \) are known integers and we want to find all values of \( x \) that satisfy this relation.
Why Do They Matter?
Linear congruences appear throughout computer science and mathematics. They are the foundation of many important algorithms and systems.
The Existence Theorem
Let \( d = \gcd(a, m) \). Then:
Visualizing the \(\gcd\) Condition
Congruence vs Equality
| Congruence | Equality | |
|---|---|---|
| Notation | \( ax \equiv b \pmod{m} \) | \( ax = b \) |
| Solutions | Infinitely many (periodic) | One value (typically) |
| Division by \( a \) | Only when \(\gcd(a,m)=1\) | Always when \( a \neq 0 \) |
| Answer form | \( x \equiv c \pmod{m} \) | \( x = c \) |
| Domain | Integers only | Integers, rationals, reals |
The Modular Inverse
The modular inverse of \( a \) modulo \( m \) is the integer \( a^{-1} \) such that:
It exists if and only if \( \gcd(a, m) = 1 \). Think of it as "division" in modular arithmetic.
Finding the Inverse: Two Methods
How to Solve \( ax \equiv b \pmod{m} \)
Example 1: \( 3x \equiv 4 \pmod{7} \)
Example 2: \( 6x \equiv 4 \pmod{10} \)
Example 3: \( 4x \equiv 5 \pmod{6} \)
Common Mistakes
Summary Cheat Sheet
| Scenario | \(\gcd(a,m)\) | Solutions | Method |
|---|---|---|---|
| \(\gcd(a,m) = 1\) | 1 | Exactly 1 | Find \(a^{-1}\), multiply |
| \(\gcd(a,m) = d\), \(d \mid b\) | \(d > 1\) | Exactly \(d\) | Divide by \(d\), then invert |
| \(\gcd(a,m) = d\), \(d \nmid b\) | \(d > 1\) | None | Stop immediately |
Question 1 of 5
What is the solution to \( 5x \equiv 3 \pmod{7} \)?
Question 2 of 5
Does the congruence \( 6x \equiv 5 \pmod{9} \) have a solution?
Question 3 of 5
How many solutions does \( 4x \equiv 8 \pmod{12} \) have modulo 12?
Question 4 of 5
What is \( 7^{-1} \pmod{11} \)?
Question 5 of 5
Solve \( 9x \equiv 6 \pmod{15} \). Which values are solutions?