70 likes | 86 Views
CSE20 Lecture 6 4/19/11. CK Cheng UC San Diego. Residual Numbers (NT-1 and Shaum’s Chapter 11). Introduction Definition Operations Range of numbers Conversion. Conversion. Number x. Mod Operation. Residual number (x 1 , x 2 , …, x k ) +, -, x operations for each x i under m i.
E N D
CSE20 Lecture 64/19/11 CK Cheng UC San Diego
Residual Numbers(NT-1 and Shaum’s Chapter 11) • Introduction • Definition • Operations • Range of numbers • Conversion
Conversion Number x Mod Operation Residual number (x1, x2, …, xk) +, -, x operations for each xi under mi Moduli (m1, m2, …, mk) Results Chinese Remainder Theorem
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.
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
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
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.