CSE20 Lecture 5: Number Systems 5. Residual Numbers

Slides:



Advertisements
Similar presentations
1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
Advertisements

Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
Quotient-Remainder Theory, Div and Mod
CSE115/ENGR160 Discrete Mathematics 03/13/12 Ming-Hsuan Yang UC Merced 1.
Number Theory and Cryptography
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Inverses and GCDs Supplementary Notes Prepared by Raymond Wong
CSE115/ENGR160 Discrete Mathematics 03/17/11 Ming-Hsuan Yang UC Merced 1.
1 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.
1 CSE20 Lecture 5 4/12/11 CK Cheng UC San Diego. Residual Numbers (NT-1 and Shaum’s Chapter 11) Introduction Definition Operations Range of numbers 2.
Lecture 3.2: Public Key Cryptography II CS 436/636/736 Spring 2012 Nitesh Saxena.
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Peter Lam Discrete Math CS.  Sometimes Referred to Clock Arithmetic  Remainder is Used as Part of Value ◦ i.e Clocks  24 Hours in a Day However, Time.
BY MISS FARAH ADIBAH ADNAN IMK
9/2/2015Discrete Structures1 Let us get into… Number Theory.
(CSC 102) Discrete Structures Lecture 10.
Introduction to Modular Arithmetic and Public Key Cryptography.
Mathematics of Cryptography Part I: Modular Arithmetic
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
CPSC 3730 Cryptography and Network Security
CSE 20 Lecture 12 Induction CK Cheng 1. Induction Outlines Introduction Theorem Examples: The complexity calculation – Tower of Hanoi – Merge Sort – Fibonacci.
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
6.5 The Remainder and Factor Theorems p. 352 How do you divide polynomials? What is the remainder theorem? What is the difference between synthetic substitution.
YSLInformation Security -- Public-Key Cryptography1 Prime and Relatively Prime Numbers Divisors: We say that b  0 divides a if a = mb for some m, where.
Chinese Remainder Theorem Dec 29 Picture from ………………………
The Remainder and Factor Theorems 6.5 p When you divide a Polynomial f(x) by a divisor d(x), you get a quotient polynomial q(x) with a remainder.
quotient is x + 6 and remainder is quotient is x.
1 CSE20 Lecture 6: Number Systems 5. Residual Numbers (cont) & 6. Cryptography CK Cheng UC San Diego.
9.1 Primes and Related Congruence Equations 23 Sep 2013.
1 CMSC 250 Chapter 3, Number Theory. 2 CMSC 250 Introductory number theory l A good proof should have: –a statement of what is to be proven –"Proof:"
Divisibility and Modular Arithmetic
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Page : 1 bfolieq.drw Technical University of Braunschweig IDA: Institute of Computer and Network Engineering  W. Adi 2011 Lecture-5 Mathematical Background:
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
Number-Theoretic Algorithms
CSE565: Computer Security Lecture 7 Number Theory Concepts
CSE15 Discrete Mathematics 03/15/17
Topic 12: Number Theory Basics (2)
CS 2210:0001Discrete Structures Modular Arithmetic and Cryptography
Introduction to Cryptography
Advanced Algorithms Analysis and Design
Chinese Remainder Theorem
More about Polynomials
Introduction to Number Theory
Number Theory and Cryptography
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 4: Number Theory
Number Theory (Chapter 7)
Cryptography Lecture 22.
Prime and Relatively Prime Numbers
Modular Arithmetic and Change of Base
Introduction to Cryptography
Algorithmic Number Theory and Cryptography (CS 303) Modular Arithmetic
Lecture 43 Section 10.1 Wed, Apr 6, 2005
CSE20 Lecture 3 Number Systems
Applied Discrete Mathematics Week 10: Introduction to Counting
Cryptography Lecture 18.
Number Theory.
5.5 Apply the Remainder and Factor Theorems
Mathematical Background: Extension Finite Fields
Presentation transcript:

CSE20 Lecture 5: Number Systems 5. Residual Numbers CK Cheng UC San Diego

5. Residual Numbers (NT-1 and Shaum’s Chapter 11) Introduction (parallel processing on huge numbers) Definition (conversion) Operations (+, -, x) Inverse Conversion (recover the solution)

5. Residual Numbers: iClicker The statement about residual number system. A counting system in Sun Tsu’s Arithmetic Manual in the 4th century AD. The system can be used for error correction. The system is efficient for numbers with wide bit width. All of the above Two of the above.

5.1 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. Usage in CSE: CSE20, CSE107, CSE127

5.1 Introduction: Flow Results Number x Residual number Residual Number System Mod Operation Moduli (m1, m2, …, mk) Number x Residual number (x1, x2, …, xk) +, -, x operations for each xi under mi Results Chinese Remainder Theorem

5.2 Definition Mod (Modular) operation: Given integers 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. Examples: 20=2*7+6 => 20%7=6 11=2*5+1 => 11%5=1 -8=(-2)*5+2 => (-8)%5=2

