Aryabhata Algorithm
   HOME

TheInfoList



OR:

In
mathematics Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an
integer An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
''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
divisor In mathematics, a divisor of an integer n, also called a factor of n, is an integer m that may be multiplied by some integer to produce n. In this case, one also says that n is a '' multiple'' of m. An integer n is divisible or evenly divisibl ...
s are
pairwise coprime In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiva ...
(no two divisors share a common factor other than 1). The theorem is sometimes called Sunzi's theorem. Both names of the theorem refer to its earliest known statement that appeared in ''
Sunzi Suanjing ''Sunzi Suanjing'' () was a mathematical treatise written during 3rd to 5th centuries CE which was listed as one of the Ten Computational Canons during the Tang dynasty. The specific identity of its author Sunzi (lit. "Master Sun") is still ...
'', a Chinese manuscript written during the 3rd to 5th century CE. This first statement was restricted to the following example: If one knows that the remainder of ''n'' divided by 3 is 2, the remainder of ''n'' divided by 5 is 3, and the remainder of ''n'' divided by 7 is 2, then with no other information, one can determine the remainder of ''n'' divided by 105 (the product of 3, 5, and 7) without knowing the value of ''n''. In this example, the remainder is 23. Moreover, this remainder is the only possible positive value of ''n'' that is less than 105. 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 In mathematics, a principal ideal domain, or PID, is an integral domain (that is, a non-zero commutative ring without nonzero zero divisors) in which every ideal is principal (that is, is formed by the multiples of a single element). Some author ...
. It has been generalized to any
ring (The) Ring(s) may refer to: * Ring (jewellery), a round band, usually made of metal, worn as ornamental jewelry * To make a sound with a bell, and the sound made by a bell Arts, entertainment, and media Film and TV * ''The Ring'' (franchise), a ...
, with a formulation involving
two-sided ideal In mathematics, and more specifically in ring theory, an ideal of a ring is a special subset of its elements. Ideals generalize certain subsets of the integers, such as the even numbers or the multiples of 3. Addition and subtraction of even n ...
s.


History

