5.6 Convolution and FFT. 2 Fast Fourier Transform: Applications Applications. n Optics, acoustics, quantum physics, telecommunications, control systems,

Slides:



Advertisements
Similar presentations
Parallel Fast Fourier Transform Ryan Liu. Introduction The Discrete Fourier Transform could be applied in science and engineering. Examples: ◦ Voice recognition.
Advertisements

Polynomial and FFT. Topics 1. Problem 2. Representation of polynomials 3. The DFT and FFT 4. Efficient FFT implementations 5. Conclusion.
Advanced Algorithms Piyush Kumar (Lecture 11: Div & Conquer) Welcome to COT5405 Source: Kevin Wayne, Harold Prokop.
DIVIDE AND CONQUER. 2 Algorithmic Paradigms Greedy. Build up a solution incrementally, myopically optimizing some local criterion. Divide-and-conquer.
Dr. Deshi Ye Divide-and-conquer Dr. Deshi Ye
Instructor: Shengyu Zhang 1. Example 1: Merge sort 2.
Fast Fourier Transform Lecture 6 Spoken Language Processing Prof. Andrew Rosenberg.
FFT1 The Fast Fourier Transform. FFT2 Outline and Reading Polynomial Multiplication Problem Primitive Roots of Unity (§10.4.1) The Discrete Fourier Transform.
Administrative Oct. 2 Oct. 4 – QUIZ #2 (pages of DPV)
Richard Fateman CS 282 Lecture 101 The Finite-Field FFT Lecture 10.
CSE 421 Algorithms Richard Anderson Lecture 15 Fast Fourier Transform.
FFT(Fast Fourier Transform). p2. FFT Coefficient representation: How to evaluate A(x 0 )?
FFT1 The Fast Fourier Transform by Jorge M. Trabal.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fast Fourier Transform Jean Baptiste Joseph Fourier ( ) These lecture.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 16: Application-Driven Hardware Acceleration (1/4)
CSE 421 Algorithms Richard Anderson Lecture 13 Divide and Conquer.
Introduction to Algorithms
The Fourier series A large class of phenomena can be described as periodic in nature: waves, sounds, light, radio, water waves etc. It is natural to attempt.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 14 Instructor: Paul Beame.
Fast Fourier Transform Irina Bobkova. Overview I. Polynomials II. The DFT and FFT III. Efficient implementations IV. Some problems.
1 How to Multiply Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. integers, matrices, and polynomials.
Numerical Analysis – Digital Signal Processing Hanyang University Jong-Il Park.
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 12.
1 Chapter 5 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CS 6068 Parallel Computing Fall 2013 Lecture 10 – Nov 18 The Parallel FFT Prof. Fred Office Hours: MWF.
FFT1 The Fast Fourier Transform. FFT2 Outline and Reading Polynomial Multiplication Problem Primitive Roots of Unity (§10.4.1) The Discrete Fourier Transform.
Piyush Kumar (Lecture 2 Div & Conquer)
The Fast Fourier Transform
Karatsuba’s Algorithm for Integer Multiplication
Applied Symbolic Computation1 Applied Symbolic Computation (CS 300) Karatsuba’s Algorithm for Integer Multiplication Jeremy R. Johnson.
The Fast Fourier Transform and Applications to Multiplication
CS223 Advanced Data Structures and Algorithms 1 Review for Final Neil Tang 04/27/2010.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
Advanced Algorithms Piyush Kumar (Lecture 11: Div & Conquer) Welcome to COT5405 Source: Kevin Wayne, Harold Prokop.
1 Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
CSE 421 Algorithms Lecture 15 Closest Pair, Multiplication.
1 Chapter 4-2 Divide and Conquer Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Fast Fourier Transform (FFT) Problem: we need an efficient way to compute the DFT. The answer is the FFT. Consider a data sequence and its DFT: We can.
1 How to Multiply Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. integers, matrices, and polynomials.
Applied Symbolic Computation1 Applied Symbolic Computation (CS 567) The Fast Fourier Transform (FFT) and Convolution Jeremy R. Johnson TexPoint fonts used.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 16.
May 9, 2001Applied Symbolic Computation1 Applied Symbolic Computation (CS 680/480) Lecture 6: Multiplication, Interpolation, and the Chinese Remainder.
Chapter 2 Divide-and-Conquer algorithms
Chapter 2 Divide-and-Conquer algorithms
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Richard Anderson Lecture 29 NP-Completeness and course wrap-up
Polynomial + Fast Fourier Transform
Applied Symbolic Computation
September 4, 1997 Applied Symbolic Computation (CS 300) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Applied Symbolic Computation
Divide-and-Conquer Divide-and-conquer.
DFT and FFT By using the complex roots of unity, we can evaluate and interpolate a polynomial in O(n lg n) An example, here are the solutions to 8 =
September 4, 1997 Applied Symbolic Computation (CS 300) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Punya Biswas Lecture 15 Closest Pair, Multiplication
The Fast Fourier Transform
Advanced Algorithms Analysis and Design
Applied Symbolic Computation
September 4, 1997 Applied Symbolic Computation (CS 567) Fast Polynomial and Integer Multiplication Jeremy R. Johnson.
Chapter 5 Divide and Conquer
Applied Symbolic Computation
Richard Anderson Lecture 30 NP-Completeness
Richard Anderson Lecture 14 Inversions, Multiplication, FFT
Applied Symbolic Computation
Transform and Conquer Transform and Conquer Transform and Conquer.
Transform and Conquer Transform and Conquer Transform and Conquer.
The Fast Fourier Transform
Lecture 15, Winter 2019 Closest Pair, Multiplication
Applied Symbolic Computation
Lecture 15 Closest Pair, Multiplication
Fast Polynomial and Integer Multiplication
Presentation transcript:

