Differential Equations · Undergraduate

The Heat Equation and Separation of Variables

Quick answer

The heat equation u_t = k u_xx describes temperature u(x, t) along a rod. With both ends held at 0 and starting temperature f(x), separation of variables looks for solutions X(x)T(t). The boundary conditions allow only the modes sin(nπx/L), and each decays like e^(−k(nπ/L)²t). The full solution is a sum of these modes, with coefficients from the Fourier sine series of f. High frequencies die out fastest, so any starting profile soon smooths into a single sine hump that fades away.

What you'll learn

  • Interpret the heat equation and its boundary and initial conditions
  • Separate variables to find the product solutions
  • Find the sine series coefficients for a starting temperature
  • Explain why high-frequency modes decay fastest

Temperature along a rod

A thin rod of length LL has temperature u(x,t)u(x, t) at position xx and time tt. Heat flows from hot to cold, which gives the heat equation

ut=k uxx,0<x<L, t>0u_t = k\,u_{xx}, \qquad 0 < x < L,\ t > 0

with diffusivity k>0k > 0. We hold both ends at 00, u(0,t)=u(L,t)=0u(0, t) = u(L, t) = 0, and start from a temperature profile u(x,0)=f(x)u(x, 0) = f(x).

The solution. It is a sum of decaying sine modes:

u(x,t)=∑n=1∞bn e−k(nπ/L)2tsin⁡nπxL,bn=2L∫0Lf(x)sin⁡nπxL dxu(x, t) = \sum_{n=1}^{\infty} b_n\,e^{-k(n\pi/L)^2t}\sin\frac{n\pi x}{L}, \qquad b_n = \frac{2}{L}\int_0^L f(x)\sin\frac{n\pi x}{L}\,dx

Why separating variables works

Try u=X(x)T(t)u = X(x)T(t). The equation becomes XT′=kX′′TXT' = kX''T, and dividing by kXTkXT:

T′kT=X′′X\frac{T'}{kT} = \frac{X''}{X}

The left side depends only on tt and the right only on xx. A function of tt can equal a function of xx for all xx and tt only if both are the same constant, −λ-\lambda. So X′′+λX=0X'' + \lambda X = 0 with X(0)=X(L)=0X(0) = X(L) = 0, whose only nonzero solutions are X=sin⁡nπxLX = \sin\tfrac{n\pi x}{L} with λ=(nπL)2\lambda = \left(\tfrac{n\pi}{L}\right)^2. Then T′=−kλTT' = -k\lambda T gives T=e−kλtT = e^{-k\lambda t}. The equation is linear, so sums of these products are solutions too, and the Fourier series of ff picks the right sum.

Worked examples

Temperature profiles from Example 1 The temperature along the rod from x = 0 to π at three times. At t = 0 the profile 3 sin x − sin 4x is a hump with a wiggle on top. At t = 0.1 the wiggle has mostly faded. At t = 0.5 the profile is a smooth, lower sine hump. 1231234xu
  • t = 0
  • t = 0.1
  • t = 0.5
Temperature profiles from Example 1

Common mistakes

Practice problems

  1. Solve ut=2uxxu_t = 2u_{xx} on 0<x<π0 < x < \pi, zero ends, u(x,0)=5sin⁡2xu(x, 0) = 5\sin 2x.

    Answer

    u=5e−8tsin⁡(2x)u = 5e^{-8t}\sin(2x)

    Full solution

    Mode n=2n = 2 decays like e−kn2t=e−8te^{-kn^2t} = e^{-8t}.

  2. With k=1k = 1 and L=πL = \pi, how much faster does mode 33 decay than mode 11?

    Answer

    Its rate is 99 times as large.

    Full solution

    The rates are n2=1n^2 = 1 and 99.

  3. On 0<x<π0 < x < \pi, find b1b_1 for f(x)=x(π−x)f(x) = x(\pi - x).

    Answer

    8π\tfrac{8}{\pi}

    Full solution

    2π∫0πx(π−x)sin⁡x dx=2π⋅4\tfrac{2}{\pi}\int_0^{\pi} x(\pi - x)\sin x\,dx = \tfrac{2}{\pi} \cdot 4, using integration by parts twice.

  4. What are the allowed spatial modes on a rod of length 22 with zero ends?

    Answer

    sin⁡nπx2\sin\tfrac{n\pi x}{2}, n=1,2,3,…n = 1, 2, 3, \ldots

    Full solution

    sin⁡nπxL\sin\tfrac{n\pi x}{L} vanishes at x=0x = 0 and x=Lx = L.

  5. In Example 1, find u(π2,0.1)u\left(\tfrac{\pi}{2}, 0.1\right).

    Answer

    About 2.712.71

    Full solution

    sin⁡2π=0\sin 2\pi = 0, so u=3e−0.1≈2.71u = 3e^{-0.1} \approx 2.71.

  6. What is lim⁡t→∞u(x,t)\lim_{t\to\infty} u(x, t) for any starting profile with zero ends?

    Answer

    00

    Full solution

    Every mode has a negative exponent, so every term decays to 00.

  7. In Example 3, the rod’s diffusivity doubles to k=1k = 1. When does the center temperature halve?

    Answer

    At t≈7.0t \approx 7.0

    Full solution

    The decay rate doubles to about 0.09870.0987, so the halving time is cut in half.

  8. A student writes the solution of Example 1 as (3sin⁡x−sin⁡4x)e−t(3\sin x - \sin 4x)e^{-t}. What is wrong?

    Answer

    Each mode has its own rate; the sin⁡4x\sin 4x term decays like e−16te^{-16t}.

    Full solution

    Check: (sin⁡4x)e−t(\sin 4x)e^{-t} has ut=−sin⁡4x e−tu_t = -\sin 4x\,e^{-t} but uxx=−16sin⁡4x e−tu_{xx} = -16\sin 4x\,e^{-t}, which do not match.

Frequently asked questions

What does the heat equation say?

u_t = k u_xx: temperature rises where the profile curves upward (a cool spot between warmer neighbors) and falls where it curves downward. k is the diffusivity of the material.

What is separation of variables?

Trying u = X(x)T(t). Substituting splits the PDE into two ordinary differential equations, one in x and one in t, linked by a constant.

Why only sine functions?

The ends are held at 0, so X(0) = X(L) = 0. Among the solutions of X″ + λX = 0, only sin(nπx/L) vanish at both ends.

How are the coefficients found?

Set t = 0: f(x) = Σ bₙ sin(nπx/L). So bₙ = (2/L)∫₀ᴸ f(x) sin(nπx/L) dx, the Fourier sine coefficients of f.

What happens as time goes on?

Every mode decays to 0, the higher ones much faster. After a while only the first mode is visible, then it too fades and the rod reaches temperature 0.

What to learn next