Heat spreads out because gradients drive it
The heat equation formalises a simple physical rule: heat flows from hot to cold at a rate proportional to how steep the temperature gradient is. In one dimension, along a thin rod, the temperature u(x,t) obeys the heat equation with a proportionality constant alpha, the thermal diffusivity of the material - how quickly it evens out temperature differences, combining thermal conductivity, density and specific heat capacity into one number.
∂u/∂t = α · ∂²u/∂x² heat equation finite-difference discretisation (explicit scheme): u[i,t+1] = u[i,t] + α·Δt/Δx² · (u[i+1,t] - 2·u[i,t] + u[i-1,t]) stability requires: α·Δt/Δx² ≤ 0.5 (1D explicit / FTCS scheme)
Solving it by finite differences
The finite difference approach replaces the continuous rod with a chain of discrete points and replaces the second spatial derivative with a difference of neighbours - the second-order central difference shown above. Marching this update rule forward in time is called the explicit (FTCS, forward-time central-space) scheme: cheap, simple to implement, but only conditionally stable. If the time step is too large relative to the spatial step, small numerical errors amplify every step instead of decaying, and the simulated rod produces oscillating, unphysical temperatures instead of smooth diffusion. The stability bound is a direct consequence of von Neumann stability analysis, which checks whether Fourier error modes grow or shrink under the update rule.
Boundary conditions decide the long-term shape
The same interior equation produces very different long-run behaviour depending on what happens at the two ends of the rod. A Dirichlet boundary condition fixes the temperature at an endpoint - like clamping the end of the rod to an ice bath - and heat continually drains out or in through that end. A Neumann boundary condition fixes the heat flux (zero for a perfectly insulated end) rather than the temperature itself, so no heat crosses that boundary and the endpoint's temperature is free to drift until the whole rod reaches equilibrium. A rod insulated at both ends conserves total heat energy and relaxes to a single uniform temperature - the average of the initial distribution - while a rod clamped at both ends to different fixed temperatures relaxes to a straight-line steady-state profile between them.
Why the analytic solution is a sum of decaying sine waves
For a rod of length L with both ends held at zero (Dirichlet), the heat equation's general solution is a Fourier sine series:
u(x,t) = Σ (n=1 to ∞) Bₙ · sin(nπx/L) · exp(-α·(nπ/L)²·t) Bₙ = Fourier sine coefficients of the initial temperature profile u(x,0)
Each term is a spatial sine mode whose amplitude decays exponentially, and critically, higher-frequency modes (larger n) decay faster - the decay rate scales with n squared. This is exactly why diffusion smooths things out: sharp, high-frequency temperature spikes (large n) vanish almost immediately, while the slow, broad, low-n variation lingers, so any initial temperature profile - however jagged - rounds itself into a smooth bump and then a nearly flat line as t grows. It is the same mathematical structure (separation of variables plus a Fourier expansion) used to solve the wave equation and Schrodinger's equation, which is why the heat equation is often the first PDE taught: it is the simplest case of the technique that reappears throughout mathematical physics.
Beyond one dimension, and why implicit schemes exist
In two or three dimensions the same equation governs heat spreading through a plate or solid, and the explicit finite-difference stability bound gets even more restrictive (tighter by roughly a factor equal to the number of spatial dimensions), which is why production codes for anything beyond simple demonstrations typically switch to implicit schemes (like Crank-Nicolson), which solve a linear system each step but remain stable for any time step size - trading a larger per-step computational cost for the freedom to take much bigger, and therefore fewer, steps overall.
Frequently asked questions
What is thermal diffusivity, and why does it control the simulation's stability?
Thermal diffusivity combines a material's conductivity, density and specific heat into one number describing how fast temperature differences even out. In an explicit finite-difference solver, the ratio alpha times delta-t over delta-x squared must stay below 0.5 in one dimension or the numerical errors amplify each step instead of decaying, producing unphysical oscillations.
What's the practical difference between a Dirichlet and a Neumann boundary condition?
A Dirichlet condition fixes the temperature at a boundary, so heat is free to flow across it to maintain that fixed value - like an end clamped to an ice bath. A Neumann condition fixes the heat flux instead, most commonly to zero for a perfectly insulated end, so no heat crosses that boundary and its temperature drifts freely until the system settles.
Why do sharp temperature spikes disappear faster than broad temperature variations?
The analytic solution decomposes the initial profile into a Fourier series of sine modes, and each mode's amplitude decays exponentially at a rate proportional to the square of its spatial frequency. Sharp spikes are built from high-frequency modes, which decay almost immediately, while broad, low-frequency variation persists far longer.
Try it live
Everything above runs in your browser — open Fourier Heat Equation and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Fourier Heat Equation simulation