← All Labs
MATHS · VISUAL LAB · IDEA 24

The Fourier / uncertainty trade-off

A signal lives in two worlds at once: time — when it happens — and frequency — which tones it's built from. This applet shows the same pulse in both worlds side by side, and computes a real FFT live. Squeeze the pulse to a sharp spike in time and its spectrum bulges wide. Stretch it into a long, pure tone and the spectrum narrows to a spike. You cannot make both sharp at once — the product of the two widths has a floor. That floor is the mathematics behind Heisenberg's uncertainty principle.

DRIVE IT

Squeeze one world, watch the other spread.

Top panel: the pulse in time. Bottom panel: its magnitude spectrum |X(ω)|, from a live FFT. The shaded bands are the measured RMS widths Δt and Δω.
CANVAS · LIVE FFT (N=1024)
Drag the width slider — or drag left/right on the top panel — to squeeze the pulse. Watch the spectrum breathe the opposite way.
narrow ←→ wide1.00
oscillations under the envelope8.0
Δt (time RMS)
Δω (band RMS)
product Δt·Δω
floor (Gaussian)
0.500
½ (minimum)Δt·Δω
time signal spectrum Gaussian ref width band
WALKTHROUGH

How to read the two panels

Five moves from a single pulse to the hard limit that binds its two shadows.
5 STEPS
1
Meet the pulse. The teal wave up top is a burst — a carrier tone ω_c living inside a bell-shaped envelope. Below it, the orange curve is that burst's spectrum: how much of each frequency it contains, computed by a real FFT every frame.
2
Squeeze time. Drag width to the left. The pulse becomes a sharp spike — you can pin down when it happens. But look down: the spectrum fans out. A short click contains a smear of many frequencies.
3
Stretch time. Drag width right. Now the pulse rings on and on, a nearly pure tone — you know its frequency precisely, so the spectrum collapses to a spike. But when is it? Smeared across the whole window.
4
Watch the product. The gold meter tracks Δt · Δω, the two widths multiplied. As you drag, one width grows exactly as the other shrinks — the product barely moves. It never drops below ½. That wall is the uncertainty principle.
5
Change the window. Swap the Gaussian for a Rectangle and the spectrum sprouts side lobes (spectral leakage) and the product jumps above ½. Only the Gaussian sits right on the floor — it is the uniquely optimal shape.
AHA

Sharp here means blurry there

One object, two irreconcilable views.
THE POINT
AHA MOMENT
A signal and its Fourier transform are two shadows of the same thing, and they are joined by an iron rule: you cannot make both sharp. Localize it in time and it delocalizes in frequency, and vice versa — their widths multiply to a fixed floor of ½. It isn't a limit of your instruments; it's built into what "frequency" means. Feed this same maths a quantum particle instead of a pulse and the floor becomes ℏ/2 — position and momentum can't both be known. Heisenberg's principle is a Fourier theorem in disguise.
EXPLANATION

The maths, computed live

No faked plot — the applet builds the sampled signal, runs a Cooley–Tukey FFT, and measures both widths from the data.
UNDER THE HOOD

The Fourier transform re-expresses a signal x(t) as a recipe of pure oscillations. Its magnitude |X(ω)| tells you how much of frequency ω the signal contains:

The applet samples x(t) at N=1024 points and evaluates this sum with a fast Fourier transform.

To measure "how spread out" each view is, treat |x(t)|² and |X(ω)|² as probability densities and take their root-mean-square widths about their centres:

These are exactly the numbers in the read-out — computed from the sampled signal and its FFT, not assumed.

The central theorem — provable with the Cauchy–Schwarz inequality — bounds their product from below:

No signal can beat this. The gold meter shows how close the current pulse gets to the wall.

Why the Gaussian is special. The inequality becomes an equality for one shape only — the Gaussian e^{-t²/2σ²}. Its transform is again a Gaussian, with reciprocal width:

Time width σ ↔ frequency width 1/σ. Halve one, the other doubles — their product is pinned at ½.

Windowing and leakage. Cut a signal off abruptly (a rectangular window) and its spectrum grows side lobes — a sinc function's ripples — because the sharp edges inject a spray of high frequencies. Smooth tapers (Hann, Hamming, Blackman) trade a slightly wider main lobe for far lower side lobes. You can watch each one's product sit strictly above the Gaussian's ½.

The quantum leap. A quantum particle's wavefunction in position, ψ(x), and in momentum, φ(p), are a Fourier pair with p = ℏk. The very same inequality then reads Δx·Δp ≥ ℏ/2 — Heisenberg. The "spookiness" is nothing but this trade-off applied to e^{ikx} waves.

Try: set the carrier to 0 for a pure baseband bump, then raise it — the spectral lobe simply slides up to ω_c while keeping its width. Frequency location and frequency spread are independent; only the spread is bound to Δt.
RESEARCH NOTE

What's genuine here

Provenance & verification.
HONESTY

Real computation. Each frame the sketch samples the complex signal x[n] = w[n]·e^{iω_c t_n} on N=1024 points, runs an in-place iterative radix-2 Cooley–Tukey FFT, fft-shifts the result to centre zero frequency, and forms |X|². Nothing is precomputed, tabled or faked.

Widths from moments. Δt and Δω are computed as second central moments of |x|² and |X|² using the true sample spacings dt = T/N and dω = 2π/T. Parseval's theorem guarantees the two energy integrals agree, which the code exploits so the product is a fair, self-consistent number.

Cross-check against theory. For the Gaussian envelope the measured product sits at 0.500 ± a small sampling error (the accompanying verify.js confirms it to <1% across the whole width range, and confirms rectangular/Hann/Hamming windows all land strictly above ½). The reference bell curve drawn in violet is the exact analytic transform σ√(2π)·e^{−σ²ω²/2}, overlaid so you can see the live FFT track it.

Built to sit alongside the repo's other applets (Eigenvectors, Lorenz, Hopf, Poincaré disc, Riemann lab). Idea #24 from the 25 maths visual-teaching ideas list. Tech: Canvas 2D + a hand-rolled FFT, KaTeX for the formulae, single self-contained file.