Download presentation
Presentation is loading. Please wait.
1
1 CSE20 Lecture 5 4/12/11 CK Cheng UC San Diego
2
Residual Numbers (NT-1 and Shaum’s Chapter 11) Introduction Definition Operations Range of numbers 2
3
Introduction Applications: communication, cryptography, and high performance signal processing Goal: Simplify arithmetic operations (+, -, x) when bit width n is huge, e.g. n= 1000. Note no division is involved. Flow: 3 Number x Residual number (x 1, x 2, …, x k ) +, -, x operations for each x i under m i Chinese Remainder Theorem Mod Operation Moduli (m 1, m 2, …, m k ) Results
4
Definition Mod (Modular) operation. – Given integer x and d (d> 0), find q and r such that x = q*d+r, 0<= r <d, where q: quotient, d: divisor, and r: remainder. We define x%d= r. Conversion to residual system: Given moduli (m 1, m 2, …, m k ), where all m i are mutually prime, transform integer x to (r 1, r 2, …, r k ), where r i =x%m i 4
5
Definitions Mutually Prime: Two integers a & b are mutually (or relatively) prime if their greatest common divisor is 1. e.g. 3 & 8, 4 & 9, but not 6 & 9 Residual number: Given (m 1, m 2,…,m k ) where m i s are mutually prime and a positive integer x <M=m 1 xm 2 x…xm k (0 ≤x <M ) represent x as ( x%m 1, x%m 2,…, x%m k ) 5
6
Examples (x%m i =r i ) Given (m 1, m 2, m 3 ) = (3, 5, 7), convert x: (r 1, r 2, r 3 ). 0: (0, 0, 0);0%3=0,0%5=0, 0%7= 0 2: (2, 2, 2);2%3=2,2%5=2,2%7=2 21: (0, 1, 0);21%3=0,21%5=1,21%7=0 -2: (1, 3, 5);-2%3=1,-2%5=3,-2%7=5 -3: (0, 2, 4); -3%3=0,-3%5=2,-3%7=4 -21: (0, 4, 0);-21%3=0,-21%5= 4,-21%7=0 Hint: 0<= r i < m i 6
7
Examples 7 k = 3 ( m 1, m 2, m 3 ) = ( 2, 3, 7 ) M = m 1 x m 2 x m 3 = 2 x 3 x 7 = 42 Given x=30, ( x%m 1, x%m 2, x%m 3 ) = ( 30%2, 30%3, 30%7 ) = ( 0, 0, 2 ) Given y=4, ( y%m 1, y%m 2, y%m 3 ) = ( 4%2, 4%3, 4%7 ) = ( 0, 1, 4 ) Given x+y=34, ((x+y)%m 1,(x+y)%m 2,(x+y)%m 3 ) = ( 34%2, 34%3, 34%7 ) = ( 0, 1, 6 )
8
8 3. Modular Operations Theorem: Given three integers x,y,d, we have (x+y)%d=(x%d+y%d)%d. Proof: Let x = q x d + r x, y = q y d + r y We have (x+y)%d = (q x d + r x + q y d + r y )%d =(r x +r y )%d Therefore, (x+y)%d = (x%d+y%d)%d
9
9 3. Modular Operations Theorem: Given three integers x,y,d, we have (x*y)%d=(x%d * y%d)%d. Proof: Let x = q x d + r x, y = q y d + r y We have (x*y)%d = (q x d + r x )*(q y d + r y )%d =(q x q y d 2 +r y q x d+r x q y d+r x *r y )%d = (r x *r y )%d Therefore, (x*y)%d = (x%d * y%d)%d
10
3. Modular Operations What about division? Could we state the following equality? ((x%d)/(y%d))%d= (x/y)%d Answer: No! We have the following problems. 1.y%d can be zero. 2.(x%d)/(y%d) or x/y can be fractional. 10
11
Range of Numbers Theorem: Given (m 1, m 2, …, m k ), where all m i are mutually prime, let M=m 1 xm 2 x…xm k. For 0<= x< M, the residual number (x 1, x 2, …, x k ) is distinct. Proof: By contradiction, let 0<= y<x < M. Suppose (x 1, x 2, …, x k )=(y 1, y 2, …, y k ) then x-y : (0,0, …,0). However, for all numbers in the range of the interval, only 0 : (0,0, …,0) because the mods m i are mutually prime. 11
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.