Heat Equation & Separation of Variables
Full step-by-step derivation • Three-case eigenvalue analysis • Fourier sine series
1. Setting Up the Heat Equation
Consider a thin, laterally insulated wire of length $L$ placed along the $x$-axis from $x = 0$ to $x = L$. Let $u(x,t)$ denote the temperature at position $x$ at time $t$. The heat equation is:
$$\frac{\partial u}{\partial t} = K\,\frac{\partial^2 u}{\partial x^2}, \qquad 0 < x < L,\quad t > 0$$where $K > 0$ is the thermal diffusivity of the material (a positive constant).
Initial and Boundary Conditions
To pin down a unique solution, the heat equation must be accompanied by:
• One initial condition (temperature at $t = 0$): $$u(x,0) = f(x), \qquad 0 < x < L$$
• Two boundary conditions (one at each end of the wire). The possibilities are:
(a) Homogeneous Dirichlet: $u(0,t) = 0$ and $u(L,t) = 0$ — both ends held at zero temperature.
(b) Non-homogeneous Dirichlet: $u(0,t) = T_1$, $u(L,t) = T_2$ — prescribed (non-zero) temperatures.
(c) Neumann: $u_x(0,t) = 0$, $u_x(L,t) = 0$ — insulated ends (no heat flux).
This page focuses on the simplest case: homogeneous Dirichlet boundary conditions. Once you understand this case completely, the others (covered in Section 6.3) follow the same logic with minor variations.
2. The Separation of Variables Idea
Assume the solution can be written as a product of two single-variable functions:
$$u(x,t) = P(x)\,Q(t)$$where $P(x)$ depends only on $x$ and $Q(t)$ depends only on $t$.
This ansatz is bold: we are assuming the space and time parts "separate". Remarkably, for linear PDEs like the heat equation, it works — and gives us infinitely many such solutions, which we can combine to satisfy arbitrary initial data.
Substituting into the Heat Equation
Compute the derivatives:
$$\frac{\partial u}{\partial t} = P(x)\,Q'(t), \qquad \frac{\partial^2 u}{\partial x^2} = P''(x)\,Q(t).$$Substituting both into $u_t = K u_{xx}$:
$$P(x)\,Q'(t) = K\,P''(x)\,Q(t).$$Divide both sides by $K\,P(x)\,Q(t)$ (assuming neither is zero):
$$\frac{Q'(t)}{K\,Q(t)} = \frac{P''(x)}{P(x)}.$$The left side depends only on $t$; the right side depends only on $x$. The only way this can hold for all $(x,t)$ is if both sides equal the same constant. We call that constant $-\lambda$:
$$\frac{Q'(t)}{K\,Q(t)} = \frac{P''(x)}{P(x)} = -\lambda.$$The choice of $-\lambda$ (rather than $+\lambda$) is a convention that makes the final eigenvalues $\lambda$ come out positive. It has no mathematical consequence — the equations would be equivalent with the opposite sign.
The Two ODEs
The single PDE has now been replaced by two ordinary differential equations, coupled through the common constant $\lambda$:
with the spatial boundary conditions inherited from $u(0,t) = u(L,t) = 0$:
$$P(0) = 0, \qquad P(L) = 0.$$This is a simple first-order linear ODE with solution $Q(t) = C\,e^{-K\lambda t}$ (once $\lambda$ is known).
Since $u(0,t) = P(0)\,Q(t) = 0$ must hold for all $t > 0$, we need $P(0) = 0$ (otherwise $Q(t) \equiv 0$ and the solution is trivially zero). Similarly $P(L) = 0$.
So the boundary conditions migrate from the PDE to the spatial ODE. This is why the spatial problem is a boundary value problem rather than an initial value problem.
3. The Three-Case Analysis of $\lambda$
We now solve the spatial BVP
$$P''(x) + \lambda\,P(x) = 0, \qquad P(0) = 0,\quad P(L) = 0.$$The form of the general solution depends on the sign of $\lambda$. There are exactly three possibilities — $\lambda < 0$, $\lambda = 0$, or $\lambda > 0$ — and we must analyse each one. Only one of them will produce non-trivial solutions compatible with the boundary conditions.
Step 1 — General solution. The ODE becomes
$$P''(x) - \alpha^2\,P(x) = 0,$$a second-order linear ODE with constant coefficients whose characteristic equation $r^2 - \alpha^2 = 0$ has real roots $r = \pm\alpha$. The general solution is
$$P(x) = C_1\,e^{\alpha x} + C_2\,e^{-\alpha x},$$or equivalently, using hyperbolic functions,
$$P(x) = A\,\cosh(\alpha x) + B\,\sinh(\alpha x).$$Step 2 — Apply $P(0) = 0$.
$$P(0) = A\,\cosh(0) + B\,\sinh(0) = A\cdot 1 + B\cdot 0 = A.$$So $A = 0$ and $P(x) = B\,\sinh(\alpha x)$.
Step 3 — Apply $P(L) = 0$.
$$P(L) = B\,\sinh(\alpha L) = 0.$$Since $\alpha > 0$ and $L > 0$, we have $\alpha L > 0$, and $\sinh(\alpha L) > 0$ (it is zero only at zero). Therefore the only way to satisfy this is $B = 0$.
Step 1 — General solution. The ODE becomes
$$P''(x) = 0,$$which we integrate twice to get
$$P(x) = C_1\,x + C_2.$$Step 2 — Apply $P(0) = 0$.
$$P(0) = C_1\cdot 0 + C_2 = C_2 = 0,$$so $P(x) = C_1\,x$.
Step 3 — Apply $P(L) = 0$.
$$P(L) = C_1\,L = 0 \implies C_1 = 0.$$Step 1 — General solution. The ODE becomes
$$P''(x) + \alpha^2\,P(x) = 0,$$whose characteristic equation $r^2 + \alpha^2 = 0$ has complex roots $r = \pm i\alpha$. The general real solution is
$$P(x) = A\,\cos(\alpha x) + B\,\sin(\alpha x).$$Step 2 — Apply $P(0) = 0$.
$$P(0) = A\,\cos(0) + B\,\sin(0) = A\cdot 1 + B\cdot 0 = A.$$So $A = 0$ and $P(x) = B\,\sin(\alpha x)$.
Step 3 — Apply $P(L) = 0$.
$$P(L) = B\,\sin(\alpha L) = 0.$$Here we have a choice: either $B = 0$ (trivial) or
$$\sin(\alpha L) = 0.$$We insist on a non-trivial solution, so we demand $\sin(\alpha L) = 0$. This happens precisely when
$$\alpha L = m\pi, \qquad m = 1,\,2,\,3,\,\ldots$$Hence $\alpha_m = \dfrac{m\pi}{L}$, and the eigenvalues are
$$\boxed{\;\lambda_m = \alpha_m^2 = \left(\frac{m\pi}{L}\right)^2,\quad m = 1, 2, 3, \ldots\;}$$The corresponding non-trivial solutions (the eigenfunctions) are
$$\boxed{\;P_m(x) = \sin\!\left(\frac{m\pi x}{L}\right),\quad m = 1, 2, 3, \ldots\;}$$| Case | General Solution of $P$ | Result under $P(0)=P(L)=0$ |
|---|---|---|
| I: $\lambda < 0$ | $A\cosh(\alpha x)+B\sinh(\alpha x)$ | Trivial only |
| II: $\lambda = 0$ | $C_1\,x + C_2$ | Trivial only |
| III: $\lambda > 0$ | $A\cos(\alpha x)+B\sin(\alpha x)$ | $\sin(m\pi x/L)$ for $m=1,2,\ldots$ |
4. Solving the Temporal ODE
Now that we know $\lambda = \lambda_m = (m\pi/L)^2$, the temporal equation becomes
$$Q'(t) + K\lambda_m\,Q(t) = 0,$$which is first-order linear and separable. Its solution is
$$Q_m(t) = C\,e^{-K\lambda_m t} = C\,\exp\!\left[-K\left(\frac{m\pi}{L}\right)^2 t\right].$$The decay rate $K(m\pi/L)^2$ is larger for higher modes ($m$). High-frequency (wiggly) components of the temperature profile die out fastest, while low-frequency (smooth) components persist. This is why heat conduction always smooths out an initial temperature profile over time.
5. Building the General Solution
For each $m = 1, 2, 3, \ldots$ we have a product solution:
$$u_m(x,t) = P_m(x)\,Q_m(t) = C_m\,\sin\!\left(\frac{m\pi x}{L}\right)\,\exp\!\left[-K\left(\frac{m\pi}{L}\right)^2 t\right].$$Because the heat equation is linear and homogeneous (and the boundary conditions are zero), any linear combination of solutions is again a solution. This is the principle of superposition. We therefore write the general solution as an infinite sum over all modes:
The constants $C_m$ are chosen to match the initial condition $u(x,0) = f(x)$.
Applying the Initial Condition — Fourier Sine Series
Setting $t = 0$ in the general solution:
$$u(x,0) = \sum_{m=1}^{\infty} C_m\,\sin\!\left(\frac{m\pi x}{L}\right) = f(x).$$This is exactly the Fourier sine series of $f(x)$ on the interval $[0, L]$. Using the orthogonality relation
$$\int_0^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/2 & m = n\end{cases}$$we can extract the coefficients: multiply both sides by $\sin(n\pi x/L)$ and integrate from $0$ to $L$:
If $f(x)$ is already written as a finite sine series — e.g., $f(x) = 3\sin(2\pi x/L) - 5\sin(7\pi x/L)$ — you can read the coefficients off directly by matching: $C_2 = 3$, $C_7 = -5$, all others zero. No integration needed.
6. Method Summary (The 5-Step Procedure)
- Separate variables. Assume $u(x,t) = P(x)Q(t)$ and substitute into $u_t = K u_{xx}$. Divide by $KPQ$ to obtain $Q'/(KQ) = P''/P = -\lambda$.
- Write the two ODEs with the spatial boundary conditions inherited from the PDE's BCs.
- Solve the spatial BVP by analysing all three cases $\lambda < 0$, $\lambda = 0$, $\lambda > 0$. For homogeneous Dirichlet BCs, only $\lambda > 0$ yields non-trivial solutions with eigenvalues $\lambda_m = (m\pi/L)^2$ and eigenfunctions $\sin(m\pi x/L)$.
- Solve the temporal ODE using the known $\lambda_m$: $Q_m(t) = C_m\,e^{-K\lambda_m t}$.
- Superpose and fit the initial condition: write $u = \sum C_m P_m Q_m$ and determine $C_m$ from $u(x,0) = f(x)$, either by comparison (if $f$ is already a sine sum) or by the Fourier sine coefficient formula.
7. Worked Examples
Step 1 — Read parameters. $K = 7$, $L = \pi$. The general solution is
$$u(x,t) = \sum_{m=1}^{\infty} C_m\,\sin(mx)\,e^{-7 m^2 t}.$$(Note that $m\pi/L = m\pi/\pi = m$, which is why the arguments of the sines are just $mx$.)
Step 2 — Apply IC by comparison. At $t=0$:
$$\sum_{m=1}^{\infty} C_m\,\sin(mx) = 3\sin(2x) - 6\sin(5x).$$Matching coefficients: $C_2 = 3$, $C_5 = -6$, and $C_m = 0$ for all other $m$.
Step 1 — General form. With $K=4$, $L=4$:
$$u(x,t) = \sum_{m=1}^{\infty} C_m\,\sin\!\left(\frac{m\pi x}{4}\right)\,e^{-4(m\pi/4)^2 t} = \sum_{m=1}^{\infty} C_m\,\sin\!\left(\frac{m\pi x}{4}\right)\,e^{-(m\pi)^2 t/4}.$$Step 2 — Match the IC. We need $\sum C_m \sin(m\pi x/4) = 5\sin(\pi x)$. Setting $m\pi/4 = \pi$ gives $m = 4$, so $C_4 = 5$, all other $C_m = 0$.
The initial condition is a polynomial, not a sine sum, so we must compute the Fourier sine coefficients by integration.
Step 1 — Set up the coefficient formula. With $L = 4$:
$$C_m = \frac{2}{4}\int_0^4 (x-1)\,\sin\!\left(\frac{m\pi x}{4}\right)\,dx = \frac{1}{2}\int_0^4 (x-1)\,\sin\!\left(\frac{m\pi x}{4}\right)\,dx.$$Step 2 — Integration by parts. Let $u = x - 1$, $dv = \sin(m\pi x/4)\,dx$, so $du = dx$, $v = -\dfrac{4}{m\pi}\cos(m\pi x/4)$. Then
$$\int_0^4 (x-1)\sin\!\left(\frac{m\pi x}{4}\right)dx = \left[-\frac{4(x-1)}{m\pi}\cos\!\left(\frac{m\pi x}{4}\right)\right]_0^4 + \frac{4}{m\pi}\int_0^4 \cos\!\left(\frac{m\pi x}{4}\right)dx.$$The remaining integral is
$$\frac{4}{m\pi}\cdot\left[\frac{4}{m\pi}\sin\!\left(\frac{m\pi x}{4}\right)\right]_0^4 = 0$$because $\sin(m\pi) = 0$ and $\sin(0) = 0$.
Evaluating the boundary term:
$$\left[-\frac{4(x-1)}{m\pi}\cos\!\left(\frac{m\pi x}{4}\right)\right]_0^4 = -\frac{4\cdot 3}{m\pi}\cos(m\pi) + \frac{4\cdot(-1)}{m\pi}\cdot 1 = -\frac{12(-1)^m}{m\pi} - \frac{4}{m\pi}.$$Therefore
$$C_m = \frac{1}{2}\left[-\frac{12(-1)^m + 4}{m\pi}\right] = -\frac{2}{m\pi}\left[1 + 3(-1)^m\right].$$For $m$ even: $(-1)^m = 1$, so $C_m = -\dfrac{2}{m\pi}(1+3) = -\dfrac{8}{m\pi}$.
For $m$ odd: $(-1)^m = -1$, so $C_m = -\dfrac{2}{m\pi}(1-3) = \dfrac{4}{m\pi}$.
All non-zero, as expected for a non-symmetric initial condition.
Step 1 — Fourier sine coefficients.
$$C_m = \frac{2}{L}\int_0^L 20\,\sin\!\left(\frac{m\pi x}{L}\right)dx = \frac{40}{L}\cdot\left[-\frac{L}{m\pi}\cos\!\left(\frac{m\pi x}{L}\right)\right]_0^L = \frac{40}{m\pi}\left[1 - (-1)^m\right].$$Step 2 — Simplify.
For $m$ even: $C_m = 0$.
For $m$ odd: $C_m = \dfrac{80}{m\pi}$.
Physical interpretation: Starting from a uniform temperature $20$, the wire is held at zero at both ends. Heat flows out through the boundaries and the interior cools down, approaching zero everywhere as $t \to \infty$. The odd-$m$ eigenfunctions (symmetric about $x = L/2$) survive because they match the symmetry of the constant initial data.