numb3rs
play

Numb3rs 11 2 10 3 The Chinese Remainder Theorem 9 4 8 5 7 - PowerPoint PPT Presentation

0 12 1 Numb3rs 11 2 10 3 The Chinese Remainder Theorem 9 4 8 5 7 6 Chiming Clocks Two clocks, with a hours and b hours on their dials 0 1 12 Say they both start at 0, and move one step every 2 11 10 3 minute 9 4 e.g.,


  1. 0 12 1 Numb3rs 11 2 10 3 The Chinese Remainder Theorem 9 4 8 5 7 6

  2. Chiming Clocks Two clocks, with a hours and b hours on their dials 0 1 12 Say they both start at 0, and move one step every 2 11 10 3 minute 9 4 e.g., a=13, b=9. After 3 minutes, both point to 3. 8 5 7 6 After 10 minutes, the first clock points to 10, 0 and the second to 1. 1 8 Each clock has a position where it chimes, say 7 2 r and s, respectively 6 3 5 4 e.g., r=11 and s=5 Question : Will the two clocks ever chime together?

  3. An Example time Clock 1 Clock 2 0 0 0 0 0 1 1 1 Say, a=3 and b=5 1 4 1 2 2 2 2 2 3 3 0 3 Note that after lcm(a,b) = 15 steps, both 4 1 4 clocks will be back to 0 5 2 0 6 0 1 So enough to check the first 15 steps 7 1 2 8 2 3 Let’ s find out all pairs (r,s) that the two 9 0 4 clocks will simultaneously reach 10 1 0 11 2 1 All 15 possible pairs occur, once each! 12 0 2 13 1 3 14 2 4

  4. As Modular Arithmetic Z 15 Z 3 Z 5 0 0 0 Consider mapping elements in Z 15 (all 15 of 1 1 1 2 2 2 them) to Z 3 and Z 5 3 0 3 x ↦ (x mod 3, x mod 5) 4 1 4 5 2 0 All 15 possible pairs occur, once each 6 0 1 That is, for each (r,s) ∈ Z 3 × Z 5 , there is 7 1 2 8 2 3 exactly one x such that 9 0 4 x ≡ r (mod 3) and x ≡ s (mod 5) 10 1 0 11 2 1 For which a,b are we guaranteed that there 12 0 2 is a solution for this system (no matter what 13 1 3 r,s is)? 14 2 4

  5. Chinese Remainder Theorem If gcd(a,b) = 1, then for all (r,s) there is a Z 15 Z 3 Z 5 unique solution (modulo ab) to the system 0 0 0 1 1 1 x ≡ r (mod a) and x ≡ s (mod b) 2 2 2 3 0 3 4 1 4 5 2 0 Any (r,s) ∈ Z × Z has exactly the same 6 0 1 7 1 2 solutions as the pair (rem(r,a),rem(s,b)) has 8 2 3 9 0 4 So, w.l.o.g, r ∈ [0,a) and s ∈ [0,b) 10 1 0 11 2 1 12 0 2 13 1 3 14 2 4

  6. Chinese Remainder Theorem If gcd(a,b) = 1, then for all (r,s) there is a Z 15 Z 3 Z 5 unique solution (modulo ab) to the system 0 0 0 1 1 1 x ≡ r (mod a) and x ≡ s (mod b) 2 2 2 Proof of existence: 3 0 3 Take snapshots of the b-clock every time 4 1 4 5 2 0 the needle of the a-clock reaches 0. 6 0 1 The snapshots correspond to the needle of 7 1 2 the b-clock moving a hours at a time 8 2 3 Since gcd(a,b)=1, all positions in the b- 9 0 4 clock will be reached in the snapshots 10 1 0 11 2 1 i.e., for all s, (0,s) has a solution 12 0 2 0 4 For any (r,s), let s’ ≡ s-r (mod b). Let x be 13 1 3 1 0 a solution for (0,s’). x+r is one for (r,s). 2 1 14 2 4

  7. Chinese Remainder Theorem If gcd(a,b) = 1, then for all (r,s) there is a Z 15 Z 3 Z 5 unique solution (modulo ab) to the system 0 0 0 1 1 1 x ≡ r (mod a) and x ≡ s (mod b) 2 2 2 Proof of existence: 3 0 3 4 1 4 Will solve for (r,s)=(1,0) and for (r,s)=(0,1) 5 2 0 i.e., α ≡ 1 (mod a), α ≡ 0 (mod b), 6 0 1 β ≡ 0 (mod a), β ≡ 1 (mod b), 7 1 2 8 2 3 Then, can let x = α r+ β s. 9 0 4 ∃ u,v au+bv=1 (can compute using EEA) 10 1 0 11 2 1 Let α = 1-au = bv and β = 1-bv = au 12 0 2 13 1 3 14 2 4

  8. Chinese Remainder Theorem If gcd(a,b) = 1, then for all (r,s) there is a Z 15 Z 3 Z 5 unique solution (modulo ab) to the system 0 0 0 1 1 1 x ≡ r (mod a) and x ≡ s (mod b) 2 2 2 Existence: x = bvr + aus, where au+bv=1 3 0 3 4 1 4 Uniqueness: 5 2 0 Recall, r ∈ [0,a) and s ∈ [0,b) 6 0 1 7 1 2 There are ab such pairs (r,s). Every pair (r,s) 8 2 3 has at least one solution. 9 0 4 10 1 0 There are only ab values of x (mod ab). 11 2 1 Each x is a solution for (at most) one (r,s). 12 0 2 Hence, no pair (r,s) has two solutions 13 1 3 14 2 4

  9. Chinese Remainder Theorem If gcd(a,b) = 1, then for all (r,s) there is a Z 15 Z 3 Z 5 unique solution (modulo ab) to the system 0 0 0 1 1 1 x ≡ r (mod a) and x ≡ s (mod b) 2 2 2 Existence: x = bvr + aus, where au+bv=1 3 0 3 4 1 4 Uniqueness: | Z ab | = | Z a | ⋅ | Z b | 5 2 0 6 0 1 CRT Representation: 7 1 2 8 2 3 Represent x ∈ Z ab as the pair 9 0 4 (r,s) = ( rem(x,a), rem(x,b) ) ∈ Z a × Z b 10 1 0 11 2 1 Can go from (r,s) to x uniquely, using EEA 12 0 2 13 1 3 14 2 4

  10. m = ab, where gcd(a,b) = 1 Arithmetic Using CRT Suppose m = ab, where gcd(a,b) = 1 m = ab, where gcd(a,b) = 1 Z 15 Z 3 Z 5 0 0 0 Can use CRT representation to do arithmetic in 1 1 1 Z m using arithmetic in Z a and Z b 2 2 2 3 0 3 CRT representation of Z m : every element of Z m 4 1 4 can be written as a unique element of Z a × Z b 5 2 0 Addition and multiplication can be done 6 0 1 coordinate-wise in CRT representation 7 1 2 8 2 3 If rem(x,a)=r and rem(x’,a)=r’, then 9 0 4 rem(x+x’,a) ≡ r + r’ (mod a). Similarly, mod b. 10 1 0 (r, s) + (m) (r’, s’) = (r + (a) r’, s + (b) s’) 11 2 1 12 0 2 Similarly, 13 1 3 (r, s) × (m) (r’, s’) = (r × (a) r’, s × (b) s’) 14 2 4

  11. m = ab, where gcd(a,b) = 1 CRT and Inverses Z 15 Z 3 Z 5 0 0 0 Addition and multiplication can be done 1 1 1 coordinate-wise in CRT representation 2 2 2 Additive identity is (0,0) and multiplicative 3 0 3 identity is (1,1) 4 1 4 5 2 0 Additive and multiplicative inverses are 6 0 1 coordinate-wise too 7 1 2 (r,s) + (m) (r’,s’) = (0,0) ⟷ r+ (a) r’= 0, s+ (b) s’= 0 8 2 3 9 0 4 (r,s) × (m) (r’,s’) = (1,1) ⟷ r × (a) r’= 1, s × (b) s’= 1 10 1 0 11 2 1 12 0 2 13 1 3 14 2 4

  12. m = ab, where gcd(a,b) = 1 CRT and Inverses Z 15 Z 3 Z 5 0 0 0 Addition and multiplication can be done 1 1 1 coordinate-wise in CRT representation 2 2 2 Additive identity is (0,0) and multiplicative 3 0 3 identity is (1,1) 4 1 4 5 2 0 Additive and multiplicative inverses are 6 0 1 coordinate-wise too 7 1 2 (r,s) + (m) (r’,s’) = (0,0) ⟷ r+ (a) r’= 0, s+ (b) s’= 0 8 2 3 9 0 4 (r,s) × (m) (r’,s’) = (1,1) ⟷ r × (a) r’= 1, s × (b) s’= 1 10 1 0 x has multiplicative inverse modulo m iff it 11 2 1 has multiplicative inverses modulo a and b 12 0 2 13 1 3 gcd(x,m)=1 ↔ gcd(x,a)=1 and gcd(x,b)=1 14 2 4

  13. CRT Beyond 2 Factors Suppose m = a 1 ·a 2 ·…·a n , where gcd(a i ,a j )=1 for all i ≠ j. For any (r 1 ,…,r n ), r i ∈ [0,a i ), there is a unique solution in [0,m) for the system of congruences x ≡ r i (mod a i ) for i=1,…,n Proof of existence, by (weak) induction: Uniqueness as before: Base case: n=1 ✓ | Z m | = | Z a1 × … × Z an | Induction step: We shall prove that for all k ≥ 1, (induction hypothesis) if every system of k congruences with co-prime moduli has a solution, (to prove) then so does every such system of k+1 congruences Given (a 1 ,…,a k+1 ,r 1 ,…,r k+1 ), define a system for (a 1 ,…,a k ,r 1 ,…,r k ), get a solution, say s. Define a system of 2 congruences, with co-prime moduli a= a 1 ⋅ … ⋅ a k , and b=a k+1 , x ≡ s (mod a) and x ≡ r k+1 (mod a k+1 ). By CRT, this has a solution. This is a solution for the original system (why?). Exercise: x ≡ s (mod a) ⋀ a 1 |a ⇒ x ≡ s (mod a 1 )

Recommend


More recommend