A waveform is one description of a signal. Fourier analysis asks for another: how strongly does that signal align with each rotating complex sinusoid?
Two views of the same object
Time-domain samples tell us what happened at each instant. Frequency-domain coefficients tell us how much of each discrete oscillation is required to reconstruct those samples. Neither view creates information; each organises the same finite sequence around a different question.
For a sequence x[n] of length N, the discrete Fourier transform is:
The index k labels a basis function completing exactly k cycles in the observation. If samples arrive at fₛ samples per second, adjacent bins are separated by Δf = fₛ/N hertz. The coefficient is complex: its length gives magnitude and its angle gives phase.
Interactive experiment
Harmonic composer
How do amplitude, frequency and phase appear in a discrete spectrum?
The waveform is the sample-wise sum; its vertical scale is automatic and labelled. The spectrum view shows 0–16 Hz of the available 0–32 Hz band. Bars use the left amplitude scale; phase points use the right −π to +π radian scale. Phase is omitted below amplitude 0.03.
What the computation is doing
Each coefficient is an inner product. The transform rotates a reference phasor at bin k, multiplies it by every sample, and sums. A matching component adds coherently; mismatched rotations tend to cancel. Our one-sided plot doubles magnitudes except at DC and, for even lengths, Nyquist to account for the omitted negative-frequency partner of a real signal.
Leakage is the boundary speaking
A DFT treats the observed block as one period of an endlessly repeated signal. A tone at 3 Hz in a one-second record fits the boundary. A tone at 3.25 Hz does not: the periodic extension jumps, and energy spreads across bins. This is spectral leakage—not an FFT error. A tapered window reduces the boundary discontinuity at the cost of a wider main lobe and changed amplitude calibration.
DFT and FFT are not synonyms
The DFT defines the representation. Direct evaluation takes order N² complex operations. An FFT is a family of algorithms that exploits symmetry to compute those same coefficients, commonly in order N log N. Normalisation and sign conventions vary between libraries, but an FFT is not a different transform.
Where the intuition breaks
A short record does not contain a perfectly resolved list of eternal tones. Frequency resolution is constrained by observation duration, phase is meaningless near zero magnitude, and a spectrally rich transient can be localised poorly by one transform of the whole record. The STFT trades some frequency precision for time localisation; sampling determines which frequencies were recoverable before the transform began.
Practical checks
- State sample rate, record length, window and normalisation.
- Keep magnitude, power and decibels distinct.
- Construct the frequency axis differently for odd and even lengths.
- Never interpret phase without checking magnitude.
Try three changes, one at a time
- Set Tone B amplitude to zero. With Tone A at 3 Hz, there are three cycles in the one-second record and one dominant positive-frequency bin.
- Change Tone A phase from 0° to 90°. The waveform shifts, while its bin-centred magnitude stays constant. Phase describes alignment with the reference basis, not a second kind of energy.
- Set the frequency to 3.25 Hz. The observation no longer contains an integer number of cycles. Inspect the neighbouring bins: one component now needs several basis functions to describe the finite record.
A number you can check by hand
Take four samples of a unit sine wave: [0, 1, 0, −1]. Under the forward convention above, its DFT is [0, −2i, 0, 2i]. Dividing the positive-frequency magnitude by four and doubling it gives amplitude one. The positive-frequency phase is −90°, even though the sine's input phase is zero: the DFT uses a cosine-oriented complex reference.
For even lengths, the Nyquist bin is its own negative-frequency partner and must not be doubled. DC is also undoubled. The composer displays only 0–16 Hz of a signal sampled at 64 Hz; its upper visible bin is not the Nyquist boundary, which is 32 Hz.
How to use a spectrum in practice
To find periodic interference in a sensor trace, first remove an irrelevant mean if appropriate, choose an observation long enough for the separation you need, and inspect neighbouring bins rather than just the tallest bar. Doubling observation duration halves bin spacing. Appending zeros makes the plotted curve denser but leaves the information-bearing duration unchanged.
Magnitude and phase together reconstruct the samples. Throwing away phase makes a useful summary for some tasks, but two very different waveforms can share a magnitude spectrum. That distinction matters when designing a model's input representation.
Further reading
NumPy's Fourier-transform reference states its sign, normalisation and frequency ordering. Continue with convolution to see how changing a signal in frequency space becomes filtering in time.