5.6 Convolution and FFT

2 Fast Fourier Transform: Applications Applications. n Optics, acoustics, quantum physics, telecommunications, control systems, signal processing, speech recognition, data compression, image processing. n DVD, JPEG, MP3, MRI, CAT scan. n Numerical solutions to Poisson's equation. The FFT is one of the truly great computational developments of this [20th] century. It has changed the face of science and engineering so much that it is not an exaggeration to say that life as we know it would be very different without the FFT.

3 Fast Fourier Transform: Brief History Gauss (1805, 1866). Analyzed periodic motion of asteroid Ceres. Runge-König (1924). Laid theoretical groundwork. Danielson-Lanczos (1942). Efficient algorithm. Cooley-Tukey (1965). Monitoring nuclear tests in Soviet Union and tracking submarines. Rediscovered and popularized FFT. Importance not fully realized until advent of digital computers.

4 Polynomials: Coefficient Representation Polynomial. [coefficient representation] Add: O(n) arithmetic operations. Evaluate: O(n) using Horner's method. Multiply (convolve): O(n 2 ) using brute force.

5 Polynomials: Point-Value Representation Fundamental theorem of algebra. A degree n polynomial with complex coefficients has n complex roots. Corollary. A degree n-1 polynomial A(x) is uniquely specified by its evaluation at n distinct values of x. x y xjxj y j = A(x j )

6 Polynomials: Point-Value Representation Polynomial. [point-value representation] Add: O(n) arithmetic operations. Multiply: O(n), but need 2n-1 points. Evaluate: O(n 2 ) using Lagrange's formula.

7 Converting Between Two Polynomial Representations Tradeoff. Fast evaluation or fast multiplication. We want both! Goal. Make all ops fast by efficiently converting between two representations. Coefficient Representation O(n 2 ) Multiply O(n) Evaluate Point-valueO(n)O(n 2 ) coefficient representation point-value representation O(n log n)

8 Converting Between Two Polynomial Representations: Brute Force Coefficient to point-value. Given a polynomial a 0 + a 1 x a n-1 x n-1, evaluate it at n distinct points x 0,..., x n-1. Point-value to coefficient. Given n distinct points x 0,..., x n-1 and values y 0,..., y n-1, find unique polynomial a 0 + a 1 x a n-1 x n-1 that has given values at given points. Vandermonde matrix is invertible iff x i distinct O(n 3 ) for Gaussian elimination O(n 2 ) for matrix-vector multiply

