Modular arithmetic is a way of systematically ignoring differences involving a multiple of an integer. If n is an integer, two integers are equal mod n if they differ by a multiple of n; it is as if multiples of n are "set equal to 0".
Definition. Let n, x, and y be integers. x is congruent to y mod n if . The notation
means that x is congruent to y mod n.
Example. ( Examples of congruences with numbers)
if and only if . Thus, congruences provide a convenient notation for dealing with divisibility relations.
As a special case, a number is even if and only if it's congruent to 0 mod 2; a number is odd if and only if it's congruent to 1 mod 2.
The following proposition says that you can work with modular equations in many of the ways that you work with ordinary equations.
Proposition. Let .
(a) If and , then
(b) If and , then
(c) If , then
(a) Suppose and .
means and means . By properties of divisibility,
(b) Suppose and .
means , which means for some . means , which means for some . Thus, , , and hence
This gives , so , and hence .
(c) Suppose . This means that . By properties of divisibility,
Example. ( Solving a congruence) Solve .
In this case, I'll solve the modular equation by adding or subtracting the same thing from both sides.
The solution is .
The next result says that congruence mod n is an equivalence relation.
(a) (Reflexivity) for all .
(b) (Symmetry) Let . If , then .
(c) (Transitivity) Let . If and , then .
Proof. (a) If , then , so .
(b) If , then , so . Therefore, .
(c) Suppose and . means ; means . Therefore,
An equivalence relation on a set gives rise to a partition of the set into equivalence classes. In the case of congruence mod n, an equivalence class consists of integers congruent to each other mod n.
Definition. (read "Z mod n") is the set of equivalence classes under congruence mod n.
Example. ( Congruence classes mod 3) Consider the equivalence relation of congruence mod 3 on . The integers break up into three disjoint sets:
All the elements of a given set are congruent mod 3, and no element in one set is congruent mod 3 to an element of another. The sets divide up the integers like three puzzle pieces.
It's cumbersome to write and use equivalence classes as is, since each equivalence class is a set (infinite, in this case). It's customary to choose a representative from each equivalence class and use the representatives to do arithmetic. I'll choose
I'll abuse notation and write
is called the cyclic group of order 3. The "cyclic" nature of can be visualized by arranging the integers in a spiral, with each congruence class on a ray.
When you do arithmetic in , it is as if you count in a circle: 0, 1, 2, then back to 0 again.
You can form other cyclic groups in an analogous way. For example,
You can do arithmetic in by adding and multiplying as usual, but reducing the results mod n.
Example. ( Operation tables for ) Here are the addition and multiplication tables for :
For example, as integers . I divide 4 by the modulus 3 and get a remainder of 1. Hence, .
Likewise, in .
Example. ( Equations in )
Strictly speaking, -8 is not in . The last statement is just another way of saying .
Example. ( Using modular arithmetic in a divisibility proof) Prove that if n is an integer, then is not divisible by 5.
Every integer n is congruent to one of 0, 1, 2, 3, or 4 mod 5. Therefore, I have 5 cases. In each case, I want to show that is not divisible by 5 --- or to say it in terms of congruences, I want to show that .
I set and "substitute" the value into . This substitution is justified by the properties of congruences I discussed above.
For example, if , then
Likewise, . So
Essentially, I can plug into , then reduce the result mod 5 to one of 0, 1, 2, 3, or 4.
Continuing in this way, I get the following table:
In all five cases, . Therefore, is never divisible by 5.
I showed earlier how to use algebraic operations to solve simple modular equations. How would you solve something like this:
I'd like to divide both sides by 6, but I only know how to add and multiply. I can subtract, but that's because I can add additive inverses. Well, division is multiplication by the multiplicative inverse; what is a multiplicative inverse mod 25?
Definition. Let . a and b are multiplicative inverses if (or in ).
If a is the multiplicative inverse of b, you can write --- but don't write " ", that's bad manners.
Example. ( Modular multiplicative inverses) 6 and 2 are multiplicative inverses mod 11, because .
1 is always its own multiplicative inverse.
On the other hand, 8 does not have a multiplicative inverse mod 12. You can see that by trying cases:
No number multiplied by 8 gives 1 mod 12.
I could try all the possibilities because the numbers were small. How would you do this kind of problem if the numbers were larger?
One approach is to simply appeal to the result following this example. However, I can also give a proof by contradiction.
Suppose that 8 has a multiplicative inverse mod 12. Let x be the multiplicative inverse. Then . Multiplying both sides by 3, I get
This is a contradiction, since 0 and 3 do not differ by a multiple of 12. Therefore, 8 does not have a multiplicative inverse mod 12.
Proposition. has a multiplicative inverse if and only if .
Proof. Suppose has a multiplicative inverse, so
I can regard this as a statement in :
This means that and 1 differ by a multiple of n:
This is a linear combination of m and n which gives 1. Therefore, .
Conversely, suppose . I may find integers a and b such that
Now regarded as an equation in , this says
That is, m is a unit with multiplicative inverse a.
Example. ( Using the Extended Euclidean algorithm to find modular inverses) Find the multiplicative inverse of 31 in .
Note that . Apply the Extended Euclidean Algorithm:
In , and . The equation says . Thus, 47 is the multiplicative inverse of 31 in .
Theorem. If , then the equation
has a unique solution.
Proof. If , then a has a multiplicative inverse in . Thus, in .
First, this means that is a solution, since
Second, if is another solution, then . Multiplying both sides by , I get
That is, . This means the solution is unique.
Example. ( Solving modular equations using modular inverses) Solve
There is a solution, since . I need to find a multiplicative inverse for 13 mod 15.
The Extended Euclidean Algorithm says that
Hence, , i.e. 7 is the multiplicative inverse of 13 mod 15.
Multiply the original equation by 7:
Bruce Ikenaga's Home Page
Copyright 2007 by Bruce Ikenaga