5.2 Definitions Residual number: Conversion Given (m1, m2,…,mk) where mi are mutually prime and a positive integer x <M=m1m2…mk (0 ≤x <M ) represent x as ( x%m1, x%m2,…, x%mk ) 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

Examples (X%mi=ri) Given moduli (m1, m2, m3) = (3, 5, 7), convert X: (x1, x2, x3), where xi=X%mi. X=0; x1=x%3=0, x2=x%5=0, x3=x%7= 0. =>(x1,x2,x3)=(0,0,0) X=21: x1=x%3=0, x2=x%5=1, x3=x%7=0. =>(x1,x2,x3)=(0,1,0) X=18: r1=x%3= , r2=x%5= , r3=x%7= . =>(x1,x2,x3)=( , , ) X=-9 : x1=x%3= , x2=x%5= , x3=x%7= =>(x1,x2,x3)=( , , )

5.2 Examples: iClicker Can we compare the value of the residual numbers by comparing the residuals? iClicker (A: Yes, B: No) Given moduli (m1, m2, m3) = (2, 5, 7) and X=17, derive the corresponding residual number (x1, x2, x3), where ri=X%mi. A. (1, 3, 2) B. (1, 2, 3) C. (0, 1, 2) D. None of the above

Examples A residual number system with (m1,m2,m3)=(2,3,7) M = m1 * m2 * m3 = 2 * 3 * 7 = 42 Given X=30, ( X%m1, X%m2, X%m3 ) = ( 30%2, 30%3, 30%7 ) = ( 0, 0, 2 ) Given Y=4, ( Y%m1, Y%m2, Y%m3 ) = ( 4%2, 4%3, 4%7 ) = ( 0, 1, 4 ) Given X+Y=34, ((X+Y)%m1,(X+Y)%m2,(X+Y)%m3 ) = ( 34%2, 34%3, 34%7 ) = ( 0, 1, 6 )

5.3 Modular Operations: Addition Theorem 1: Given three integers x,y,d (d>0), we have (x+y)%d=(x%d+y%d)%d. Proof: Let x = qxd + rx and y = qyd + ry We have (x+y)%d = (qxd + rx + qyd + ry)%d =(rx+ry)%d Therefore, (x+y)%d = (x%d+y%d)%d

5.3 Modular Operations: Multiplication Theorem 2: Given three integers x,y,d (d>0), we have (x*y)%d=(x%d * y%d)%d. Proof: Let x = qxd + rx, y = qyd + ry We have (x*y)%d = (qxd + rx )*(qyd + ry)%d =(qxqyd2+ryqxd+rxqyd+rx*ry)%d = (rx*ry)%d Therefore, (x*y)%d = (x%d * y%d)%d

5.3 Modular Operations What about division? Could we state the following equality? ((x%d)/(y%d))%d= (x/y)%d E.g. try the case that x=6, y=3 & d=3

5.3 Modular Operations What about division? Could we state the following equality? ((x%d)/(y%d))%d= (x/y)%d Answer: Not always! We have the following problems. y%d can be zero. (x%d)/(y%d) or x/y can be fractional.

5.3 Modular Operations: Examples Given x=24 and y=19, derive x+y in the residual number system (m1,m2,m3)=(3,5,8) . I. x+y=24+19=43, r1=43%3=1, r2=43%5=3, r3=43%8=3. =>(r1,r2,r3)=(1,3,3) II. Apply theorem 1. x=> (x1,x2,x3)= y=> (y1,y2,y3)= x+y=> ((x1+y1)%m1,(x2+y2)%m2,(x3+y3)%m3) =

5.3 Modular Operations: Examples Given x=9 and y=12, derive x*y in the residual number system (m1,m2,m3)=(3,5,8) . I. x*y=9*12=108, r1=108%3=0, r2=108%5=3, r3=108%8=4. =>(r1,r2,r3)=(0,3,4) II. Apply theorem 2. x=> (x1,x2,x3)= y=> (y1,y2,y3)= x*y=> ((x1*y1)%m1,(x2*y2)%m2,(x3*y3)%m3) =

5.3 Range of Numbers Theorem 3: In a residual number system with (m1, m2, …, mk), where all mi are mutually prime, for any 0<=y<x<M=m1m2…mk, we have the inequality (x1, x2, …, xk) != (y1, y2, …, yk), i.e. there exists an 0<i<=k such that xi!= yi. Proof: By contradiction. Suppose that (x1, x2, …, xk)=(y1, y2, …, yk), then x-y : (0,0, …,0) (theorem 1). However, for all numbers in the range of the interval, only 0 : (0,0, …,0) because the mods mi are mutually prime.

5.3 Range of Numbers Example: Let k=3 & (m1, m2, m3)=(3,4,5) M=3x4x5=60 Given X=45 and Y=40 (x1,x2,x3)=(45%3, 45%4, 45%5)=(0,1,0) and (y1,y2,y3)=(40%3, 40%4, 40%5)=(1,0,0) 3. Suppose Y=105 then (y1,y2,y3)=(105%3, 105%4, 105%5)=(0,1,0)