Math Methods · Learn

Fourier Series

Any periodic signal — even a hard-cornered square wave — is secretly a sum of pure sine waves. Here's why that works, how to find the amounts, and why sharp edges never quite behave.

▶ Play the lab📖 Learn the theory

1The idea

A function with period $2L$ can be written as a sum of sines and cosines whose frequencies are integer multiples of the fundamental:

$$ f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty}\left[a_n\cos\frac{n\pi x}{L} + b_n\sin\frac{n\pi x}{L}\right] $$

The lowest frequency is the fundamental; the higher terms are harmonics that fill in the fine detail.

2Orthogonality — how to find the coefficients

The trick that makes it all work: sines and cosines of different integer frequencies are orthogonal — multiply two different ones and integrate over a period and you get zero. So each coefficient can be read off independently by projecting $f$ onto that harmonic:

$$ a_n = \frac1L\int_{-L}^{L} f(x)\cos\frac{n\pi x}{L}\,dx, \qquad b_n = \frac1L\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx $$

3Symmetry: sine, cosine, or full

Odd functions ($f(-x)=-f(x)$) contain only sines; even functions only cosines; a general signal needs both. This same choice reappears in PDEs: sine series match fixed (Dirichlet) ends, cosine series match insulated (Neumann) ends.

4Convergence & the Gibbs phenomenon

How fast the series converges depends on smoothness. A smooth function's coefficients fall like $1/n^2$ — a few terms nail it. A function with jumps falls only like $1/n$, and near each jump the partial sum overshoots by about 9% no matter how many terms you add. The spike narrows but never shrinks — the Gibbs phenomenon.

▶ In the lab

Build a square wave term by term and watch the Gibbs overshoot refuse to die; switch to a triangle and see $1/n^2$ convergence nail it in a handful of terms. Open the lab →

5Harmonics as spinning circles

Using complex exponentials, $f(x)=\sum_n c_n e^{in\pi x/L}$, each term is a vector rotating at frequency $n$. Stack them tip-to-tail and the chain's end traces the signal — the "epicycle" view in the lab. It's the same mathematics behind an FM radio, an MRI, and JPEG compression.

Key takeaways

📄 Further reading

Bjorn Poonen's free MIT 18.03 lecture notes (PDF) cover Fourier series in §26, and §27.2 shows how to solve $x''+x=f(t)$ when the forcing $f(t)$ is itself given as a Fourier series — superpose the periodic solution for each harmonic. Try it live in the Auto-Tuner lab.

EngineeringCandy · Learn · the theory behind the playground