45  Fourier series

Every periodic signal is a sum of pure frequencies

The Fourier series starts from a single observation: the simplest periodic functions are sines and cosines. They oscillate at a fixed frequency, they never change shape, and their behaviour is completely described by amplitude and phase. Every other periodic function — however jagged, however asymmetric — can be built from them by superposition. The question is: how do you find the right mix?

The answer is integration. Multiply the function by each candidate sine or cosine and integrate over one period. The result, as we will show, is exactly the amplitude of that frequency component. Everything else cancels out.


45.1 Periodic functions

A function \(f\) is periodic with period \(T\) if \(f(x + T) = f(x)\) for all \(x\). The smallest such \(T > 0\) is called the fundamental period.

We write \(T = 2L\), which places one full period over the interval \([-L, L]\). This notation is standard in engineering texts and makes the coefficient formulas symmetric.

Familiar examples: \(\sin(nx)\) and \(\cos(nx)\) have period \(2\pi/n\); the square wave (defined below) has the same period as the fundamental sine used to construct it.

The idea geometrically. A periodic function is completely determined by its values on any interval of length \(T\). Knowing one period is knowing everything. The Fourier series asks: which sum of sines and cosines, with the same period, most accurately represents \(f\)?


45.2 The Fourier series

For a function \(f\) of period \(2L\), the Fourier series is:

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

The Fourier coefficients are:

\[a_0 = \frac{1}{L}\int_{-L}^{L} f(x)\,dx\]

\[a_n = \frac{1}{L}\int_{-L}^{L} f(x)\cos\!\left(\frac{n\pi x}{L}\right)dx \qquad (n = 1, 2, 3, \ldots)\]

\[b_n = \frac{1}{L}\int_{-L}^{L} f(x)\sin\!\left(\frac{n\pi x}{L}\right)dx \qquad (n = 1, 2, 3, \ldots)\]

The term \(a_0/2\) is the mean value of \(f\) over one period. The \(a_n\) terms give the amplitudes of the cosine components; the \(b_n\) terms give the amplitudes of the sine components.

45.2.1 Why these formulas: orthogonality

The formulas above are not guessed — they follow from a single property of the trigonometric functions: orthogonality.

Over the interval \([-L, L]\):

\[\int_{-L}^{L}\cos\!\left(\frac{m\pi x}{L}\right)\cos\!\left(\frac{n\pi x}{L}\right)dx = \begin{cases} 0 & m \neq n \\ L & m = n \geq 1 \\ 2L & m = n = 0 \end{cases}\]

\[\int_{-L}^{L}\sin\!\left(\frac{m\pi x}{L}\right)\sin\!\left(\frac{n\pi x}{L}\right)dx = \begin{cases} 0 & m \neq n \\ L & m = n \geq 1 \end{cases}\]

\[\int_{-L}^{L}\cos\!\left(\frac{m\pi x}{L}\right)\sin\!\left(\frac{n\pi x}{L}\right)dx = 0 \qquad \text{for all } m, n\]

These follow from the product-to-sum identities. Take the \(m \neq n\) case of the cosine integral as an example: the identity \(\cos A \cos B = \tfrac{1}{2}[\cos(A-B)+\cos(A+B)]\) turns the product into a sum of two cosines at frequencies \((m-n)\pi/L\) and \((m+n)\pi/L\). Integrating either of those over exactly one complete period gives zero — the positive and negative half-cycles cancel. When \(m = n\) the first term becomes \(\cos(0) = 1\), which integrates to \(2L\), accounting for the factor of \(L\) in the diagonal case. The sine-sine and cosine-sine cases follow by the same argument with the analogous identities.

They mean that multiplying the Fourier series by \(\cos(m\pi x/L)\) and integrating over \([-L, L]\) kills every term except the one with \(n = m\) — which is exactly how \(a_m\) is isolated.

Think of the trigonometric functions as a set of directions in function space that are pairwise perpendicular. The Fourier coefficients are the projections of \(f\) onto those directions.


45.3 Worked example: the square wave

Define the square wave with period \(2\pi\) as:

\[f(x) = \begin{cases} 1 & 0 < x < \pi \\ -1 & -\pi < x < 0 \end{cases}\]

extended periodically to all \(x\).

Step 1: compute \(a_0\).

\[a_0 = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\,dx = \frac{1}{\pi}\left[\int_{-\pi}^{0}(-1)\,dx + \int_{0}^{\pi}(1)\,dx\right] = \frac{1}{\pi}[-\pi + \pi] = 0\]

The mean value is zero — the positive and negative halves cancel.

Step 2: compute \(a_n\).

\(f(x)\) is an odd function: \(f(-x) = -f(x)\). The cosines \(\cos(nx)\) are even functions. An odd function times an even function is odd, and the integral of an odd function over a symmetric interval is zero:

