Simultaneous Linear Congruences- Chinese Remainder Theorem (CRT)



We will now consider the solutions of simultaneous congruences. In the 1st century AD, the Chinese mathematician Sun-Tsu considered problems like ‘find a number which leaves remainders 2,3,2 when divided by 3,5,7 respectively’. Equivalently, he wanted to find x such that the congruences

x2(mod3),x3(mod5),x2(mod7)
 
are simultaneously true. Note that if x0 is any solution, then so is x0+(3×5×7)t for any integer t, so the solutions form a union of congruence classes mod (105).

We shall show that in this particular case the solutions form a single congruence class, but in other cases we may find that there are several classes or none: as an example, the simultaneous congruences

x3(mod9),x2(mod6)

have no solutions, for if x3(mod9) then 3 divides x, whereas if x2(mod6) then 3 does not divide x. The difficulty here is that the moduli 9 and 6 have a factor 3 in common, so both congruences have implications about the congruence class of x(mod3), and in this particular case these implications are m utually inconsistent. To avoid this type of difficulty, we will initially restrict our attention to cases like our first example, where the moduli are mutually coprime. 
  
Fortunately, the following result, known as the Chinese Remainder Theorem, gives a very satisfactory solution to this type of problem.

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 ij, gcd(ni,nj)=1), and let a1,a2,,akbe any integers. Then the system of simultaneous congruences

xa1(modn1)xa2(modn2)xak(modnk)

has a unique solution modulo N=n1×n2××nk

Proof:

  1. Existence of a Solution:

    Let N=n1×n2××nkFor each i, let Ni=N/ni. Since niand Niare coprime, there exist integers bi such that Nibi1(modni). Now, let x=ki=1aiNibi We claim that x is a solution to the system of congruences.

    Indeed, for any i, we have:

    xaiNibiai.1ai(modni)

    Thus, x satisfies all the congruences.

  2. Uniqueness of Solution:

    Suppose x1 and x2 are two solutions to the system of congruences. Then x1x2(modni) for all i. Hence, x1x2(modNi) for all i.

    Since N=n1×n2××nk by the Chinese Remainder Theorem, x1x2(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:

x2(mod3)x3(mod5)x2(mod7)

Here, n1=3, n2=5, and n3=7 are pairwise coprime.

  1. Compute N=n1×n2×n3=3×5×7=105.
  2. Compute N1=105/3=35, N2=105/5=21, and N3=105/7=15
  3. Compute the inverses b1, b2, and b3 such that Nibi1(modni). 35b11(mod3),21b21(mod5),15b31(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=233

Therefore, the unique solution to the given system of congruences modulo N=105 is x23(mod105)


Example:

Suppose we have the following system of congruences:

x1(mod3)x4(mod5)x6(mod7)
 

We follow the steps of the Chinese Remainder Theorem:

  1. Compute N=n1×n2×n3=3×5×7=105
  2. Compute N1=105/3=35, N2=105/5=21, and N3=105/7=15
  3. Compute the inverses b1, b2, and b3 such that Nibi1(modni)

For n1=3, we have N1b11(mod3), so 35b11(mod3)Solving this congruence, we find b12(mod3)

For n2=5, we have N2b21(mod5), so 21b21(mod5). Solving this congruence, we find b21(mod5)

For n3=7, we have N3b31(mod7), so 15b31(mod7). Solving this congruence, we find b31(mod7)

  1. 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 xaimod(ni). If we are given a set of simultaneous linear congruences, with one (or more) of them in the more general form axbmod(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

7x3(mod12),10x6(mod14)

This can be reduced into

x9(mod12),x2(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:

  1. Compute N=n1×n2=12×7=84
  2. Compute N1=84/12=7 and N2=84/7=12
  3. Compute the inverses b1 and b2 such that Nibi1(modni)

For n1=12, we have N1b11(mod12), so 7b11(mod12). Solving this congruence, we find b17(mod12)

For n2=7, we have N2b21(mod7), so 12b21(mod7). Solving this congruence, we find b23(mod7)

  1. 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 x9(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  13x71(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.

13x71(mod4),13x71(mod5),13x71(mod19)

These can be immediately reduced to
x3(mod4),3x1(mod5),13x14(mod19)

We can further reduce this into
x3(mod4),x2(mod5),x4(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 Nibi1(modni)

For n1=4, we have N1b11(mod4), so 95.b11(mod4). Solving this congruence, we find b13(mod4)

For n2=5, we have N2b21(mod5), so 76.b21(mod5). Solving this congruence, we find b21(mod5)

For n3=19, we have N3b31(mod19), so 20.b31(mod19). Solving this congruence, we find b31(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 x327(mod380). General solution is 327+380t

Python code 
x2(mod3)x3(mod5)x2(mod7)

from sympy.ntheory.modular import crt

print(crt([3, 5, 7], [2, 3, 2]))

Output:(23, 105)

Comments

Popular posts from this blog

Number Theory CST 292 KTU IV Semester Honors Course Notes Dr Binu V P 9847390760

Sum of Squares

Well Ordering Principle