Section 6.2

Fourier Series & Finding the Coefficients

Orthogonality • The Euler–Fourier formulas • Half-range sine and cosine expansions

1. Why This Section Exists

Separation of variables always ends in the same place. You build a family of solutions, superpose them, set $t = 0$, and are left staring at

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

where $f$ is whatever initial temperature or displacement you were given. Two questions have to be answered before that line means anything.

The two questions

Can an arbitrary $f$ really be written as a sum of sines? For a very large class of functions, yes — and this section says exactly which.

How do we find the numbers $C_n$? By a trick so useful it is worth learning on its own: orthogonality.

Where this gets used

Everything here is applied in Section 6.3 (heat equation) and Section 6.5 (wave equation). The boundary conditions decide which kind of series you need: homogeneous Dirichlet conditions call for a sine series, homogeneous Neumann conditions call for a cosine series. That is the whole connection, and it is made precise in Section 4 below.

2. The Fourier Series of a Function

Definition: Fourier Series on $[-L, L]$

For a function $f$ defined on $-L \le x \le L$, its Fourier series is

$$f(x) \;\sim\; \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 constant term is written $a_0/2$ rather than $a_0$ so that one single formula covers every $a_n$, including $n = 0$. It is bookkeeping, nothing more.

The functions $1, \cos(\pi x/L), \sin(\pi x/L), \cos(2\pi x/L), \sin(2\pi x/L), \dots$ all have period $2L$, so the series represents a $2L$-periodic function. Outside $[-L, L]$ it simply repeats what it did inside.

3. Orthogonality: the Engine

Everything rests on the following integrals. They say that distinct members of this family of sines and cosines are orthogonal: multiply two different ones together, integrate over a full period, and the answer is zero.