9 Coefficient to Point-Value Representation: Intuition Coefficient to point-value. Given a polynomial a 0 + a 1 x a n-1 x n-1, evaluate it at n distinct points x 0,..., x n-1. Divide. Break polynomial up into even and odd powers. n A(x) = a 0 + a 1 x + a 2 x 2 + a 3 x 3 + a 4 x 4 + a 5 x 5 + a 6 x 6 + a 7 x 7. n A even (x) = a 0 + a 2 x + a 4 x 2 + a 6 x 3. n A odd (x) = a 1 + a 3 x + a 5 x 2 + a 7 x 3. n A(-x) = A even (x 2 ) + x A odd (x 2 ). n A(-x) = A even (x 2 ) - x A odd (x 2 ). Intuition. Choose two points to be  1. n A(-1) = A even (1) + 1 A odd (1). n A(-1) = A even (1) - 1 A odd (1). Can evaluate polynomial of degree  n at 2 points by evaluating two polynomials of degree  ½n at 1 point.

10 Coefficient to Point-Value Representation: Intuition Coefficient to point-value. Given a polynomial a 0 + a 1 x a n-1 x n-1, evaluate it at n distinct points x 0,..., x n-1. Divide. Break polynomial up into even and odd powers. n A(x) = a 0 + a 1 x + a 2 x 2 + a 3 x 3 + a 4 x 4 + a 5 x 5 + a 6 x 6 + a 7 x 7. n A even (x) = a 0 + a 2 x + a 4 x 2 + a 6 x 3. n A odd (x) = a 1 + a 3 x + a 5 x 2 + a 7 x 3. n A(-x) = A even (x 2 ) + x A odd (x 2 ). n A(-x) = A even (x 2 ) - x A odd (x 2 ). Intuition. Choose four points to be  1,  i. n A(-1) = A even (-1) + 1 A odd ( 1). n A(-1) = A even (-1) - 1 A odd (-1). n A(-i) = A even (-1) + i A odd (-1). n A(-i) = A even (-1) - i A odd (-1). Can evaluate polynomial of degree  n at 4 points by evaluating two polynomials of degree  ½n at 2 points.

11 Discrete Fourier Transform Coefficient to point-value. Given a polynomial a 0 + a 1 x a n-1 x n-1, evaluate it at n distinct points x 0,..., x n-1. Key idea: choose x k =  k where  is principal n th root of unity. Discrete Fourier transform Fourier matrix F n

12 Roots of Unity Def. An n th root of unity is a complex number x such that x n = 1. Fact. The n th roots of unity are:  0,  1, …,  n-1 where  = e 2  i / n. Pf. (  k ) n = (e 2  i k / n ) n = (e  i ) 2k = (-1) 2k = 1. Fact. The ½n th roots of unity are: 0, 1, …, n/2-1 where = e 4  i / n. Fact.  2 = and (  2 ) k = k.  0 = 0 = 1 11  2 = 1 = i 33  4 = 2 = -1 55  6 = 3 = -i 77 n = 8

13 Fast Fourier Transform Goal. Evaluate a degree n-1 polynomial A(x) = a a n-1 x n-1 at its n th roots of unity:  0,  1, …,  n-1. Divide. Break polynomial up into even and odd powers. n A even (x) = a 0 + a 2 x + a 4 x 2 + … + a n/2-2 x (n-1)/2. n A odd (x) = a 1 + a 3 x + a 5 x 2 + … + a n/2-1 x (n-1)/2. n A(x) = A even (x 2 ) + x A odd (x 2 ). Conquer. Evaluate degree A even (x) and A odd (x) at the ½n th roots of unity: 0, 1, …, n/2-1. Combine. n A(  k+n ) = A even ( k ) +  k A odd ( k ), 0  k < n/2 n A(  k+n ) = A even ( k ) -  k A odd ( k ), 0  k < n/2  k+n = -  k k = (  k ) 2 = (  k+n ) 2

