Jump to content

Chinese remainder theorem: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Added an Algebraic Method
Reverted 1 edit by Fly by Night (talk): Unsourced, and the general description of the method is lacking. (TW)
Line 136: Line 136:


This method works well for hand-written computation with a product of moduli that is not too big. However it is much slower than other methods, for very large products of moduli.
This method works well for hand-written computation with a product of moduli that is not too big. However it is much slower than other methods, for very large products of moduli.

=== Algebraic Method ===
Since <math>x \equiv 0 \bmod 3</math>, we know <math>x</math> is a multiple of 3, i.e. there exists an integer <math>a</math> for which <math>x=3a</math>.

Substituting this into the second congruence <math>x \equiv 3 \bmod 4</math> gives <math>3a \equiv 3 \bmod 4</math>. To solve for <math>a</math> we multiply both sides of the congruence by the [[Modular multiplicative inverse|multiplicative inverse]] of 3, mod 4, namely 3.

<math>3 \times 3a \equiv 3 \times 3 \bmod 4 \implies 9a \equiv 9 \bmod 4 \implies a \equiv 1 \bmod 4</math>

It follows that <math>a</math> is one more than a multiple of 4, i.e. there is an integer <math>b</math> for which <math>a = 4b+1</math>. Since

<math>x=3a</math> we have <math>x=3(4b+1)=12b+3</math>, i.e. <math>x \equiv 3 \bmod 12</math> solves the first two congruences.

Finally, substituting <math>x=12b+3</math> into the third congruence <math>x \equiv 4 \bmod 5</math> gives

<math>12b+3 \equiv 4 \bmod 5 \implies 12b \equiv 1 \bmod 5 \implies 2b \equiv 1 \bmod 5</math>

We multiply both sides of this final congruence by the multiplicative inverse of 2, mod 5, namely 3.

<math>3 \times 2b \equiv 3 \times 1 \bmod 5 \implies 6b \equiv 3 \bmod 5 \implies b \equiv 3 \bmod 5</math>

It follows that <math>b</math> is 3 more than a multiple of 5, i.e. there is an integer <math>c</math> for which <math>b = 5c+3</math>. Since <math>x=12b+3</math> we have <math>x=12(5c+3)+3 = 60c + 39</math>. Hence, <math>x</math> is 39 more than a mutliple of 60:

<math>x \equiv 39 \bmod 60</math>


=== Using the existence construction ===
=== Using the existence construction ===

Revision as of 21:02, 28 August 2016

The Chinese remainder theorem appears in Gauss's 1801 book Disquisitiones Arithmeticae.[1]

The Chinese remainder theorem is a theorem of number theory, which states that, if one knows the remainders of the division of an integer n by several integers, then one can determine uniquely the remainder of the division of n by the product of these integers, under the condition that the divisors are pairwise coprime.

This theorem has this name because it is a theorem about remainders, which was first discovered in the 3rd century AD by the Chinese mathematician Sun Tzu.

The Chinese remainder theorem is widely used for computing with large integers, as it allows replacing a computation for which one knows a bound on the size of the result by several similar computations on small integers.

The Chinese remainder theorem (expressed in terms of congruences) is true over every principal ideal domain. It has been generalized to any commutative ring, with a formulation involving ideals.

History

Sun Tzu's original formulation: x ≡ 2 (mod 3) ≡ 3 (mod 5) ≡ 2 (mod 7) with the solution x = 23 + 105k where k ∈ ℤ

The earliest known statement of the theorem, as a problem with specific numbers, appears in the 3rd-century book Sunzi's Mathematical Classic (孫子算經) by the Chinese mathematician Sun Tzu:[2]

There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there? [3]

Sun Tzu's work contains neither a proof nor a full algorithm.[4] What amounts to an algorithm for solving this problem was described by Aryabhata (6th century).[5] Special cases of the Chinese remainder theorem were also known to Brahmagupta (7th century), and appear in Fibonacci's Liber Abaci (1202).[6] The result was later generalized with a complete solution called Dayanshu (大衍術) in Qin Jiushao's 1247 Mathematical Treatise in Nine Sections (數書九章, Shushu Jiuzhang).[7]

