From Convolution to FFT
Slide a convolution, inspect a spectrum, and step through butterflies to understand how FFT speeds up computation.
What you hear now is the sum of past echoes
Compare the pianist view (overlapping echoes), listener view (flipped & shifted response), and continuous slicing.
Bars are colored by source: color i is the echo from input i. The stacked pieces in the selected column match the highlighted diagonal in the table on the left.
Linear convolution has length 3+4−1=6. Set N to 6 or larger and cyclic convolution matches it exactly; below 6, tail terms wrap back to the start.
Two views of a polynomial: coefficients vs. point values
A degree < n polynomial is uniquely fixed by n distinct points; switching to roots of unity turns evaluation into DFT.
A=1+2xB=3+4xC=AB
| −1.5 | −2 | −3 | 6 |
| −0.5 | 0 | 1 | 0 |
| 0.5 | 2 | 5 | 10 |
In point-value form, multiplication multiplies two values per row (3 mults for 3 points). Since deg(C) = 2, 3 points already suffice; extra points simply confirm the same polynomial.
Interpolation stability: Vandermonde condition number
| Points n | Real nodes here | Roots of unity | |
|---|---|---|---|
| 2 | 1.6 | 2.6 | 1 |
| 3 | 5.6 | 13.9 | 1 |
| 4 | 21.9 | 154 | 1 |
| 6 | 424 | 5.77×10⁴ | 1 |
| 8 | 9539 | 5.29×10⁷ | 1 |
| 12 | 6.00×10⁶ | 2.46×10¹⁴ | 1 |
| 16 | 4.37×10⁹ | >10¹⁵ | 1 |
Recovering coefficients solves with . Perturbing point values amplifies the 2-norm relative coefficient error by at most in the worst case.
At roots of unity, V is the Fourier matrix F (), so is unitary and : the linear solve itself adds zero amplification (though floating-point rounding still occurs). For the current 3 real nodes, estimated κ₂ ≈ 5.6.
Multiplying by a complex number rotates and scales the plane
Moduli multiply and angles add: drag z and w or press z ← zw repeatedly.
The faint unit square and letter F are the originals; the solid outline shows them multiplied by z. The whole plane rotates and scales uniformly without shearing.
Why the exponential series winds into a circle
Each term multiplies the previous by iθ/(n+1), turning 90° while factorials eventually shrink the spiral onto the unit circle.
- Real axis +1, len 1
- Imag axis +i, len 3.142
- Real axis −1, len 4.935
- Imag axis −i, len 5.168
- Real axis +1, len 4.059
- Imag axis +i, len 2.55
Each term multiplies the previous by : rotate 90° left and scale by . With enough terms, the spiral converges to the point at angle θ on the unit circle; even terms sum to cos θ and odd terms to sin θ.
Bar height is term magnitude (log scale, clipped below ); blue bars are included terms. Consecutive ratios are : terms grow while the ratio exceeds 1 and shrink afterward. Orange highlights a peak term (n=3, magnitude 5.17); the 30-term spiral reaches distance 5.04 from the origin.
The error above compares the partial sum against cos/sin, combining truncation and floating-point rounding. Cancellation of large intermediate terms raises rounding risk, while large θ still leaves truncation error within 30 terms.
Full turns close the polygon back to zero
Summing ω^(jr) over j = 0..N-1 yields N when N | r and 0 otherwise.
. ω^1 rotates by 1/8 turn. Returning to start in 8 steps traces a regular 8-gon; a closed polygon sums to 0. The dashed diameter links ω⁰ and ω^4: , so opposite roots negate each other — the symmetry FFT uses to halve the work.
The same sum as a matrix:
The Fourier matrix has . Entry of is , the exact sum above for : 8 on the diagonal and 0 off it. Highlighted diagonal: (click any cell to switch r). Thus : swap ω with and divide by N.
Canceling a frequency with a counter-rotating probe
Matching the signal frequency freezes the vectors along one direction; mismatched frequencies average to zero.
Vectors close into a polygon back at the origin: this probe frequency cancels out.
Pairs of roots share the same half-size computation
Splitting even and odd terms pairs ω^k with −ω^k into (u + v, u − v) butterflies across log₂N stages.
Click "Next stage" to start merging. Click any node in the active column to inspect its butterfly.
- Direct DFT
- 64 complex mults
- FFT used
- 0 / 12 butterflies
Zero-pad, transform, multiply pointwise, and invert step by step
Compare floating-point complex FFT against exact finite-field NTT modulo a prime p.
- Zero-pad
- Transform a
- Transform b
- Pointwise ×
- Inverse
- Read output
| 0 | 1 | 3 | · | · | · | · | · |
|---|---|---|---|---|---|---|---|
| 1 | 2 | 4 | · | · | · | · | · |
| 2 | 0 | 0 | · | · | · | · | · |
| 3 | 0 | 0 | · | · | · | · | · |
Each step reveals the next column; muted columns have not been computed yet.
This panel runs the same radix-2 FFT as the butterfly lab (conjugate, forward FFT, divide by N for the inverse). Numbers reflect this implementation rather than a universal bound.
What the Fourier transform diagonalizes
Every circulant matrix is a polynomial in the shift matrix P, so the Fourier basis diagonalizes all of them.
Each column shifts the previous one cyclically down by one, so C_b = b₀I + b₁P + b₂P² + b₃P³. Fourier vectors are eigenvectors of P and hence of C_b: the diagonal is the DFT of b and off-diagonals are 0.
Three multiplications instead of four
Compute (a₀+a₁)(b₀+b₁) and subtract a₀b₀ and a₁b₁ to recover the cross term.
Direct expansion: 4 cells, 4 mults
The two diagonal cells are and . We only need the sum of the off-diagonal cells: computes all four together, then subtracts the diagonal.
Karatsuba: 3 multiplications
Same idea: evaluate at 0, 1, ∞ & interpolate
denotes the leading coefficient. A degree-2 product is fixed by 3 point values (3 mults) — the exact Point Values idea at three cheap points.
Replacing coefficients with half-length polynomials, 4 levels (n = 16)
Multiplications alone: vs. (31.6%), lowering the exponent from 2 to . Each level adds additions; the table counts both mults and adds (direct: ):
| n | Direct | Full recursion | Ratio | Best cutoff | Ratio |
|---|---|---|---|---|---|
| 2 | 1.40 | No recursion | 1.00 | ||
| 4 | 1.32 | No recursion | 1.00 | ||
| 8 | 1.12 | 4 | 0.91 | ||
| 16 | 0.92 | 4 | 0.77 | ||
| 32 | 0.73 | 4 | 0.62 | ||
| 64 | 0.57 | 4 | 0.49 | ||
| 128 | 0.44 | 4 | 0.38 | ||
| 256 | 0.34 | 4 | 0.29 | ||
| 512 | 0.26 | 4 | 0.22 | ||
| 1024 | 0.19 | 4 | 0.17 |
Ratio < 1 means fewer total ops. "Best cutoff" switches to direct multiplication at that block size to minimize total ops. Full recursion starts saving at n=16; cutting off at length 4 saves ~9% at n=8 and 50% at n=64.
Seven products instead of eight for 2×2 blocks
Seven bilinear products cancel unwanted cross terms without using commutativity.
Where M₁ lands when expanded
| Entry of A | e | f | g | h |
|---|---|---|---|---|
| a | +1 | +1 | ||
| b | ||||
| c | ||||
| d | +1 | +1 |
| Entry of A | e | f | g | h |
|---|---|---|---|---|
| a | ||||
| b | ||||
| c | ||||
| d |
| Entry of A | e | f | g | h |
|---|---|---|---|---|
| a | ||||
| b | ||||
| c | ||||
| d |
| Entry of A | e | f | g | h |
|---|---|---|---|---|
| a | +1 | +1 | ||
| b | ||||
| c | ||||
| d | +1 | +1 |
Cell (, ) is the coefficient of monomial (e.g. ) in that output; outlined cells are the two needed terms. +1 and −1 are contributed by this product; entries outside the boxes must be canceled by others.
Inspect a product
- C₁₁ (coeff +1): supplies ae; +ah canceled by −M₅; +de canceled by −M₄; +dh canceled by −M₇
- C₂₂ (coeff +1): supplies dh; +ae canceled by −M₆; +ah canceled by −M₃; +de canceled by −M₂
Replacing scalars with blocks, 4 recursion levels (n = 16)
Multiplications alone: vs. (58.6%), dropping the exponent from 3 to . Each level also adds 18 block additions; the table below counts both mults and adds (direct: ):
| n | Direct | Full recursion | Ratio | Best cutoff | Ratio |
|---|---|---|---|---|---|
| 2 | 2.08 | No recursion | 1.00 | ||
| 4 | 2.21 | No recursion | 1.00 | ||
| 8 | 2.10 | No recursion | 1.00 | ||
| 16 | 1.92 | 8 | 0.99 | ||
| 32 | 1.73 | 8 | 0.93 | ||
| 64 | 1.54 | 8 | 0.84 | ||
| 128 | 1.36 | 8 | 0.75 | ||
| 256 | 1.19 | 8 | 0.66 | ||
| 512 | 1.05 | 8 | 0.58 | ||
| 1024 | 0.92 | 8 | 0.51 |
Ratio < 1 means fewer total ops. "Best cutoff" switches to direct multiplication at that block size to minimize total ops. Full recursion beats direct only at n=1024; cutting off at 8×8 already saves 16% at n=64.
Packing matrix multiplication into one polynomial product
Place matrix entries at chosen exponents so C_ij lands in distinct slots at the cost of Θ(n³) degree.
All 16 products of with their degrees
| b₂₁·x⁰ | b₁₁·x¹ | b₂₂·x⁴ | b₁₂·x⁵ | |
|---|---|---|---|---|
| a₁₁·x⁰ | x⁰7 | x¹5 | x⁴8 | x⁵6 |
| a₁₂·x¹ | x¹14 | x²10 | x⁵16 | x⁶12 |
| a₂₁·x² | x²21 | x³15 | x⁶24 | x⁷18 |
| a₂₂·x³ | x³28 | x⁴20 | x⁷32 | x⁸24 |
Collect by degree and read the 4 target slots
, matching direct product.
Both terms of each land cleanly on their own degree with no collisions. Try a smaller gap above to see terms collide. Click any degree slot to highlight its contributing cells on the left; red borders mark needed AB terms that failed to land cleanly.
Useful entries are only a small fraction
In general, this encoding requires slots of which only belong to . Even with polynomial multiplication, , so it is no faster than naive multiplication.
Reading notes & further questions
Companion interactive experiments for FFT:
- Sliding convolution, point-value interpolation, complex rotation, Euler series, roots of unity, and DFT frequency probing.
- Radix-2 FFT butterflies, full complex FFT vs. zero-error NTT pipeline, circulant diagonalization, Karatsuba, Strassen, and matrix encoding.