Explicit finite differences for the heat equation
The question
A grid follows heat around a 20 cm ring for 200 equal time steps. How large can each step Δt be before the run fails?
Larger steps reach later times for the same work. Run the grid as often as you like.
- 1 SeeSearch for the largest clean time step.
- 2 TryPredict what one step does to a wiggle.
- 3 ProveBuild the step limit, line by line.
- 4 ApplyProblems on rods, grids and option prices.
Before you start · 3 quick checks on second differences, the heat equation and powers, about 3 min
Two ideas before you start
2 ideasHeat flows toward the neighbors
Figure (needs JavaScript): three neighboring grid values as bars, with a dashed line through the two outer values.
rate = κ(U₋ − 2U₀ + U₊)/Δx² = 2 × (50 − 180 + 70)/1 = −120 °C/s
The middle point is above the line through its neighbors: it cools.
On a grid the heat equation compares each value with its two neighbors. A point above the line through them cools, a point below it warms, at a rate set by κ and the spacing Δx.
Exact definition
The heat equation on a ring. A thin ring of wire, 20 cm around, has temperature \(u(x, t)\) in °C at arc length \(x\) (cm) and time \(t\) (s), with \(x\) and \(x + 20\) the same point. Assume the material is uniform with constant diffusivity \(\kappa = 2\) cm²/s, the temperature is the same across each cross section, the surface is insulated and there are no heat sources. Then
\[u_t = \kappa\,u_{xx}.\]The true solution never goes below the coldest or above the hottest starting temperature (the maximum principle).
The grid. Take \(N\) points \(x_j = j\Delta x\), \(\Delta x = 20/N\) cm, \(j = 0, \ldots, N - 1\), with point 0 and point \(N - 1\) neighbors. The rate at \(x_j\) is estimated by \(\kappa(U_{j-1} - 2U_j + U_{j+1})/\Delta x^2\), the second difference from the lesson on finite differences. The card uses \(N = 20\), so \(\Delta x = 1\) cm.
One explicit step
Figure (needs JavaScript): the hot segment around the ring, unrolled, and the profile after one explicit step.
Δt = 0.1 s: r = 2 × 0.1/1² = 0.2 x = 7 cm: 20 → 36 °C; x = 8 cm: 100 → 84 °C
The explicit scheme moves every value forward by Δt times its rate, all at once. The solid line is the hot segment: 100 °C from 8 to 12 cm, 20 °C elsewhere; the dashed line is one step later. Dotted lines mark 20 °C and 100 °C.
Exact definition
Explicit scheme. With \(U_j^n\) the computed value at \(x_j\) after \(n\) steps of length \(\Delta t\), the next values are
\[\begin{aligned} U_j^{n+1} &= U_j^n + r\big(U_{j-1}^n \\ &\quad - 2U_j^n + U_{j+1}^n\big), \\ r &= \frac{\kappa\Delta t}{\Delta x^2}. \end{aligned}\]Each new value comes straight from old ones; no equations have to be solved.
Clean run. A run is clean when every computed value, at every step, stays between the coldest and hottest starting values: 20 °C and 100 °C for both starts on this page. The true temperatures do.
Fine print: the two starts, names and scope
Hot segment: 100 °C at the points with \(8 \le x \le 12\) cm, 20 °C elsewhere. Smooth bump: \(U_j = 20 + 80\,b(x_j)\) with \(b(x) = 16(x/20)^2(1 - x/20)^2\), which rises from 20 °C at \(x = 0\) to 100 °C at \(x = 10\) cm and joins up smoothly around the ring.
“Explicit” means the new values are given by a formula in the old ones; implicit schemes solve a system of equations at each step. The page treats one space variable, an evenly spaced grid and constant \(\kappa\). A ring is used so that every point has two neighbors; a rod with fixed ends is treated in stage 3.
Search for the largest clean time step
- Choose the start and the number of steps, then set Δt with the slider, from 0.01 s to 0.6 s.
- Press Run the grid. The page computes every step exactly and says whether the run is clean. Run as often as you like.
- A goal is reached when your runs show a clean Δt and a failing Δt just 0.01 s above it. Halving the gap between a clean and a failed Δt, as in bisection, gets there in a few runs.
The ring has \(N = 20\) points, so \(\Delta x = 1\) cm, and \(\kappa = 2\) cm²/s. A run is clean when every value stays between 20 °C and 100 °C at every step.
Three goals
How the page computes
Nothing is rounded during a run. The start values are fractions, \(r = 2\Delta t\) is a fraction \(p/q\), and after \(k\) steps every value is a whole number divided by the same denominator, so each step is exact integer arithmetic. The verdict compares these exact values with 20 and 100. Only the numbers you see are rounded, to 2 decimals or 3 significant digits.
A sawtooth, one step at a time
A failed run ends in a zigzag: values swing up and down from one point to the next. The purest zigzag is a sawtooth, a constant plus a wiggle \(a(-1)^j\) whose sign alternates from point to point. On a ring with an even number of points it fits all the way around.
The sawtooth explorer, its goals and one more question open after you answer the prediction.
Explorer: one step of the sawtooth
Goals
A finer grid
Why r = 1/2 is the limit
Assumptions. A ring of \(N \ge 2\) points carries values \(U_0, \ldots, U_{N-1}\), all positive, with indices taken mod \(N\). Let \(m\) and \(M\) be the smallest and largest of them, take \(r \gt 0\), and let one explicit step give
\[\begin{aligned} V_j &= U_j + r(U_{j-1} - 2U_j \\ &\qquad + U_{j+1}). \end{aligned}\](a) If \(r \le \tfrac{1}{2}\), then \(m \le V_j \le M\) for every \(j\). So every run with \(r \le \tfrac{1}{2}\) is clean, at every step and for every start.
(b) If \(N\) is even, one step turns the sawtooth \(s_j = (-1)^j\) into \((1 - 4r)s\), so \(n\) steps turn \(as\) into \(a(1 - 4r)^n s\). If \(r \gt \tfrac{1}{2}\), then \(|1 - 4r| \gt 1\), and for \(a \ne 0\) this grows without bound.
Why “positive”. Part (a) does not need it; it makes each wrong option below false in every allowed case. Temperatures in kelvins are positive, and both starts on this page are positive in °C.
Lines 1 to 3 prove (a) for a fixed \(r\) with \(0 \lt r \le \tfrac{1}{2}\) and a fixed point \(j\); lines 4 to 6 prove (b).
Each option is one step about the fixed values. Pick the one that is true in every case the theorem allows.
Problems
Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.
Related: the heat kernel (the exact solution on a line); eigenvectors (vectors that a matrix only rescales); bisection (the search in stage 1).
Further reading
- R. J. LeVeque, Finite Difference Methods for Ordinary and Partial Differential Equations: Steady-State and Time-Dependent Problems (SIAM, 2007), chapter 9, “Diffusion Equations and Parabolic Problems.”
- K. W. Morton and D. F. Mayers, Numerical Solution of Partial Differential Equations: An Introduction, 2nd ed. (Cambridge University Press, 2005), chapter 2, “Parabolic equations in one space variable.”
- P. Wilmott, S. Howison and J. Dewynne, The Mathematics of Financial Derivatives: A Student Introduction (Cambridge University Press, 1995), chapter 8, “Finite-difference Methods.”