The notion of congruences was first introduced and used by Gauss in his Disquisitiones Arithmeticae of 1801.[8] Gauss illustrates the Chinese remainder theorem on a problem involving calendars, namely, "to find the years that have a certain period number with respect to the solar and lunar cycle and the Roman indiction."[9] Gauss introduces a procedure for solving the problem that had already been used by Euler but was in fact an ancient method that had appeared several times.[10]

Theorem statement

Let n1, ..., nk be integers greater than 1, which are often called moduli or divisors. Let us denote by N the product of the ni.

The Chinese remainder theorem asserts that if the ni are pairwise coprime, and if a1, ..., ak are integers such that 0 ≤ ai < ni for every i, then there is one and only one integer x, such that 0 ≤ x < N and the remainder of the Euclidean division of x by ni is ai for every i.

This may be restated as follows in term of congruences: If the ni are pairwise coprime, and if a1, ..., ak are any integers, then there exists an integer x such that

and any two such x are congruent modulo N.[11]

In abstract algebra, the theorem is often restated as: if the ni are pairwise coprime, the map

defined a ring isomorphism[12]

between the ring of integers modulo N and the direct product of the rings of integers modulo the ni. This means that for doing a sequence of arithmetic operations in one may do the same computation independently in each and then get the result by applying the isomorphism (from the right to the left). This may be much faster than the direct computation if N and the number of operations are large. This is widely used, under the name multi-modular computation, for linear algebra over the integers or the rational numbers.

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.[13]

Proof

The existence and the uniqueness of the solution may be proved independently. However the first proof of existence, given below, uses the uniqueness.

Uniqueness

Suppose that x and y are both solutions to all the congruences. As x and y give the same remainder, when divided by ni, their difference xy is a multiple of each ni. As the ni are pairwise coprime, their product N divides also xy, and thus x and y are congruent modulo N. If x and y are supposed to be non negative and less than N (as in the first statement of the theorem), then their difference may be a multiple of N only if x = y.

Existence (first proof)

The map

maps congruence classes modulo N to sequences of congruence classes modulo ni. The proof of uniqueness shows that this map is injective. As the domain and the codomain of this map have the same number of elements, the map is also surjective, which proves the existence of the solution.

This proof is very simple, but does not provide any direct way for computing a solution. Moreover, it cannot be generalized to other situations where the following proof can.

Existence (constructive proof)

Existence may be established by an explicit construction of x.[14] This construction may be split in two steps, firstly by solving the problem in the case of two moduli, and the second one by extending this solution to the general case by induction on the number of moduli.

Case of two moduli

We want to solve the system

where and are coprime.

Bézout's identity asserts the existence of two integers and such that

The integers and may be computed by Extended Euclidean algorithm.

A solution is given by

In fact

This shows that The second congruence is proved similarly, by exchanging the indices.

General case

Let us consider a sequence of congruence equations

where the are pairwise coprime. The two first equations have a solution provided by the method of the previous section. The set of the solutions of these two first equations is the set of all solutions of the equation

As the other are coprime with this reduces solving the initial problem of k equations to a similar problem with equations. Iterating the process, one gets eventually the solutions of the initial problem

Existence (direct construction)

For constructing a solution, it is not necessary to make an induction on the number of moduli. However, such a direct construction involves more computation with large numbers, which makes it less efficient and less used. Nevertheless, Lagrange interpolation is a special case of this construction, applied to polynomials instead of integers.

Let be the product of all moduli but one. As the are pairwise coprime, and are coprime. Thus Bézout's identity applies, and there exist integers and such that

A solution of the system of congruences is

In fact, as is a multiple of for we have

for every

Finding the solution

As an example, consider the problem of finding an integer x such that

Brute-force approach

