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.
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:
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:
The central theorem — provable with the Cauchy–Schwarz inequality — bounds their product from below:
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:
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.
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.