Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Fast Fourier Transform and Applications to Multiplication

Similar presentations


Presentation on theme: "The Fast Fourier Transform and Applications to Multiplication"— Presentation transcript:

1 The Fast Fourier Transform and Applications to Multiplication
Analysis of Algorithms Prepared by John Reif, Ph.D.

2 Reading Selection: CLR, Chapter 30 Topics and Readings: - The Fast Fourier Transform Advanced Material : - Using FFT to solve other Multipoint Evaluation Problems - Applications to Multiplication

3 Nth Roots of Unity Assume Commutative Ring (R,+,·, 0,1)
ω is principal nth root of unity if ωk ≠ 1 for k = 1, …, n-1 ωn = 1, and Example: for complex numbers

4 Example of nth Root of Unity for Complex Numbers
is the 8th root of unity

5 Fourier Matrix

6 Discrete Fourier Transform
Input a column n-vector a = (a0, …, an-1)T Output an n-vector which is the product of the Fourier matrix times the input vector

7 Inverse Fourier Transform

8 Fourier Transform is Polynomial Evaluation at the Roots of Unity
Input a column n-vector a = (a0, …, an-1)T Output an n-vector (f0, …, fn-1)T which are the values polynomial f(x)at the n roots of unity

9 Fast Fourier Transform
Viewed as Evaluation Problem: naïve algorithm takes n2 ops Divide and Conquer gives FFT with O(n log n) ops for n a power of 2 Key Idea: If ω is nth root of unity then ω2 is n/2th root of unity So can reduce the problem to two subproblems of size n/2

10 Algorithm FFTn Input a = (a0, …, an-1)T, n a power of 2

11 FFT Circuit (also known as Butterfly Network)
Total Recursion depth = log n Communication Distance 2d at depth d

12

13

14 Operation Counts for FFT Algorithm
Assume n = 2k # additions Add(n) = 2· Add(n/2) + n = n log n # multiplications Mult(n) = 2· Mult(n/2) + n/ = ½ n log n Total Time O(n log n) Note in complex FFT, # real ops is 5 n log n

15 Multipoint Polynomial Evaluation
Input polynomial Problem evaluate f(x) at x0, x1, …, xn-1 Easy Cases: eval at roots of unity FFT Case xk = ωk for k=0,…,n

16 Multipoint Polynomial Evaluation (cont’d)

17 Other Polynomial Evaluation Problems Solved by FFT
Each costs O(n log n) time Evaluate at points Xi = bai + d for i=0,…, n-1(Chirp Transfom) Reduced to FFT Single point evaluation of all derivatives of a polynomial Solve by reduction to above Chirp Transform of case 2) Evaluate at points Xi = b(ai)2+ cai + d for i=0,…, n-1 Solve by divide and conquer similar to FFT

18 Single Point Evaluation of all Derivatives of Polynomial
Input and point x0 output

19 Single Point Evaluation of all Derivatives of Polynomial (cont’d)
Taylor Series Representation of Then This reduces to case of evaluation at points Solve this Chirp Transform problem by reduction FFT

20 Advanced Material: Further Applications of FFT
Convolution: Products and Powers of Polynomials Used for for Integer Multiplication Algorithms Also used for Filtering on infinite input streams Division and Inverse of Polynomials Multipoint Evaluation and Interpolation

21 Advanced Material: Products and Powers of Polynomials
Input vectors a = (a0, a1, …, an-1)T b = (b0, b1, …, bn-1)T Definition of Convolution c = a ⊗ b Where for i=0, …, 2n-1 define ak = bk = 0 if k< 0 or k>n

22 Products and Powers of Polynomials (cont’d)
Convolution Theorem Application to Polynomial Products:

23 Products of m Polynomials
Generalized Convolution Theorem

24 Wrapped Convolutions a = (a0, a1, …, an-1)T , b = (b0, b1, …, bn-1)T
Positive wrapped convolution is c = (c0, c1, …, cn-1)T Negative wrapped convolution is d = (d0, d1, …, dn-1)T

25 Application of Wrapped Convolution to Modular Polynomial Products

26 Computing Positive Wrapped Convolution
Let ω = principal nth root of unity Assume n has multiplicative inverse, Theorem is the positive wrapped convolution of n-vectors a and b.

27 Computing Negative Wrapped Convolution
Also is the negatively wrapped convolution of n-vectors a and b where and Ψ2 = ω = principal nth root of unity

28 Integer Multiplication by Polynomial Product (solved via FFT)
Input n bit integers a,b define polynomials degree k = n/L

29 Integer Multiplication by Polynomial Product (cont’d)
Idea Compute c(x) = a(x)· b(x) by convolution Evaluate c(2L) = a· b

30 Integer Multiplication Algorithms using Reduction to Polynomial Product
Pollard Mult Algorithm Karp Mult Algorithm Schönage-Strassen Mult Algorithm

31 Pollard Multiplication Algorithm
n = kL, L = 1 + log k Choose primes P1, P2, P3 where Compute C(x) by convolution over finite field Zpi for i =1,2,3 (requires k mults on 2L bit integers)

32 Pollard Multiplication Algorithm (cont’d)
Evaluate C(2L) Time Bounds recursive mults FFT

33 Korp Multiplication Algorithm
Compute C(x) modulo k by convolution Compute C(x) modulo (22L+1) by convolution Compute C(x) coefficients from C(x) mod k, C(x) mod (22L+1) by Chinese remaindering

34 Korp Multiplication Algorithm (cont’d)
Compute C(2L) Time recursive mults FFT

35 Schönage-Strassen Multiplication Algorithm
(2’) Compute C(x) mod (xk+1) modulo (22L+1) by wrapped convolution Requires only k recursive mults on 2L bit numbers Time recursive mults FFT

36 Still Open Problem: How Fast Can You Multiply Integers?
Can you mult n bit integers in O(n log n) time?

37 The Fast Fourier Transform and Applications to Multiplication
Analysis of Algorithms Prepared by John Reif, Ph.D.


Download ppt "The Fast Fourier Transform and Applications to Multiplication"

Similar presentations


Ads by Google