D52 of 13
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

D5 · Lesson 2 · How the FFT works

The discrete Fourier transform as N correlations of the signal with sampled sinusoids, what each bin means in hertz, the frequency resolution set by record length, how splitting even and odd samples turns N² work into N log N, the butterfly, and why spectrum analyzers and OFDM radios depend on it

The discrete Fourier transform answers a simple question: how much of each frequency does this block of samples contain? Computed directly it takes N² multiplications, which for a million samples is a trillion, far too slow for real time. In 1965 James Cooley and John Tukey published (and others had found before them, Gauss among them) an algorithm that does the same job in about N log₂ N steps: twenty million for a million samples. The fast Fourier transform made digital spectrum analysis, audio compression, medical imaging and OFDM radio practical.

  • Complex multiplications needed for an N-point DFT computed directly (N2) and by a radix-2 FFT (N2log2⁡N), on logarithmic axes.
  • The gap widens with N: for 16 points the FFT is 8 times faster, for a million about 100,000 times.
  • The readouts give the counts and the speedup for the chosen size.

Predict

An audio analyzer takes 1024 samples at 48 kHz. How far apart are the frequencies of its DFT bins?

Name it

The DFT

Xk=∑n=0N−1xne−j2πkn/N,k=0,1,…,N−1

Each Xk is the correlation of the signal with a complex sinusoid that completes k cycles over the record, so it measures the content near frequency kfs/N. Bins are spaced fs/N apart: the resolution is one over the record length. For a real signal, XN−k=Xk*, so only bins 0 to N/2 are independent; bins above N/2 stand for negative frequencies.

The fast algorithm

Split the sum into even and odd samples:

Xk=Ek+e−j2πk/NOk

where Ek and Ok are the N/2-point DFTs of the even and odd samples. Since those repeat with period N/2, one pair of half-size transforms gives all N outputs, with Xk+N/2=Ek−e−j2πk/NOk. That pair of equations is the butterfly: one complex multiplication by the twiddle factor, an addition and a subtraction.

Splitting again and again, log2⁡N times, leaves N/2 butterflies per stage:

N2log2⁡N complex multiplications

against N2 directly: a speedup of 2N/log2⁡N.

Worked example

How much work does a 1024-point FFT save?

Show the solution
  1. Direct DFT. Each of the 1024 outputs takes 1024 multiplications: 10242=1048576
  2. FFT. 10 stages of 512 butterflies: 10×512=5120
  3. Speedup. 10485765120=2×102410=205

Answer the FFT takes 5120 multiplications instead of 1,048,576, a speedup of about 205.

Worked example

With 4096 samples at 1 MHz, which bin holds a 123 kHz tone, and what's the resolution?

Show the solution
  1. Bin spacing. Δf=106Hz4096=244.1Hz
  2. Bin of the tone. k=123000Hz244.14Hz=503.8
  3. Between bins. The tone falls between bins 503 and 504, mostly in 504. (Lesson 3 shows what happens to a tone that falls between bins.)

Answer the resolution is 244.1 Hz, and the tone falls between bins 503 and 504, mostly in 504.

Worked example

1000 samples at 10 kHz are zero-padded to a 4096-point FFT. What is the bin spacing, and what is the real frequency resolution?

Show the solution
  1. Bin spacing. Δf=10000Hz4096=2.44Hz
  2. Record length. The record still lasts only 0.1 s.
  3. Real resolution. Two tones closer than about one over the record length still merge: 10.1s=10Hz
  4. What padding does. Zero padding interpolates the spectrum; only a longer record resolves finer detail.

Answer the bins are 2.44 Hz apart, but the real resolution is still about 10 Hz.

Check

A 256-point DFT is taken of samples at 44.1 kHz. How far apart are its bins?

Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.

Check

In a 512-point DFT of samples at 8 kHz, what frequency does bin 200 stand for?

Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.

Check

How many times fewer multiplications does a radix-2 FFT of 210 points need than a direct DFT?

Check

How many butterflies does a radix-2 FFT of 210 points compute in all?

Check

A transform has 1024 points.

(a)

How many times fewer complex multiplies does the FFT (N2log2⁡N) need than the direct DFT (N2)?

(b)

How many stages does a radix-2 FFT have?

Check

1000 samples at 10 kHz are zero-padded to 16384 points.

(a)

What is the bin spacing?

Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.

(b)

What frequency resolution does the record really have?

Explain why

Why does splitting a DFT into even and odd samples save so much work?

Practice

Keep practicing

8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.