# chinese remainder theorem

Topics: Modular arithmetic, Euclidean algorithm, Principal ideal domain Pages: 11 (3044 words) Published: February 25, 2014
﻿Chinese remainder theorem

The Chinese remainder theorem is a result about congruences in number theory and its generalizations in abstract algebra. It was first published in the 3rd to 5th centuries by Chinese mathematician Sun Tzu. In its basic form, the Chinese remainder theorem will determine a number n that when divided by some given divisors leaves given remainders. For example, what is the lowest number n that when divided by 3 leaves a remainder of 2, when divided by 5 leaves a remainder of 3, and when divided by 7 leaves a remainder of 2?

Theorem statement
The original form of the theorem, contained in the 5th-century book Sunzi's Mathematical Classic (孫子算經) by the Chinese mathematician Sun Tzu and later generalized with a complete solution called Dayanshu (大衍術) in Qin Jiushao's 1247 Mathematical Treatise in Nine Sections (數書九章, Shushu Jiuzhang), is a statement about simultaneous congruences. Suppose n1, n2, …, nk are positive integers that are pairwise coprime. Then, for any given sequence of integers a1,a2, …, ak, there exists an integer x solving the following system of simultaneous congruences.

Furthermore, all solutions x of this system are congruent modulo the product, N = n1n2…nk. Hence  for all , if and only if .
Sometimes, the simultaneous congruences can be solved even if the ni's are not pairwise coprime. A solution x exists if and only if:

All solutions x are then congruent modulo the least common multiple of the ni. Sun Tzu's work contains neither a proof nor a full algorithm. What amounts to an algorithm for solving this problem was described by Aryabhata (6th century; see Kak 1986). Special cases of the Chinese remainder theorem were also known to Brahmagupta (7th century), and appear in Fibonacci's Liber Abaci (1202). A modern restatement of the theorem in algebraic language is that for a positive integer  with prime factorization  we have the isomorphism between a ring and the direct product of its prime power parts:

The theorem can also be restated in the language of combinatorics as the fact that the infinite arithmetic progressions of integers form a Helly family (Duchet 1995). Existence and uniqueness

The existence and uniqueness of the solution can easily be seen through a non-constructive argument. There are N = n1n2...nk different k-tuples of remainders. Let us call this set R. And there are also N different numbers between 1 and N. For each number between 1 and N, there corresponds member of R. Can two numbers a, b, between 1 and N correspond to the same member of R? That is, can they have the same set of remainders when divided by n1, n2..., nk? If they did then a - b would be divisible by each n. Since the n's are relatively prime, a - b would be divisible by their product: N. This can't be. So this function from {1, ... N } to R is one-to-one. Since {1, ... , N} and R have the same number of elements, this function must also be onto. Thus we have established the existence of a bijection. Existence can be seen by an explicit construction of . We will use the notation  to denote the multiplicative inverse of  as calculated by the Extended Euclidean algorithm. It is defined exactly when  and  are coprime; the following construction explains why the coprimality condition is needed.

Case of two equations
Given the system (corresponding to )

Since , we have from Bézout's identity

This is true because we agreed to use the inverses that came out of the Extended Euclidean algorithm; for any other inverses, it would not necessarily hold true, but only hold true . Multiplying both sides by , we get

If we take the congruence modulo  for the right-hand-side expression, it is readily seen that

But we know that

thus this suggests that the coefficient of the first term on the right-hand-side expression can be replaced by . Similarly, we can show that the coefficient of the second term can be substituted by . We can now define the value

and it is seen to...