Orthogonality Relations on $[-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 \ne n \\ L & m = n \ne 0 \\ 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 \ne n \\ L & m = n \end{cases}$$ $$\int_{-L}^{L}\sin\!\left(\frac{m\pi x}{L}\right)\cos\!\left(\frac{n\pi x}{L}\right)dx = 0 \quad\text{for all } m, n$$
The idea in one sentence

To pull one coefficient out of an infinite sum, multiply the whole equation by the matching function and integrate. Every term dies except the one you aimed at. It is the same move as taking a dot product with a basis vector to extract one component — and that is exactly what it is.

Deriving the Coefficient Formulas

Start from the series and multiply both sides by $\cos(m\pi x/L)$, then integrate from $-L$ to $L$:

$$\int_{-L}^{L} f(x)\cos\!\left(\frac{m\pi x}{L}\right)dx = \frac{a_0}{2}\underbrace{\int_{-L}^{L}\cos\!\left(\frac{m\pi x}{L}\right)dx}_{=\,0} + \sum_{n=1}^{\infty} a_n \underbrace{\int_{-L}^{L}\cos\cos}_{=\,L \text{ only if } n = m} + \sum_{n=1}^{\infty} b_n \underbrace{\int_{-L}^{L}\sin\cos}_{=\,0}$$

The entire infinite sum collapses to the single surviving term $a_m L$. Dividing by $L$ gives the formula. Repeating the argument with $\sin(m\pi x/L)$ gives the other one.

The Euler–Fourier Coefficient Formulas $$\boxed{\;a_n = \frac{1}{L}\int_{-L}^{L} f(x)\cos\!\left(\frac{n\pi x}{L}\right)dx, \qquad n = 0, 1, 2, \ldots\;}$$ $$\boxed{\;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\;}$$

With the $a_0/2$ convention, the $n = 0$ case of the first formula gives $a_0 = \frac{1}{L}\int_{-L}^{L} f\,dx$, so the constant term $a_0/2$ is the average value of $f$ over the interval.

Two slips to avoid

The factor is $\dfrac{1}{L}$ for the full series on $[-L, L]$, but $\dfrac{2}{L}$ for the half-range series on $[0, L]$ in Section 4. Mixing them up is the single most common error in this topic.

And the constant term of the series is $a_0/2$, not $a_0$. If you quote $a_0$ as the constant, every answer is out by a factor of two.

4. Even, Odd, and Half-Range Expansions

Symmetry does half the work for you, and it is worth checking before computing a single integral.

If $f$ isthenbecauseExample
Even, $f(-x) = f(x)$all $b_n = 0$: a cosine series$f(x)\sin(\cdot)$ is odd, and an odd function integrates to zero over $[-L,L]$$x^2$, $\cos x$, $|x|$
Odd, $f(-x) = -f(x)$all $a_n = 0$: a sine series$f(x)\cos(\cdot)$ is odd$x$, $x^3$, $\sin x$
Neitherboth families appear—$e^x$, $x + x^2$

Half-Range Expansions

In a PDE problem $f$ is given only on $[0, L]$ — the physical rod or string. Nothing is defined to the left of the origin, so we choose what happens there, and the choice decides which series we get.

Definition: Half-Range Sine and Cosine Series

Given $f$ on $[0, L]$:

Odd extension → a pure sine series, with

$$\boxed{\;b_n = \frac{2}{L}\int_0^L f(x)\sin\!\left(\frac{n\pi x}{L}\right)dx\;}$$

Even extension → a pure cosine series, with

$$\boxed{\;a_n = \frac{2}{L}\int_0^L f(x)\cos\!\left(\frac{n\pi x}{L}\right)dx\;}$$

Both use $\dfrac{2}{L}$ and integrate only over $[0, L]$: the extension is never actually computed, it is just the reason the formula looks like this.

This is the formula Section 6.3 uses

The heat equation with $u(0,t) = u(L,t) = 0$ produces eigenfunctions $\sin(m\pi x/L)$, and its coefficients $C_m = \frac{2}{L}\int_0^L f(x)\sin(m\pi x/L)\,dx$ are exactly the half-range sine coefficients above, with $m$ written in place of $n$. You have been using this section's result already.

Why the boundary conditions choose the series

A sine series vanishes at $x = 0$ and $x = L$ no matter what the coefficients are — so it can only ever represent a Dirichlet problem. A cosine series has zero derivative at both ends, which is precisely the Neumann condition. The eigenfunctions of the boundary value problem are the right basis, and the BCs pick them.

5. Does the Series Actually Converge?

Dirichlet Convergence Theorem

If $f$ is piecewise continuous on $[-L, L]$ and $f'$ is piecewise continuous there, then the Fourier series of $f$ converges at every point $x$ to

$$\frac{f(x^-) + f(x^+)}{2}$$

the average of the left and right limits. At a point where $f$ is continuous this is just $f(x)$; at a jump it is the midpoint of the jump.

The series does not always give you back $f$

Take $f(x) = 1$ on $[0, L]$ and expand it in a half-range sine series. Every term vanishes at $x = 0$, so the series converges to $0$ there, not to $1$.

That is not a mistake — it is the theorem doing its job. The odd extension of $f$ jumps from $-1$ to $+1$ at the origin, and the series returns the midpoint, $0$. In a heat problem this is exactly right: the end of the rod is being held at zero.

Gibbs phenomenon

Near a jump, every partial sum overshoots by about $9\%$ of the jump height, and adding more terms does not reduce the overshoot — it only squeezes it closer to the jump. If your plotted partial sum has little horns beside a discontinuity, nothing has gone wrong.

6. The Procedure

Worked Examples

Example 1: Full Fourier series of $f(x) = x$ on $(-L, L)$ ▼

Step 1 — use symmetry. $f(x) = x$ is odd, so every $a_n = 0$ immediately, including $a_0$. Only sines survive.

Step 2 — set up $b_n$.

$$b_n = \frac{1}{L}\int_{-L}^{L} x\sin\!\left(\frac{n\pi x}{L}\right)dx = \frac{2}{L}\int_{0}^{L} x\sin\!\left(\frac{n\pi x}{L}\right)dx$$

(the integrand is even, so we may double the half-interval integral).

Step 3 — integrate by parts with $u = x$, $dv = \sin(n\pi x/L)\,dx$:

$$\int_0^L x\sin\!\left(\frac{n\pi x}{L}\right)dx = \left[-\frac{Lx}{n\pi}\cos\!\left(\frac{n\pi x}{L}\right)\right]_0^L + \frac{L}{n\pi}\int_0^L \cos\!\left(\frac{n\pi x}{L}\right)dx$$

Step 4 — evaluate. The last integral is zero (a full number of half-periods), and the bracket gives $-\dfrac{L^2}{n\pi}\cos(n\pi)$. Using $\cos(n\pi) = (-1)^n$:

$$b_n = \frac{2}{L}\cdot\left(-\frac{L^2(-1)^n}{n\pi}\right) = \frac{2L(-1)^{n+1}}{n\pi}$$ $$\boxed{\;x \;\sim\; \frac{2L}{\pi}\sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n}\sin\!\left(\frac{n\pi x}{L}\right)\;}$$

