School/□ Systems Engineer/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?
About 40 min · 3 goals · Checked by automated tests
1.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.
2.Predict
x = [1, 1, 1, 1, 1, 1, 1, 1] (a constant). Which DFT bin is non-zero?
Guess first. Being wrong here is how the surprise works.
3.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?
Loading the interactive…
Can't use the interactive? Read a description instead
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.
4.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
In an N-point DFT, what does bin k measure?
Practice 2
x = [1, 0, −1, 0]. What is |X[1]| of its 4-point DFT?
5.Watch
→ 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.
19 min 41 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
The video is optional: everything you need is also in the lesson text and the interactive.
6.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
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]|.
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.
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.
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).
7.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 3 · a fresh version every time
x[n] = [-1, 1, 1, 1] for n = 0…3. Compute |X[1]|, the magnitude of the 4-point DFT X[k] = Σ x[n]·e^(−j2πkn/4). Give 2 decimal places.
Practice 4
A 1024-point DFT is taken of a signal sampled at 8 kHz. What frequency, in Hz, does bin k = 64 represent?
Practice 5
You need to tell 100 Hz and 102 Hz apart. What helps most?
8.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.
9.Reflect
Concepts: Frequency domain and the Fourier transform