A brute-force approach converts these congruences into sets and writes the elements out to the product of 3×4×5 = 60 (the solutions modulo 60 for each congruence):

x ∈ {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57}
x ∈ {3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59}
x ∈ {4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59}

To find an x that satisfies simultaneously all three congruences, intersect the three sets to get:

x ∈ {39}

This solution is modulo 60, hence all solutions are expressed as

Exhaustive search

As the result must be a nonnegative integer less than the product of moduli (here 60), a simple method consists in considering successively the integers up to 60, and computing the remainders of the division by 3, 4, 5, until getting the result (here 39).

However, one may obtain the result faster by considering only the integers, which are congruent to 4 modulo 5 (the largest modulus); that is 4, 9 = 4 + 5, 14 = 9 + 5, ... For each of them, compute the remainder by 4 (the second largest modulus) until getting a number congruent to 3 modulo 4. Then one can proceed by adding 20 = 5×4 at each step, and computing only the remainders by 3. This gives

4 mod 4 → 0. Continue
4 + 5 = 9 mod 4 →1. Continue
9 + 5 = 14 mod 4 → 2. Continue
14 + 5 = 19 mod 4 → 3. OK, continue by considering remainders modulo 3 and adding 5×4 = 20 each time
19 mod 3 → 1. Continue
19 + 20 = 39 mod 3 → 0. OK, this is the result.

This method works well for hand-written computation with a product of moduli that is not too big. However it is much slower than other methods, for very large products of moduli.

Using the existence construction

Bézout's identity for 3 and 4 is

Putting this in the formula given for proving the existence gives

for a solution of the two first congruences, the other solutions being obtained by adding to −9 any multiple of 3×4 = 12. One may continue with any of these solutions, but the solution 3 = −9 +12 is smaller (in absolute value) and thus leads probably to an easier computation

Bézout identity for 5 and 3×4 = 12 is

Applying the same formula again, we get a solution of the problem:

The other solutions are obtained by adding any multiple of 3×4×5 = 60, and the smallest positive solution is −21 + 60 = 39.

Over principal ideal domains

In § Theorem statement, the Chinese remainder theorem has been stated in three different ways: in terms of remainders, of congruences and of a ring isomorphism. The statement in terms of remainders does not apply, in general to principal ideal domains, as remainders are not defined in such rings. However, the two other version make sense over a principal ideal domain R: it suffices to replace "integer" by "element of the domain", and by R. These two versions of the theorem are true in this context, because the proofs (except for the first existence proof), are based on Euclid's lemma and Bézout's identity, which are true over every principal domain.

However, in general, the theorem is only an existence theorem, and does not provide any way for computing the solution, unless if one has an algorithm for computing the coefficients of Bézout's identity.

Over univariate polynomial rings and Euclidean domains

The statement in terms of remainders given in § Theorem statement cannot be generalized to any principal ideal domain, but its generalization to Euclidean domains is straightforward. The univariate polynomials over a field is the typical example of a Euclidean domain, which is not the integers. therefore, we state the theorem for the case of a ring of univariate domain over a field For getting the theorem for a general Euclidean domain, it suffices to replace the degree by the Euclidean function of the Euclidean domain.

The Chinese remainder theorem for polynomials is thus: Let (the moduli) be, for i=1, ..., k, pairwise coprime polynomials in . Let be the degree of , and be the sum of the If are polynomials such that or for every i, then, there is one and only one polynomial , such that and the remainder of the Euclidean division of by is for every i.

The construction of the solution may be done as in § Existence (constructive proof) or § Existence (direct proof). However, the latter construction may be simplified by using, as follows, partial fraction decomposition instead of extended Euclidean algorithm.

Thus, we want to find a polynomial , which satisfies the congruences

for

Let us consider the polynomials

The partial fraction decomposition of gives k polynomials with degrees such that

and thus

Then a solution of the simultaneous congruence system is given by the polynomial

In fact, we have

for

This solution may have a degree larger that The unique solution of degree less than may be deduced by considering the remainder of the Euclidean division of by This solution is