Step 5 — check the first two. $b_1 = 2L/\pi$ and $b_2 = -L/\pi$: alternating signs and decaying like $1/n$, which is the signature of a function whose periodic extension has a jump (here at $x = \pm L$).

Example 2: The square wave on $(-\pi, \pi)$ ▼

Let $f(x) = -1$ for $-\pi < x < 0$ and $f(x) = +1$ for $0 < x < \pi$. Here $L = \pi$.

Step 1 — symmetry. $f$ is odd, so all $a_n = 0$.

Step 2 — compute $b_n$, doubling the right half as before:

$$b_n = \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\left(1 - (-1)^n\right)}{n\pi}$$

Step 3 — split odd and even. For even $n$, $1 - (-1)^n = 0$. For odd $n$ it equals $2$:

$$b_n = \begin{cases} \dfrac{4}{n\pi} & n \text{ odd} \\[4pt] 0 & n \text{ even}\end{cases}$$ $$\boxed{\;f(x) \;\sim\; \frac{4}{\pi}\left[\sin x + \frac{\sin 3x}{3} + \frac{\sin 5x}{5} + \cdots\right]\;}$$
A famous by-product. Put $x = \pi/2$, where $f = 1$ and $\sin(n\pi/2)$ runs $1, 0, -1, 0, 1, \dots$ over the odd terms: $$1 = \frac{4}{\pi}\left(1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \cdots\right) \;\Longrightarrow\; \frac{\pi}{4} = 1 - \frac{1}{3} + \frac{1}{5} - \cdots$$ A series for $\pi$, produced as a side effect of expanding a square wave.

At the jump. At $x = 0$ every term is zero, so the series gives $0$ — the midpoint of $-1$ and $+1$, exactly as the convergence theorem promises.

Example 3: Half-range sine series of $f(x) = 1$ on $[0, L]$ ▼

This is the one you need for a rod starting at a uniform temperature with both ends held at zero.

Step 1 — use the half-range formula (note the $2/L$):

$$b_n = \frac{2}{L}\int_0^L 1 \cdot \sin\!\left(\frac{n\pi x}{L}\right)dx = \frac{2}{L}\left[-\frac{L}{n\pi}\cos\!\left(\frac{n\pi x}{L}\right)\right]_0^L$$

Step 2 — evaluate.

$$= \frac{2}{n\pi}\left(1 - \cos n\pi\right) = \frac{2\left(1 - (-1)^n\right)}{n\pi} = \begin{cases} \dfrac{4}{n\pi} & n \text{ odd} \\[4pt] 0 & n \text{ even}\end{cases}$$ $$\boxed{\;1 \;\sim\; \frac{4}{\pi}\sum_{n \text{ odd}}\frac{1}{n}\sin\!\left(\frac{n\pi x}{L}\right) \quad \text{on } (0, L)\;}$$

Step 3 — read the endpoints. At $x = 0$ and $x = L$ the series gives $0$, not $1$. For a rod held at zero at both ends and starting at temperature $1$, that mismatch is the physics: the ends are chilled to zero the instant the clock starts.

Same coefficients as the square wave, and not by accident: the odd extension of $f = 1$ on $[0,L]$ is a square wave.
Example 4: Half-range cosine series of $f(x) = x$ on $[0, L]$ ▼

The cosine series is what an insulated rod (Neumann conditions) needs.

Step 1 — the constant term.