\[a_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\cos(nx)\,dx = 0 \quad \text{for all } n \geq 1\]

Step 3: compute \(b_n\).

\(\sin(nx)\) is odd; \(f\) is odd; their product is even:

\[b_n = \frac{1}{\pi}\int_{-\pi}^{\pi} f(x)\sin(nx)\,dx = \frac{2}{\pi}\int_{0}^{\pi}\sin(nx)\,dx\]

\[= \frac{2}{\pi}\left[-\frac{\cos(nx)}{n}\right]_{0}^{\pi} = \frac{2}{n\pi}\left[1 - \cos(n\pi)\right] = \frac{2}{n\pi}\left[1 - (-1)^n\right]\]

Here \(\cos(n\pi) = (-1)^n\) for any integer \(n\): the cosine alternates between \(-1\) and \(1\) at multiples of \(\pi\). When \(n\) is even, \(\cos(n\pi) = 1\), so \(b_n = 0\). When \(n\) is odd, \(\cos(n\pi) = -1\), so \(b_n = 4/(n\pi)\).

Result:

\[f(x) = \frac{4}{\pi}\left[\sin(x) + \frac{\sin(3x)}{3} + \frac{\sin(5x)}{5} + \frac{\sin(7x)}{7} + \cdots\right]\]

The partial sums progressively sharpen toward the square wave, with the edges becoming steeper as more terms are included.


45.4 Convergence and the Gibbs phenomenon

The Fourier series of a well-behaved periodic function converges in the following sense.

Dirichlet conditions. If \(f\) is periodic, bounded, and piecewise continuous (at most finitely many jump discontinuities per period, and finitely many maxima and minima per period), then:

  • At points where \(f\) is continuous, the Fourier series converges to \(f(x)\).
  • At a jump discontinuity \(x_0\), the Fourier series converges to the average of the left and right limits: \(\frac{1}{2}\left[f(x_0^-) + f(x_0^+)\right]\).

Gibbs phenomenon. Near a jump discontinuity, the partial sums overshoot the true value by approximately \(8.9\%\) of the jump height, regardless of how many terms are included. Adding more terms moves the overshoot closer to the discontinuity but does not reduce its size. This is not an error in the method — it is a fundamental property of Fourier partial sums near discontinuities. It appears in real systems as ringing — the ripple artefact you see in a sharply filtered audio signal or a steeply edge-enhanced image.

For the square wave with a jump of magnitude 2, the Gibbs overshoot is approximately \(2 \times 0.089 \approx 0.18\).


45.5 Even and odd functions

Identifying the symmetry of \(f\) before computing is practical, not just elegant: it cuts the integration work in half.

Even function (\(f(-x) = f(x)\), symmetric about the \(y\)-axis): odd-function integrands vanish, so \(b_n = 0\) for all \(n\). The Fourier series is a cosine series:

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

Odd function (\(f(-x) = -f(x)\), antisymmetric about the \(y\)-axis): even-function integrands vanish, so \(a_n = 0\) for all \(n\). The Fourier series is a sine series:

\[f(x) = \sum_{n=1}^{\infty} b_n\sin\!\left(\frac{n\pi x}{L}\right)\]

The square wave example above was odd, which is why we only needed to compute \(b_n\).


45.6 Half-range series

Often \(f\) is defined only on \([0, L]\) — for example, the initial temperature profile in a rod. We cannot compute a full Fourier series without knowing \(f\) on \([-L, 0]\), but we can choose how to extend it:

  • Even extension: define \(f(-x) = f(x)\) on \([-L, 0]\). This produces a Fourier cosine series with only \(a_n\) terms: \[f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n\cos\!\left(\frac{n\pi x}{L}\right), \quad a_n = \frac{2}{L}\int_0^L f(x)\cos\!\left(\frac{n\pi x}{L}\right)dx\]

  • Odd extension: define \(f(-x) = -f(x)\) on \([-L, 0]\). This produces a Fourier sine series with only \(b_n\) terms: \[f(x) = \sum_{n=1}^{\infty} b_n\sin\!\left(\frac{n\pi x}{L}\right), \quad b_n = \frac{2}{L}\int_0^L f(x)\sin\!\left(\frac{n\pi x}{L}\right)dx\]

Which to choose? The boundary conditions of the physical problem decide: if \(f(0) = f(L) = 0\) is required (as in a fixed-end vibrating string or a rod with fixed-temperature endpoints), use the sine extension. If the derivative \(f'(0) = f'(L) = 0\) is required (insulated endpoints), use the cosine extension.


45.7 Complex Fourier series

Using Euler’s formula \(e^{i\theta} = \cos\theta + i\sin\theta\), the Fourier series can be written in complex exponential form:

