Chinese Remainder Theorem
According to D. Wells, the following problem was posed by Sun Tsu Suan-Ching (4th century AD):
There are certain things whose number is unknown. Repeatedly divided by 3, the remainder is 2; by 5 the remainder is 3; and by 7 the remainder is 2. What will be the number?
Oystein Ore mentions another puzzle with a dramatic element from Brahma-Sphuta-Siddhanta (Brahma's Correct System) by Brahmagupta (born 598 AD):
An old woman goes to market and a horse steps on her basket and crashes the eggs. The rider offers to pay for the damages and asks her how many eggs she had brought. She does not remember the exact number, but when she had taken them out two at a time, there was one egg left. The same happened when she picked them out three, four, five, and six at a time, but when she took them seven at a time they came out even. What is the smallest number of eggs she could have had?
Problems of this kind are all examples of what universally became known as the Chinese Remainder Theorem. In mathematical parlance the problems can be stated as finding n, given its remainders of division by several numbers
| (1) |
n = n1 (mod m1) n = n2 (mod m2) ... n = nk (mod mk) |
The modern day theorem is best stated with a couple of useful notations. For non-negative integers
where, as always, "s|m" means that s divides m exactly. The least common multiple of k numbers is defined as
Both gcd() and lcm() are symmetric functions of their arguments. They are complementary in the sense that, for
gcd(m1, m2)·lcm(m1, m2) = m1· m2.
(A proof and an interactive illustration for this identity appears elsewhere.)
However, for k > 2 a similar identity does not in general hold. For an example, consider two triplets:
gcd(m1, (gcd(m2, m3)) = gcd(gcd(m1, m2), m3)
and, both equal gcd(m1, m2, m3). Similarly,
lcm(m1, (lcm(m2, m3)) = lcm(lcm(m1, m2), m3)
Note
If, for a prime p, pαi|mi, with αi being the largest exponent with that property, then
Associativity allows one to proceed a step at a time with an inductive argument without putting all eggs into a basket at once. Jumping at the opportunity I'll prove the most basic case of
Theorem 1
Two simultaneous congruences
n = n1 (mod m1) and
n = n2 (mod m2)
are only solvable when
(When m1 and m2 are coprime their gcd is 1. By convention,
Proof
By a generalization of the Euclid's algorithm, there are integers s and t such that
tm1 + sm2 = gcd(m1, m2).
Since n2 - n1 = 0 (mod gcd(m1, m2)), for some, possibly different t and s,
tm1 + sm2 = n2 - n1.
Then n = tm1 + n1 = -sm2 + n2 satisfies both congruences in the theorem. This proves the existence of a solution.
To prove the uniqueness part, assume n and N satisfy the two congruences. Taking the differences we see that
N - n = 0 (mod m1) and N - n = 0 (mod m2)
which implies N - n = 0 (mod lcm(m1, m2)).
As was previously stated, a more general theorem can now be proved by induction.
Theorem 2
The simultaneous congruences (1)
|
n = n1 (mod m1) n = n2 (mod m2) ... n = nk (mod mk) |
Proof
Theorem 1 serves the initial step verification. Assume the theorem holds for k congruences and consider
n = n1 (mod m1)
n = n2 (mod m2)
...
n = nk (mod mk)
n = nk+1 (mod mk+1)
Let s be a solution to the first k equations. Then the congrurence
s = nk+1 (mod gcd(lcm(m1, ..., mk), mk+1)).
Let's write g u = gcd(m u, mk+1), u = 1, ..., k. Then we know that
s = nk+1 (mod g u), u = 1, 2, ..., k.
If so,
| s | = nk+1 (mod lcm(g1, ..., gk)) | |
| = nk+1 (mod lcm(gcd(m1, mk+1), ..., gcd(mk, mk+1))). | ||
| = nk+1 (mod gcd(lcm(m1, ..., mk), mk+1)) |
because lcm(gcd(m1, mk+1), ..., gcd(mk, mk+1)) = gcd(lcm(m1, ..., mk), mk+1).
Thus the system
n = s (mod lcm(m1, m2, ..., mk))
n = nk+1 (mod mk+1)
has a solution which is unique modulo
Corollary
The simultaneous congruences (1)
n = n1 (mod m1)
n = n2 (mod m2)
...
n = nk (mod mk)
where all mi's are pairwise coprime has a unique solution modulo
If some mi's are not mutually prime, a solution may not exist unless the corresponding congruence agree. For example, the system
Let's now solve the two problems we started the page with.
Problem #1
Solve
| p1: | x = 2 (mod 3) |
| p2: | x = 3 (mod 5) |
| p3: | x = 2 (mod 7) |
From p1, x = 3t + 2, for some integer t. Substituting this into p2 gives
t = 2 (mod 5)
which, in turn, is equivalent to t = 5s + 2 for an integer s. Substitution into
Note that 105 = lcm(3, 5, 7). Thus we have solutions 23, 128, 233, ...
Problem #2
Solve
| q1: | x = 1 (mod 2) |
| q2: | x = 1 (mod 3) |
| q3: | x = 1 (mod 4) |
| q4: | x = 1 (mod 5) |
| q5: | x = 1 (mod 6) |
| q6: | x = 0 (mod 7) |
With the experience we acquired so far, the combination of q1-q5 is equivalent to
x = 1 (mod 60),
x = 60t + 1. Plugging this into q6 gives 60t = -1 (mod 7). Casting out 7 simplifies this to
Note: Chinese Remainder Theorem finds an important application in the clendrical calculations.
References
- H. Davenport, The Higher Arithmetic, Cambridge University Press; 7 edition (December 9, 1999)
- P. J. Davis and R. Hersh, The Mathematical Experience, Houghton Mifflin Company, Boston, 1981
- U. Dudley, Elementary Number Theory, Dover, 2008
- R. Graham, D. Knuth, O. Patashnik, Concrete Mathematics, 2nd edition, Addison-Wesley, 1994.
- Oystein Ore, Number Theory and Its History, Dover Publications, 1976
- D. Wells, The Penguin Book of Curious and Interesting Puzzles, Penguin Books, 1992
- Modular Arithmetic
- Chinese Remainder Theorem
- Euclid's Algorithm
- Pick's Theorem
- Fermat's Little Theorem
- Wilson's Theorem
- Euler's Function
- Divisibility Criteria
- Examples
- Equivalence relations
- A real life story
|Contact| |Front page| |Contents| |Algebra| |Store|
Copyright © 1996-2012 Alexander Bogomolny
| 41162659 |

