← All days ◀ Day 11Day 13 ▶
15-Day Differential Equations Course · Week 3 · Day 12

Fourier Series and the Heat Equation

Partial differential equations describe fields — temperature along a rod, displacement along a string. Derive the heat equation from energy balance, solve it by separation of variables, and discover Fourier's great idea: any shape is a sum of sines, and each sine decays at its own rate.

⏱ about 2–3 hours🧪 Lab: Fourier builder and heated rod❓ 5-question quiz

1Today's goals

  • Derive the heat equation from conservation of energy and Fourier's law
  • Solve it by separation of variables with fixed-temperature ends
  • Compute Fourier sine and cosine coefficients
  • Explain why sharp features smooth out first (decay ∝ n²)
  • Estimate thermal time scales from L²/α

2From energy balance to a PDE

Take a thin slice of a rod between x and x + dx. Heat flux q (W/m²) flows in at x and out at x + dx. Fourier's law: heat flows down the temperature gradient, q = −k·∂u/∂x. Energy balance on the slice:

ρ·c·∂u/∂t = −∂q/∂x = k·∂²u/∂x² → ut = α·uxx, α = k/(ρ·c) (thermal diffusivity, m²/s)

Read it: the temperature at a point rises if it is below the average of its neighbours (uxx > 0, a valley) and falls if it is above (a peak). Diffusion fills valleys and flattens peaks. The same equation governs ink spreading in water, a pollutant in groundwater, and — after a change of variables — the Black–Scholes model of option prices.

A PDE needs boundary conditions as well as an initial shape: fixed temperature (Dirichlet), insulated ends (Neumann, ux = 0), or convection to the air (Robin).

3Separation of variables

Rod of length L, both ends held at 0, initial shape f(x). Guess u = X(x)·T(t):

X·T′ = α·X″·T → T′/(αT) = X″/X = −λ (a constant, because one side depends only on t, the other only on x)
X″ + λX = 0 with X(0) = X(L) = 0 → Xn = sin(nπx/L), λn = (nπ/L)²
T′ = −αλnT → Tn = e−α(nπ/L)²t

u(x, t) = Σ bn·sin(nπx/L)·e−α(nπ/L)²t

Each sine shape (a mode, just like Day 8) keeps its shape and simply decays. Mode n decays n² times faster than mode 1, so fine detail disappears first and every profile ends up looking like the single hump sin(πx/L).

4Fourier series

To fit the initial shape, choose the bn so that Σ bn·sin(nπx/L) = f(x). Because the sines are orthogonal (∫ sin(mπx/L)·sin(nπx/L) dx = 0 for m ≠ n), each coefficient can be picked out alone:

bn = (2/L)·∫₀ᴸ f(x)·sin(nπx/L) dx
Full series on (−π, π): f(x) = a₀/2 + Σ (an·cos nx + bn·sin nx), an = (1/π)∫ f·cos nx dx, bn = (1/π)∫ f·sin nx dx
Wave (amplitude 1, period 2π)CoefficientsDecay of coefficients
Squarebn = 4/(nπ), odd n only1/n — it has jumps
Sawtoothbn = 2(−1)n+1/(nπ)1/n — one jump per period
Trianglebn = ±8/(n²π²), odd n1/n² — continuous, kinked

The smoother the function, the faster its coefficients fall. Near a jump, any partial sum overshoots by about 9 % of the jump — the Gibbs phenomenon — and adding terms only squeezes the overshoot closer to the jump.

Fourier, eigenfunctions and the FFT you already use

The sines are the eigenfunctions of d²/dx² with the boundary conditions — exactly as eigenvectors were for a matrix on Day 8. Expanding in eigenfunctions decouples the PDE into independent ODEs, one per mode. The same idea with complex exponentials over a finite record is the discrete Fourier transform; the FFT computes it fast. When your vibration analyser shows a spectrum, it is printing the an, bn of a measured signal.

5Worked example

A 0.5 m steel bar (k = 50 W/m·K, ρ = 7850 kg/m³, c = 490 J/kg·K), ends held at room temperature. How fast do disturbances decay?α = 50 / (7850 × 490) = 1.30 × 10⁻⁵ m²/s Mode 1 time constant τ₁ = L²/(α·π²) = 0.25 / (1.30e-5 × 9.87) = 1950 s ≈ 32 min Mode 3 time constant τ₃ = τ₁/9 ≈ 3.6 min So a hot spot spreads into a smooth hump within minutes, then the hump fades over half an hour. Rule of thumb: diffusion across a length L takes about L²/α — double the size, four times the time.
Where you meet thisWarm-up of a gearbox casing and its bearing seats, quenching and through-hardening times, thermal soak before a measurement, heat-sink design, freezing of food, drying of timber, diffusion of moisture into composites, and signal smoothing (a Gaussian blur is the heat equation run for a short time).

6Lab: Fourier builder

Build a wave from sines. With "separate harmonics" on, the thin orange curves are the first few terms; the blue curve is their sum. Press P to add terms one by one and watch the Gibbs overshoot sit stubbornly at the jumps. Compare the spectra of the square and the triangle.

The heated rod

Press P. Left: the profile flattening. Middle: the space–time map building upwards. Right: the sine coefficients decaying — the outlines are their starting sizes. With "both held at 0" watch mode 5 vanish long before mode 1. Try insulated ends: the average never changes.

7Pro tips and common mistakes

  • Match the series to the boundary conditions: sines for fixed-zero ends, cosines for insulated ends.
  • Non-zero end temperatures: subtract the steady straight-line solution first, solve for the remainder with zero ends, then add it back.
  • Heat "travels" infinitely fast in this model (any change is felt everywhere at once, though tiny far away). For most engineering it does not matter.

8Practice

  1. Compute b₁ and b₂ for f(x) = x on (0, π) with a sine series.
  2. For the steel bar above, how long until mode 1 falls to 5 %?
  3. In the heat lab, start with "sin πx + 0.5 sin 5πx". After what fraction of the run is the wiggle invisible?
  4. Show that u = e−αk²t·sin kx satisfies ut = α·uxx.

9Quick quiz

5 questions. Click an answer — you get the explanation straight away.

Progress is kept in this browser (and in your account when signed in).