No calculus, no complex-number panic. Just: what it asks, why the answer makes sense, and a picture for every step.
A discrete signal is nothing but a list of numbers. One number per moment. That's it.
Below we'll use 64 numbers, written x[0], x[1], … x[63]. Picture a microphone sampling a sound 64 times in a row. The DFT's only job is to look at that list and tell you which wobbles are hiding inside it.
The DFT takes the list and asks a single question over and over again:
“If I listen only for a wave that goes up-and-down exactly k times across these 64 samples — how loud does it come through?”
Ask it for k = 0, then k = 1, then k = 2, … all the way to k = 32. Those 33 answers are the whole DFT. Each answer is one bin of the spectrum.
Drag the slider to change k. Watch the three panels react.
Where X[k] lands. The answer for one k is a single point — how much cosine (horizontal) and how much sine (vertical). Its distance from the centre is the strength of that frequency. When you drag k, this arrow swings around.
For the k you picked, we draw cos(2πkn/N). It's a plain cosine that fits exactly k full cycles into the 64 samples. k = 4 → 4 wiggles. k = 16 → 16 wiggles. This is our “tuning fork.”
For every sample, multiply the signal by the test wave: x[n] × cos(…). The blue bars are those products. The orange bars are the same idea with a sine wave instead.
Now sum every blue bar. That number is the real part. Sum every orange bar — that's the imaginary part.
• If the signal contains frequency k, the test wave lines up with it, so the products are almost all positive → the sum is large.
• If it doesn't, the products swing positive and negative and mostly cancel → the sum is ≈ 0.
Slide k onto one of the signal's real frequencies and you'll see the bars all flip the same way and the numbers jump. That's the spike in the spectrum.
A cosine only recognises waves that are in step with it. If the real wave is shifted — a different phase — part of it would go missing. The sine wave catches exactly that shifted part. So we always ask two questions per frequency, and glue the two answers into one length:
Do all that for every k and line the answers up as bars. Spikes are where the signal actually lives; the flat bits are the frequencies it doesn't contain. Press ▶ Sweep k and watch the sum climb up each spike and drop away between them.
Everything above, written in math:
Σ means “add up.” The exponential is just shorthand, because
e−iθ = cos θ − i·sin θ — that is literally “multiply by the cosine and by minus-the-sine.” So the formula is exactly the three steps you watched. Nothing new is hiding in it.| Question | Answer |
|---|---|
| Why stop at k = 32? | N samples give N coefficients, but for a real signal the upper half is a mirror image of the lower half (the “negative frequencies” turn out to be redundant). Bins 0…N/2 are all the independent information there is. |
| Is k a frequency in Hz? | Not yet. k counts cycles across the whole 64-sample record. To get Hz: Hz = k × (sample rate / N). |
| What does k = 0 mean? | Zero wiggles — a flat line. The k = 0 bin just measures the signal's average level (its “DC offset”). |
| Where does the fast Fourier transform come in? | The FFT isn't a different transform. It's the same DFT answers, computed with far fewer multiplications when N is a power of two (like our 64). Same result, quicker. |
| Why is my magnitude huge? | Raw |X[k]| scales with N — a longer recording gives bigger sums. That's why we divided by N/2 to get a readable “strength.” |