Académique Documents
Professionnel Documents
Culture Documents
A * x B mod C
**If A was coprime to C**
i.e. gcd(A,C)=1
To solve for x we would multiply both sides by the modular inverse of A mod C
A * A^-1 * x B * A^-1 mod C
But A * A^-1 mod C = 1
1 * x B * A^-1 mod C
And 1 * x mod C = x
x B * A^-1 mod C
e.g.
5 * x 2 mod 14
5 is coprime with 14, so 5 has an inverse mod 14
5 * 5^-1 * x 2 * 5^-1 mod 14
1 * x 2 * 5^-1 mod 14
x 2 * 5^-1 mod 14
5^-1 mod 14 is 3, since 3 * 5 mod 14 = 15 mod 14 = 1
x 2 * 3 mod 14
x 6 mod 14
Equivalent Statements
Before proceeding its important to remember the following statements are equivalent
A mod CB mod CA \text{ mod } C \equiv B \text{ mod }CA mod CB mod C
This lets us move back and forth between different forms of expressing the same idea.
For example the following are equivalent:
We will never find a value in more than one slice (slices are mutually disjoint)
If we combine all the slices together they would form a pie containing all of the
values
A pie with slices that have these properties has an equivalence relation.
An equivalence relation defines how we can cut up our pie (how we partition our set of
values) into slices (equivalence classes).
In general, equivalence relations must have these properties:
A slice of pie labelled BBB: Equivalence class where all the values mod C=B\text{mod
} C = Bmod C=B
How we cut the pie into slices: Using the congruence modulo C relation,
(mod C)\equiv (\text{mod } C)(mod C)
This is why we say that Congruence modulo C is an equivalence relation. It partitions the
integers into C different equivalence classes.
Since congruence modulo is an equivalence relation for (mod C). This means:
Example
Let's apply these properties to a concrete example using mod 5:\text{mod }5:mod 5:
33
if 38 (mod 5)3 \equiv 8\ (\text{mod }5)38 (mod 5) and if 818 (mod 5)8
\equiv 18\ (\text{mod }5)818 (mod 5) then 318 mod 53 \equiv 18\
\text{ mod }5318 mod 5 (transitive property)
Ask a question
Questions
Report a mistake
Guidelines
Top Recent
mod 5
(reflexive property)
What level of math is this? I think it would be interesting to know whether you would learn
this in high school, college, or even farther on then that.
27 Votes
1 Comment Flag Zachary Mass's comment
3 years ago by
View profile for: Zachary Mass
Here in Oregon I was seeing it for the first time at university in a Computer Science Discrete
Mathematics course, 2nd year course.
14 Votes
1 Comment Flag david.knepprath's comment
2 years ago by
View profile for: david.knepprath
Show all 22 answers to Zachary Mass's question Answer this question
Amazing stuff !
can you post som exampels of the type
x^3+7x^2+7x+5= 0 Mod 11
6 Votes
Comment on Nils Eriksson's question Flag Nils Eriksson's comment
3 years ago by
View profile for: Nils Eriksson
x^3+7x^2+7x+5 0 (mod 11)
Solve for x.
The key to solving a problem like this is recognizing the properties for modulo arithmetic
under multiplication.
(A * B) mod C = (A mod C * B mod C) mod C
So when we look at the x^3 term in the expression, we can say:
x * x * x mod 11 = (x mod 11 * x mod 11 * x mod 11) mod 11
similarly for the 7x^2 term we have
7 * x * x mod 11 = (7 mod 11 * x mod 11 * x mod 11) mod 11
similarly for the 7x term we have
7x mod 11 = (7 mod 11 * x mod 11) mod 11
Observe the figure below. If we want to calculate 12+9 mod 7 we can easily go around the
modular circle for a sequence of 12+9 steps clockwise (as shown in the bottom left circle).
We can take a shortcut by observing that every 7 steps we end up in the same position on the
modular circle. These complete loops around the modular circle dont contribute to our
final position. We ignore these complete loops around the circle by calculating each
number mod 7 (as shown in the two upper modular circles). This will give us the number of
clockwise steps, relative to 0, that contributed to each of their final positions around the
modular circle.
Now, we only have to go around the circle clockwise the total of the number of steps that
contributed to each of numbers final position (as shown in the bottom right modular circle).
This method applies, in general, to any two integers and any modular circle.
Proof for Modular Addition
Start at the rightmost digit, let k=0 and for each digit:
5^8 mod 19 = (5^4 * 5^4) mod 19 = (5^4 mod 19 * 5^4 mod 19) mod 19
5^8 mod 19 = (17 * 17) mod 19 = 289 mod 19
5^8 mod 19 = 4
5^16 mod 19 = (5^8 * 5^8) mod 19 = (5^8 mod 19 * 5^8 mod 19) mod 19
5^16 mod 19 = (4 * 4) mod 19 = 16 mod 19
5^16 mod 19 = 16
5^32 mod 19 = (5^16 * 5^16) mod 19 = (5^16 mod 19 * 5^16 mod 19) mod 19
5^32 mod 19 = (16 * 16) mod 19 = 256 mod 19
5^32 mod 19 = 9
5^64 mod 19 = (5^32 * 5^32) mod 19 = (5^32 mod 19 * 5^32 mod 19) mod 19
5^64 mod 19 = (9 * 9) mod 19 = 81 mod 19
5^64 mod 19 = 5
Step 3: Use modular multiplication properties to combine the calculated
mod C values
5^117 mod 19 = ( 5^1 * 5^4 * 5^16 * 5^32 * 5^64) mod 19
5^117 mod 19 = ( 5^1 mod 19 * 5^4 mod 19 * 5^16 mod 19 * 5^32 mod 19 * 5^64 mod
19) mod 19
5^117 mod 19 = ( 5 * 17 * 16 * 9 * 5 ) mod 19
5^117 mod 19 = 61200 mod 19 = 1
5^117 mod 19 = 1
Notes:
More optimization techniques exist, but are outside the scope of this article. It should be
noted that when we perform modular exponentiation in cryptography, it is not unusual to use
exponents for B > 1000 bits.
(a - b) mod p = ((a mod p - b mod p) + p) mod p
(a / b) mod p = ((a mod p) * (b^(-1) mod p)) mod p
A^p1=1modp
for p prime, and all aZ.