14 fft(n, a 0,a 1,…,a n-1 ) { if (n == 1) return a 0 (e 0,e 1,…,e n/2-1 )  FFT(n/2, a 0,a 2,a 4,…,a n-2 ) (d 0,d 1,…,d n/2-1 )  FFT(n/2, a 1,a 3,a 5,…,a n-1 ) for k = 0 to n/2 - 1 {  k  e 2  ik/n y k+n/2  e k +  k d k y k+n/2  e k -  k d k } return (y 0,y 1,…,y n-1 ) } FFT Algorithm

15 FFT Summary Theorem. FFT algorithm evaluates a degree n-1 polynomial at each of the n th roots of unity in O(n log n) steps. Running time. T(2n) = 2T(n) + O(n)  T(n) = O(n log n). assumes n is a power of 2 O(n log n) coefficient representation point-value representation

16 Recursion Tree a 0, a 1, a 2, a 3, a 4, a 5, a 6, a 7 a 1, a 3, a 5, a 7 a 0, a 2, a 4, a 6 a 3, a 7 a 1, a 5 a 0, a 4 a 2, a 6 a0a0 a4a4 a2a2 a6a6 a1a1 a5a5 a3a3 a7a7 "bit-reversed" order perfect shuffle

17 Point-Value to Coefficient Representation: Inverse DFT Goal. Given the values y 0,..., y n-1 of a degree n-1 polynomial at the n points  0,  1, …,  n-1, find the unique polynomial a 0 + a 1 x a n-1 x n-1 that has given values at given points. Inverse DFT Fourier matrix inverse (F n ) -1

18 Claim. Inverse of Fourier matrix is given by following formula. Consequence. To compute inverse FFT, apply same algorithm but use  -1 = e -2  i / n as principal n th root of unity (and divide by n). Inverse FFT

19 Inverse FFT: Proof of Correctness Claim. F n and G n are inverses. Pf. Summation lemma. Let  be a principal n th root of unity. Then Pf. n If k is a multiple of n then  k = 1  sums to n. n Each n th root of unity  k is a root of x n - 1 = (x - 1) (1 + x + x x n-1 ). n if  k  1 we have: 1 +  k +  k(2)  k(n-1) = 0  sums to 0. ▪ summation lemma

20 Inverse FFT: Algorithm ifft(n, a 0,a 1,…,a n-1 ) { if (n == 1) return a 0 (e 0,e 1,…,e n/2-1 )  FFT(n/2, a 0,a 2,a 4,…,a n-2 ) (d 0,d 1,…,d n/2-1 )  FFT(n/2, a 1,a 3,a 5,…,a n-1 ) for k = 0 to n/2 - 1 {  k  e -2  ik/n y k+n/2  (e k +  k d k ) / n y k+n/2  (e k -  k d k ) / n } return (y 0,y 1,…,y n-1 ) }

21 Inverse FFT Summary Theorem. Inverse FFT algorithm interpolates a degree n-1 polynomial given values at each of the n th roots of unity in O(n log n) steps. assumes n is a power of 2 O(n log n) coefficient representation O(n log n) point-value representation

22 Polynomial Multiplication Theorem. Can multiply two degree n-1 polynomials in O(n log n) steps. O(n) point-value multiplication O(n log n) FFT inverse FFT O(n log n) coefficient representation

Course summary Major computational problems:  DFS  BFS  Dijkstra’s algorithm  Bellman-Ford algorithm  Scheduling algorithms (e.g. interval partitioning)  Knapsack – fractional, 0,1-version, integer version  String similarity and edit distance – Smith-Waterman algorithm  RNA folding  Network flow  k-connectivity  Maximum matching in a bipartite graph  Sorting  Integer multiplication (Karatsuba’s algorithm)  Fast Fourier Transform  Polynomial multplication 23

Course summary Major computational problems (color coded by technique):  DFS  BFS  Dijkstra’s algorithm  Bellman-Ford algorithm  Scheduling algorithms (e.g. interval partitioning)  Knapsack – fractional, 0,1-version, integer version  String similarity and edit distance – Smith-Waterman algorithm  RNA folding  Network flow  k-connectivity  Maximum matching in a bipartite graph  Sorting  Integer multiplication (Karatsuba’s algorithm)  Fast Fourier Transform  Polynomial multiplication 24 Generic Greedy Dynamic programming Iterative improvement Divide and conquer