x[0]–x[1]–x[2]–x[3]–x[4]–x[5]–x[6]–x[7]–––––––––––––––––X[0]–X[1]–X[2]–X[3]–X[4]–X[5]–X[6]–X[7]–1import numpy as np2x = [1,1,1,1,0,0,0,0]3X = np.fft.fft(x)4abs(X).round(2)×−j×−j×W¹×−j×W³
0123456700.51n (sample number)x[n]INPUT x[n]0123456701234k (ω = 2πk/8)|X|SPECTRUM |X[k]|DTFT|X[k]|286410244096110²10⁴10⁶10⁸10¹⁰N (samples, log scale)count (log)MULTIPLICATIONSN²(N/2)log2N64121,048,5765,120
Coloured parts: what the current step is about; everything else rests in whiteBlocks: four rows of eight memory cells (input, after stage 1, after stage 2, output) and a Python code cardWires on the table: the butterflies of each stage; plots: input, spectrum and multiplication countsYellow tokens carry values along the wires; the cells crossfade to the new values as they landAn 8-point radix-2 decimation-in-time FFT of the pulse x = [1, 1, 1, 1, 0, 0, 0, 0]: bit-reversed input, three stages of four butterflies, 12 complex multiplications instead of 64. This is the radix-2 decimation-in-time FFT published by Cooley and Tukey in 1965. Gauss had found the same idea around 1805, unpublished in his lifetime. numpy.fft uses its own optimized FFT code, but the cost has the same N·log N shape.

The direct DFT

  1. Our signal is a pulse of N = 8 samples. Each output X[k] multiplies all 8 samples by a twiddle factor W^(nk) and adds them up. Eight outputs × eight products = 64 multiplications.

Divide and conquer

Butterflies, stage by stage

The payoff

The working

# step 1/10 · direct

X[k] = Σ x[n]·W^(nk),  n = 0 .. 7
W = e^(−j2π/8)  (a turn of 1/8 circle)

x = [1, 1, 1, 1, 0, 0, 0, 0]

one X[k]:   8 multiplications
8 outputs:  8 × 8 = 64

N samples cost N² multiplications.
N = 1024 -> 1,048,576

Counts are complex multiplications, the usual measure (Oppenheim and Schafer, ch. 9). They include the trivial ones by 1 and −j; real programs skip those, so they do even less work. The direct DFT also needs N(N−1) additions; the FFT needs N·log2 N. Every value in the figure is computed from the model: the pulse x = [1, 1, 1, 1, 0, 0, 0, 0], the butterflies, and the direct sum, which agree to rounding.