$$a_0 = \frac{2}{L}\int_0^L x\,dx = \frac{2}{L}\cdot\frac{L^2}{2} = L \qquad\Longrightarrow\qquad \frac{a_0}{2} = \frac{L}{2}$$

which is the average value of $x$ on $[0,L]$, as it must be.

Step 2 — the rest, by parts.

$$a_n = \frac{2}{L}\int_0^L x\cos\!\left(\frac{n\pi x}{L}\right)dx = \frac{2}{L}\left\{\left[\frac{Lx}{n\pi}\sin\!\left(\frac{n\pi x}{L}\right)\right]_0^L - \frac{L}{n\pi}\int_0^L \sin\!\left(\frac{n\pi x}{L}\right)dx\right\}$$

Step 3 — the first bracket vanishes because $\sin(n\pi) = 0$. The remaining integral gives

$$a_n = -\frac{2}{n\pi}\left[-\frac{L}{n\pi}\cos\!\left(\frac{n\pi x}{L}\right)\right]_0^L = \frac{2L\left((-1)^n - 1\right)}{n^2\pi^2}$$ $$a_n = \begin{cases} -\dfrac{4L}{n^2\pi^2} & n \text{ odd} \\[4pt] 0 & n \text{ even}\end{cases}$$ $$\boxed{\;x \;\sim\; \frac{L}{2} - \frac{4L}{\pi^2}\sum_{n \text{ odd}}\frac{1}{n^2}\cos\!\left(\frac{n\pi x}{L}\right)\;}$$
Compare with Example 1. The same function $x$, on the same $[0,L]$, has a sine series with coefficients decaying like $1/n$ and a cosine series decaying like $1/n^2$. The cosine series converges faster because its even extension has no jump — it is continuous everywhere. Smoother extension, faster decay: that rule holds throughout the subject.
Example 5: Half-range sine series of $f(x) = x(L - x)$ ▼

This is the parabolic initial profile used in Section 6.3 (with $L = 1$, $f = x(1-x)$).

Step 1 — set up.

$$b_n = \frac{2}{L}\int_0^L \left(Lx - x^2\right)\sin\!\left(\frac{n\pi x}{L}\right)dx$$

Step 2 — integrate by parts twice. The $x^2$ needs two rounds; all the boundary terms containing $\sin(n\pi)$ vanish, and the surviving pieces combine to

$$b_n = \frac{4L^2\left(1 - (-1)^n\right)}{n^3\pi^3} = \begin{cases} \dfrac{8L^2}{n^3\pi^3} & n \text{ odd} \\[4pt] 0 & n \text{ even}\end{cases}$$ $$\boxed{\;x(L-x) \;\sim\; \frac{8L^2}{\pi^3}\sum_{n \text{ odd}}\frac{1}{n^3}\sin\!\left(\frac{n\pi x}{L}\right)\;}$$

Step 3 — sanity check at the midpoint. With $L = 1$ and $x = \tfrac12$ the left side is $\tfrac14$. The right side is $\frac{8}{\pi^3}\left(1 - \frac{1}{27} + \frac{1}{125} - \cdots\right) \approx 0.2500$. ✓

Why only odd harmonics? $x(L-x)$ is symmetric about the midpoint $x = L/2$, and so is every odd harmonic $\sin(n\pi x/L)$; the even ones are antisymmetric there and cannot help. Spotting that symmetry tells you half the coefficients are zero before you integrate.

And the decay. $1/n^3$ — faster than both earlier examples, because this extension is continuous and has a continuous derivative. Three examples, three decay rates, each explained by how smooth the periodic extension is.

📝 Exam-Style Practice Problems

Click each problem to reveal the full solution.

Practice 1: Find the half-range sine series of $f(x) = x$ on $[0, 2]$ ▼

Step 1 — identify. Half-range sine, $L = 2$, so the formula is $b_n = \frac{2}{2}\int_0^2 x\sin\!\left(\frac{n\pi x}{2}\right)dx = \int_0^2 x\sin\!\left(\frac{n\pi x}{2}\right)dx$.

Step 2 — by parts with $u = x$:

$$= \left[-\frac{2x}{n\pi}\cos\!\left(\frac{n\pi x}{2}\right)\right]_0^2 + \frac{2}{n\pi}\int_0^2\cos\!\left(\frac{n\pi x}{2}\right)dx$$

Step 3 — evaluate. The remaining integral is zero, and the bracket gives $-\frac{4}{n\pi}\cos(n\pi)$:

$$b_n = -\frac{4(-1)^n}{n\pi} = \frac{4(-1)^{n+1}}{n\pi}$$ $$\boxed{\;x \;\sim\; \frac{4}{\pi}\sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n}\sin\!\left(\frac{n\pi x}{2}\right)\;}$$

Check against the general result. Example 1 gave $b_n = 2L(-1)^{n+1}/(n\pi)$; putting $L = 2$ gives $4(-1)^{n+1}/(n\pi)$ ✓

Practice 2: Solve the heat problem $u_t = u_{xx}$, $u(0,t) = u(1,t) = 0$, $u(x,0) = x(1-x)$ ▼

This is the whole chapter in one problem: separation gives the shape, this section gives the numbers.

Step 1 — the general solution. From Section 6.3, with $K = 1$ and $L = 1$, Dirichlet conditions give

$$u(x,t) = \sum_{n=1}^{\infty} C_n \sin(n\pi x)\,e^{-n^2\pi^2 t}$$

Step 2 — fit the initial condition. Setting $t = 0$:

$$\sum_{n=1}^{\infty} C_n\sin(n\pi x) = x(1-x)$$

so the $C_n$ are the half-range sine coefficients of $x(1-x)$ — Example 5 with $L = 1$:

$$C_n = \frac{4\left(1 - (-1)^n\right)}{n^3\pi^3} = \begin{cases} \dfrac{8}{n^3\pi^3} & n \text{ odd} \\[4pt] 0 & n \text{ even}\end{cases}$$

Step 3 — assemble.

$$\boxed{\;u(x,t) = \frac{8}{\pi^3}\sum_{n \text{ odd}}\frac{1}{n^3}\sin(n\pi x)\,e^{-n^2\pi^2 t}\;}$$
Read the answer. At $t = 0$ all the harmonics are present. As $t$ grows, the $n = 3$ term decays like $e^{-9\pi^2 t}$ against $e^{-\pi^2 t}$ for $n = 1$ — nine times faster in the exponent. Very quickly only the first harmonic is left, and the temperature profile becomes a simple arch regardless of how complicated it started. Heat smooths everything.
Practice 3: Without integrating, write down the series for $f(x) = 5\sin(2\pi x) - 3\sin(7\pi x)$ on $[0,1]$ ▼

Step 1 — recognise the form. With $L = 1$ the half-range sine basis is $\sin(n\pi x)$, and $f$ is already written in exactly that basis.

Step 2 — match. The $n = 2$ term has coefficient $5$, the $n = 7$ term has $-3$, and every other coefficient is zero.

$$\boxed{\;b_2 = 5, \quad b_7 = -3, \quad b_n = 0 \text{ otherwise}\;}$$

Step 3 — why this is legitimate. Fourier coefficients are unique, so a function that is already a finite sine sum is its own Fourier series. Computing $\frac{2}{1}\int_0^1 f(x)\sin(n\pi x)dx$ would give the same answer after a page of orthogonality arguments — all of which just reproduce the matching.

But check the basis first. This shortcut works only when the function is written in the eigenfunctions of your problem. On $[0,1]$ with Dirichlet conditions, $\sin(2\pi x)$ is a basis function; $\sin(2x)$ is not, and that one would need the integral.

Check Your Understanding

Q1: In the Fourier series $\frac{a_0}{2} + \sum\left[a_n\cos + b_n\sin\right]$ on $[-L, L]$, the coefficient $a_n$ is

Q2: If $f$ is an odd function on $[-L, L]$, then

Q3: The half-range sine coefficients of $f$ on $[0, L]$ are

Q4: At a jump discontinuity, the Fourier series of $f$ converges to

Q5: Which initial condition needs no integration to find its coefficients on $[0,1]$?

Q6: The half-range sine series of $f(x) = 1$ on $[0, L]$ converges at $x = 0$ to