Skip to main content

9.5 Fast Fourier transform

Source: Ideas from Computational Physics (Landau, Páez, Bordeianu), §9.5. Rewritten in original wording — no textbook code dumps. Continues 9.4c. Next: 9.5b.

Why N2N^2 hurts​

The DFT

Yn=12π∑k=0N−1Znkyk,Z=e−2πi/NY_n=\frac{1}{\sqrt{2\pi}}\sum_{k=0}^{N-1} Z^{nk} y_k,\qquad Z=e^{-2\pi i/N}

needs a complex multiply for each (n,k)(n,k) pair — about N2N^2 work. At N∼103N\sim10^3 that is the difference between a coffee break and an overnight job. Cooley–Tukey (and earlier rediscoveries) reuse the periodicity of ZnkZ^{nk} to cut the cost to roughly Nlog⁡2NN\log_2 N.

Divide, butterfly, conquer​

Split the data into halves, transform each half, combine. Each stage of length NN costs O(N)O(N) butterflies; log⁡2N\log_2 N stages ⇒O(Nlog⁡N)\Rightarrow O(N\log N). Pick the butterfly map (yp,yq)↦(yp±Zyq)(y_p,y_q)\mapsto(y_p\pm Z y_q) and the bit-reversal consequence among lookalikes.

Figure 9.8 — butterfly operation.

For N=8N=8, powers of ZZ collapse to four independent values (Z0..Z3Z^0..Z^3 and sign flips). Grouping yp±yqy_p\pm y_q before multiplying by ZZ removes redundant work — 24 complex multiplies in a staged butterfly network versus 64 in the naive sum.

Bit reversal​

With b=log⁡2Nb=\log_2 N bits, reverse the bits of each index 0..N−10..N-1 (table below for N=8N=8).

decbits (N=8N=8)reverseddec′
00000000
10011004
20100102
30111106
41000011
51011015
61100113
71111117

Same idea with 4 bits for N=16N=16 (first half of reversed indices are even). Production FFTs hide this shuffle; you should still know it exists when comparing hand butterflies to library fft.

Practice stance​

Prefer a trusted FFT for production spectra. Implement a tiny radix-2 butterfly / bit-reverse once so the Nlog⁡NN\log N story is visceral — then call libraries. Pair with §9.4 filters: FFT → multiply by H(ω)H(\omega) → iFFT is the fast convolution route.

Quiz

FFT

1 / 4

Naive DFT cost scales as…

Pick an answer to see if you are right.

Next: 9.5b FFT labs.