The Chinese Remainder Theorem (CRT) is a fundamental theorem in number theory with applications in various fields such as cryptography, computer science, and pure mathematics. It provides a solution to simultaneous congruences.
Statement:
Let n1,n2,…,nkbe positive integers that are pairwise coprime (i.e., for every i≠j, gcd(ni,nj)=1), and let a1,a2,…,akbe any integers. Then the system of simultaneous congruences
x≡a1(modn1)x≡a2(modn2)⋮x≡ak(modnk)
has a unique solution modulo N=n1×n2×…×nk
Proof:
Existence of a Solution:
Let N=n1×n2×…×nk.For each i, let Ni=N/ni. Since niand Niare coprime, there exist integers bi such that Nibi≡1(modni). Now, let x=∑ki=1aiNibi. We claim that x is a solution to the system of congruences.
Indeed, for any i, we have:
x≡aiNibi≡ai.1≡ai(modni)
Thus, x satisfies all the congruences.
Uniqueness of Solution:
Suppose x1 and x2 are two solutions to the system of congruences. Then x1≡x2(modni) for all i. Hence, x1≡x2(modNi) for all i.
Since N=n1×n2×…×nk by the Chinese Remainder Theorem, x1≡x2(modN)
Thus, any two solutions are congruent modulo N, and hence, the solution is unique modulo N.
Example:
Let's solve the following system of simultaneous congruences:
x≡2(mod3)x≡3(mod5)x≡2(mod7)
Here, n1=3, n2=5, and n3=7 are pairwise coprime.
- Compute N=n1×n2×n3=3×5×7=105.
- Compute N1=105/3=35, N2=105/5=21, and N3=105/7=15
- Compute the inverses b1, b2, and b3 such that Nibi≡1(modni). 35b1≡1(mod3),21b2≡1(mod5),15b3≡1(mod7)
4.We get
b1=2,
b2=1, and
b3=1.
5.Calculate
x=a1N1b1+a2N2b2+a3N3b3=2×35×2+3×21×1+2×15×1=233Therefore, the unique solution to the given system of congruences modulo N=105 is x≡23(mod105).
Example: Suppose we have the following system of congruences:
x≡1(mod3)x≡4(mod5)x≡6(mod7)
We follow the steps of the Chinese Remainder Theorem:
- Compute N=n1×n2×n3=3×5×7=105
- Compute N1=105/3=35, N2=105/5=21, and N3=105/7=15
- Compute the inverses b1, b2, and b3 such that Nibi≡1(modni)
For n1=3, we have N1b1≡1(mod3), so 35b1≡1(mod3).Solving this congruence, we find b1≡2(mod3)
For n2=5, we have N2b2≡1(mod5), so 21b2≡1(mod5). Solving this congruence, we find b2≡1(mod5)
For n3=7, we have N3b3≡1(mod7), so 15b3≡1(mod7). Solving this congruence, we find b3≡1(mod7)
- Calculate x=a1N1b1+a2N2b2+a3N3b3=1×35×2+4×21×1+6×15×1=244
Therefore, the unique solution to the given system of congruences modulo N=105 is x≡34(mod105)
The linear congruences in the Chinese Remainder Theorem are all of the form x≡aimod(ni). If we are given a set of simultaneous linear congruences, with one (or more) of them in the more general form ax≡bmod(ni), then we will first need to use the earlier algorithm to solve this congruence, expressing its general solution as a congruence class modulo some divisor of ni; it will then be possible to apply the techniques based on the Chinese Remainder Theorem to solve the resulting simultaneous congruences.
Example:Consider the congruences
7x≡3(mod12),10x≡6(mod14)This can be reduced into
x≡9(mod12),x≡2(mod7)Now it is in standard form and can be solved with CRT
The solution is
We follow the steps of the Chinese Remainder Theorem:
- Compute N=n1×n2=12×7=84
- Compute N1=84/12=7 and N2=84/7=12
- Compute the inverses b1 and b2 such that Nibi≡1(modni)
For n1=12, we have N1b1≡1(mod12), so 7b1≡1(mod12). Solving this congruence, we find b1≡7(mod12)
For n2=7, we have N2b2≡1(mod7), so 12b2≡1(mod7). Solving this congruence, we find b2≡3(mod7)
- Calculate x=a1N1b1+a2N2b2=9×7×7+2×12×3=513
Therefore, the unique solution to the given system of congruences modulo N=84 is x≡9(mod84)
The Chinese Remainder Theorem (CRT) can be used to convert a single congruence, with a large modulus into several simultaneous congruences with smaller moduli
Example:
Consider the congruence
13x≡71(mod380)Instead of solving this single linear congruence, we can use factorization
380=22×5×19 So we can replace the original congruence with three simultaneous congruences.
13x≡71(mod4),13x≡71(mod5),13x≡71(mod19)
These can be immediately reduced to
x≡3(mod4),3x≡1(mod5),13x≡14(mod19)
We can further reduce this into
x≡3(mod4),x≡2(mod5),x≡4(mod19)
We follow the steps of the Chinese Remainder Theorem:Compute
N=n1×n2×n3=4×5×19=380 Compute N1=380/4=95 and N2=380/5=76 and N3=380/19=20
Compute the inverses b1,b2 and b3 such that Nibi≡1(modni)
For n1=4, we have N1b1≡1(mod4), so 95.b1≡1(mod4). Solving this congruence, we find b1≡3(mod4)
For n2=5, we have N2b2≡1(mod5), so 76.b2≡1(mod5). Solving this congruence, we find b2≡1(mod5)
For n3=19, we have N3b3≡1(mod19), so 20.b3≡1(mod19). Solving this congruence, we find b3≡1(mod19)
Calculate x=a1N1b1+a2N2b2+a3N3b3=3×95×3+2×76×1+4×20×1=1080=327(mod380)
Therefore, the unique solution to the given system of congruences modulo N=380 is x≡327(mod380). General solution is 327+380t
Python code
x≡2(mod3)x≡3(mod5)x≡2(mod7)
from sympy.ntheory.modular import crt
print(crt([3, 5, 7], [2, 3, 2]))
Output:(23, 105)
Comments
Post a Comment