Euclidean Algorithm Applied Symbolic Computation CS 567 Jeremy Johnson.

Slides:



Advertisements
Similar presentations
Richard Fateman CS 282 Lecture eea1 Extended Euclidean Algorithm Lecture eea.
Advertisements

1 Lect. 12: Number Theory. Contents Prime and Relative Prime Numbers Modular Arithmetic Fermat’s and Euler’s Theorem Extended Euclid’s Algorithm.
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
Quotient-Remainder Theory, Div and Mod
NUMBER THEORY Chapter 1: The Integers. The Well-Ordering Property.
Chapter II. THE INTEGERS
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Recursion CS-240/CS341. What is recursion? a function calls itself –direct recursion a function calls its invoker –indirect recursion f f1 f2.
Chapter 4 – Finite Fields Introduction  will now introduce finite fields  of increasing importance in cryptography AES, Elliptic Curve, IDEA, Public.
October 1, 2009Theory of Computation Lecture 8: Primitive Recursive Functions IV 1 Primitive Recursive Predicates Theorem 6.1: Let C be a PRC class. If.
CSE 311 Foundations of Computing I Lecture 12 Primes, GCD, Modular Inverse Spring
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
Divisibility October 8, Divisibility If a and b are integers and a  0, then the statement that a divides b means that there is an integer c such.
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
Module :MA3036NI Cryptography and Number Theory Lecture Week 7
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Continued Fractions, Euclidean Algorithm and Lehmer’s Algorithm Applied Symbolic Computation CS 567 Jeremy Johnson TexPoint fonts used in EMF. Read the.
Cryptography Inverses and GCD Piotr Faliszewski. GCD(a,b) gcd(a, 0) = a gcd(a, b) = gcd(b, a mod b) a = b*q + r Here: q =  a / b  r = a mod b (a –
Advanced Algebraic Algorithms on Integers and Polynomials Prepared by John Reif, Ph.D. Analysis of Algorithms.
CompSci 102 Discrete Math for Computer Science
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Rational Numbers and Fields
MAT 320 Spring 2008 Section 1.2.  Start with two integers for which you want to find the GCD. Apply the division algorithm, dividing the smaller number.
Chinese Remainder Theorem Dec 29 Picture from ………………………
CSE 311: Foundations of Computing Fall 2014 Lecture 12: Primes, GCD.
1 Network and Computer Security (CS 475) Modular Arithmetic and the RSA Public Key Cryptosystem Jeremy R. Johnson.
Lecture 6.1: Misc. Topics: Number Theory CS 250, Discrete Structures, Fall 2011 Nitesh Saxena.
Network and Computer Security (CS 475) Modular Arithmetic
Chinese Remainder Theorem. How many people What is x? Divided into 4s: remainder 3 x ≡ 3 (mod 4) Divided into 5s: remainder 4 x ≡ 4 (mod 5) Chinese Remainder.
CSE 311 Foundations of Computing I Lecture 14 Euclid’s Algorithm Mathematical Induction Autumn 2012 CSE
Ref: Pfleeger96, Ch.31 Properties of Arithmetic Reference: Pfleeger, Charles P., Security in Computing, 2nd Edition, Prentice Hall, 1996.
CSE 311: Foundations of Computing Fall 2013 Lecture 12: Primes, GCD, modular inverse.
Divide & Conquer Themes –Reasoning about code (correctness and cost) –iterative code, loop invariants, and sums –recursion, induction, and recurrence relations.
CS 312: Algorithm Analysis Lecture #4: Primality Testing, GCD This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.Creative.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
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
Discrete Math II Howon Kim
CSCI 3333 Data Structures Recursion Exercises
Advanced Algorithms Analysis and Design
Integers and Division Section 3.4.
Numerical Algorithms x x-1 Numerical Algorithms
CMSC Discrete Structures
CSE 311 Foundations of Computing I
Greatest Common Divisor
CSE 311 Foundations of Computing I
Applied Discrete Mathematics Week 3: Algorithms
Numerical Algorithms x x-1
Applied Discrete Mathematics Week 4: Number Theory
September 4, 1997 Applied Symbolic Computation (CS 300) Dixon’s Algorithm for Solving Rational Linear Systems Jeremy R. Johnson.
Applied Symbolic Computation (CS 300) Modular Arithmetic
Enough Mathematical Appetizers!
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
Applied Symbolic Computation (CS 300) Modular Arithmetic
Systems Architecture I
Applied Symbolic Computation (CS 300) Modular Arithmetic
Algorithmic Number Theory and Cryptography (CS 303) Modular Arithmetic
Copyright © Zeph Grunschlag,
Application: Algorithms
Application: Algorithms
Applied Symbolic Computation (CS 300) Modular Arithmetic
Applied Symbolic Computation (CS 300) Modular Arithmetic
Applied Discrete Mathematics Week 10: Introduction to Counting
Applied Symbolic Computation (CS 300) Modular Arithmetic
Number Theory.
Number Theory.
Presentation transcript:

Euclidean Algorithm Applied Symbolic Computation CS 567 Jeremy Johnson

Greatest Common Divisors g = gcd(a,b) – g|a and g|b – e|a and e|b  e|g

Unique Factorization p|ab  p|a or p|b a = p 1    p t = q 1    q s  s = t and  i  j: p i = q j a = p 1 e1    p t et b = p 1 f1    p t ft gcd(a,b) = p 1 min(e1,f1)    p t min(et,ft)

Bezout’s Identity g = gcd(a,b)  x,y: g = ax + by

Bezout’s Identity g = gcd(a,b)  x,y: g = ax + by

Euclidean Algorithm g = gcd(a,b) if (b = 0) then return a; else return gcd(b,a mod b)

Correctness

Tail Recursion g = gcd(a,b) if (b = 0) then return a; else return gcd(b,a mod b)

Iterative Algorithm g = gcd(a,b) a1 = a; a2 = b; while (a2  0) a3 = a1 mod a2; a1 = a2; a2 = a3; } return a1;

