Shine white light through a prism and it fans out into a rainbow : the prism reveals that “white” was secretly a mixture of every colour. The Fourier transform is a prism for signals. It takes a sound, an image, a stock price, any wiggly function of time, and reveals the hidden mixture of pure tones it is made of. This one idea underpins audio compression, medical imaging, quantum mechanics and the way Transformers encode the position of a word. But it raises a nagging question that most treatments skip : of all possible building blocks, why should sine waves be the right ones ? This post answers that properly, then follows the consequences — the handful of properties that make the transform useful, the uncertainty principle that falls out of them for free, and the algorithm that made the whole thing practical.
the question that justifies everything else
1. The big idea : signals are recipes of sine waves
A sine wave $\sin(2\pi f t)$ is the purest oscillation there is : a single, unwavering frequency $f$. The claim at the heart of Fourier analysis is startling in its generality.
In plain words : just as a chord is several pure notes played together, any repeating waveform, however jagged, is really a stack of simple sine waves added up. Fourier analysis hands you the sheet music.
2. Why sinusoids, and not something else ?
This is the question worth taking seriously, because the answer is not “tradition”. You could try to build signals out of square pulses, or polynomials, or wavelets — and people do. Sine waves earn their place for two reasons, and the second is the deep one.
First : they stay out of each other’s way. Over one period, the average product of two sine waves of different whole-number frequencies is exactly zero. Concretely, for integers $m \ne n$,
\[\begin{equation} \int_{0}^{2\pi} \sin(mt)\sin(nt)\,\mathrm{d}t = 0, \qquad \int_{0}^{2\pi} \sin(mt)\cos(nt)\,\mathrm{d}t = 0. \label{eq:orth} \end{equation}\]The first one is a two-line computation : the product-to-sum identity turns $\sin(mt)\sin(nt)$ into $\tfrac{1}{2}[\cos((m-n)t) - \cos((m+n)t)]$, and a cosine of a non-zero whole-number frequency integrates to zero over a full period. Only when $m = n$ does the first term become $\cos 0 = 1$ and survive.
This is orthogonality, and it is precisely the property that makes the recipe recoverable. It means you can ask “how much of frequency $n$ is in this signal ?” and get a clean answer, uncontaminated by all the other frequencies. Without it, the ingredients would leak into each other and the notion of a spectrum would be ill-defined.
Second : they are what linear physics leaves alone. This is the real reason, and it is worth stating precisely. Consider any system that is linear (doubling the input doubles the output) and time-invariant (its behaviour does not change from one moment to the next). A vibrating string, an electrical circuit, a room with echoes, a lens, a mechanical suspension — almost every physical system you meet, at least approximately.
Proof sketch. Write the output as $y(t) = L[e^{i\omega t}]$. Time invariance says that delaying the input by $\tau$ delays the output by $\tau$ : $L[e^{i\omega (t-\tau)}] = y(t-\tau)$. But $e^{i\omega(t-\tau)} = e^{-i\omega\tau}e^{i\omega t}$, and by linearity the constant $e^{-i\omega\tau}$ pulls straight out, so $e^{-i\omega\tau} y(t) = y(t-\tau)$. Setting $t = 0$ gives $y(-\tau) = e^{-i\omega\tau} y(0)$, that is, $y(t) = y(0)\,e^{i\omega t}$. So the output is the input times the constant $H(\omega) = y(0)$.
$\square$
In plain words : sine waves are the shapes that pass through the physical world unchanged in character. Play a pure tone into a room and you hear the same pure tone, louder or softer and slightly delayed — never a different note. No other family of functions has this property, and it means that once you know what a system does to each frequency, you know what it does to everything.
That is why the frequency domain is not merely a convenient coordinate change. It is the coordinate system in which linear physical systems become diagonal : a hopelessly tangled operation in time becomes, one frequency at a time, a single multiplication.
3. The Fourier series, and how to read off a coefficient
For a signal $f(t)$ that repeats with period $T$ (base frequency $\omega = 2\pi/T$), the recipe is written
\[\begin{equation} f(t) = a_0 + \sum_{n=1}^{\infty}\Big( a_n \cos(n\omega t) + b_n \sin(n\omega t) \Big). \label{eq:series} \end{equation}\]The amplitudes are recovered by the orthogonality trick above. To find how much of frequency $n$ is present, multiply the signal by that pure wave and average over a period :
\[\begin{equation} a_n = \frac{2}{T}\int_{0}^{T} f(t)\cos(n\omega t)\,\mathrm{d}t, \qquad b_n = \frac{2}{T}\int_{0}^{T} f(t)\sin(n\omega t)\,\mathrm{d}t. \label{eq:coeffs} \end{equation}\]Why this works is worth spelling out, because it is the whole mechanism. Substitute the series $\eqref{eq:series}$ into the integral $\eqref{eq:coeffs}$. Every term $a_m\cos(m\omega t)$ with $m \ne n$ integrates against $\cos(n\omega t)$ to zero, by $\eqref{eq:orth}$. Every sine term does too. Exactly one term survives — the one you were asking about — and the factor $2/T$ normalises it.
In plain words : each integral asks “how much does the signal resemble this particular pure wave ?” It is a similarity score, exactly the kind of projection a dot product performs, but for functions instead of vectors. Orthogonality is what guarantees the other ingredients score zero and do not pollute the measurement.
4. Watching a square wave being built
Nothing makes $\eqref{eq:series}$ more convincing than watching it work. A square wave, all sharp corners and flat tops, seems the least “sine-like” shape imaginable 1. Yet it is just
\[f(t) = \frac{4}{\pi}\left( \sin t + \frac{\sin 3t}{3} + \frac{\sin 5t}{5} + \frac{\sin 7t}{7} + \cdots \right),\]odd harmonics only, each a little weaker than the last. The animation adds them one at a time : with a single sine it is a gentle wave, and as more harmonics join, the corners sharpen and the tops flatten toward the ideal square (grey).
Look closely at the corners as the harmonics pile up. The overshoot does not shrink — it narrows, but its height converges to about 9 % of the jump and stays there forever. This is the Gibbs phenomenon (Gibbs, 1899), and it is not a numerical artefact : it is what happens when you insist on building a discontinuity out of continuous pieces. It is also the reason ringing appears around sharp edges in over-compressed JPEG images, which discard exactly the high harmonics that would have tamed it.
six properties, and one principle that follows from them
5. From series to transform
The Fourier series handles periodic signals. For a signal that does not repeat, take the period $T$ to infinity. The harmonics sit at frequencies $n/T$, spaced $1/T$ apart — so as $T$ grows, the spacing shrinks, the discrete comb of allowed frequencies fills in, and the sum over $n$ becomes an integral over a continuum. Using Euler’s identity $e^{i\theta} = \cos\theta + i\sin\theta$ to package sine and cosine into one object, we arrive at the Fourier transform :
In plain words : $\hat{f}(\xi)$ is still just “how much of frequency $\xi$ is in the signal”, the same similarity score as $\eqref{eq:coeffs}$, now measured for every frequency on a continuum instead of a discrete list.
6. Amplitude and phase : the half everyone forgets
The transform returns complex numbers, and that is not a technicality. Each $\hat f(\xi)$ carries two pieces of information :
\[\hat f(\xi) = \underbrace{\lvert \hat f(\xi) \rvert}_{\text{amplitude}} \cdot\; e^{\,i\,\underbrace{\arg \hat f(\xi)}_{\text{phase}}}.\]The amplitude says how loud that frequency is. The phase says where its peaks sit — how the ingredient is aligned in time. Almost every spectrum plot you will ever see shows only the amplitude, which quietly throws half the information away.
How much does phase matter ? Take two photographs, compute the transform of each, then rebuild two new images : one using the amplitudes of image A with the phases of image B, and one the other way round. The result is not a blend. Each reconstruction looks like the picture whose phase was used. Structure — edges, positions, what the thing actually is — lives in the phase. The amplitude spectrum mostly records texture and contrast.
In plain words : the amplitudes say which ingredients are in the cake ; the phases say in what order and alignment they were combined. It turns out the arrangement is what you recognise.
7. The rules that make it useful
Six properties do nearly all the work in practice. The first three are quick ; the fourth is the one that changed the world.
| operation in time | becomes, in frequency |
|---|---|
| $af(t) + bg(t)$ | $a\hat f(\xi) + b\hat g(\xi)$ |
| $f(t - t_0)$ — a delay | $e^{-2\pi i \xi t_0}\,\hat f(\xi)$ — a phase ramp, amplitude untouched |
| $f(at)$ — squeeze in time | $\tfrac{1}{\lvert a \rvert}\hat f(\xi/a)$ — stretch in frequency |
| $(f * g)(t)$ — convolution | $\hat f(\xi)\,\hat g(\xi)$ — plain multiplication |
| $f’(t)$ | $2\pi i \xi\, \hat f(\xi)$ |
| $\int \lvert f \rvert^2$ — total energy | $\int \lvert \hat f \rvert^2$ — the same total |
The delay rule explains why a shifted signal has the same amplitude spectrum : moving a sound later in time does not change which notes it contains, only their alignment. All the shifting information is stored in the phase — which is another reason to stop discarding it.
The scaling rule is the seed of section 8 : you cannot compress a signal in time without spreading it out in frequency, and the trade is exactly reciprocal.
The derivative rule turns calculus into arithmetic. A differential equation, which couples a function to its own slopes, becomes an algebraic equation in $\xi$ that you solve by dividing. This is why the transform shows up wherever differential equations do — heat flow, which is the problem Fourier invented all this to solve (Fourier, 1822), quantum mechanics, and every vibration problem in engineering.
The convolution theorem is the crown jewel, and it deserves a proof.
Proof. Write out the transform of the convolution and swap the order of integration : $$ \int\!\!\left[\int f(\tau)g(t-\tau)\,\mathrm{d}\tau\right] e^{-2\pi i\xi t}\,\mathrm{d}t = \int f(\tau)\left[\int g(t-\tau)\,e^{-2\pi i \xi t}\,\mathrm{d}t\right]\mathrm{d}\tau. $$ In the inner integral substitute $u = t - \tau$, so $e^{-2\pi i\xi t} = e^{-2\pi i \xi u}\,e^{-2\pi i \xi\tau}$ and the inner integral becomes $e^{-2\pi i\xi\tau}\hat g(\xi)$. The factor $\hat g(\xi)$ no longer depends on $\tau$, so it comes out : $$ \hat g(\xi)\int f(\tau)\,e^{-2\pi i \xi \tau}\,\mathrm{d}\tau = \hat g(\xi)\,\hat f(\xi). $$
$\square$
In plain words : convolution is the expensive, tangled operation — every output sample depends on every input sample, which costs $\mathcal{O}(N^2)$. Multiplication is the cheap one, costing $\mathcal{O}(N)$. The theorem says you can always take the second route : transform, multiply pointwise, transform back. Combined with the fast algorithm of section 10, this turns an $\mathcal{O}(N^2)$ problem into an $\mathcal{O}(N\log N)$ one, and it is why blurring an image, filtering audio and multiplying enormous integers are all fast.
There is a second reason this theorem matters, far from signal processing. Adding two independent random variables convolves their probability densities — and by this theorem, that becomes an ordinary product in Fourier space. Repeating it $n$ times gives an $n$-th power, and taking the limit is what produces the bell curve. That argument is the proof of the central limit theorem, and it is why the normal distribution is the shape that survives being added to itself.
8. The uncertainty principle, for free
The scaling rule already hinted at it : squeeze in time, spread in frequency. Made precise, that hint becomes a theorem — and it is the same theorem physicists know by another name.
In plain words : a signal cannot be both brief and pure. A very short click contains every frequency at once — that is why a snare drum has no pitch. A very pure tone must ring on for a long time — that is why a tuning fork sustains. There is no trick, no cleverness, no better instrument that beats this ; it is a property of the transform itself (Gabor, 1946).
Two consequences worth carrying :
- In practice. To measure a frequency precisely you must listen for a long time. A spectrum analyser with 1 Hz resolution needs at least a full second of signal, no matter how good it is. This is why a music transcription system faces a genuine trade-off between telling you what note and telling you exactly when.
- In physics. A quantum particle’s position and momentum are related by exactly this transform pair. Heisenberg’s uncertainty principle is not an extra postulate about measurement disturbing things — it is this mathematical fact, applied to wavefunctions.
sampling, the fast algorithm, and the traps
9. Sampling : how often is often enough ?
A computer never sees a continuous signal. It sees samples, taken every $\Delta t$ seconds, at rate $f_s = 1/\Delta t$. What gets lost ?
Sample more slowly than that and something worse than blurring happens : frequencies above $f_s/2$ do not vanish, they fold back and masquerade as lower frequencies that were never there. This is aliasing, and once it has happened no amount of processing can undo it, because the impostor is indistinguishable from a genuine low-frequency component.
In plain words : you have seen this. A wagon wheel in a film appearing to spin backwards is aliasing — 24 frames per second is too slow for the spokes. Moiré patterns on a striped shirt on television are aliasing in space. The fix is always the same and always happens before sampling : a low-pass filter that removes the frequencies you cannot afford to capture. That is why audio is sampled at 44.1 kHz — comfortably above twice the ~20 kHz limit of human hearing.
10. The DFT, and the algorithm that made it practical
For $N$ samples $x_0, \dots, x_{N-1}$, the discrete Fourier transform is the finite version of the same idea :
\[\begin{equation} X_k = \sum_{n=0}^{N-1} x_n\, e^{-2\pi i kn/N}, \qquad k = 0, \dots, N-1. \label{eq:dft} \end{equation}\]This is a matrix–vector product : $N$ outputs, each a sum of $N$ terms, so $\mathcal{O}(N^{2})$ operations. For an hour of CD audio, $N \approx 1.6 \times 10^{8}$ and $N^2$ is about $2.5 \times 10^{16}$ — decades of computation. The Fourier transform was mathematically beautiful and practically unusable.
The Fast Fourier Transform (Cooley & Tukey, 1965) fixes this with one observation. Split the sum into even-indexed and odd-indexed samples :
\[\begin{equation} X_k = \underbrace{\sum_{m=0}^{N/2-1} x_{2m}\,e^{-2\pi i k m/(N/2)}}_{E_k,\;\text{a DFT of half the size}} \;+\; e^{-2\pi i k/N} \underbrace{\sum_{m=0}^{N/2-1} x_{2m+1}\,e^{-2\pi i k m/(N/2)}}_{O_k,\;\text{another one}}. \label{eq:fft} \end{equation}\]Both halves are themselves DFTs of length $N/2$. And because $E_k$ and $O_k$ are periodic with period $N/2$, the same two half-transforms give you the second half of the output almost free :
\[X_k = E_k + e^{-2\pi i k/N} O_k, \qquad X_{k + N/2} = E_k - e^{-2\pi i k/N} O_k.\]In plain words : one problem of size $N$ becomes two of size $N/2$, and combining them costs only $\mathcal{O}(N)$. Recurse, and the cost obeys $T(N) = 2T(N/2) + \mathcal{O}(N)$, which solves to $\mathcal{O}(N\log N)$. For that hour of audio, $N \log_2 N \approx 4.4 \times 10^{9}$ — a few seconds instead of decades. It is hard to overstate how much modern technology rests on that single factorisation.
import cmath
def fft(x):
"""Radix-2 Cooley-Tukey. len(x) must be a power of two."""
n = len(x)
if n == 1:
return list(x)
even = fft(x[0::2])
odd = fft(x[1::2])
out = [0] * n
for k in range(n // 2):
w = cmath.exp(-2j * cmath.pi * k / n) * odd[k]
out[k] = even[k] + w
out[k + n // 2] = even[k] - w
return out
11. Spectral leakage, and why your FFT looks smeared
Here is the trap that catches everyone the first time. Feed a perfect sine wave into an FFT and you expect a single clean spike. You usually get a spike surrounded by a skirt of spurious neighbours.
The reason is that the DFT does not see your $N$ samples as a finite chunk. It assumes they repeat forever, end joined to start. If your window does not contain a whole number of periods, that wrap-around creates a discontinuity — and by section 4, a discontinuity needs high harmonics. Those harmonics are entirely an artefact of where you cut, and they are called spectral leakage.
The fix is windowing : before transforming, multiply the samples by a function that tapers smoothly to zero at both ends, so the wrap-around is seamless. The Hann window $w_n = \tfrac{1}{2}\big(1 - \cos(2\pi n/N)\big)$ is the usual default. You pay for it — tapering widens the main peak slightly — and choosing a window is exactly a trade between how narrow the peak is and how fast the skirt decays (Harris, 1978).
In plain words : the DFT thinks your recording is a loop. If the loop clicks, the spectrum shows the click.
12. Where it shows up
Once a signal is in the frequency domain, things that were hard become easy.
- Compression. JPEG splits an image into blocks and keeps only the low-frequency coefficients, because the eye barely notices the rest. MP3 does the same for hearing, with a model of which frequencies get masked by louder neighbours. Both are throwing away parts of a spectrum.
- Filtering. Removing hiss, isolating a bass line, or cleaning mains hum from an ECG is deleting or attenuating a band of frequencies — one multiplication in the frequency domain, thanks to the convolution theorem.
- Medical imaging. An MRI scanner does not measure an image. It measures the Fourier transform of the body slice directly, one frequency at a time, and the picture you see is produced by an inverse transform.
- Diffraction. The pattern X-rays make when they scatter off a crystal is the Fourier transform of the crystal’s electron density. Working out the structure of DNA meant inverting one of these by hand.
- Probability. The characteristic function is the Fourier transform of a density, and it is the standard machinery for proving results about sums of random variables.
- Deep learning. The Transformer tags each word position with a vector of sines and cosines of many different frequencies, exactly the ingredients of a Fourier series. Fast-oscillating components pin down fine position, slow ones the coarse position, so the whole vector is a Fourier-style fingerprint of where a word sits.
13. Conclusion
The Fourier transform is a change of perspective : stop describing a signal by what it does at each moment, and start describing it by which frequencies it is made of.
Sine waves earn their central role honestly. They are orthogonal, so the recipe can be read off cleanly, one ingredient at a time. And they are the eigenfunctions of every linear time-invariant system, which means the frequency domain is the coordinate system where physics becomes diagonal — where a tangled operation over all of time collapses into one multiplication per frequency. Everything else follows from those two facts : the convolution theorem, and with it fast filtering and the central limit theorem ; the uncertainty principle, and with it Heisenberg ; the sampling theorem, and with it every digital recording ever made.
From a prism splitting light to a Transformer locating a word, the same idea keeps reappearing. Complicated things are often simple mixtures of pure oscillations — if only you look at them through the right prism.
References
- Cooley, J. W., & Tukey, J. W. (1965). An Algorithm for the Machine Calculation of Complex Fourier Series. Mathematics of Computation, 19(90), 297–301.
@article{Cooley1965, author = {Cooley, James W. and Tukey, John W.}, title = {An Algorithm for the Machine Calculation of Complex Fourier Series}, journal = {Mathematics of Computation}, volume = {19}, number = {90}, pages = {297--301}, year = {1965} } - Fourier, J. (1822). Théorie Analytique de la Chaleur. Firmin Didot.
@book{Fourier1822, author = {Fourier, Joseph}, title = {Th{\'e}orie Analytique de la Chaleur}, publisher = {Firmin Didot}, year = {1822} } - Gabor, D. (1946). Theory of Communication. Journal of the Institution of Electrical Engineers, 93(26), 429–457.
@article{Gabor1946, author = {Gabor, Dennis}, title = {Theory of Communication}, journal = {Journal of the Institution of Electrical Engineers}, volume = {93}, number = {26}, pages = {429--457}, year = {1946} } - Gibbs, J. W. (1899). Fourier’s Series. Nature, 59(1539), 606.
@article{Gibbs1899, author = {Gibbs, J. Willard}, title = {Fourier's Series}, journal = {Nature}, volume = {59}, number = {1539}, pages = {606}, year = {1899} } - Harris, F. J. (1978). On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform. Proceedings of the IEEE, 66(1), 51–83.
@article{Harris1978, author = {Harris, Fredric J.}, title = {On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform}, journal = {Proceedings of the IEEE}, volume = {66}, number = {1}, pages = {51--83}, year = {1978} } - Nyquist, H. (1928). Certain Topics in Telegraph Transmission Theory. Transactions of the American Institute of Electrical Engineers, 47(2), 617–644.
@article{Nyquist1928, author = {Nyquist, Harry}, title = {Certain Topics in Telegraph Transmission Theory}, journal = {Transactions of the American Institute of Electrical Engineers}, volume = {47}, number = {2}, pages = {617--644}, year = {1928} } - Shannon, C. E. (1949). Communication in the Presence of Noise. Proceedings of the IRE, 37(1), 10–21.
@article{Shannon1949, author = {Shannon, Claude E.}, title = {Communication in the Presence of Noise}, journal = {Proceedings of the IRE}, volume = {37}, number = {1}, pages = {10--21}, year = {1949} }
-
Joseph Fourier introduced these series in 1822 while studying heat flow (Fourier, 1822), to considerable scepticism : his contemporaries, Lagrange among them, doubted that sums of smooth sines could represent functions with sharp corners. They were not being obtuse — the claim is genuinely delicate, and pinning down exactly which functions it holds for occupied analysts for the next century and produced a good deal of modern mathematics along the way. ↩