\[f(x) = \sum_{n=-\infty}^{\infty} c_n\,e^{in\pi x/L}\]

where the complex Fourier coefficients are:

\[c_n = \frac{1}{2L}\int_{-L}^{L} f(x)\,e^{-in\pi x/L}\,dx\]

The relationship to the real coefficients: \(c_0 = a_0/2\), \(c_n = (a_n - ib_n)/2\), \(c_{-n} = (a_n + ib_n)/2 = \overline{c_n}\) for \(n \geq 1\).

The complex form is more compact and connects directly to the Fourier transform: letting \(L \to \infty\) (so the period grows without bound) turns the discrete sum into an integral — the subject of the next chapter.


45.8 Parseval’s theorem

The total energy of a periodic signal is distributed across its frequency components. Parseval’s theorem makes this precise:

\[\frac{1}{L}\int_{-L}^{L}|f(x)|^2\,dx = \frac{a_0^2}{2} + \sum_{n=1}^{\infty}(a_n^2 + b_n^2)\]

In the complex form: \(\frac{1}{2L}\int_{-L}^{L}|f|^2\,dx = \sum_{n=-\infty}^{\infty}|c_n|^2\).

The right side is the sum of squared amplitudes of each Fourier mode — the power spectrum. Parseval’s theorem says that power is conserved: the total power in the time domain equals the total power in the frequency domain. It also provides a shortcut for evaluating certain series (see Exercise 5).


45.9 Applications

45.9.1 Signal analysis and filtering

A microphone converts a sound wave into a voltage signal \(f(t)\). To apply an equaliser (boost bass, cut treble), you compute the Fourier coefficients, multiply each \(b_n\) by the desired gain at frequency \(n\), and reconstruct. In practice this is done with the Fast Fourier Transform (FFT), which computes all \(N\) Fourier coefficients in \(O(N \log N)\) operations instead of \(O(N^2)\).

The Fast Fourier Transform (FFT) is an algorithm that computes all \(N\) discrete Fourier coefficients in \(O(N \log N)\) arithmetic operations rather than the \(O(N^2)\) operations needed by direct summation. For \(N = 1024\) this is roughly a hundredfold speedup; for \(N = 10^6\) the gap is enormous. The FFT is what makes real-time frequency analysis practical — a direct calculation would be too slow for audio, video, and communications applications.

45.9.2 Heat equation initial conditions

The heat equation on a rod of length \(L\) with zero-temperature endpoints:

\[\frac{\partial u}{\partial t} = \alpha^2\frac{\partial^2 u}{\partial x^2}, \qquad u(0,t) = u(L,t) = 0\]

has general solution \(u(x,t) = \sum_{n=1}^{\infty} B_n\sin(n\pi x/L)\,e^{-\alpha^2 n^2\pi^2 t/L^2}\).

The coefficients \(B_n\) are exactly the Fourier sine coefficients of the initial temperature profile \(u(x,0) = f(x)\). Higher-frequency modes (large \(n\)) decay exponentially faster — this is why sharp temperature gradients smooth out quickly while broad gradients persist. The Fourier series is not just a tool for computing the answer: it explains the physics.


45.10 Exercises


45.10.1 Exercise 1: Fourier coefficients of the square wave

Compute all Fourier coefficients for \(f(x) = 1\) for \(0 < x < \pi\) and \(f(x) = -1\) for \(-\pi < x < 0\), period \(2\pi\). Write out the first four nonzero terms of the series.


45.10.2 Exercise 2: Sawtooth wave Fourier coefficients

The function \(f(x) = x\) for \(-\pi < x < \pi\), extended with period \(2\pi\), is the sawtooth wave. Compute its Fourier series.


45.10.3 Exercise 3: Half-range cosine series for \(f(x) = x\)

Find the half-range Fourier cosine series of \(f(x) = x\) on \(0 < x < \pi\).


45.10.4 Exercise 4: Half-range sine series for \(f(x) = 1\)

Find the half-range Fourier sine series of \(f(x) = 1\) on \(0 < x < L\). Interpret the result.


45.10.5 Exercise 5: Parseval’s theorem and a series sum

Apply Parseval’s theorem to the square wave result from Exercise 1 to evaluate \(\displaystyle\sum_{k=0}^{\infty}\frac{1}{(2k+1)^2}\).


45.10.6 Exercise 6: Heat equation — reading off the solution from a Fourier series

A rod of length \(L = \pi\) has initial temperature \(u(x,0) = 3\sin(x) - \sin(2x)\) for \(0 < x < \pi\). The endpoints are held at zero: \(u(0,t) = u(\pi,t) = 0\). The heat equation is \(u_t = \alpha^2 u_{xx}\).

Write down the complete solution \(u(x,t)\) and identify which component decays faster.