Remainder Sequence a 1 = a, a 2 = b a 1 = q 3  a 2 + a 3, 0  a 3 < a 2    a i = q i  a i+1 + a i+2, 0  a i+2 < a i+1    a n = q n  a n+1 gcd(a,b) = a n+1

Bounding Number of Divisions Theorem. Let a  b  0 and n = number of divisions required by the Euclidean algorithm to compute gcd(a,b). Then n < 2lg(a).

Bounding Number of Divisions

Fibonacci Numbers F 0 = 0, F 1 = 1 F n+2 = F n+1 + F n

Solving the Fibonacci Recurrence F n = 1/  5(  n +  * n ),  = (1 +  5)/2,  * = (1 -  5)/2 F n  1/  5  n+1

Solving the Fibonacci Recurrence

Maximum Number of Divisions Theorem. The smallest pair of integers that require n divisions to compute their gcd is F n+2 and F n+1.

Maximum Number of Divisions Theorem. Let a  b  0 and n = number of divisions required by the Euclidean algorithm to compute gcd(a,b). Then n < 1.44 lg(a).

Maximum Number of Divisions

Extended Euclidean Algorithm g = gcd(a,b,*x,*y) a1 = a; a2 = b; x1 = 1; x2 = 0; y1 = 0; y2 = 1; while (a2  0) a3 = a1 mod a2; q = floor(a1/a2); x3 = x1 – q*x2; y3 = y1 – q*y2; a1 = a2; a2 = a3; x1 = x2; x2 = x3; y1 = y2; y2 = y3; } return a1;

Correctness

Probability of Relative Primality  p/d 2 = 1  p = 1/  (2)  (z) =  1/n z  (2) =  2 /6

Formal Proof Let q n be the number of 1 a,b  n such that gcd(a,b) = 1. Then lim n  q n /n 2 = 6/  2

Mobius Function  (1) = 1  (p 1    p t ) = -1 t  (n) = 0 if p 2 |n  (ab) =  (a)  (b) if gcd(a,b) = 1.

Mobius Inversion  d|n  (d) = 0 (  n  (n)n s )  (  n 1/n s ) = 1

Formal Proof q n =  n  n/k  2 lim n  q n /n 2 =  n  (n)n 2 =  n 1/n 2 = 6/  2