Diff. EquationsFourier Series and PDEs

Fourier Series

Write a periodic function as a sum of sines and cosines.

Not started Jump to practice

Taylor series build a function from powers of $x$. Fourier series build a periodic function from sines and cosines, the eigenfunctions of the previous lesson. They describe sound, heat and signals, and they solve the heat and wave equations. Computing coefficients uses integration by parts again and again.

Key idea

For $f$ with period $2L$, $$f(x) \sim \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),$$ $$a_n = \frac{1}{L}\int_{-L}^{L} f(x)\cos\frac{n\pi x}{L}\,dx,$$ $$b_n = \frac{1}{L}\int_{-L}^{L} f(x)\sin\frac{n\pi x}{L}\,dx.$$ Here $L$ is half the period. If $f$ is odd, every $a_n = 0$; if $f$ is even, every $b_n = 0$. At a jump, the series converges to the average of the two one-sided values.

Why it works

The building blocks are orthogonal on $[-L, L]$. Using $\cos A\cos B$ $= \frac{1}{2}\left(\cos(A - B) + \cos(A + B)\right)$, the integral $\int_{-L}^{L} \cos\frac{m\pi x}{L}\cos\frac{n\pi x}{L}\,dx$ is a sum of cosines over whole periods, so it is 0 when $m \ne n$ and $L$ when $m = n \ge 1$. The same holds for sines, and every sine-cosine product integrates to 0. Now multiply the series by $\cos\frac{m\pi x}{L}$ and integrate: every term dies except $a_m\cdot L$, which gives the formula for $a_m$. For $n = 0$, $\int_{-L}^{L} 1\,dx = 2L$, which is why the constant term is written $\frac{a_0}{2}$: then one formula covers every $a_n$.

Worked example: A square wave

Find the Fourier series of $f = -1$ on $(-\pi, 0)$ and $f = 1$ on $(0, \pi)$, period $2\pi$.
  1. $f$ is odd, so $a_n = 0$. Here $L = \pi$.
  2. $b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f\sin nx\,dx$ $= \frac{2}{\pi}\int_0^{\pi} \sin nx\,dx$ $= \frac{2}{n\pi}(1 - \cos n\pi)$.
  3. $\cos n\pi = (-1)^{n}$: $b_n = \frac{4}{n\pi}$ for odd $n$ and 0 for even $n$.

Answer: $f(x) \sim \frac{4}{\pi}\left(\sin x + \frac{\sin 3x}{3} + \frac{\sin 5x}{5} + \dots\right)$

Worked example: A sawtooth

Find $b_n$ for $f(x) = x$ on $(-1, 1)$, period 2.
  1. $L = 1$ and $f$ is odd, so $b_n = 2\int_0^{1} x\sin n\pi x\,dx$.
  2. By parts: $\int_0^{1} x\sin n\pi x\,dx$ $= \left[-\frac{x\cos n\pi x}{n\pi}\right]_0^{1}$ $+ \frac{1}{n\pi}\int_0^{1}\cos n\pi x\,dx$ $= -\frac{(-1)^{n}}{n\pi} + 0$.

Answer: $b_n = \frac{2(-1)^{n+1}}{n\pi}$

Worked example: An even function

Find the series of $f(x) = x^{2}$ on $(-\pi, \pi)$.
  1. $f$ is even: $b_n = 0$. $a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi} x^{2}\,dx = \frac{2\pi^{2}}{3}$, so $\frac{a_0}{2} = \frac{\pi^{2}}{3}$.
  2. Integrating by parts twice, $a_n = \frac{2}{\pi}\int_0^{\pi} x^{2}\cos nx\,dx$ $= \frac{4(-1)^{n}}{n^{2}}$.

Answer: $x^{2} \sim \frac{\pi^{2}}{3} - 4\cos x + \cos 2x$ $- \frac{4}{9}\cos 3x + \dots$; at $x = \pi$ this gives $\sum \frac{1}{n^{2}} = \frac{\pi^{2}}{6}$

Common mistake

Using the wrong interval length. $L$ is half the period: for period $2\pi$, $L = \pi$, and for period 6, $L = 3$. The factor in front is $\frac{1}{L}$ (or $\frac{2}{L}$ over half the interval for odd or even functions), and the same $L$ appears inside $\frac{n\pi x}{L}$. Using $\frac{1}{2L}$, or $\frac{1}{\pi}$ when the period is not $2\pi$, scales every coefficient wrongly.
Partial sums of the square wave's series. Add terms: the sum hugs the square wave more closely, passes through the midpoint 0 at each jump, and keeps a small overshoot right next to each jump (the Gibbs phenomenon, about 9% of the jump).
The square wave's series at $x = \frac{\pi}{2}$, where $\sin nx$ is $1, 0, -1, 0, \dots$: the terms are $\frac{4}{\pi}\left(1 - \frac{1}{3} + \frac{1}{5} - \dots\right)$, and the partial sums settle on $f\left(\frac{\pi}{2}\right) = 1$.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 3 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • Paul's Online Math Notes, Differential Equations: Fourier Series
  • Paul's Online Math Notes, Differential Equations: Convergence of Fourier Series
  • MIT OpenCourseWare 18.03SC Differential Equations (Fall 2011), Unit III: Fourier Series and Laplace Transform
@teddyrookbook GitHub