Skip to content

Fourier series, explained

6 min read

Short answer

A periodic function on [−π,π][-\pi,\pi] can be written as f(x)=a02+∑n≥1(ancos⁡nx+bnsin⁡nx)f(x)=\dfrac{a_0}{2}+\sum_{n\ge1}\big(a_n\cos nx+b_n\sin nx\big) with an=1π∫−ππf(x)cos⁡nx dxa_n=\dfrac1\pi\int_{-\pi}^{\pi}f(x)\cos nx\,dx and bn=1π∫−ππf(x)sin⁡nx dxb_n=\dfrac1\pi\int_{-\pi}^{\pi}f(x)\sin nx\,dx. Each coefficient measures how much of that frequency ff contains.

Bar chartn=1n=2n=3n=4n=5Sine coefficients |bₙ| = 2/n for f(x) = x.
Low frequencies carry most of the shape; coefficients fall off like 1/n.

Why the formulas work

Sines and cosines of different frequencies are orthogonal: ∫−ππsin⁡mxsin⁡nx dx=0\int_{-\pi}^{\pi}\sin mx\sin nx\,dx=0 for m≠nm\ne n and equals π\pi for m=nm=n. Multiply the series by sin⁡nx\sin nx and integrate: every term vanishes except the bnb_n term, leaving πbn\pi b_n. It is projection onto a basis, as in linear algebra.

Even and odd shortcuts

If ff is odd, all an=0a_n=0 (only sines). If ff is even, all bn=0b_n=0 (only cosines). Checking this first halves the work.

Worked example

Find the Fourier series of f(x)=xf(x)=x on (−π,π)(-\pi,\pi).

ff is odd, so an=0a_n=0. bn=1π∫−ππxsin⁡nx dx=2(−1)n+1nb_n=\dfrac1\pi\int_{-\pi}^{\pi}x\sin nx\,dx=\dfrac{2(-1)^{n+1}}{n} (integration by parts). So x=2(sin⁡x−sin⁡2x2+sin⁡3x3−⋯ )x=2\left(\sin x-\dfrac{\sin2x}2+\dfrac{\sin3x}3-\cdots\right). Check at x=π2x=\tfrac\pi2: 2(1−13+15−⋯ )=2⋅π4=π22\left(1-\tfrac13+\tfrac15-\cdots\right)=2\cdot\tfrac\pi4=\tfrac\pi2. ✓

Try it yourself

Without computing, which coefficients vanish for f(x)=x2f(x)=x^2 on (−π,π)(-\pi,\pi)?

Show the answer

x2x^2 is even, so every bn=0b_n=0 and the series contains only a constant and cosine terms.

Keep going with practice

Vidi's linear algebra lessons explain this as an orthogonal projection onto a basis of sines and cosines.