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: for the DFT done directly, and 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?
About 200: against . The ratio is , which keeps growing with N.
Name it
Splitting the DFT
Write the N-point DFT as a sum over even-numbered and odd-numbered samples:
where E and O are the N/2-point DFTs of the even and odd samples and . Each pair of outputs costs one multiplication by (a twiddle factor) and two additions, a butterfly. Splitting again and again, for , gives stages of N/2 butterflies:
| Method | Complex multiplications |
|---|---|
| direct DFT | |
| radix-2 FFT |
a speedup of . 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 , giving L + M − 1 output samples, and the blocks' outputs overlap by M − 1 samples and are added. With fixed, . 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
- Direct DFT. multiplications.
- FFT. 10 stages of 512 butterflies: multiplications.
- 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
- Block length. Each block holds new samples.
- Cost per block. A forward FFT (5120), 1024 multiplications by the filter's spectrum, and an inverse FFT (5120): complex multiplications for 924 outputs.
- Cost per output. against 101 real multiplications each directly.
- 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
- Directly. multiplies, which take 16.8 s.
- By FFT. stages of 2048 butterflies: multiplies, which take 24.6 ms.
- 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 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 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 ?
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 -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 = points.
(a)
How many complex multiplications does it take, as ?
(b)
How many times fewer than the direct DFT's ?
Check
Overlap-add uses -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?
Computed directly, each of the N output bins multiplies all N samples by its own set of complex exponentials, and many of those products are the same numbers computed again for different bins. The even/odd split shows that the bins in the bottom half and the top half share the same two half-size DFTs, differing only in the sign of the twiddle factor. Applying the split again at every level reuses each intermediate result many times, so the work drops from N² to about N log₂N.
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.