Download presentation
Presentation is loading. Please wait.
Published byRoss Campbell Modified over 9 years ago
1
Continued Fractions, Euclidean Algorithm and Lehmer’s Algorithm Applied Symbolic Computation CS 567 Jeremy Johnson TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAA A A A
2
Outline Fast Fibonacci Continued Fractions Lehmer’s Algorithm Analysis of the Euclidean Algorithm (bit complexity) Assignment 1
3
Euclidean Algorithm g = gcd(a,b) a1 = a; a2 = b; while (a2 0) a3 = a1 mod a2; a1 = a2; a2 = a3; } return a1;
4
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 l = q l a l +1 gcd(a,b) = a l +1
5
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;
6
Lehmer’s Algorithm u = 27182818, v = 10000000 u’ v’ q’ u’’ v’’ q’’ 2718 1001 2 2719 1000 2 1001 716 1 1000 719 1 716 285 2 719 281 2 285 146 1 281 157 1 146 139 1 157 124 1 139 7 19 124 33 3 u’/v’ < u/v < u’’/v’’
7
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 < 2lg(a).
8
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. Theorem. Let a b 0 and n = number of divisions required by the Euclidean algorithm to compute gcd(a,b). Then n < 1.44lg(a).
9
Average Number of Divisions Theorem. Let a b 0 and n = average number of divisions required by the Euclidean algorithm to compute gcd(a,b). Then n 12ln(2) 2 / 2 lg(a) 0.584 lg(a). Theorem [Dixon] D(a,b) ½ ln(a) for almost all pairs u a b 1 as u
10
Dominance and Codominance Definition. Let f, g be real valued functions on a common set S. [Dominance] [Codominance] [Strict Dominance]
11
Basic Properties Theorem. Let f, f 1, f 2, g, g 1, and g 2 be nonnegative real-valued functions on S and c>0.
12
Integer Length Definition. A = i=0..m a i i, L (A) = m
13
Basic Arithmetic Computing Times Theorem. Let A, M, D be the classical algorithms for addition, multiplication and division.
14
Maximum Computing Time Theorem.
15
Average Computing Time Theorem.
16
Probability of Relative Primality p/d 2 = 1 p = 1/ (2) (z) = 1/n z (2) = 2 /6
17
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
18
Mobius Function (1) = 1 (p 1 p t ) = -1 t (n) = 0 if p 2 |n (ab) = (a) (b) if gcd(a,b) = 1.
19
Mobius Inversion d|n (d) = 0 ( n (n)n s ) ( n 1/n s ) = 1
20
Formal Proof q n = n (k) n/k 2 lim n q n /n 2 = n (n)/n 2 = 1/( n 1/n 2 ) = 6/ 2
21
Assignment 1 Empirically investigate distribution of quotients in Euclidean algorithm Implement and analyze classical division algorithm Implement and analyze Lehmer’s algorithm Study and summarize gcd algorithms in GMP
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.