The DFT and the FFT
The DFT as samples of the DTFT, frequency bins, the DFT matrix, circular convolution, the radix-2 FFT and N² against N log N
1963 — seismometers and a test ban
A meeting of President Kennedy's Science Advisory Committee turns to a hard question: could seismometers placed around the Soviet Union, outside its borders, reveal its nuclear tests? Analysing their records would take an enormous number of Fourier transforms. John Tukey, a statistician at the meeting, comes up with a faster way to compute them (Fast Fourier transform).
In discussion with Tukey, Richard Garwin of IBM sees that the method matters far beyond national security — he needs it himself, to find periodicities in a crystal of helium-3 — and hands the idea to James Cooley at IBM's Watson laboratory. Cooley and Tukey publish it within six months, in 1965. Because Tukey did not work for IBM, the method's patentability was doubtful, and it went into the public domain, where the computing revolution made it one of the indispensable algorithms of signal processing (Fast Fourier transform).
This lesson is the transform a computer actually computes — the DFT — and the fast Fourier transform that computes it.
The DTFT of an -sample record is a continuous function of . The discrete Fourier transform keeps samples of it, equally spaced around the circle: , . That is just enough: numbers in, numbers out, and the inverse transform gives the record back exactly.
The DFT and its inverse: N samples of the DTFT, and the N-term sum that rebuilds the record.
💡Frequency bins
Bin sits at , which for samples taken at is the frequency
The bins are apart — the reciprocal of the record's duration. Bins above are the negative frequencies: bin is frequency . For a real record , so the second half adds nothing, and
numpy.fft.rfft computes only the first. A one-second record sampled at 8 kHz has 8000 bins, 1 Hz apart; a 1 kHz tone lands in bin 1000, and its mirror image in bin 7000.A matrix. Written out, the DFT is a matrix product , with and . Its columns are orthogonal — — so the inverse is . Computed this way, the DFT costs complex multiplications: about for a million samples.
Derivation
The radix-2 FFT
Let be a power of two and split the sum into even and odd samples, and :
Since , each sum is an -point DFT: , where and are the transforms of the even and odd samples. Both repeat with period , and , so
One multiplication by serves two outputs — a butterfly. Combining the halves costs multiplications; splitting again and again gives stages, and multiplications in all.
📐How much faster
- : the direct sum needs million multiplications; the FFT — 205 times fewer.
- , about a million samples: against — a hundred thousand times fewer. A transform that would take a day takes about a second.
💡Circular convolution
The DFT treats a record as one period of a periodic sequence. Multiplying two DFTs therefore computes a circular convolution, in which the tail of the result wraps round onto its start:
Zero-pad both records to at least samples and nothing wraps: the result is the ordinary linear convolution (the lab of Lesson 4-2). Done this way, a long convolution costs on the order of operations instead of — fast convolution.
the most important numerical algorithm of our lifetime
🕰Gauss got there first
In 1805, interpolating the orbits of the asteroids Pallas and Juno from observations, Carl Friedrich Gauss used a method very similar to Cooley and Tukey's. He never published it — it appeared only in his collected works — and its connection to the FFT was recognised in 1984, when Heideman, Johnson and Burrus showed that Cooley and Tukey had independently rediscovered an algorithm Gauss knew around 1805 (Fast Fourier transform).
⚠The DFT thinks your record repeats
Every DFT assumes the record is one period of a periodic signal. If its two ends do not join smoothly — and for a real recording they almost never do — the jump at the seam is part of what gets transformed, and it spreads energy across the spectrum. That spreading is leakage, the subject of Lesson 6-3; zero padding does not remove it.
💡Where you will use this
Spectrum analysers, audio codecs, the OFDM modulation of Wi-Fi and mobile networks, and MRI reconstruction all run on FFTs. Lesson 6-3 reads DFT spectra honestly, Lesson 6-4 strings them together into spectrograms, and the correlations of Lesson 10-3 are computed as fast convolutions.
📚Further reading
- James W. Cooley and John W. Tukey, "An Algorithm for the Machine Calculation of Complex Fourier Series", Mathematics of Computation 19 (1965), 297–301.
- Alan V. Oppenheim and Ronald W. Schafer, Discrete-Time Signal Processing (3rd ed., Pearson, 2010), chapters 8 and 9.
- Fast Fourier transform on Wikipedia.
↓But there is a problem
Put a tone exactly on a bin and the DFT shows one clean line. Move it half a bin and it lights up every bin in the spectrum — and a faint tone nearby can vanish in the glow.
In 1978 a San Diego engineer published a long paper on how to stop it, and it became the most famous thing he ever wrote.