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

C9 · Lesson 27 · The FFT and fast convolution

Computing the DFT in N log N steps, and filtering with it

Computing a 1024-point DFT straight from its definition takes about a million complex multiplications. The fast Fourier transform gets the identical answer with about five thousand, by noticing that a DFT of N points can be split into two DFTs of N/2 points, and those into four, and so on. That factor of 200, growing with N, is why spectrum analyzers, Wi-Fi, MP3 and MRI scanners exist. It also turns convolution around: for long filters, transforming, multiplying and transforming back beats doing the sum directly.

  • The two curves count complex multiplications: N2 for the DFT done directly, and N2log2⁡N for the radix-2 FFT, on log scales.
  • The gap widens as N grows. Move the marker to compare at a particular size.
  • At N = 8 the FFT saves a factor of about 5; at a million points, about 100,000.

Predict

How many times faster is a radix-2 FFT than the direct DFT at N = 1024, counting complex multiplications?

Name it

Splitting the DFT

Write the N-point DFT as a sum over even-numbered and odd-numbered samples:

X[k]=E[k]+WNkO[k],X[k+N/2]=E[k]−WNkO[k]

where E and O are the N/2-point DFTs of the even and odd samples and WN=e−j2π/N. Each pair of outputs costs one multiplication by WNk (a twiddle factor) and two additions, a butterfly. Splitting again and again, for N=2m, gives log2⁡N stages of N/2 butterflies:

MethodComplex multiplications
direct DFTN2
radix-2 FFTN2log2⁡N

a speedup of 2N/log2⁡N. Other sizes work too (radix 3, 5, mixed radix), but powers of two are simplest.

Fast convolution

Convolving by DFT: pad x and h to N ≥ L + M − 1, FFT both, multiply bin by bin, inverse FFT. With h's FFT computed once, each block costs two FFTs and N multiplications, against M multiplications per output sample directly.

Overlap-add

A long signal is cut into blocks of L samples. Each block is convolved with the M-tap filter by FFTs of size N≥L+M−1, giving L + M − 1 output samples, and the blocks' outputs overlap by M − 1 samples and are added. With N=2m fixed, L=N−M+1. For filters longer than a few dozen taps, this beats direct convolution.

Worked example

Compare the direct DFT and the FFT at N = 1024.

Show the solution
  1. Direct DFT. 10242=1,048,576 multiplications.
  2. FFT. 10 stages of 512 butterflies: 10×512=5120 multiplications.
  3. Compare. That's 205 times fewer.

Answer the FFT needs 5120 multiplications against 1,048,576 for the direct DFT, 205 times fewer.

Worked example

A 101-tap FIR filter is applied by overlap-add with 1024-point FFTs. How does its cost compare with direct convolution?

Show the solution
  1. Block length. Each block holds L=1024−101+1=924 new samples.
  2. Cost per block. A forward FFT (5120), 1024 multiplications by the filter's spectrum, and an inverse FFT (5120): 5120+1024+5120=11,264 complex multiplications for 924 outputs.
  3. Cost per output. 11,264/924=12.2 against 101 real multiplications each directly.
  4. Compare. Even counting a complex multiply as four real ones, it's about twice as fast, and the advantage grows with the filter length.

Answer about 12.2 complex multiplications per output against 101 real ones directly, roughly twice as fast even counting a complex multiply as four real ones.

Worked example

A processor does a complex multiply in 1 µs. How long does a 4096-point DFT take directly, and by FFT?

Show the solution
  1. Directly. 40962=16.8million multiplies, which take 16.8 s.
  2. By FFT. log2⁡4096=12 stages of 2048 butterflies: 12×2048=24,576 multiplies, which take 24.6 ms.
  3. Compare. That's 683 times faster, and the gap grows with N.

Answer 16.8 s directly and 24.6 ms by FFT.

Check

A DFT has N=210 points.

(a)

How many complex multiplications does the direct DFT take?

(b)

How many does the radix-2 FFT take?

Check

A radix-2 FFT has N=212 points.

(a)

How many stages?

(b)

How many butterflies per stage?

Check

How many times fewer multiplications does the FFT need than the direct DFT at N=211?

Check

Overlap-add filters 1000000 samples with a 65-tap filter using 2048-point FFTs.

(a)

How many new input samples does each block take?

(b)

How many blocks does the whole signal need?

Check

With the filter's FFT precomputed, overlap-add with 1024-point FFTs and a 128-tap filter costs two FFTs and N products per block. How many complex multiplications is that per output sample?

Check

A processor does 100 million complex multiplications a second. How long does a 210-point FFT's multiplying take?

Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.

Check

The FFT splits an N-point DFT into two DFTs of half the size. Why does that save work?

Check

An FFT of N = 210 points.

(a)

How many complex multiplications does it take, as N2log2⁡N?

(b)

How many times fewer than the direct DFT's N2?

Check

Overlap-add uses 210-point FFTs for a 33-tap filter.

(a)

How many new samples does each block hold?

(b)

How many complex multiplications per output sample (two FFTs plus N products per block)?

Explain why

Where does the FFT's saving come from, in terms of repeated work?

Practice

Keep practicing

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