Fast Fourier transform
What the discrete Fourier transform measures, and how splitting the samples into even and odd halves computes it in n log n steps instead of n squared.
In 30 seconds
A sampled signal is a mix of waves. The discrete Fourier transform finds how much of each wave is present: n samples in, n strengths out.
Done directly, every output needs every sample: n × n multiplications. The fast Fourier transform gets the same result by splitting the samples into even and odd positions, transforming each half, and combining them with one addition and one subtraction per pair.
Halving again and again leaves about n × log₂ n steps: tens of thousands of times less work at a million samples. That is why it sits inside audio tools, wireless networks and medical scanners.
Fast Fourier transform, step by step
The example is chosen so every result is a whole number. In general DFT values are complex numbers, giving each wave’s strength and its shift in time, and this FFT assumes n is a power of two.
- Step 1: A signal is a mix of waves. A digital signal is a list of samples: here four numbers, 6, 1, 0, 1. Any such list can be built by adding simple waves of different speeds. This one is a flat level of 2, plus a slow wave of height 3, plus a fast wave of height 1.
- Step 2: What the DFT computes. The discrete Fourier transform (DFT) measures how much of each wave a signal contains. For each wave it multiplies signal and wave sample by sample and adds up the products. The fast wave scores 4, the flat one 8, the slow one 6. Position 3 mirrors position 1 and repeats its strength, as for any real signal.
- Step 3: The direct way costs n × n. Computed directly, every output needs every sample: n outputs times n samples, so n × n multiplications. Four samples take 16. A short clip of 1,024 samples already takes over a million, and doubling the length quadruples the work.
- Step 4: Split into even and odd. The fast Fourier transform (FFT) gets the same answer by divide and conquer. Deal the samples into two piles, those at even positions and those at odd positions, and transform each half-length pile on its own. For a pile of two, the transform is just their sum and their difference.
- Step 5: Combine the halves. Each pair of half-results yields two outputs: add them for one, subtract them for the other. The odd value is first multiplied by a turning factor w^k, a complex number that accounts for the odd samples sitting one step later. Four cheap combinations rebuild the full answer 8, 6, 4, 6, the same as the direct method.
- Step 6: Why it is n log n. The halves are split again, and again, until each pile holds one sample, which is its own transform. Eight samples need three levels of combining, and each level handles all eight values once. That is n × log₂ n steps instead of n × n, and the gap widens fast as n grows.
- Step 7: Where it is used. Because it is so cheap, the FFT runs wherever signals are taken apart into frequencies or put back together. It shows which pitches are in a sound, lets Wi-Fi and mobile networks carry data on many frequencies at once, and turns the frequency measurements of an MRI scanner into an image. JPEG and MP3 rely on a close relative.
Try it yourself
Learn this first
- The Fourier transformAny signal taken apart into pure sine waves, and the spectrum that lists them. Intermediate
- Divide and conquerSplit a problem, solve the halves, join the answers: why merge sort takes n log n. Intermediate
- Complex numbersA second axis for numbers, where multiplying means rotating. Beginner
Spotted a mistake on this page?