A1347 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A13 · Lesson 47 · The FFT as an algorithm

Splitting a transform in half, again and again

C9 and A10 used the FFT as a black box that computes a DFT quickly. Here's what's inside. A DFT of N points is N sums of N terms: N2 multiplications. The fast Fourier transform notices that an N-point DFT is two N/2-point DFTs (of the even and odd samples) glued together with N/2 extra multiplications, and applies that idea recursively. The cost drops to N2log2⁡N, a 200-fold saving at 1024 points and 100 000-fold at a million. The same trick makes fast convolution, fast filtering and spectral methods for differential equations possible.

  • The curves count complex multiplications for a direct DFT (N2) and a radix-2 FFT (N2log2⁡N), on log scales.
  • At small N they're close; by N = 1024 the FFT is 200 times faster, and the gap keeps widening in proportion to N/log⁡N.
  • The readouts give both counts and the speedup at the marked N.

Predict

An FFT of 220 (about a million) points is about how many times faster than a direct DFT?

Name it

The DFT

Xk=∑n=0N−1xnWNnk,WN=e−j2π/N,k=0,…,N−1

Decimation in time (radix 2)

Split x into even and odd samples, with N/2-point DFTs Ek and Ok. Then for k=0,…,N/2−1:

Xk=Ek+WNkOk,Xk+N/2=Ek−WNkOk

the butterfly: one multiplication by the twiddle factor WNk makes two outputs. Recursing down to 1-point DFTs takes log2⁡N stages of N/2 butterflies:

cost=N2log2⁡N complex multiplications,Nlog2⁡N additions

Done in place, the input ends up in bit-reversed order: sample n is stored at the index whose binary digits are n's, reversed.

Practical points

  • Any N: mixed-radix FFTs handle products of small primes; Bluestein's algorithm turns a prime-length DFT into a convolution done by power-of-two FFTs. Libraries like FFTW choose a plan for each N.
  • Real signals: an N-point real FFT costs about half as much, since the spectrum is conjugate-symmetric.
  • Accuracy: the FFT is backward stable, with relative RMS error growing only as O(εlog⁡N); a direct DFT's grows faster.

Uses

  • Fast convolution: zero-pad both sequences to at least L+M−1 points (to avoid circular wrap-around), transform, multiply, transform back. For long signals, overlap-add (C9) does it in blocks.
  • Spectral differentiation: for a periodic signal, multiply coefficient k by jk (in radians per sample) and transform back. For smooth periodic functions this is accurate to nearly every digit, far beyond any finite difference: the basis of spectral PDE solvers.

Worked example

Compare direct and FFT cost for N = 1024.

Show the solution
  1. Direct. 10242=1048576 multiplications.
  2. FFT. 512×10=5120 multiplications.
  3. Speedup. The ratio is 205.

Answer 1 048 576 multiplications directly against 5120 by FFT, a speedup of 205.

Worked example

Convolve a 1000-sample signal with a 200-tap filter, directly and by FFT.

Show the solution
  1. Directly. 1000×200=200000 multiplications.
  2. Pad. The result has 1199 samples, so pad to 2048.
  3. The transforms. Two forward transforms and one inverse cost 3×1024×11=33792 multiplications, plus 2048 for the spectra: about 36 000.
  4. Compare. That's under a fifth of the direct cost. (Transforming the filter once and reusing it saves a third more.)

Answer 200 000 multiplications directly against about 36 000 by FFT, under a fifth.

Worked example

Two tones 10 Hz apart are sampled at 1 kHz. How many samples does an FFT need to separate them, and does zero padding help?

Show the solution
  1. Bin spacing. It is fs/N, so separating tones 10 Hz apart needs at least N=1000/10=100 samples.
  2. With a window. A Hann window's main lobe is four bins wide, so about 200 to 400 samples are needed in practice to see two clear peaks.
  3. Zero padding. Padding a 100-sample record to 1024 points draws the same spectrum on a finer grid of 0.98 Hz, which makes the peaks easier to locate, but the two tones stay as blurred together as before.
  4. Where resolution comes from. It comes from the record length, 1/T, and nothing else.

Answer at least 100 samples, and 200 to 400 with a Hann window; zero padding doesn't help separate the tones.

Check

How many complex multiplications does a radix-2 FFT of 212 points take?

Check

How many times fewer multiplications does an FFT of 216 points need than a direct DFT?

Check

To convolve 2000 samples with a 64-tap filter by FFT, what's the smallest power-of-two length that avoids wrap-around?

Check

What's the real part of the twiddle factor W161=e−j2πk/N?

Check

In an in-place 8-point FFT, where does input sample 3 end up (its 3-bit index reversed)?

Check

You need the derivative of a smooth periodic signal from 64 samples per period. Which gives the most accurate result?

Check

A record of 256 samples at 1000 Hz is analyzed with an FFT.

(a)

What is its bin spacing?

Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.

(b)

After zero padding to 4N points, what is the spacing of the plotted points?

Check

Count the work of a radix-2 FFT of length N.

Step 1

How many complex multiplications (one per butterfly)?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

How does splitting a DFT into even and odd samples save work?

Practice

Keep practicing

9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.