Calculus · Infinite series
A Taylor series builds a function out of powers of \(x\). A Fourier series builds it out of sines and cosines, and that works even for functions with corners and jumps, where Taylor series fail completely. This post explains when a function has a Fourier series, how to compute it, and how it leads to surprising results like \( 1 + \frac14 + \frac19 + \cdots = \frac{\pi^2}{6} \).
A musical note from a violin and the same note from a flute have the same pitch but sound different. The reason: each instrument produces a fundamental wave plus a different mix of overtones, waves vibrating 2, 3, 4, ... times faster. Fourier's insight was that this works for almost any periodic shape: it can be written as a sum of sines and cosines with frequencies \(1, 2, 3, \dots\) times a basic frequency.
For a function on the interval \((-l, l)\), the building blocks are
\[ 1, \quad \cos\frac{\pi x}{l},\ \sin\frac{\pi x}{l}, \quad \cos\frac{2\pi x}{l},\ \sin\frac{2\pi x}{l}, \quad \dots \]all of which repeat with period \(2l\). The question is how much of each one to take.
Compared with Taylor series, Fourier series have a big advantage: a Taylor series needs a function that is infinitely differentiable and is built from information at a single point. A Fourier series uses information from the whole interval and needs very little smoothness. Even a function with jumps can be represented.
In plain terms: the graph is made of finitely many smooth-ish, monotone pieces, possibly with finitely many jumps between them. Step functions, sawtooth waves, \(|x|\), \(x^2\) and every polynomial qualify. What does not qualify is a function that oscillates infinitely often, such as \( \sin\frac1x \) near \(0\) (it is bounded, but has infinitely many maxima and minima), or one that blows up, like \( \frac1x \).
How to read the condition. At a point where \(f\) is continuous, \(f(x - 0) = f(x + 0) = f(x)\), so the condition holds automatically and the series equals \(f(x)\). At a jump, the series always converges to the average of the left and right limits, the midpoint of the jump. So, more precisely:
\[ \frac{a_0}{2} + \sum_{n=1}^\infty\Big(a_n\cos\frac{n\pi x}{l} + b_n\sin\frac{n\pi x}{l}\Big) = \frac12\big[f(x - 0) + f(x + 0)\big] \quad \text{for every } x \in (-l, l). \]What happens outside \((-l, l)\)? The series is periodic with period \(2l\), so outside the interval it repeats the function: it represents the periodic extension of \(f\). In particular, at the endpoints \(x = \pm l\) it converges to \( \frac12\big[f(-l + 0) + f(l - 0)\big] \), because the end of one period meets the start of the next there.
Why \(\frac{a_0}{2}\) and not \(a_0\)? Writing half of \(a_0\) lets one formula (2) serve for all \(n\), including \(n = 0\). Note that \( \frac{a_0}{2} = \frac{1}{2l}\int_{-l}^{l} f\,dx \) is simply the average value of \(f\) on the interval, the "constant offset" of the wave.
The formulas (2) follow from one beautiful property of sines and cosines, called orthogonality. For natural numbers \(m, n\):
\[ \int_{-l}^{l}\cos\frac{m\pi x}{l}\cos\frac{n\pi x}{l}\,dx = \int_{-l}^{l}\sin\frac{m\pi x}{l}\sin\frac{n\pi x}{l}\,dx = \begin{cases} 0, & m \ne n,\\ l, & m = n, \end{cases} \qquad \int_{-l}^{l}\cos\frac{m\pi x}{l}\sin\frac{n\pi x}{l}\,dx = 0. \](Each follows from the product-to-sum formulas: the integrand becomes a sum of cosines or sines that integrate to zero over a whole number of periods.)
Now take (1), multiply both sides by \( \cos\frac{m\pi x}{l} \), and integrate over \((-l, l)\), term by term. Every integral on the right vanishes except the one with \(n = m\), which equals \(a_m\cdot l\). So
\[ \int_{-l}^{l} f(x)\cos\frac{m\pi x}{l}\,dx = a_m\,l, \]which is exactly the formula for \(a_m\). Multiplying by \( \sin\frac{m\pi x}{l} \) gives \(b_m\) the same way.
The intuition: the waves behave like perpendicular axes in space. To find the \(x\)-coordinate of a vector you take a dot product with \(\vec i\); to find "how much of \( \cos\frac{m\pi x}{l} \)" is in \(f\), you take the integral of \(f\) times that wave. The integral plays the role of the dot product from the post on vectors.
Symmetry halves the work. Recall: the integral of an odd function over \((-l, l)\) is zero, and the integral of an even function is twice the integral over \((0, l)\).
This makes sense: cosines are even and sines are odd, so an even function can only be built from cosines (and a constant), and an odd function only from sines. Check the symmetry first, every time; it saves half the integrals.
In the examples we take \(l = \pi\), so the waves are simply \(\cos nx\) and \(\sin nx\).
In applications (a vibrating string, heat in a rod), the function is often given only on \((0, l)\). We may then extend it to \((-l, 0)\) however we like, and the most convenient choices are:
Both series represent the same \(f\) on \((0, l)\); they differ only on \((-l, 0)\) and at the endpoints. This mirrors exactly what we did with the Fourier integral on a half-line in an earlier post.
This is remarkable. In the post on series of functions, integrating term by term required uniform convergence. Fourier series are much better behaved: integration only makes the coefficients smaller (it divides them by \(n\)), so the integrated series converges whatever the original series does. Differentiation is the dangerous operation: it multiplies the coefficients by \(n\), and in general may not be done term by term.
| Case | Series | Coefficients |
|---|---|---|
| General, on \((-l, l)\) | \( \frac{a_0}{2} + \sum\big(a_n\cos\frac{n\pi x}{l} + b_n\sin\frac{n\pi x}{l}\big) \) | \( a_n = \frac1l\int_{-l}^l f\cos\frac{n\pi x}{l}dx,\ \ b_n = \frac1l\int_{-l}^l f\sin\frac{n\pi x}{l}dx \) |
| Even \(f\) | \( \frac{a_0}{2} + \sum a_n\cos\frac{n\pi x}{l} \) | \( a_n = \frac2l\int_0^l f\cos\frac{n\pi x}{l}dx \) |
| Odd \(f\) | \( \sum b_n\sin\frac{n\pi x}{l} \) | \( b_n = \frac2l\int_0^l f\sin\frac{n\pi x}{l}dx \) |
| \(f\) on \((0, l)\) | cosine series (even ext.) or sine series (odd ext.) | formulas for even / odd \(f\) |
Convergence: under the Dirichlet conditions, the series converges at every point to \( \frac12[f(x - 0) + f(x + 0)] \): to \(f(x)\) where \(f\) is continuous, to the midpoint at jumps, and to the periodic extension outside the interval. Integration term by term is always allowed for integrable \(f\).
| Standard series (\(l = \pi\)) | Famous value obtained |
|---|---|
| square wave \(= \frac4\pi\sum\frac{\sin(2k-1)x}{2k-1}\) | \( 1 - \frac13 + \frac15 - \cdots = \frac\pi4 \) |
| \( x^2 = \frac{\pi^2}{3} + 4\sum\frac{(-1)^n\cos nx}{n^2} \) | \( \sum\frac{1}{n^2} = \frac{\pi^2}{6} \), \( \sum\frac{(-1)^{n+1}}{n^2} = \frac{\pi^2}{12} \) |
| \( |x| = \frac\pi2 - \frac4\pi\sum\frac{\cos(2k-1)x}{(2k-1)^2} \) | \( \sum\frac{1}{(2k-1)^2} = \frac{\pi^2}{8} \) |
Try each one before opening the solution. More solved problems from this topic are in Series.
Here \(l = 1\) and \(f\) is odd: \( b_n = 2\int_0^1 x\sin n\pi x\,dx = \frac{2(-1)^{n+1}}{n\pi} \). So \( x = \frac2\pi\sum_{n=1}^\infty\frac{(-1)^{n+1}\sin n\pi x}{n} \) for \(-1 < x < 1\).
\( a_0 = \frac1\pi\int_0^\pi dx = 1 \), \( a_n = \frac1\pi\int_0^\pi\cos nx\,dx = 0 \), \( b_n = \frac1\pi\int_0^\pi\sin nx\,dx = \frac{1 - (-1)^n}{\pi n} \). So \( f(x) = \frac12 + \frac2\pi\sum_{k=1}^\infty\frac{\sin(2k-1)x}{2k-1} \). (It is the square wave of Example 1, halved and shifted up by \(\frac12\).)
For \(x\): to \( \frac12[f(-\pi + 0) + f(\pi - 0)] = \frac12(-\pi + \pi) = 0 \). For \(x^2\): the periodic extension is continuous at \(\pi\), so to \(\pi^2\).
\( 0 = \frac{\pi^2}{3} + 4\sum\frac{(-1)^n}{n^2} \Rightarrow \sum\frac{(-1)^{n+1}}{n^2} = \frac{\pi^2}{12} \).
Odd extension gives the square wave: \( 1 = \frac4\pi\sum_{k=1}^\infty\frac{\sin(2k-1)x}{2k-1} \) for \(0 < x < \pi\). (The cosine series of \(1\) is just \(1\) itself.)
Put \(x = \pi - t\) in Example 2 (\(t \in (0, 2\pi)\) means \(x \in (-\pi, \pi)\)): \( \pi - t = 2\sum\frac{(-1)^{n+1}\sin n(\pi - t)}{n} \). Since \( \sin n(\pi - t) = (-1)^{n+1}\sin nt \), this becomes \( \pi - t = 2\sum_{n=1}^\infty\frac{\sin nt}{n} \), i.e. \( \sum\frac{\sin nt}{n} = \frac{\pi - t}{2} \) on \((0, 2\pi)\), the formula quoted in the post on series of functions.
No. It is bounded and has only one point of discontinuity, but near \(x = 0\) it has infinitely many maxima and minima, violating condition 3.
Fourier series split a function into its "notes": a constant average plus waves of frequencies \(1, 2, 3, \dots\). Two habits make the computations easy: check symmetry first (even means cosines only, odd means sines only), and remember the midpoint rule at jumps. Beyond computation, Fourier series are one of the great ideas of mathematics: they are how we solve the heat and wave equations, how audio is compressed, and, as Examples 3 and 4 show, a surprisingly powerful way to sum numerical series.
Next in the series: infinite products. See also the Fourier integral, which extends these ideas to non-periodic functions, and series of functions, which explains the convergence behaviour seen here.