Lite / Engineering Complex Systems / Week 21
The DFT: asking 'how much of this wave?'
A computer only has eight numbers from a sensor. How can it say there is a strong 250 Hz component in them?
Why should I care?
The discrete Fourier transform, usually computed by the fast FFT algorithm, runs inside every spectrum analyser, phone camera, Wi-Fi radio and audio app. It is just multiply-and-add, done cleverly. Seeing it as correlation makes the formula obvious rather than magic.
- Explain the DFT as correlating a signal with probe cosines and sines.
- Compute a 4-point DFT by hand and interpret |X[k]|.
- Relate bin index k to frequency: f = k·fs/N.
Predict
x = [1, 1, 1, 1, 1, 1, 1, 1] (a constant). Which DFT bin is non-zero?
- All of them equally
- Only k = 0
- Only k = 4
- None
Guess first, then reveal
A constant matches only the k = 0 probe (a constant). Every other probe has as much positive as negative area over the window, so the sum cancels. Try the 'Constant' signal in the probe.
Discover
Pick 'cos 2 + ½·sin 3'. Step the probe k from 0 to 7, watching the products column. Which k give big sums, and why do the cosine part and the sine part show up in different columns?
What the interactive shows (text version)
For the signal cos(2·2πn/8) + ½·sin(3·2πn/8), the probe shows |X[k]| = 4 at k = 2 and 6 (cosine part, through the Σx·cos column) and 2 at k = 3 and 5 (sine part, through the Σx·sin column); every other bin is zero.
Watch (optional)
Watch for: Watch the 'winding' picture: the centre of mass moves away from the origin only when the winding frequency matches a frequency in the signal. That is exactly a big |X[k]|.
Winds a signal around a circle at different speeds to show how a transform picks out the frequencies hiding inside it: the same idea as the DFT's correlation with probe waves.
“But what is the Fourier Transform? A visual introduction.” by 3Blue1Brown (opens YouTube; streaming video uses a lot of data)
The video is optional. Everything you need is in this lesson's text.
Understand
Correlation with probes
X[k] = Σ x[n]·cos(2πkn/N) − j·Σ x[n]·sin(2πkn/N). Each bin multiplies the signal by a probe wave with k cycles in the window and adds up. If the signal contains that wave, products are mostly positive and the sum is big; otherwise positives and negatives cancel. The cosine and sine sums together catch the component whatever its phase.
Bins and frequencies
With N samples at rate fs, bin k corresponds to f = k·fs/N. Resolution is fs/N: to tell close frequencies apart, record for longer. For a real signal, bins above N/2 mirror those below (they are the negative frequencies). A pure cosine of amplitude A exactly on bin k gives |X[k]| = A·N/2.
Small enough to do by hand
For N = 4 the probes take only the values 1, 0 and −1, so X[0] = x0 + x1 + x2 + x3, X[2] = x0 − x1 + x2 − x3, and X[1] = (x0 − x2) − j(x1 − x3). For x = [1, 0, −1, 0], X[1] = 2: one cycle of a cosine, amplitude 1, times N/2 = 2.
Explain it another way
Intuitive
It is like testing a bell with tuning forks: hold up each fork in turn and see which one makes the bell hum along. The loudness of the hum is |X[k]|.
Technical
The FFT computes all N bins in about N·log₂N operations instead of N², by reusing shared partial sums. Leakage occurs when a frequency falls between bins; windowing functions reduce it.
Mathematical
X[k] = Σ_{n=0}^{N−1} x[n]·e^{−j2πkn/N}. Probes are orthogonal: Σₙ e^{j2π(k−m)n/N} = N if k = m (mod N), else 0. That orthogonality is why each bin isolates one frequency.
Applied
A condition-monitoring system takes 4096 samples of a pump's vibration at 10 kHz (bin spacing ≈ 2.4 Hz) and watches for growth in the bins near the bearing's characteristic fault frequency.
Worked example 1
Compute all four DFT bins of x = [2, 1, 0, 1].
X[0] = 4. X[2] = 2 − 1 + 0 − 1 = 0. X[1] = (2 − 0) − j(1 − 1) = 2. X[3] = 2. So DC of 1 (4/N) plus one cosine cycle of amplitude 1 (2·2/N).
Common mix-ups
The DFT finds frequencies by guessing.
✓ It is plain multiply-and-add: correlation with fixed probe waves.Sampling faster gives finer frequency resolution.
✓ Resolution is set by the recording length, 1/(N·T).
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Write out the eight probe cosines for N = 8, k = 2. Then correlate them by hand with the 'Square' signal [1, 1, 1, 1, −1, −1, −1, −1]. Explain why bin 2 is zero and bin 1 is not, using what you learned about square waves.
Reflect
Why does the DFT need both a cosine and a sine probe for each k?
Write your answer on paper or in your own notes. Lite never stores what you write.