The earliest known statement of the problem appears in the 5th-century book ''
Sunzi Suanjing ''Sunzi Suanjing'' () was a mathematical treatise written during 3rd to 5th centuries CE which was listed as one of the Ten Computational Canons during the Tang dynasty. The specific identity of its author Sunzi (lit. "Master Sun") is still ...
'' by the Chinese mathematician Sunzi: Sunzi's work would not be considered a
theorem In mathematics and formal logic, a theorem is a statement (logic), statement that has been Mathematical proof, proven, or can be proven. The ''proof'' of a theorem is a logical argument that uses the inference rules of a deductive system to esta ...
by modern standards; it only gives one particular problem, without showing how to solve it, much less any
proof Proof most often refers to: * Proof (truth), argument or sufficient evidence for the truth of a proposition * Alcohol proof, a measure of an alcoholic drink's strength Proof may also refer to: Mathematics and formal logic * Formal proof, a co ...
about the general case or a general
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
for solving it. An algorithm for solving this problem was described by
Aryabhata Aryabhata ( ISO: ) or Aryabhata I (476–550 CE) was the first of the major mathematician-astronomers from the classical age of Indian mathematics and Indian astronomy. His works include the '' Āryabhaṭīya'' (which mentions that in 3600 ' ...
(6th century). Special cases of the Chinese remainder theorem were also known to
Brahmagupta Brahmagupta ( – ) was an Indian Indian mathematics, mathematician and Indian astronomy, astronomer. He is the author of two early works on mathematics and astronomy: the ''Brāhmasphuṭasiddhānta'' (BSS, "correctly established Siddhanta, do ...
(7th century) and appear in
Fibonacci Leonardo Bonacci ( – ), commonly known as Fibonacci, was an Italians, Italian mathematician from the Republic of Pisa, considered to be "the most talented Western mathematician of the Middle Ages". The name he is commonly called, ''Fibonacci ...
's
Liber Abaci The or (Latin for "The Book of Calculation") was a 1202 Latin work on arithmetic by Leonardo of Pisa, posthumously known as Fibonacci. It is primarily famous for introducing both base-10 positional notation and the symbols known as Arabic n ...
(1202). The result was later generalized with a complete solution called ''Da-yan-shu'' () in
Qin Jiushao Qin Jiushao (, ca. 1202–1261), courtesy name Daogu (道古), was a Chinese mathematician, meteorologist, inventor, politician, and writer. He is credited for discovering Horner's method as well as inventing Tianchi basins, a type of rain gau ...
's 1247 ''
Mathematical Treatise in Nine Sections The ''Mathematical Treatise in Nine Sections'' () is a mathematical text written by Chinese Southern Song dynasty mathematician Qin Jiushao in the year 1247. The mathematical text has a wide range of topics and is taken from all aspects of th ...
'' which was translated into English in early 19th century by British missionary Alexander Wylie. The notion of congruences was first introduced and used by
Carl Friedrich Gauss Johann Carl Friedrich Gauss (; ; ; 30 April 177723 February 1855) was a German mathematician, astronomer, geodesist, and physicist, who contributed to many fields in mathematics and science. He was director of the Göttingen Observatory and ...
in his ''
Disquisitiones Arithmeticae (Latin for ''Arithmetical Investigations'') is a textbook on number theory written in Latin by Carl Friedrich Gauss in 1798, when Gauss was 21, and published in 1801, when he was 24. It had a revolutionary impact on number theory by making the f ...
'' of 1801. 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." Gauss introduces a procedure for solving the problem that had already been used by
Leonhard Euler Leonhard Euler ( ; ; ; 15 April 170718 September 1783) was a Swiss polymath who was active as a mathematician, physicist, astronomer, logician, geographer, and engineer. He founded the studies of graph theory and topology and made influential ...
but was in fact an ancient method that had appeared several times.


Statement

Let ''n''1, ..., ''n''''k'' be integers greater than 1, which are often called '' moduli'' or ''
divisors In mathematics, a divisor of an integer n, also called a factor of n, is an integer m that may be multiplied by some integer to produce n. In this case, one also says that n is a '' multiple'' of m. An integer n is divisible or evenly divisibl ...
''. Let us denote by ''N'' the product of the ''n''''i''. The Chinese remainder theorem asserts that if the ''n''''i'' are
pairwise coprime In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiva ...
, and if ''a''1, ..., ''a''''k'' are integers such that 0 ≤ ''a''''i'' < ''n''''i'' for every ''i'', then there is one and only one integer ''x'', such that 0 ≤ ''x'' < ''N'' and the remainder of the
Euclidean division In arithmetic, Euclidean division – or division with remainder – is the process of dividing one integer (the dividend) by another (the divisor), in a way that produces an integer quotient and a natural number remainder strictly smaller than ...
of ''x'' by ''n''''i'' is ''a''''i'' for every ''i''. This may be restated as follows in terms of
congruences In abstract algebra, a congruence relation (or simply congruence) is an equivalence relation on an algebraic structure (such as a group (mathematics), group, ring (mathematics), ring, or vector space) that is compatible with the structure in the ...
: If the n_i are pairwise coprime, and if ''a''1, ..., ''a''''k'' are any integers, then the system :\begin x &\equiv a_1 \pmod \\ &\,\,\,\vdots \\ x &\equiv a_k \pmod, \end has a solution, and any two solutions, say ''x''1 and ''x''2, are congruent modulo ''N'', that is, . In
abstract algebra In mathematics, more specifically algebra, abstract algebra or modern algebra is the study of algebraic structures, which are set (mathematics), sets with specific operation (mathematics), operations acting on their elements. Algebraic structur ...
, the theorem is often restated as: if the ''n''''i'' are pairwise coprime, the map :x \bmod N \;\mapsto\;(x \bmod n_1,\, \ldots,\, x \bmod n_k) defines a
ring isomorphism In mathematics, a ring homomorphism is a structure-preserving function between two rings. More explicitly, if ''R'' and ''S'' are rings, then a ring homomorphism is a function that preserves addition, multiplication and multiplicative identity ...
:\mathbb/N\mathbb \cong \mathbb/n_1\mathbb \times \cdots \times \mathbb/n_k\mathbb between the
ring (The) Ring(s) may refer to: * Ring (jewellery), a round band, usually made of metal, worn as ornamental jewelry * To make a sound with a bell, and the sound made by a bell Arts, entertainment, and media Film and TV * ''The Ring'' (franchise), a ...
of integers modulo ''N'' and the
direct product In mathematics, a direct product of objects already known can often be defined by giving a new one. That induces a structure on the Cartesian product of the underlying sets from that of the contributing objects. The categorical product is an abs ...
of the rings of integers modulo the ''n''''i''. This means that for doing a sequence of arithmetic operations in \mathbb/N\mathbb, one may do the same computation independently in each \mathbb/n_i\mathbb 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 Linear algebra is the branch of mathematics concerning linear equations such as :a_1x_1+\cdots +a_nx_n=b, linear maps such as :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mathemat ...
over the integers or the
rational number In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (for example, The set of all ...
s. The theorem can also be restated in the language of
combinatorics Combinatorics is an area of mathematics primarily concerned with counting, both as a means and as an end to obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many ...
as the fact that the infinite
arithmetic progression An arithmetic progression or arithmetic sequence is a sequence of numbers such that the difference from any succeeding term to its preceding term remains constant throughout the sequence. The constant difference is called common difference of that ...
s of integers form a
Helly family In combinatorics, a Helly family of order is a family of Set (mathematics), sets in which every minimal ''subfamily with an empty Intersection (set theory), intersection'' has or fewer sets in it. Equivalently, every finite subfamily such that ...
.


Proof

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


Uniqueness

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


Existence (first proof)

The map :x \bmod N \mapsto (x \bmod n_1, \ldots, x\bmod n_k) maps
congruence class In mathematics, modular arithmetic is a system of arithmetic operations for integers, other than the usual ones from elementary arithmetic, where numbers "wrap around" when reaching a certain value, called the modulus. The modern approach to mod ...
es modulo to sequences of congruence classes modulo . The proof of uniqueness shows that this map is
injective In mathematics, an injective function (also known as injection, or one-to-one function ) is a function that maps distinct elements of its domain to distinct elements of its codomain; that is, implies (equivalently by contraposition, impl ...
. As the
domain A domain is a geographic area controlled by a single person or organization. Domain may also refer to: Law and human geography * Demesne, in English common law and other Medieval European contexts, lands directly managed by their holder rather ...
and the
codomain In mathematics, a codomain, counter-domain, or set of destination of a function is a set into which all of the output of the function is constrained to fall. It is the set in the notation . The term '' range'' is sometimes ambiguously used to ...
of this map have the same number of elements, the map is also
surjective In mathematics, a surjective function (also known as surjection, or onto function ) is a function such that, for every element of the function's codomain, there exists one element in the function's domain such that . In other words, for a f ...
, 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 . This construction may be split into two steps, first solving the problem in the case of two moduli, and then extending this solution to the general case by induction on the number of moduli.


Case of two moduli

We want to solve the system: : \begin x &\equiv a_1 \pmod \\ x &\equiv a_2 \pmod , \end where n_1 and n_2 are
coprime In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiv ...
.
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
asserts the existence of two integers m_1 and m_2 such that :m_1n_1+m_2n_2=1. The integers m_1 and m_2 may be computed by the
extended Euclidean algorithm In arithmetic and computer programming, the extended Euclidean algorithm is an extension to the Euclidean algorithm, and computes, in addition to the greatest common divisor (gcd) of integers ''a'' and ''b'', also the coefficients of Bézout's id ...
. A solution is given by :x = a_1m_2n_2+a_2m_1n_1. Indeed, :\begin x&=a_1m_2n_2+a_2m_1n_1\\ &=a_1(1 - m_1n_1) + a_2m_1n_1 \\ &=a_1 + (a_2 - a_1)m_1n_1, \end implying that x \equiv a_1 \pmod . The second congruence is proved similarly, by exchanging the subscripts 1 and 2.


General case

Consider a sequence of congruence equations: : \begin x &\equiv a_1 \pmod \\ &\vdots \\ x &\equiv a_k \pmod, \end where the n_i are pairwise coprime. The two first equations have a solution a_ 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 :x \equiv a_ \pmod. As the other n_i are coprime with n_1n_2, this reduces solving the initial problem of equations to a similar problem with k-1 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 In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data. Given a data set of coordinate pairs (x_j, y_j) with 0 \leq j \leq k, the x_j are called ''nodes'' ...
is a special case of this construction, applied to
polynomial In mathematics, a polynomial is a Expression (mathematics), mathematical expression consisting of indeterminate (variable), indeterminates (also called variable (mathematics), variables) and coefficients, that involves only the operations of addit ...
s instead of integers. Let N_i = N/n_i be the product of all moduli but one. As the n_i are pairwise coprime, N_i and n_i are coprime. Thus
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
applies, and there exist integers M_i and m_i such that :M_iN_i + m_in_i=1. A solution of the system of congruences is :x=\sum_^k a_iM_iN_i. In fact, as N_j is a multiple of n_i for i\neq j, we have :x \equiv a_iM_iN_i \equiv a_i(1-m_in_i) \equiv a_i \pmod, for every i.


Computation

Consider a system of congruences: :\begin x &\equiv a_1 \pmod \\ &\vdots \\ x &\equiv a_k \pmod, \\ \end where the n_i are
pairwise coprime In number theory, two integers and are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides does not divide , and vice versa. This is equiva ...
, and let N=n_1 n_2\cdots n_k. In this section several methods are described for computing the unique solution for x, such that 0\le x and these methods are applied on the example : \begin x &\equiv 0 \pmod 3 \\ x &\equiv 3 \pmod 4 \\ x &\equiv 4 \pmod 5. \end Several methods of computation are presented. The two first ones are useful for small examples, but become very inefficient when the product n_1\cdots n_k is large. The third one uses the existence proof given in . It is the most convenient when the product n_1\cdots n_k is large, or for computer computation.


Systematic search

It is easy to check whether a value of is a solution: it suffices to compute the remainder of the
Euclidean division In arithmetic, Euclidean division – or division with remainder – is the process of dividing one integer (the dividend) by another (the divisor), in a way that produces an integer quotient and a natural number remainder strictly smaller than ...
of by each . Thus, to find the solution, it suffices to check successively the integers from to until finding the solution. Although very simple, this method is very inefficient. For the simple example considered here, integers (including ) have to be checked for finding the solution, which is . This is an
exponential time In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
algorithm, as the size of the input is, up to a constant factor, the number of digits of , and the average number of operations is of the order of . Therefore, this method is rarely used, neither for hand-written computation nor on computers.


Search by sieving

The search of the solution may be made dramatically faster by sieving. For this method, we suppose, without loss of generality, that 0\le a_i (if it were not the case, it would suffice to replace each a_i by the remainder of its division by n_i). This implies that the solution belongs to the
arithmetic progression An arithmetic progression or arithmetic sequence is a sequence of numbers such that the difference from any succeeding term to its preceding term remains constant throughout the sequence. The constant difference is called common difference of that ...
:a_1, a_1 + n_1, a_1+2n_1, \ldots By testing the values of these numbers modulo n_2, one eventually finds a solution x_2 of the two first congruences. Then the solution belongs to the arithmetic progression :x_2, x_2 + n_1n_2, x_2+2n_1n_2, \ldots Testing the values of these numbers modulo n_3, and continuing until every modulus has been tested eventually yields the solution. This method is faster if the moduli have been ordered by decreasing value, that is if n_1>n_2> \cdots > n_k. For the example, this gives the following computation. We consider first the numbers that are congruent to 4 modulo 5 (the largest modulus), which are 4, , , ... 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 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. Although dramatically faster than the systematic search, this method also has an
exponential time In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
complexity and is therefore not used on computers.


Using the existence construction

The constructive existence proof shows that, in the case of two moduli, the solution may be obtained by the computation of the Bézout coefficients of the moduli, followed by a few multiplications, additions and reductions modulo n_1n_2 (for getting a result in the interval (0, n_1n_2-1)). As the Bézout's coefficients may be computed with the
extended Euclidean algorithm In arithmetic and computer programming, the extended Euclidean algorithm is an extension to the Euclidean algorithm, and computes, in addition to the greatest common divisor (gcd) of integers ''a'' and ''b'', also the coefficients of Bézout's id ...
, the whole computation, at most, has a
quadratic time In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
complexity Complexity characterizes the behavior of a system or model whose components interact in multiple ways and follow local rules, leading to non-linearity, randomness, collective dynamics, hierarchy, and emergence. The term is generally used to c ...
of O((s_1+s_2)^2), where s_i denotes the number of digits of n_i. For more than two moduli, the method for two moduli allows the replacement of any two congruences by a single congruence modulo the product of the moduli. Iterating this process provides eventually the solution with a complexity, which is quadratic in the number of digits of the product of all moduli. This quadratic time complexity does not depend on the order in which the moduli are regrouped. One may regroup the two first moduli, then regroup the resulting modulus with the next one, and so on. This strategy is the easiest to implement, but it also requires more computation involving large numbers. Another strategy consists in partitioning the moduli in pairs whose product have comparable sizes (as much as possible), applying, in parallel, the method of two moduli to each pair, and iterating with a number of moduli approximatively divided by two. This method allows an easy parallelization of the algorithm. Also, if fast algorithms (that is, algorithms working in
quasilinear time In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
) are used for the basic operations, this method provides an algorithm for the whole computation that works in quasilinear time. On the current example (which has only three moduli), both strategies are identical and work as follows.
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
for 3 and 4 is :1\times 4 + (-1)\times 3 = 1. Putting this in the formula given for proving the existence gives :0\times 1\times 4 + 3\times (-1)\times 3 =-9 for a solution of the two first congruences, the other solutions being obtained by adding to −9 any multiple of . One may continue with any of these solutions, but the solution is smaller (in
absolute value In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign. Namely, , x, =x if x is a positive number, and , x, =-x if x is negative (in which case negating x makes -x positive), ...
) and thus leads probably to an easier computation Bézout identity for 5 and 3 × 4 = 12 is :5\times 5 +(-2)\times 12 =1. Applying the same formula again, we get a solution of the problem: :5\times 5 \times 3 + 12\times (-2)\times 4 = -21. The other solutions are obtained by adding any multiple of , and the smallest positive solution is .


As a linear Diophantine system

The system of congruences solved by the Chinese remainder theorem may be rewritten as a system of linear Diophantine equations: :\begin x &= a_1 +x_1n_1\\ &\vdots \\ x &=a_k+x_kn_k, \end where the unknown integers are x and the x_i. Therefore, every general method for solving such systems may be used for finding the solution of Chinese remainder theorem, such as the reduction of the
matrix Matrix (: matrices or matrixes) or MATRIX may refer to: Science and mathematics * Matrix (mathematics), a rectangular array of numbers, symbols or expressions * Matrix (logic), part of a formula in prenex normal form * Matrix (biology), the m ...
of the system to
Smith normal form In mathematics, the Smith normal form (sometimes abbreviated SNF) is a normal form that can be defined for any matrix (not necessarily square) with entries in a principal ideal domain (PID). The Smith normal form of a matrix is diagonal, and can ...
or
Hermite normal form In linear algebra, the Hermite normal form is an analogue of reduced echelon form for matrices over the integers \Z. Just as reduced echelon form can be used to solve problems about the solution to the linear system Ax=b where x \in \mathbb^n, the ...
. However, as usual when using a general algorithm for a more specific problem, this approach is less efficient than the method of the preceding section, based on a direct use of
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
.


Over principal ideal domains

In , the Chinese remainder theorem has been stated in three different ways: in terms of remainders, of congruences, and of a
ring isomorphism In mathematics, a ring homomorphism is a structure-preserving function between two rings. More explicitly, if ''R'' and ''S'' are rings, then a ring homomorphism is a function that preserves addition, multiplication and multiplicative identity ...
. The statement in terms of remainders does not apply, in general, to
principal ideal domain In mathematics, a principal ideal domain, or PID, is an integral domain (that is, a non-zero commutative ring without nonzero zero divisors) in which every ideal is principal (that is, is formed by the multiples of a single element). Some author ...
s, as remainders are not defined in such rings. However, the two other versions make sense over a principal ideal domain : it suffices to replace "integer" by "element of the domain" and \mathbb Z by . 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 In algebra and number theory, Euclid's lemma is a lemma that captures a fundamental property of prime numbers: For example, if , , , then , and since this is divisible by 19, the lemma implies that one or both of 133 or 143 must be as well. In ...
and
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
, 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 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 cannot be generalized to any principal ideal domain, but its generalization to
Euclidean domain In mathematics, more specifically in ring theory, a Euclidean domain (also called a Euclidean ring) is an integral domain that can be endowed with a Euclidean function which allows a suitable generalization of Euclidean division of integers. Th ...
s is straightforward. The
univariate polynomial In mathematics, a polynomial is a mathematical expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication and exponentiation to nonnegative integer ...
s over a
field Field may refer to: Expanses of open ground * Field (agriculture), an area of land used for agricultural purposes * Airfield, an aerodrome that lacks the infrastructure of an airport * Battlefield * Lawn, an area of mowed grass * Meadow, a grass ...
is the typical example of a Euclidean domain which is not the integers. Therefore, we state the theorem for the case of the ring R=K /math> for a field K. For getting the theorem for a general Euclidean domain, it suffices to replace the degree by the
Euclidean function In mathematics, more specifically in ring theory, a Euclidean domain (also called a Euclidean ring) is an integral domain that can be endowed with a Euclidean function which allows a suitable generalization of Euclidean division of integers. Thi ...
of the Euclidean domain. The Chinese remainder theorem for polynomials is thus: Let P_i(X) (the moduli) be, for i = 1, \dots, k, pairwise
coprime polynomials In algebra, the greatest common divisor (frequently abbreviated as GCD) of two polynomials is a polynomial, of the highest possible degree, that is a factor of both the two original polynomials. This concept is analogous to the greatest common di ...
in R=K /math>. Let d_i =\deg P_i be the degree of P_i(X), and D be the sum of the d_i. If A_i(X), \ldots,A_k(X) are polynomials such that A_i(X)=0 or \deg A_i for every , then, there is one and only one polynomial P(X), such that \deg P and the remainder of the
Euclidean division In arithmetic, Euclidean division – or division with remainder – is the process of dividing one integer (the dividend) by another (the divisor), in a way that produces an integer quotient and a natural number remainder strictly smaller than ...
of P(X) by P_i(X) is A_i(X) for every . The construction of the solution may be done as in or . However, the latter construction may be simplified by using, as follows,
partial fraction decomposition In algebra, the partial fraction decomposition or partial fraction expansion of a rational fraction (that is, a fraction such that the numerator and the denominator are both polynomials) is an operation that consists of expressing the fraction as ...
instead of the
extended Euclidean algorithm In arithmetic and computer programming, the extended Euclidean algorithm is an extension to the Euclidean algorithm, and computes, in addition to the greatest common divisor (gcd) of integers ''a'' and ''b'', also the coefficients of Bézout's id ...
. Thus, we want to find a polynomial P(X), which satisfies the congruences :P(X)\equiv A_i(X) \pmod , for i=1,\ldots,k. Consider the polynomials :\begin Q(X) &= \prod_^P_i(X) \\ Q_i(X) &= \frac. \end The partial fraction decomposition of 1/Q(X) gives polynomials S_i(X) with degrees \deg S_i(X) < d_i, such that :\frac = \sum_^k \frac, and thus :1 = \sum_^S_i(X) Q_i(X). Then a solution of the simultaneous congruence system is given by the polynomial :\sum_^k A_i(X) S_i(X) Q_i(X). In fact, we have : \sum_^k A_i(X) S_i(X) Q_i(X)= A_i(X)+ \sum_^(A_j(X) - A_i(X)) S_j(X) Q_j(X) \equiv A_i(X)\pmod, for 1 \leq i \leq k. This solution may have a degree larger than D=\sum_^k d_i. The unique solution of degree less than D may be deduced by considering the remainder B_i(X) of the Euclidean division of A_i(X)S_i(X) by P_i(X). This solution is :P(X)=\sum_^k B_i(X) Q_i(X).


Lagrange interpolation

A special case of Chinese remainder theorem for polynomials is
Lagrange interpolation In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data. Given a data set of coordinate pairs (x_j, y_j) with 0 \leq j \leq k, the x_j are called ''nodes'' ...
. For this, consider
monic polynomial In algebra, a monic polynomial is a non-zero univariate polynomial (that is, a polynomial in a single variable) in which the leading coefficient (the nonzero coefficient of highest degree) is equal to 1. That is to say, a monic polynomial is one ...
s of degree one: :P_i(X)=X-x_i. They are pairwise coprime if the x_i are all different. The remainder of the division by P_i(X) of a polynomial P(X) is P(x_i), by the
polynomial remainder theorem In algebra, the polynomial remainder theorem or little Bézout's theorem (named after Étienne Bézout) is an application of Euclidean division of polynomials. It states that, for every number r, any polynomial f(x) is the sum of f(r) and the p ...
. Now, let A_1, \ldots, A_k be constants (polynomials of degree 0) in K. Both Lagrange interpolation and Chinese remainder theorem assert the existence of a unique polynomial P(X), of degree less than k such that :P(x_i)=A_i, for every i. Lagrange interpolation formula is exactly the result, in this case, of the above construction of the solution. More precisely, let :\begin Q(X) &= \prod_^(X-x_i) \\ pt Q_i(X) &= \frac. \end The
partial fraction decomposition In algebra, the partial fraction decomposition or partial fraction expansion of a rational fraction (that is, a fraction such that the numerator and the denominator are both polynomials) is an operation that consists of expressing the fraction as ...
of \frac is :\frac = \sum_^k \frac. In fact, reducing the right-hand side to a common denominator one gets : \sum_^k \frac= \frac \sum_^k \frac, and the numerator is equal to one, as being a polynomial of degree less than k, which takes the value one for k different values of X. Using the above general formula, we get the Lagrange interpolation formula: :P(X)=\sum_^k A_i\frac.


Hermite interpolation

Hermite interpolation In numerical analysis, Hermite interpolation, named after Charles Hermite, is a method of polynomial interpolation, which generalizes Lagrange interpolation. Lagrange interpolation allows computing a polynomial of degree less than that takes th ...
is an application of the 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
derivative In mathematics, the derivative is a fundamental tool that quantifies the sensitivity to change of a function's output with respect to its input. The derivative of a function of a single variable at a chosen input value, when it exists, is t ...
s take given values at some fixed points. More precisely, let x_1, \ldots, x_k be k elements of the ground
field Field may refer to: Expanses of open ground * Field (agriculture), an area of land used for agricultural purposes * Airfield, an aerodrome that lacks the infrastructure of an airport * Battlefield * Lawn, an area of mowed grass * Meadow, a grass ...
K, and, for i=1,\ldots, k, let a_, a_, \ldots, a_ be the values of the first r_i derivatives of the sought polynomial at x_i (including the 0th derivative, which is the value of the polynomial itself). The problem is to find a polynomial P(X) such that its ''j''th derivative takes the value a_ at x_i, for i=1,\ldots,k and j=0,\ldots,r_j. Consider the polynomial :P_i(X) = \sum_^\frac(X - x_i)^j. This is the
Taylor polynomial In mathematics, the Taylor series or Taylor expansion of a function is an infinite sum of terms that are expressed in terms of the function's derivatives at a single point. For most common functions, the function and the sum of its Taylor ser ...
of order r_i-1 at x_i, of the unknown polynomial P(X). Therefore, we must have :P(X)\equiv P_i(X) \pmod .
Conversely In logic and mathematics, the converse of a categorical or implicational statement is the result of reversing its two constituent statements. For the implication ''P'' → ''Q'', the converse is ''Q'' → ''P''. For the categorical proposition '' ...
, any polynomial P(X) that satisfies these k congruences, in particular verifies, for any i=1, \ldots, k :P(X)= P_i(X) +o(X-x_i)^ therefore P_i(X) is its Taylor polynomial of order r_i - 1 at x_i, that is, P(X) solves the initial Hermite interpolation problem. The Chinese remainder theorem asserts that there exists exactly one polynomial of degree less than the sum of the r_i, which satisfies these k congruences. There are several ways for computing the solution P(X). One may use the method described at the beginning of . One may also use the constructions given in or .


Generalization to non-coprime moduli

The Chinese remainder theorem can be generalized to non-coprime moduli. Let m, n, a, b be any integers, let g = \gcd(m,n); M = \operatorname(m,n), and consider the system of congruences: : \begin x &\equiv a \pmod m \\ x &\equiv b \pmod n, \end If a \equiv b \pmod g, then this system has a unique solution modulo M = mn/g. Otherwise, it has no solutions. If one uses
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
to write g = um + vn, then the solution is given by : x = \frac. This defines an integer, as divides both and . Otherwise, the proof is very similar to that for coprime moduli.


Generalization to arbitrary rings

The Chinese remainder theorem can be generalized to any
ring (The) Ring(s) may refer to: * Ring (jewellery), a round band, usually made of metal, worn as ornamental jewelry * To make a sound with a bell, and the sound made by a bell Arts, entertainment, and media Film and TV * ''The Ring'' (franchise), a ...
, by using coprime ideals (also called comaximal ideals). Two ideals and are coprime if there are elements i\in I and j\in J such that i+j=1. This relation plays the role of
Bézout's identity In mathematics, Bézout's identity (also called Bézout's lemma), named after Étienne Bézout who proved it for polynomials, is the following theorem: Here the greatest common divisor of and is taken to be . The integers and are called B ...
in the proofs related to this generalization, which otherwise are very similar. The generalization may be stated as follows. Let be two-sided ideals of a ring R and let be their
intersection In mathematics, the intersection of two or more objects is another object consisting of everything that is contained in all of the objects simultaneously. For example, in Euclidean geometry, when two lines in a plane are not parallel, their ...
. If the ideals are pairwise coprime, we have the
isomorphism In mathematics, an isomorphism is a structure-preserving mapping or morphism between two structures of the same type that can be reversed by an inverse mapping. Two mathematical structures are isomorphic if an isomorphism exists between the ...
: :\begin R/I &\to (R/I_1) \times \cdots \times (R/I_k) \\ x \bmod I &\mapsto (x \bmod I_1,\, \ldots,\, x \bmod I_k), \end between the
quotient ring In ring theory, a branch of abstract algebra, a quotient ring, also known as factor ring, difference ring or residue class ring, is a construction quite similar to the quotient group in group theory and to the quotient space in linear algebra. ...
R/I and the
direct product In mathematics, a direct product of objects already known can often be defined by giving a new one. That induces a structure on the Cartesian product of the underlying sets from that of the contributing objects. The categorical product is an abs ...
of the R/I_i, where "x \bmod I" denotes the
image An image or picture is a visual representation. An image can be Two-dimensional space, two-dimensional, such as a drawing, painting, or photograph, or Three-dimensional space, three-dimensional, such as a carving or sculpture. Images may be di ...
of the element x in the quotient ring defined by the ideal I. Moreover, if R is
commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
, then the ideal intersection of pairwise coprime ideals is equal to their
product Product may refer to: Business * Product (business), an item that can be offered to a market to satisfy the desire or need of a customer. * Product (project management), a deliverable or set of deliverables that contribute to a business solution ...
; that is : I= I_1\cap I_2 \cap\cdots\cap I_k= I_1I_2\cdots I_k, if and are coprime for all .


Interpretation in terms of idempotents

Let I_1, I_2, \dots, I_k be pairwise coprime two-sided ideals with \bigcap_^k I_i = 0, and :\varphi:R\to (R/I_1) \times \cdots \times (R/I_k) be the isomorphism defined above. Let f_i=(0,\ldots,1,\ldots, 0) be the element of (R/I_1) \times \cdots \times (R/I_k) whose components are all except the th which is , and e_i=\varphi^(f_i). The e_i are
central idempotent In ring theory, a branch of mathematics, an idempotent element or simply idempotent of a ring (mathematics), ring is an element such that . That is, the element is idempotent under the ring's multiplication. Mathematical induction, Inductively the ...
s that are pairwise
orthogonal In mathematics, orthogonality (mathematics), orthogonality is the generalization of the geometric notion of ''perpendicularity''. Although many authors use the two terms ''perpendicular'' and ''orthogonal'' interchangeably, the term ''perpendic ...
; this means, in particular, that e_i^2=e_i and e_ie_j=e_je_i=0 for every and . Moreover, one has e_1+\cdots+e_n=1, and I_i=R(1-e_i). In summary, this generalized Chinese remainder theorem is the equivalence between giving pairwise coprime two-sided ideals with a zero intersection, and giving central and pairwise orthogonal idempotents that sum to .


Applications


Sequence numbering

The Chinese remainder theorem has been used to construct a
Gödel numbering for sequences In mathematics, a Gödel numbering for sequences provides an effective way to represent each finite sequence of natural numbers as a single natural number. While a set theoretical embedding is surely possible, the emphasis is on the effectiveness ...
, which is involved in the proof of
Gödel's incompleteness theorems Gödel's incompleteness theorems are two theorems of mathematical logic that are concerned with the limits of in formal axiomatic theories. These results, published by Kurt Gödel in 1931, are important both in mathematical logic and in the phi ...
.


Fast Fourier transform

The
prime-factor FFT algorithm The prime-factor algorithm (PFA), also called the Good–Thomas algorithm (1958/1963), is a fast Fourier transform (FFT) algorithm that re-expresses the discrete Fourier transform (DFT) of a size as a two-dimensional DFT, but ''only'' for the ca ...
(also called Good-Thomas algorithm) uses the Chinese remainder theorem for reducing the computation of a
fast Fourier transform A fast Fourier transform (FFT) is an algorithm that computes the discrete Fourier transform (DFT) of a sequence, or its inverse (IDFT). A Fourier transform converts a signal from its original domain (often time or space) to a representation in ...
of size n_1n_2 to the computation of two fast Fourier transforms of smaller sizes n_1 and n_2 (providing that n_1 and n_2 are coprime).


Encryption

Most implementations of RSA use the Chinese remainder theorem during signing of
HTTPS Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP). It uses encryption for secure communication over a computer network, and is widely used on the Internet. In HTTPS, the communication protoc ...
certificates and during decryption. The Chinese remainder theorem can also be used in
secret sharing Secret sharing (also called secret splitting) refers to methods for distributing a secrecy, secret among a group, in such a way that no individual holds any intelligible information about the secret, but when a sufficient number of individuals c ...
, 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 The thumb is the first digit of the hand, next to the index finger. When a person is standing in the medical anatomical position (where the palm is facing to the front), the thumb is the outermost digit. The Medical Latin English noun for thum ...
.


Range ambiguity resolution

The
range ambiguity resolution Range ambiguity resolution is a technique used with medium pulse-repetition frequency (PRF) radar to obtain range information for distances that exceed the distance between transmit pulses. This signal processing technique is required with puls ...
techniques used with medium pulse repetition frequency radar can be seen as a special case of the Chinese remainder theorem.


Decomposition of surjections of finite abelian groups

Given a
surjection In mathematics, a surjective function (also known as surjection, or onto function ) is a function such that, for every element of the function's codomain, there exists one element in the function's domain such that . In other words, for a f ...
\mathbb/n \to \mathbb/m of
finite Finite may refer to: * Finite set, a set whose cardinality (number of elements) is some natural number * Finite verb, a verb form that has a subject, usually being inflected or marked for person and/or tense or aspect * "Finite", a song by Sara Gr ...
abelian group In mathematics, an abelian group, also called a commutative group, is a group in which the result of applying the group operation to two group elements does not depend on the order in which they are written. That is, the group operation is commu ...
s, we can use the Chinese remainder theorem to give a complete description of any such map. First of all, the theorem gives isomorphisms :\begin \mathbb/n &\cong \mathbb/p_^ \times \cdots \times \mathbb/p_^ \\ \mathbb/m &\cong \mathbb/p_^ \times \cdots \times \mathbb/p_^ \end where \ \subseteq \. In addition, for any induced map :\mathbb/p_^ \to \mathbb/p_^ from the original surjection, we have a_k \geq b_l and p_ = p_, since for a pair of
primes A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways ...
p,q, the only non-zero surjections :\mathbb/p^a \to \mathbb/q^b can be defined if p = q and a \geq b. These observations are pivotal for constructing the ring of
profinite integer In mathematics, a profinite integer is an element of the ring (mathematics), ring (sometimes pronounced as zee-hat or zed-hat) :\widehat = \varprojlim \mathbb/n\mathbb, where the inverse limit of the quotient rings \mathbb/n\mathbb runs through al ...
s, which is given as an
inverse limit In mathematics, the inverse limit (also called the projective limit) is a construction that allows one to "glue together" several related objects, the precise gluing process being specified by morphisms between the objects. Thus, inverse limits ca ...
of all such maps.


Dedekind's theorem

Dedekind's theorem on the linear independence of characters. Let be a
monoid In abstract algebra, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being . Monoids are semigroups with identity ...
and an
integral domain In mathematics, an integral domain is a nonzero commutative ring in which the product of any two nonzero elements is nonzero. Integral domains are generalizations of the ring of integers and provide a natural setting for studying divisibilit ...
, viewed as a monoid by considering the multiplication on . Then any finite family of distinct
monoid homomorphism In abstract algebra, a monoid is a set equipped with an associative binary operation and an identity element. For example, the nonnegative integers with addition form a monoid, the identity element being . Monoids are semigroups with identity ...
s is
linearly independent In the theory of vector spaces, a set of vectors is said to be if there exists no nontrivial linear combination of the vectors that equals the zero vector. If such a linear combination exists, then the vectors are said to be . These concep ...
. In other words, every family of elements satisfying :\sum_\alpha_i f_i = 0 must be equal to the family . Proof. First assume that is a
field Field may refer to: Expanses of open ground * Field (agriculture), an area of land used for agricultural purposes * Airfield, an aerodrome that lacks the infrastructure of an airport * Battlefield * Lawn, an area of mowed grass * Meadow, a grass ...
, otherwise, replace the integral domain by its
quotient field In abstract algebra, the field of fractions of an integral domain is the smallest field in which it can be embedded. The construction of the field of fractions is modeled on the relationship between the integral domain of integers and the fiel ...
, and nothing will change. We can linearly extend the monoid homomorphisms to -
algebra homomorphism In mathematics, an algebra over a field (often simply called an algebra) is a vector space equipped with a bilinear product. Thus, an algebra is an algebraic structure consisting of a set together with operations of multiplication and addition ...
s , where is the
monoid ring In abstract algebra, a monoid ring is a ring constructed from a ring and a monoid, just as a group ring is constructed from a ring and a group. Definition Let ''R'' be a ring and let ''G'' be a monoid. The monoid ring or monoid algebra of ''G'' o ...
of over . Then, by linearity, the condition :\sum_\alpha_i f_i = 0, yields :\sum_\alpha_i F_i = 0. Next, for the two -linear maps and are not proportional to each other. Otherwise and would also be proportional, and thus equal since as monoid homomorphisms they satisfy: , which contradicts the assumption that they are distinct. Therefore, the
kernels Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learnin ...
and are distinct. Since is a field, is a
maximal ideal In mathematics, more specifically in ring theory, a maximal ideal is an ideal that is maximal (with respect to set inclusion) amongst all ''proper'' ideals. In other words, ''I'' is a maximal ideal of a ring ''R'' if there are no other ideals ...
of for every in . Because they are distinct and maximal the ideals and are coprime whenever . The Chinese Remainder Theorem (for general rings) yields an isomorphism: :\begin \phi: k / K &\to \prod_k / \mathrm F_i \\ \phi(x + K) &= \left(x + \mathrm F_i\right)_ \end where :K = \prod_\mathrm F_i = \bigcap_\mathrm F_i. Consequently, the map :\begin \Phi: k &\to \prod_k \mathrm F_i \\ \Phi(x) &= \left(x + \mathrm F_i\right)_ \end is surjective. Under the isomorphisms the map corresponds to: :\begin \psi: k &\to \prod_k \\ \psi(x) &= \left _i(x)\right \end Now, :\sum_\alpha_i F_i = 0 yields :\sum_\alpha_i u_i = 0 for every vector in the
image An image or picture is a visual representation. An image can be Two-dimensional space, two-dimensional, such as a drawing, painting, or photograph, or Three-dimensional space, three-dimensional, such as a carving or sculpture. Images may be di ...
of the map . Since is surjective, this means that :\sum_\alpha_i u_i = 0 for every vector :\left(u_i\right)_ \in \prod_k. Consequently, . QED.


See also

*
Covering system In mathematics, a covering system (also called a complete residue system) is a collection :\ of finitely many residue classes : a_i\pmod = \, whose union contains every integer. Examples and definitions The notion of covering system was i ...
*
Hasse principle In mathematics, Helmut Hasse's local–global principle, also known as the Hasse principle, is the idea that one can find an integer solution to an equation by using the Chinese remainder theorem to piece together solutions modulo powers of each d ...
*
Residue number system A residue number system or residue numeral system (RNS) is a numeral system representing integers by their values modular arithmetic, modulo several pairwise coprime integers called the moduli. This representation is allowed by the Chinese remaind ...


Notes


References

* * *. See in particular Section 2.5, "Helly Property"
pp. 393–394
* * * * * * * * * * *


Further reading

*. See Section 31.5: The Chinese remainder theorem, pp. 873–876. * * *. See Section 4.3.2 (pp. 286–291), exercise 4.6.2–3 (page 456).


External links

* * *
Full text of the Sun-tzu Suan-ching
(Chinese)
Chinese Text Project The Chinese Text Project (CTP; ) is a digital library project that assembles collections of early Chinese texts. The name of the project in Chinese literally means "The Chinese Philosophical Book Digitization Project", showing its focus on books ...
{{authority control Articles containing proofs Sun, Master Commutative algebra Modular arithmetic Theorems in number theory