Unit 12, lesson 71

The Heat Equation and Separation of Variables

How the heat equation and thermal diffusivity model diffusion, how separation of variables builds solutions from Dirichlet and Neumann modes, why insulated ends conserve the mean, and how boundary lifting handles end temperatures.

  • Video 71
  • Heat, Wave and Laplace Equations

A metal rod starts with an uneven temperature profile while both of its ends are held at a fixed temperature. Which features of the profile fade first, and what is left after a long time? Here u(x,t)u(x, t) is the temperature at position xx and time tt, measured from a chosen reference so that negative values are allowed, and subscripts denote partial derivatives, so ut=∂u/∂tu_t = \partial u/\partial t and uxx=∂2u/∂x2u_{xx} = \partial^2 u/\partial x^2. This lesson writes the solution as a sum of spatial modes that each decay at their own rate, and it shows how insulated ends and nonzero end temperatures change the modes and the final state.

Key terms

Heat equation

Definition The one-dimensional heat equation for a temperature u(x,t)u(x, t) on an interval 0≤x≤L0 \le x \le L is

ut=κ uxx,κ>0,u_t = \kappa\,u_{xx}, \qquad \kappa > 0,

where the constant κ\kappa is the thermal diffusivity, with units of length squared per time. For a uniform rod, Fourier’s law gives the heat flux ϕ=−k ux\phi = -k\,u_x with the thermal conductivity kk, and the heat balance of a short piece of the rod gives ρcp ut=−ϕx\rho c_p\,u_t = -\phi_x, where ρ\rho is the density and cpc_p the specific heat. Together these give the heat equation with

κ=kρ cp.\kappa = \frac{k}{\rho\,c_p}.

A well-posed problem on the interval adds the initial temperature u(x,0)=f(x)u(x, 0) = f(x) and one boundary condition at each end, and it is solved forward in time, for t≥0t \ge 0.

In plain words The temperature rises where the profile curves upward and falls where it curves downward. Peaks cool, valleys warm, and sharp features smooth out. A larger diffusivity means faster smoothing.

Example Take κ=2\kappa = 2 on 0≤x≤π0 \le x \le \pi with both ends held at 00, and the initial profile sin⁡x\sin x, which has its peak at π/2\pi/2. Its second derivative is −sin⁡x<0-\sin x < 0 at every interior point, so the whole interior starts to cool. The function u=e−2tsin⁡xu = e^{-2t}\sin x shows this exactly, since ut=−2e−2tsin⁡xu_t = -2e^{-2t}\sin x and 2uxx=−2e−2tsin⁡x2u_{xx} = -2e^{-2t}\sin x. The opposite profile −sin⁡x-\sin x is a valley, and it warms toward 00 at the same rate.

Separation of variables for PDEs

Definition Separation of variables looks for solutions of a linear homogeneous partial differential equation with linear homogeneous boundary conditions in the product form u(x,t)=X(x) T(t)u(x, t) = X(x)\,T(t), a function of position alone times a function of time alone. Write T′=dT/dtT' = dT/dt and X′′=d2X/dx2X'' = d^2X/dx^2. For the heat equation, substitution gives X T′=κ X′′ TX\,T' = \kappa\,X''\,T, and dividing by κXT\kappa XT where it is nonzero gives

