The DFT is usually taught as a formula, which makes it opaque. It is simpler than that: to find how much of a frequency is present, correlate the signal with that frequency. Multiply point by point, sum the products, and the result is that component’s amplitude.
It works because the basis functions are orthogonal. Correlate any two different ones and you get exactly zero — not approximately. So every other frequency in your signal contributes precisely nothing to the measurement, and each answer comes out uncontaminated.
The basis functions, and why two outputs are always zero
Figure
Cosines on the left, sines on the right, for a 32-point transform at k = 0, 2, 10 and 16. The curve is the underlying sinusoid; the dots are the 32 points the transform actually sees. Each completes exactly k cycles across the window, and that exactness is what makes them orthogonal.
Two panels are flat, and they explain a detail that otherwise looks arbitrary. The sine at k = 0 is zero everywhere — a sine of zero frequency has no amplitude to carry. And look carefully at the sine at k = 16, the Nyquist frequency: the curve is oscillating as fast as it possibly can, yet every single sample lands exactly on zero. Neither can hold information, which is why an N-point real transform yields N + 2 numbers of which exactly two are always zero — conserving information precisely.
Why correlation extracts one frequency cleanly
Figure
The signal contains exactly three cycles. Correlating it against each basis function — multiply point by point, sum the products — gives 0.000000 against 2 cycles, 16.00 against 3, and -0.000000 against 5. The mismatched ones are not merely small, they are exactly zero: across a whole number of cycles the product spends precisely as much time positive as negative. That is orthogonality, and it is the entire reason the DFT works — every other frequency in your signal contributes nothing to the measurement, so each answer comes out uncontaminated. It is also why each basis function must complete a whole number of cycles; two and a half would not cancel.
The assumption that explains everything else
The DFT treats your N samples as one period of a signal repeating forever. You did not ask for this, it is not true of your data, and it is baked into the mathematics.
Nearly every confusing thing the transform does traces back to it: spectral leakage, circular convolution wrapping the end of a result onto its start, and the entire existence of windowing. Remember the assumption and the strange behaviour becomes predictable.
Polar notation, and its nuisances
Real and imaginary parts are how the transform comes out; magnitude and phase are how you want to think. Magnitude says how much energy is at that frequency — it is what people mean by “the spectrum.” Phase says how the components line up in time.
Keep a recording’s magnitudes, randomise its phases, transform back, and it sounds like noise. Both carry real structure.
Three traps. Always use atan2 — computing the ratio yourself and calling ordinary arctangent throws away the quadrant and gives phases wrong by 180° for half your data. Phase is meaningless where magnitude is near zero, because you are measuring the phase of noise. And phase wrapping turns a steadily increasing phase into a sawtooth; those vertical jumps are reporting artefacts, not signal features.
Key points
There are four Fourier transforms, chosen by whether the signal is continuous or discrete and periodic or aperiodic. Only the discrete Fourier transform has finite lists on both sides, so it is the only one a computer can compute.
The DFT treats your N samples as one period of a signal repeating forever. You did not ask for this, it is not true of your data, and it explains spectral leakage, circular convolution, and the existence of windowing.
An N point real DFT produces N over two plus one cosine amplitudes, called the real part, and the same number of sine amplitudes, called the imaginary part. Nothing imaginary is happening yet — it is a label.
Two of those outputs are always zero: the sine at zero frequency and the sine at the Nyquist frequency, both of which are identically zero at every sample point. So information is exactly conserved.
The frequency axis has four standard labellings — bin index from zero to N over two, fraction of sampling rate from zero to zero point five, radians from zero to pi, and actual hertz. Libraries and textbooks disagree, often silently.
Bin spacing is the sampling rate divided by N. Finer frequency resolution comes from observing for longer, not from sampling faster.
Each basis function completes exactly a whole number of cycles across the window. That exactness is what makes the whole method work, and it follows from the periodicity assumption.
Synthesis, the inverse transform, scales each basis function by its amplitude and adds them all up. It is superposition with sinusoids as the chosen pieces.
Scaling conventions differ between sources. Errors of a factor of two or a factor of N are almost always this, and are never conceptually interesting.
Analysis, the forward transform, correlates the signal against each basis function. To find how much of a frequency is present, multiply the signal by that frequency's sinusoid and sum the products.
It works because the basis functions are orthogonal — correlate any two different ones and you get exactly zero. So each measurement is uncontaminated by every other frequency present.
Forward and inverse transforms are nearly the same computation run in opposite directions. That symmetry is duality, and it is why Fourier results come in pairs.
Direct computation costs on the order of N squared operations. A million point transform would need about a trillion, which is what the fast Fourier transform exists to fix.
Convert to polar notation for interpretation. Magnitude is the root of the sum of the squares and says how much energy is at that frequency. Phase is the arctangent and says how the sinusoid is aligned in time.
Keep the magnitudes of a recording and randomize the phases, and it sounds like noise. Magnitude says which frequencies are present; phase says how they line up.
Always use the two argument arctangent, atan2. Computing the ratio and calling ordinary arctangent discards the quadrant information and gives phases wrong by one hundred and eighty degrees for half your data.
Phase is meaningless where magnitude is near zero — you are measuring the phase of noise. Check magnitude before believing a phase.
Phase wrapping makes a steadily increasing phase appear as a sawtooth with vertical jumps. Those jumps are reporting artifacts, not signal features, and an unwrapping routine removes them. A straight line of phase versus frequency means a pure time delay.