Hexa Scholar

Explicit finite differences for the heat equation

A copper wire ring with evenly spaced brass pegs lies on a navy base, one short arc glowing gold, with a brass hourglass beside it.
A ring with one warm arc, and an hourglass beside it.

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. 1 SeeSearch for the largest clean time step.
  2. 2 TryPredict what one step does to a wiggle.
  3. 3 ProveBuild the step limit, line by line.
  4. 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 ideas

Heat flows toward the neighbors

Figure (needs JavaScript): three neighboring grid values as bars, with a dashed line through the two outer values.

Shape

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

Δ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.

1 See

Search for the largest clean time step

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

2 Try

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.

3 Prove

Why r = 1/2 is the limit

Theorem

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.

4 Apply

Problems

Each problem has hints and a full solution. Exact answers can be typed as a decimal or a fraction.

Key point The explicit scheme for \(u_t = \kappa u_{xx}\) is stable on every grid when \(r = \kappa\Delta t/\Delta x^2 \le \tfrac{1}{2}\). On a ring with an even number of points that is exactly the limit; on a coarse rod with fixed ends the limit is a little higher. The limit costs: halving \(\Delta x\) quarters the step. Above the limit the fastest zigzag is multiplied in size by \(|1 - 4r| \gt 1\) at every step, without end; it can take many steps to show when \(r\) is just above \(\tfrac{1}{2}\) or the start is smooth.
Level Intermediate Prerequisites Finite differences on a grid; the heat equation (refreshed in Before you start and the first idea card) Time ~40 min

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