D5 · Lesson 2 · How the FFT works
The discrete Fourier transform as N correlations of the signal with sampled sinusoids, what each bin means in hertz, the frequency resolution set by record length, how splitting even and odd samples turns N² work into N log N, the butterfly, and why spectrum analyzers and OFDM radios depend on it
The discrete Fourier transform answers a simple question: how much of each frequency does this block of samples contain? Computed directly it takes N² multiplications, which for a million samples is a trillion, far too slow for real time. In 1965 James Cooley and John Tukey published (and others had found before them, Gauss among them) an algorithm that does the same job in about N log₂ N steps: twenty million for a million samples. The fast Fourier transform made digital spectrum analysis, audio compression, medical imaging and OFDM radio practical.
- Complex multiplications needed for an N-point DFT computed directly () and by a radix-2 FFT (), on logarithmic axes.
- The gap widens with N: for 16 points the FFT is 8 times faster, for a million about 100,000 times.
- The readouts give the counts and the speedup for the chosen size.
Predict
An audio analyzer takes 1024 samples at 48 kHz. How far apart are the frequencies of its DFT bins?
The bins are spaced = 48,000/1024 = 46.9 Hz apart. That's the frequency resolution, and it's the reciprocal of the record's length, 1024/48,000 = 21.3 ms. To resolve tones 5 Hz apart you need at least 0.2 s of signal, whatever the algorithm.
Name it
The DFT
Each is the correlation of the signal with a complex sinusoid that completes k cycles over the record, so it measures the content near frequency . Bins are spaced apart: the resolution is one over the record length. For a real signal, , so only bins 0 to N/2 are independent; bins above N/2 stand for negative frequencies.
The fast algorithm
Split the sum into even and odd samples:
where and are the N/2-point DFTs of the even and odd samples. Since those repeat with period N/2, one pair of half-size transforms gives all N outputs, with . That pair of equations is the butterfly: one complex multiplication by the twiddle factor, an addition and a subtraction.
Splitting again and again, times, leaves N/2 butterflies per stage:
against directly: a speedup of .
Worked example
How much work does a 1024-point FFT save?
Show the solution
- Direct DFT. Each of the 1024 outputs takes 1024 multiplications:
- FFT. 10 stages of 512 butterflies:
- Speedup.
Answer the FFT takes 5120 multiplications instead of 1,048,576, a speedup of about 205.
Worked example
With 4096 samples at 1 MHz, which bin holds a 123 kHz tone, and what's the resolution?
Show the solution
- Bin spacing.
- Bin of the tone.
- Between bins. The tone falls between bins 503 and 504, mostly in 504. (Lesson 3 shows what happens to a tone that falls between bins.)
Answer the resolution is 244.1 Hz, and the tone falls between bins 503 and 504, mostly in 504.
Worked example
1000 samples at 10 kHz are zero-padded to a 4096-point FFT. What is the bin spacing, and what is the real frequency resolution?
Show the solution
- Bin spacing.
- Record length. The record still lasts only 0.1 s.
- Real resolution. Two tones closer than about one over the record length still merge:
- What padding does. Zero padding interpolates the spectrum; only a longer record resolves finer detail.
Answer the bins are 2.44 Hz apart, but the real resolution is still about 10 Hz.
Check
A 256-point DFT is taken of samples at 44.1 kHz. How far apart are its bins?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
In a 512-point DFT of samples at 8 kHz, what frequency does bin 200 stand for?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
How many times fewer multiplications does a radix-2 FFT of points need than a direct DFT?
Check
How many butterflies does a radix-2 FFT of points compute in all?
Check
A transform has 1024 points.
(a)
How many times fewer complex multiplies does the FFT () need than the direct DFT ()?
(b)
How many stages does a radix-2 FFT have?
Check
1000 samples at 10 kHz are zero-padded to 16384 points.
(a)
What is the bin spacing?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
(b)
What frequency resolution does the record really have?
Explain why
Why does splitting a DFT into even and odd samples save so much work?
The DFT of N points multiplies every sample by every frequency's sinusoid, which is N² products. Splitting the samples into even and odd halves turns the sum into two DFTs of N/2 points each, and because those half-size transforms repeat with period N/2, a single set of them serves both the lower and upper halves of the outputs, combined with one extra multiplication by a twiddle factor. Two half-size problems cost half as much as one full-size problem, and repeating the split until only single points remain takes log₂N levels, each costing about N/2 multiplications, so the total is N/2 times log₂N instead of N².
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.