Chinese Remainder Theorem
Given a residual number (r1, r2, …, rk) with
moduli (m1, m2, …, mk), where all mi are
mutually prime, set M= m1×m2× …×mk, and
Mi=M/mi.
Let Si be the solution that (Mi×Si)%mi = 1
Then we have the corresponding number
x = (∑i=1,k(Mi Si ri))%M.
1
Example
Given (m1,m2,m3)=(2,3,7), M=2×3×7=42, we have
M1=m2×m3=3×7=21 (M1S1)%m1=(21S1)%2=1
M2=m1×m3=2×7=14 (M2S2)%m2=(14S2)%3=1
M3=m1×m2=2×3=6 (M3S3)%m3=(6S3)%7=1
Thus, (S1, S2, S3) = (1,2,6)
For a residual number (0,2,1):
x=(M1S1r1 + M2S2r2 + M3S3r3)%M
=(21×1×0 + 14×2×2 + 6×6×1 )%42
= ( 0 + 56 + 36 )%42 = 92%42 = 8
2
Example
For a residual number (1,2,5):
• x=(M1S1r1 + M2S2r2 + M3S3r3)%M
= (21×1×1 + 14×2×2 + 6×6×5)%42
= (21 + 56 + 180)%42
= 257%42 = 5
3
Proof of Chinese Remainder
Theorem
Let A = ∑i=1,k(Mi Si ri), we show that
1. A%mv = rv and 2. x=A%M is unique.
1. A%mv= (∑i=1,k(Mi Si ri) )% mv
= (Σ(MiSiri) % mv)%mv = (MvSvrv)%mv
= [(MvSv)%mv × rv%mv ]%mv = rv%mv = rv
2. Proof was shown in lecture 5.
4
Chinese Remainder Theorem
 used to speed up modulo computations
 if working modulo a product of numbers
 e.g., mod M, where M = m1m2..mk
 Chinese Remainder theorem lets us work
in each modulus mi separately
 since computational cost is proportional to
size, this is faster than working in the full
modulus M
Chinese Remainder Theorem
 can implement CRT in several ways
 to compute A(mod M)
 first compute all ai = A mod mi separately
 determine constants ci below, where Mi = M/mi
 then combine results to get answer using:

Chinese remainder theorem -new.ppt

  • 1.
    Chinese Remainder Theorem Givena residual number (r1, r2, …, rk) with moduli (m1, m2, …, mk), where all mi are mutually prime, set M= m1×m2× …×mk, and Mi=M/mi. Let Si be the solution that (Mi×Si)%mi = 1 Then we have the corresponding number x = (∑i=1,k(Mi Si ri))%M. 1
  • 2.
    Example Given (m1,m2,m3)=(2,3,7), M=2×3×7=42,we have M1=m2×m3=3×7=21 (M1S1)%m1=(21S1)%2=1 M2=m1×m3=2×7=14 (M2S2)%m2=(14S2)%3=1 M3=m1×m2=2×3=6 (M3S3)%m3=(6S3)%7=1 Thus, (S1, S2, S3) = (1,2,6) For a residual number (0,2,1): x=(M1S1r1 + M2S2r2 + M3S3r3)%M =(21×1×0 + 14×2×2 + 6×6×1 )%42 = ( 0 + 56 + 36 )%42 = 92%42 = 8 2
  • 3.
    Example For a residualnumber (1,2,5): • x=(M1S1r1 + M2S2r2 + M3S3r3)%M = (21×1×1 + 14×2×2 + 6×6×5)%42 = (21 + 56 + 180)%42 = 257%42 = 5 3
  • 4.
    Proof of ChineseRemainder Theorem Let A = ∑i=1,k(Mi Si ri), we show that 1. A%mv = rv and 2. x=A%M is unique. 1. A%mv= (∑i=1,k(Mi Si ri) )% mv = (Σ(MiSiri) % mv)%mv = (MvSvrv)%mv = [(MvSv)%mv × rv%mv ]%mv = rv%mv = rv 2. Proof was shown in lecture 5. 4
  • 5.
    Chinese Remainder Theorem used to speed up modulo computations  if working modulo a product of numbers  e.g., mod M, where M = m1m2..mk  Chinese Remainder theorem lets us work in each modulus mi separately  since computational cost is proportional to size, this is faster than working in the full modulus M
  • 6.
    Chinese Remainder Theorem can implement CRT in several ways  to compute A(mod M)  first compute all ai = A mod mi separately  determine constants ci below, where Mi = M/mi  then combine results to get answer using:

Editor's Notes