Download SUPPLY AND DEMAND and more Essays (high school) English Language in PDF only on Docsity! The Chinese Remainder Theorem Chinese Remainder Theorem: If m1, m2, .., mk are pairwise relatively prime positive integers, and if a1, a2, .., ak are any integers, then the simultaneous congruences x ≡ a1 (mod m1), x ≡ a2 (mod m2), ..., x ≡ ak (mod mk) have a solution, and the solution is unique modulo m, where m = m1m2⋅⋅⋅mk . Proof that a solution exists: To keep the notation simpler, we will assume k = 4. Note the proof is constructive, i.e., it shows us how to actually construct a solution. Our simultaneous congruences are x ≡ a1 (mod m1), x ≡ a2 (mod m2), x ≡ a3 (mod m3), x ≡ a4 (mod m4). Our goal is to find integers w1, w2, w3, w4 such that: value mod m1 value mod m2 value mod m3 value mod m4 w1 1 0 0 0 w2 0 1 0 0 w3 0 0 1 0 w4 0 0 0 1 Once we have found w1, w2, w3, w4, it is easy to construct x: x = a1w1 + a2w2 + a3w3 + a4w4. Moreover, as long as the moduli (m1, m2, m3, m4) remain the same, we can use the same w1, w2, w3, w4 with any a1, a2, a3, a4. First define: z1 = m / m1 = m2m3m4 z2 = m / m2 = m1m3m4 z3 = m / m3 = m1m2m4 z4 = m / m4 = m1m2m3 Note that i) z1 ≡ 0 (mod mj) for j = 2, 3, 4. ii) gcd(z1, m1) = 1. (If a prime p dividing m1 also divides z1= m2m3m4, then p divides m2, m3, or m4.) and likewise for z2, z3, z4. Next define: y1 ≡ z1 –1 (mod m1) y2 ≡ z2 –1 (mod m2) y3 ≡ z3 –1 (mod m3) y4 ≡ z4 –1 (mod m4) The inverses exist by (ii) above, and we can find them by Euclid’s extended algorithm. Note that iii) y1z1 ≡ 0 (mod mj) for j = 2, 3, 4. (Recall z1 ≡ 0 (mod mj) ) iv) y1z1 ≡ 1 (mod m1) and likewise for y2z2, y3z3, y4z4. Lastly define: w1 ≡ y1z1 (mod m) w2 ≡ y2z2 (mod m) w3 ≡ y3z3 (mod m) w4 ≡ y4z4 (mod m) Then w1, w2, w3, and w4 have the properties in the table on the previous page.