T′(t)κ T(t)=X′′(x)X(x)=−λ.\frac{T'(t)}{\kappa\,T(t)} = \frac{X''(x)}{X(x)} = -\lambda.

The left side depends only on tt and the middle only on xx, so both equal one constant, written −λ-\lambda. The spatial factor solves the eigenvalue problem X′′+λX=0X'' + \lambda X = 0 with the boundary conditions, and the time factor solves T′=−κλTT' = -\kappa\lambda T, so T=e−κλtT = e^{-\kappa\lambda t} up to a constant factor. Since the equation and the boundary conditions are linear and homogeneous, finite sums of these product solutions are again solutions. The initial condition is met by an infinite sum whose coefficients are the coefficients of ff in the orthogonal eigenfunctions. For a piecewise continuous ff those coefficients are bounded, so for every t>0t > 0 the factors e−κλnte^{-\kappa\lambda_n t} make the series converge together with all its termwise derivatives, and the sum solves the equation and the boundary conditions for t>0t > 0.

In plain words Each building block keeps a fixed spatial shape and only changes its size in time. The boundary conditions decide which shapes are allowed, each allowed shape decays at its own rate, and the initial profile decides how much of each shape to use.

Example For κ=2\kappa = 2 on 0≤x≤π0 \le x \le \pi with u(0,t)=u(π,t)=0u(0, t) = u(\pi, t) = 0, the problem X′′+λX=0X'' + \lambda X = 0 with X(0)=X(π)=0X(0) = X(\pi) = 0 has the eigenvalues λn=n2\lambda_n = n^2 and the eigenfunctions sin⁡nx\sin nx for n=1,2,3,…n = 1, 2, 3, \dots. The initial profile f(x)=sin⁡x+2sin⁡2xf(x) = \sin x + 2\sin 2x is already a sum of two of them, so orthogonality gives the coefficient 11 for n=1n = 1, the coefficient 22 for n=2n = 2, and 00 for every other nn. Hence

u=e−2tsin⁡x+2e−8tsin⁡2x.\begin{aligned} u &= e^{-2t}\sin x \\[0.4em] &\quad + 2e^{-8t}\sin 2x. \end{aligned}

To check, ut=−2e−2tsin⁡x−16e−8tsin⁡2xu_t = -2e^{-2t}\sin x - 16e^{-8t}\sin 2x and uxx=−e−2tsin⁡x−8e−8tsin⁡2xu_{xx} = -e^{-2t}\sin x - 8e^{-8t}\sin 2x, so ut=2uxxu_t = 2u_{xx}. At t=0t = 0 the profile is ff, and both sines vanish at 00 and at π\pi, so the end conditions hold too.

Dirichlet and Neumann modes

Definition On 0≤x≤L0 \le x \le L, the Dirichlet conditions u(0,t)=u(L,t)=0u(0, t) = u(L, t) = 0 hold both end temperatures at zero. The separated problem then has the eigenvalues λn=(nπ/L)2\lambda_n = (n\pi/L)^2 and the Dirichlet modes Xn=sin⁡(nπx/L)X_n = \sin(n\pi x/L) for n=1,2,3,…n = 1, 2, 3, \dots. The Neumann conditions ux(0,t)=ux(L,t)=0u_x(0, t) = u_x(L, t) = 0 describe insulated ends, through which no heat flows. They give the same eigenvalues λn=(nπ/L)2\lambda_n = (n\pi/L)^2 with the Neumann modes Xn=cos⁡(nπx/L)X_n = \cos(n\pi x/L) for n=0,1,2,…n = 0, 1, 2, \dots, including the zero mode λ0=0\lambda_0 = 0 with the constant X0=1X_0 = 1. In both cases

u=∑ncn e−κλntXn(x),u = \sum_n c_n\,e^{-\kappa\lambda_n t}X_n(x),

with the half-range coefficients of ff,

bn=2L∫0Lf(x)sin⁡nπxL dxan=2L∫0Lf(x)cos⁡nπxL dx\begin{gathered} b_n = \tfrac{2}{L}\int_0^L f(x)\sin\frac{n\pi x}{L}\,dx \\[0.4em] a_n = \tfrac{2}{L}\int_0^L f(x)\cos\frac{n\pi x}{L}\,dx \end{gathered}

Dirichlet problems use cn=bnc_n = b_n. Neumann problems use cn=anc_n = a_n for n≥1n \ge 1 and c0=a0/2c_0 = a_0/2, which is the mean value of ff.

In plain words Zero end temperatures call for sines, which vanish at the ends. Insulated ends call for cosines, which are flat at the ends, and the cosines include the constant, which never decays because heat cannot leave.

Example Take κ=2\kappa = 2 on 0≤x≤π0 \le x \le \pi with insulated ends and f(x)=3+cos⁡xf(x) = 3 + \cos x. The cosine coefficients are a0=6a_0 = 6, so c0=3c_0 = 3, and a1=1a_1 = 1, with all others zero, so

u=3+e−2tcos⁡x.u = 3 + e^{-2t}\cos x.

Its slope ux=−e−2tsin⁡xu_x = -e^{-2t}\sin x vanishes at 00 and at π\pi, and ut=−2e−2tcos⁡x=2uxxu_t = -2e^{-2t}\cos x = 2u_{xx}. The cosine fades and the constant 33 remains. Leaving out the zero mode would predict decay to 00, which is wrong for this problem.

Conserved mean temperature

Definition Let uu solve ut=κ uxxu_t = \kappa\,u_{xx} on 0≤x≤L0 \le x \le L for t>0t > 0, with uu, uxu_x, utu_t and uxxu_{xx} continuous up to the ends. Integrating the equation over the interval gives

ddt∫0Lu dx=κ [ ux ]x=0x=L.\frac{d}{dt}\int_0^L u\,dx = \kappa\,\Big[\,u_x\,\Big]_{x=0}^{x=L}.

With insulated ends both values of uxu_x are zero, so the total ∫0Lu dx\int_0^L u\,dx is constant, and so is the mean temperature

uˉ=1L∫0Lu dx=a02.\bar{u} = \frac{1}{L}\int_0^L u\,dx = \frac{a_0}{2}.

For a piecewise continuous ff, every Neumann mode with n≥1n \ge 1 decays, and uu approaches the constant uˉ\bar{u} uniformly as t→∞t \to \infty. With Dirichlet ends the boundary fluxes are in general nonzero, and the total is not conserved.

In plain words Insulation means that no heat crosses the ends, so the heat already in the rod has nowhere to go. It spreads out evenly, and the final temperature is the average of the initial one.

Example For u=3+e−2tcos⁡xu = 3 + e^{-2t}\cos x on 0≤x≤π0 \le x \le \pi, the cosine integrates to zero, so ∫0πu dx=3π\int_0^\pi u\,dx = 3\pi at every time, and the mean is 33, which is also the limit. For the Dirichlet solution e−2tsin⁡x+2e−8tsin⁡2xe^{-2t}\sin x + 2e^{-8t}\sin 2x the total is

∫0πu dx=2e−2t,\int_0^\pi u\,dx = 2e^{-2t},

which decays because heat leaves through the ends. Its derivative −4e−2t-4e^{-2t} matches the flux formula, since 2[ux]0π=−4e−2t2\big[u_x\big]_0^\pi = -4e^{-2t}.

Boundary lifting

Definition For constant end temperatures u(0,t)=Au(0, t) = A and u(L,t)=Bu(L, t) = B, the lift

ℓ(x)=A+(B−A)xL\ell(x) = A + (B - A)\frac{x}{L}

is the steady solution with these end values, since ℓ′′=0\ell'' = 0. The difference v=u−ℓv = u - \ell satisfies vt=κ vxxv_t = \kappa\,v_{xx} with zero end values and v(x,0)=f(x)−ℓ(x)v(x, 0) = f(x) - \ell(x). That is a Dirichlet problem, solved by the sine series, and u=ℓ+vu = \ell + v tends to ℓ\ell as t→∞t \to \infty. If the end temperatures A(t)A(t) and B(t)B(t) vary in time, the same formula gives a lift ℓ(x,t)\ell(x, t), and

vt=κ vxx+κ ℓxx−ℓt,v_t = \kappa\,v_{xx} + \kappa\,\ell_{xx} - \ell_t,

where ℓxx=0\ell_{xx} = 0 for this linear lift, so the changing ends act as a source −ℓt-\ell_t in the equation for vv. For uu to be continuous at the corners (0,0)(0, 0) and (L,0)(L, 0), the data must agree there, f(0)=A(0)f(0) = A(0) and f(L)=B(0)f(L) = B(0).

In plain words Subtract a simple profile that already has the right end temperatures. What remains has zero end temperatures, which the sine modes handle, and adding the profile back restores the correct end values.

Example On 0≤x≤π0 \le x \le \pi with κ=2\kappa = 2, hold the ends at u(0,t)=1u(0, t) = 1 and u(π,t)=3u(\pi, t) = 3, and start from f(x)=1+2x/π+sin⁡xf(x) = 1 + 2x/\pi + \sin x. The lift is ℓ=1+2x/π\ell = 1 + 2x/\pi, so v(x,0)=sin⁡xv(x, 0) = \sin x and v=e−2tsin⁡xv = e^{-2t}\sin x. Hence

u=1+2xπ+e−2tsin⁡x,u = 1 + \frac{2x}{\pi} + e^{-2t}\sin x,

which takes the values 11 and 33 at the ends, satisfies ut=−2e−2tsin⁡x=2uxxu_t = -2e^{-2t}\sin x = 2u_{xx}, and tends to the straight-line profile from 11 to 33. The data agree at the corners, since f(0)=1f(0) = 1 and f(π)=3f(\pi) = 3.

Diffusive decay

Definition In the Dirichlet problem on 0≤x≤L0 \le x \le L with a piecewise continuous ff, the mode nn decays like e−κ(nπ/L)2te^{-\kappa(n\pi/L)^2 t}, at a rate proportional to n2n^2. If b1≠0b_1 \ne 0, then

eκπ2t/L2 u(x,t)→b1sin⁡πxLe^{\kappa\pi^2 t/L^2}\,u(x, t) \to b_1\sin\frac{\pi x}{L}

uniformly as t→∞t \to \infty, so the solution comes to look like a decaying first mode with the time scale L2/(κπ2)L^2/(\kappa\pi^2). For every t>0t > 0 the profile is infinitely differentiable in xx, even when ff has jumps. For a solution with zero Dirichlet or zero Neumann conditions that is smooth up to the ends, the energy H(t)=12∫0Lu2 dxH(t) = \tfrac{1}{2}\int_0^L u^2\,dx satisfies

H′(t)=−κ∫0Lux2 dx≤0,H'(t) = -\kappa\int_0^L u_x^2\,dx \le 0,

because the boundary term κ[u ux]0L\kappa\big[u\,u_x\big]_0^L from integration by parts vanishes.

In plain words Fine wiggles die out much faster than broad ones. After a short time only the smoothest modes are visible, and after a long time only the slowest mode present in the data. A rod twice as long takes four times as long to smooth out.

Example In the solution u=e−2tsin⁡x+2e−8tsin⁡2xu = e^{-2t}\sin x + 2e^{-8t}\sin 2x, the second mode starts twice as large as the first but decays four times as fast. At t=0.5t = 0.5 the amplitudes are e−1≈0.368e^{-1} \approx 0.368 and 2e−4≈0.0372e^{-4} \approx 0.037, a ratio of 2e−3≈0.102e^{-3} \approx 0.10. The energy is

H(t)=π4(e−4t+4e−16t),H(t) = \frac{\pi}{4}\left(e^{-4t} + 4e^{-16t}\right),

and its derivative −π(e−4t+16e−16t)-\pi\left(e^{-4t} + 16e^{-16t}\right) equals −2∫0πux2 dx-2\int_0^\pi u_x^2\,dx, as the identity says.

Check yourself

  1. Solve ut=uxxu_t = u_{xx} on 0≤x≤π0 \le x \le \pi with u(0,t)=u(π,t)=0u(0, t) = u(\pi, t) = 0 and u(x,0)=sin⁡3xu(x, 0) = \sin^3 x, using the identity sin⁡3x=34sin⁡x−14sin⁡3x\sin^3 x = \tfrac{3}{4}\sin x - \tfrac{1}{4}\sin 3x.
Show the answer

The initial profile is already a sum of the Dirichlet modes sin⁡x\sin x and sin⁡3x\sin 3x, with the eigenvalues 11 and 99. Each coefficient picks up its own decay factor, so

u=34e−tsin⁡x−14e−9tsin⁡3x.\begin{aligned} u &= \tfrac{3}{4}e^{-t}\sin x \\[0.4em] &\quad - \tfrac{1}{4}e^{-9t}\sin 3x. \end{aligned}

Both terms satisfy ut=uxxu_t = u_{xx}, both vanish at 00 and at π\pi, and at t=0t = 0 the sum is sin⁡3x\sin^3 x. By t=0.8t = 0.8 the factor e−9te^{-9t} has fallen to e−7.2≈0.0007e^{-7.2} \approx 0.0007, while e−te^{-t} is still about 0.450.45, so the profile already looks like a single sine arch.

  1. Solve ut=uxxu_t = u_{xx} on 0≤x≤π0 \le x \le \pi with insulated ends and u(x,0)=xu(x, 0) = x. A classmate expands xx in sines and predicts that the rod cools to 00. What went wrong, and what temperature does the rod approach?
Show the answer

Insulated ends call for the cosine modes, including the constant one. The sine series belongs to the problem with zero end temperatures, a different problem. The cosine coefficients are a0=2π∫0πx dx=πa_0 = \tfrac{2}{\pi}\int_0^\pi x\,dx = \pi and, for n≥1n \ge 1,

an=2π∫0πxcos⁡nx dx=2((−1)n−1)πn2,\begin{aligned} a_n &= \frac{2}{\pi}\int_0^\pi x\cos nx\,dx \\[0.4em] &= \frac{2\big((-1)^n - 1\big)}{\pi n^2}, \end{aligned}

which is −4/(πn2)-4/(\pi n^2) for odd nn and 00 for even nn. So

u=π2−4π∑n odde−n2tcos⁡nxn2.\begin{aligned} u &= \frac{\pi}{2} \\[0.4em] &\quad - \frac{4}{\pi}\sum_{n \text{ odd}} \frac{e^{-n^2 t}\cos nx}{n^2}. \end{aligned}

Every term of the sum decays, and the rod approaches the mean of ff, which is π/2\pi/2, in agreement with the conserved mean temperature. The data have f′=1f' = 1 at both ends, which does not match the insulated ends at t=0t = 0, but the series still solves the problem for every t>0t > 0.

  1. Take ut=uxxu_t = u_{xx} on 0≤x≤π0 \le x \le \pi with u(0,t)=0u(0, t) = 0, u(π,t)=tu(\pi, t) = t and u(x,0)=0u(x, 0) = 0. With the lift ℓ=xt/π\ell = xt/\pi, which problem does v=u−ℓv = u - \ell solve? What goes wrong if the extra term is dropped, and which profile does uu approach for large tt?
Show the answer

The lift has ℓt=x/π\ell_t = x/\pi and ℓxx=0\ell_{xx} = 0, so

vt=vxx−xπ,v_t = v_{xx} - \frac{x}{\pi},

with v(0,t)=v(π,t)=0v(0, t) = v(\pi, t) = 0 and v(x,0)=0v(x, 0) = 0. The data agree at the corners, since both end temperatures start at 00. Dropping the term −x/π-x/\pi would give v=0v = 0 and u=xt/πu = xt/\pi, but that function has ut=x/πu_t = x/\pi and uxx=0u_{xx} = 0, so it does not solve the heat equation. A steady solution ww of the problem for vv needs w′′=x/πw'' = x/\pi with w(0)=w(π)=0w(0) = w(\pi) = 0, which gives

w(x)=x3−π2x6π.w(x) = \frac{x^3 - \pi^2 x}{6\pi}.

The difference v−wv - w solves the homogeneous Dirichlet problem with initial value −w-w, so it decays like e−te^{-t}. For large tt, therefore,

u≈xtπ+x3−π2x6π.u \approx \frac{xt}{\pi} + \frac{x^3 - \pi^2 x}{6\pi}.

This profile satisfies ut=x/π=uxxu_t = x/\pi = u_{xx} and the end conditions exactly. The full solution adds −∑n2(−1)nπn3e−n2tsin⁡nx-\sum_n \tfrac{2(-1)^n}{\pi n^3}e^{-n^2 t}\sin nx, which cancels the profile at t=0t = 0.

How this lesson connects