Lagrange interpolation

A special case of Chinese remainder theorem for polynomials is Lagrange interpolation. For this, let us consider k monic polynomials of degree one:

They are pairwise coprime if the are all different. The remainder of the division by of a polynomial is

Now, let be constants (polynomials of degree 0) in Both Lagrange interpolation and Chinese remainder theorem assert the existence of a unique polynomial of degree less than k such that

for every i.

Lagrange interpolation formula is exactly the result, in this case, of the above construction of the solution. More precisely, let

The partial fraction decomposition of is

In fact, reducing the right-hand side to a common denominator one gets and the numerator is equal to one, as being a polynomial of degree less than k, which takes the value one for different values of

Using the above general formula, we get the Lagrange interpolation formula

Hermite interpolation

Hermite interpolation is an application of Chinese remainder theorem for univariate polynomials, which may involve moduli of arbitrary degrees (Lagrange interpolation involves only moduli of degree one).

The problem consists of finding a polynomial of the least possible degree, such that the polynomial and its first derivatives take given values at some fixed points.

More precisely, let be elements of the ground field and, for let be the values of the first derivatives of the sought polynomial at (including the 0th derivative, which is the value of the polynomial itself). The problem is to find a polynomial such that its jth derivative takes the value at for and

Let us consider the polynomial

This is the Taylor expansion at up to the order of the unknown polynomial Therefore, we must have

The Chinese remainder theorem asserts that there exists exactly one polynomial of degree less than the sum of the which satisfies these congruences.

There are several ways for computing the solution One may use the method described at the beginning of § Over univariate polynomial rings and Euclidean domains. One may also use the constructions given in § Existence (constructive proof) or § Existence (direct proof).

Generalization to arbitrary rings

The Chinese remainder theorem can be generalized to any ring, by using coprime ideals (also called comaximal ideals). Two ideals I and J are coprime if there are elements and such that This relation plays the role of Bézout's identity in the proofs related to this generalization, which, otherwise are very similar. The generalization may be stated as follows.[15]

Let I1, ..., Ik be two-sided ideals of a ring that are pairwise coprime, and I be their intersection. Then we have the isomorphism

between the quotient ring and the direct product of the where "" denotes the image of the element in the quotient ring defined by the ideal Moreover, if is commutative, then the ideal intersection I is equal to the product of the ideals

Applications

Sequence numbering

The Chinese remainder theorem has been used to construct a Gödel numbering for sequences, which is involved in the proof of Gödel's incompleteness theorems.

Fast Fourier transform

The prime-factor FFT algorithm (also called Good-Thomas algorithm) uses the Chinese remainder theorem for reducing the computation of a fast Fourier transform of size to the computation of two fast Fourier transforms of smaller sizes and (providing that and are coprime).

Encryption

Most implementations of RSA use the Chinese remainder theorem during signing of HTTPS certificates and during decryption.

The Chinese remainder theorem can also be used in secret sharing, which consists of distributing a set of shares among a group of people who, all together (but no one alone), can recover a certain secret from the given set of shares. Each of the shares is represented in a congruence, and the solution of the system of congruences using the Chinese remainder theorem is the secret to be recovered. Secret sharing using the Chinese remainder theorem uses, along with the Chinese remainder theorem, special sequences of integers that guarantee the impossibility of recovering the secret from a set of shares with less than a certain cardinality.

Range ambiguity resolution

The range ambiguity resolution techniques used with medium pulse repetition frequency radar can be seen as a special case of the Chinese remainder theorem.

Dedekind's theorem

Dedekind's Theorem on the Linear Independence of Characters. Let M be a monoid and k an integral domain, viewed as a monoid by considering the multiplication on k. Then any finite family fi )iI of distinct monoid homomorphisms  fi : Mk is linearly independent. In other words, every family (αi)iI of elements αik satisfying

must be equal to the family (0)iI.

