Docsity

Fast Fourier Transform: Applications and Algorithms, Study notes of Computer Science

Partial preview of the text

Download Fast Fourier Transform: Applications and Algorithms and more Study notes Computer Science in PDF only on Docsity!

9/24/ A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

Adam Smith

Algorithm Design and Analysis

LECTURE 14

Divide and Conquer

• Fast Fourier Transform

Midterm Exam

• Willard Building Room 76

• Tuesday night, September 30, 8:15pm

• You may bring: one (1)

double-sided,

hand-written 8.5” x 11” sheet of notes

on colored paper

– Hint: use its preparation as a study aid

9/24/ A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

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.

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.

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.

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-value O(n) O(n^2 ) coefficient representation point-value representation

Coefficient to Point-Value Representation: Intuition

Coefficient to point-value. Given a polynomial a 0 + a 1 x + ... + an-1 xn-1, evaluate it at n distinct points x 0 , ... , xn-1. Divide. Break polynomial up into even and odd powers.  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.  Aeven(x) = a 0 + a 2 x + a 4 x 2

  • a 6 x 3 .  Aodd (x) = a 1 + a 3 x + a 5 x^2 + a 7 x^3.  A(-x) = Aeven(x^2 ) + x Aodd(x^2 ).  A(-x) = Aeven(x^2 ) - x Aodd(x^2 ). Intuition. Choose two points to be ±1.  A(-1) = Aeven(1) + 1 Aodd(1).  A(-1) = Aeven(1) - 1 Aodd(1). Can evaluate polynomial of degree^ ≤^ n at 2 points by evaluating two polynomials of degree ≤ ½n at 1 point.

Coefficient to Point-Value Representation: Intuition

Coefficient to point-value. Given a polynomial a 0 + a 1 x + ... + an-1 xn-1, evaluate it at n distinct points x 0 , ... , xn-1. Divide. Break polynomial up into even and odd powers.  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.  Aeven(x) = a 0 + a 2 x + a 4 x 2

  • a 6 x 3 .  Aodd (x) = a 1 + a 3 x + a 5 x^2 + a 7 x^3.  A(-x) = Aeven(x^2 ) + x Aodd(x^2 ).  A(-x) = Aeven(x^2 ) - x Aodd(x^2 ). Intuition. Choose four points to be ±1, ±i.  A(-1) = Aeven(-1) + 1 Aodd( 1).  A(-1) = Aeven(-1) - 1 Aodd(-1).  A(-i) = Aeven(-1) + i Aodd(-1).  A(-i) = Aeven(-1) - i Aodd(-1). Can evaluate polynomial of degree ≤ n at 4 points by evaluating two polynomials of degree ≤ ½n at 2 points. -1 1 i

- i

Roots of Unity

Def. An nth^ root of unity is a complex number x such that xn^ = 1. Fact. The n th roots of unity are: ω 0 , ω 1 , …, ω n- 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- where ν = e 4 π i / n . Fact. ω^2 = ν and (ω^2 )k^ = νk. ω^0 = ν^0 = 1 ω^1 ω^2 = ν^1 = i ω^3 ω^4 = ν^2 = - ω^5 ω^6 = ν^3 = -i ω^7 n = 8

Fast Fourier Transform

Goal. Evaluate a degree n-1 polynomial A(x) = a 0 + ... + an-1 xn-1^ at its nth roots of unity: ω^0 , ω^1 , …, ωn-1. Divide. Break polynomial up into even and odd powers.  Aeven(x) = a 0 + a 2 x + a 4 x^2 + … + an/2-2 x(n-1)/2.  Aodd (x) = a 1 + a 3 x + a 5 x 2

  • … + an/2-1 x (n-1)/ .  A(x) = Aeven(x^2 ) + x Aodd(x^2 ). Conquer. Evaluate degree Aeven(x) and Aodd(x) at the ½nth^ roots of unity: ν 0 , ν 1 , …, ν n/2- . Combine.  A(ω k+n ) = Aeven(ν k ) + ω k Aodd(ν k ), 0 ≤ k < n/  A(ωk+n/2) = Aeven(νk) - ωk^ Aodd(νk), 0 ≤ k < n/ ω k+n/ = -ω k νk^ = (ωk)^2 = (ωk+n/2)^2

FFT Summary

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

Recursion Tree

a 0 , a 1 , a 2 , a 3 , a 4 , a 5 , a 6 , a 7 a 0 , a 2 , a 4 , a 6 a 1 , a 3 , a 5 , a 7 a 0 , a 4 a 2 , a 6 a 1 , a 5 a 3 , a 7 a 0 a 4 a 2 a 6 a 1 a 5 a 3 a 7 "bit-reversed" order (^000 100 010 110 001 101 011 ) perfect shuffle

Claim. Inverse of Fourier matrix is given by following formula. Consequence. To compute inverse FFT, apply same algorithm but use ω

  • = e -2π i / n as principal n th root of unity (and divide by n).

Inverse FFT

Inverse FFT: Proof of Correctness

Claim. Fn and Gn are inverses. Pf. Summation lemma. Let ω be a principal nth^ root of unity. Then Pf.  If k is a multiple of n then ωk^ = 1 ⇒ sums to n.  Each n th root of unity ω k is a root of x n

  • 1 = (x - 1) (1 + x + x 2 + ... + x n- ).  if ω k ≠ 1 we have: 1 + ω k
  • ω k(2) +... + ω k(n-1) = 0 ⇒ sums to 0. ▪ summation lemma