🌊 Fourier Series

Any periodic signal can be decomposed into a sum of pure sine waves — this is the Fourier series. The left panel shows rotating phasors: each circle spins at a harmonic frequency, and the tip of the last phasor traces the waveform. The right panel shows the signal built so far (green) vs the ideal target (dim). The bottom panel is the frequency spectrum — amplitude of each harmonic. Notice the Gibbs phenomenon: the ~9% overshoot at discontinuities that never fully disappears even with infinitely many harmonics. 🇺🇦 Українська

Waveform

Frequency Spectrum

Harmonics1
Max error
Gibbs overshoot

How It Works

The Fourier coefficients for a square wave (±1, period 2π) are: a_n = 4/(nπ) for odd n, zero for even n. Each rotating phasor has length equal to its amplitude. As you increase N, the partial sum converges to the target waveform — but never quite reaches the corners. This 9% overshoot at discontinuities is the Gibbs phenomenon, named after J. W. Gibbs (1899). It affects audio engineering (ringing near transients), image compression (JPEG ringing at edges), and numerical PDE solvers.

About Fourier Transform

The Fourier transform converts a signal from the time domain (amplitude versus time) to the frequency domain (amplitude versus frequency), revealing the spectral content hidden in any waveform. The continuous Fourier transform is defined as F(ω) = ∫ f(t) e^(-iωt) dt and its inverse recovers the original signal. The Discrete Fourier Transform (DFT) applies to sampled signals with N samples, requiring O(N²) operations—made practical by the Fast Fourier Transform (FFT) algorithm, which reduces this to O(N log N).

The FFT, published by Cooley and Tukey in 1965, is considered one of the most important algorithms of the 20th century. By recursively decomposing an N-point DFT into smaller transforms, FFT transforms 1 million points in about 0.02 seconds instead of 3 hours. Key properties include linearity, the convolution theorem (multiplication in frequency space equals convolution in time space), Parseval's theorem (energy is conserved between domains), and the shift property (time delay causes phase shift in frequency domain).

This simulator lets you construct time-domain signals by adding components, compute and display their frequency spectrum, apply windowing functions to reduce spectral leakage, and observe how filtering in the frequency domain changes the time-domain signal. Applications span audio processing, image compression (JPEG), radio communications, medical imaging (MRI), seismology, and machine learning feature extraction.

Frequently Asked Questions

What does the frequency spectrum of a signal reveal?

The frequency spectrum shows how much energy is present at each frequency in a signal. A pure sine wave at 440 Hz produces a single spike at 440 Hz in the spectrum. A complex musical chord shows spikes at multiple harmonically related frequencies. A square wave shows energy at the fundamental and all odd harmonics with amplitude falling as 1/n. Noise has energy spread across all frequencies (white noise) or with a specific spectral shape. The spectrum reveals periodicities, harmonic relationships, and frequency components that are not obvious in the raw time-domain signal.

What is spectral leakage and how do window functions reduce it?

Spectral leakage occurs when the DFT implicitly assumes the signal repeats periodically, but the signal within the analysis window does not begin and end at the same value. The discontinuity at the window boundary spreads energy from a pure tone across neighboring frequency bins, obscuring nearby spectral features. Window functions (Hann, Hamming, Blackman) taper the signal smoothly to zero at both ends, eliminating the discontinuity. This trades frequency resolution (slightly broadened peaks) for reduced leakage (suppressed sidelobes), with different windows optimizing different trade-offs.

Why is the FFT so much faster than the DFT?

The DFT computes each of N frequency components as a sum of N time-domain samples, requiring N² multiplications total. For N=1,000,000, that is 10¹² operations. The FFT exploits the DFT's symmetry and periodicity properties to factor the computation recursively: an N-point DFT is broken into two N/2-point DFTs, each broken into N/4-point DFTs, and so on for log₂(N) levels. Total operations become N·log₂(N) ≈ 20,000,000 for N=1,000,000—a 50,000-fold speedup that made real-time signal processing feasible.

What is the relationship between time resolution and frequency resolution?

The time-frequency uncertainty principle (analogous to Heisenberg's in quantum mechanics) states that Δt·Δf ≥ 1/(4π): you cannot simultaneously achieve arbitrarily good time resolution and frequency resolution. A short analysis window gives good time resolution (you know when events occur) but poor frequency resolution (peaks are broad). A long window gives sharp frequency resolution but smears transient events over time. This trade-off is fundamental to all spectral analysis and motivates time-frequency representations like wavelets and short-time Fourier transforms (spectrograms).

How does Fourier transform enable MRI imaging?

MRI scanners measure the Fourier transform of the patient's body, called k-space. Radiofrequency pulses excite hydrogen nuclei, which emit signals at a frequency proportional to their local magnetic field strength. By applying gradient magnetic fields, each spatial location is encoded at a unique frequency—meaning the detected signal is the Fourier transform of the hydrogen density distribution. Applying the inverse FFT to k-space data reconstructs the anatomical image. Modern parallel imaging and compressed sensing MRI techniques sample k-space non-uniformly to reduce scan time while maintaining image quality.