Proof. First assume that k is a field, otherwise, replace the integral domain k by its quotient field, and nothing will change. We can linearly extend the monoid homomorphisms  fi : Mk to k-algebra homomorphisms Fi : k[M] → k, where k[M] is the monoid ring of M over k. Then, by linearity, the condition

yields

Next, for i, jI; ij the two k-linear maps Fi : k[M] → k and Fj : k[M] → k are not proportional to each other. Otherwise  fi  and  fj  would also be proportional, and thus equal since as monoid homomorphisms they satisfy:  fi (1) = 1 =  fj (1), which contradicts the assumption that they are distinct.

Therefore, the kernels Ker Fi and Ker Fj are distinct. Since k[M]/Ker FiFi(k[M]) = k is a field, Ker Fi is a maximal ideal of k[M] for every iI. Because they are distinct and maximal the ideals Ker Fi and Ker Fj are coprime whenever ij. The Chinese Remainder Theorem (for general rings) yields an isomorphism:

where

Consequently, the map

is surjective. Under the isomorphisms k[M]/Ker FiFi(k[M]) = k, the map Φ corresponds to:

Now,

yields

for every vector (ui)iI in the image of the map ψ. Since ψ is surjective, this means that

for every vector

Consequently, (αi)iI = (0)iI. QED.

See also

Notes

  1. ^ Gauss & Clarke 1986, Art. 32-36
  2. ^ Katz 1998, p. 197
  3. ^ Joseph B. Dence, Thomas P. Dence. "Elements of the Theory of Numbers". Retrieved 28 August 2016.
  4. ^ Dauben 2007, p. 302
  5. ^ Kak 1986
  6. ^ Leonardo Pisano; Sigler, Laurence E. (translator into English) (2002), Fibonacci's Liber Abaci, Springer-Verlag, pp. 402–403, ISBN 0-387-95419-8 {{citation}}: |first2= has generic name (help)
  7. ^ Dauben 2007, p. 310
  8. ^ Ireland & Rosen 1990, p. 36
  9. ^ Ore 1988, p. 247
  10. ^ Ore 1988, p. 245
  11. ^ Ireland & Rosen 1990, p. 34
  12. ^ Ireland & Rosen 1990, p. 35
  13. ^ Duchet 1995
  14. ^ Rosen 1993, p. 136
  15. ^ Ireland & Rosen 1990, p. 181

References

  • Dauben, Joseph W. (2007), "Chapter 3: Chinese Mathematics", in Katz, Victor J. (ed.), The Mathematics of Egypt, Mesopotamia, China, India and Islam : A Sourcebook, Princeton University Press, pp. 187–384, ISBN 978-0-691-11485-9
  • Duchet, Pierre (1995), "Hypergraphs", in Graham, R. L.; Grötschel, M.; Lovász, L. (eds.), Handbook of combinatorics, Vol. 1, 2, Amsterdam: Elsevier, pp. 381–432, MR 1373663. See in particular Section 2.5, "Helly Property", pp. 393–394.
  • Gauss, Carl Friedrich; Clarke, Arthur A. (translator into English) (1986), Disquisitiones Arithemeticae (Second, corrected ed.), New York: Springer, ISBN 978-0-387-96254-2 {{citation}}: |first2= has generic name (help)
  • Ireland, Kenneth; Rosen, Michael (1990), A Classical Introduction to Modern Number Theory (2nd ed.), Springer-Verlag, ISBN 0-387-97329-X
  • Kak, Subhash (1986), "Computational aspects of the Aryabhata algorithm" (PDF), Indian Journal of History of Science, 21 (1): 62–71
  • Katz, Victor J. (1998), A History of Mathematics / An Introduction (2nd ed.), Addison Wesley Longman, ISBN 978-0-321-01618-8
  • Ore, Oystein (1988) [1948], Number Theory and Its History, Dover, ISBN 978-0-486-65620-5
  • Rosen, Kenneth H. (1993), Elementary Number Theory and its Applications (3rd ed.), Addison-Wesley, ISBN 978-0201-57889-8

Further reading

External links