Implicit schemes and Crank–Nicolson
The question
Which methods keep a warm rod’s computed temperature under control when you take a large time step?
Start from the same temperatures and compare three ways to march forward.
- 1 SeeChoose a method for a large step.
- 2 TryChange the grid and measure error.
- 3 ProveBuild a bound for each step.
- 4 ApplyAssemble and solve heat updates.
Before you start · 3 quick checks on differences, equations, and repeated multiplication
Two ideas before you start
2 ideasA grid replaces the rod
Samples on a smooth curve. The center and two adjacent grid points form a stencil.
The three marked grid points supply the centered second difference. Move the stencil to see which samples enter it.
Exact definition
On a rod of length \(L\), use \(N\) equal intervals of length \(h=L/N\). The \(j\)-th node is \(x_j=jh\). Write \(u_j^n\) for the excess temperature above the fixed end temperature at time \(n\Delta t\). The end values are held at zero excess temperature.
For an interior vector \(u\), write \(D\) for the unscaled second-difference operator that uses those zero endpoints.
\[(Du)_j=u_{j-1}-2u_j+u_{j+1}.\]Dividing \(Du\) by \(h^2\) approximates the spatial second derivative. The explicit heat scheme uses it at the old time level.
Choose which time level supplies the slope
Two rows of grid nodes show which time levels contribute to an update.
A slope taken at the new time uses temperatures you still have to find. When neighboring unknowns appear in the same equation, solve the rows together.
Exact definition
Assume one-dimensional heat flow with constant diffusivity \(\kappa\gt 0\), no heat source after the start, and both ends held at the same fixed temperature. Excess temperature \(u(x,t)\) satisfies \(u_t=\kappa u_{xx}\), where the subscripts denote derivatives. Set \(r=\kappa\Delta t/h^2\) for a positive time step \(\Delta t\).
Let \(\theta\) be the weight of the new slope. The update is
\[\begin{aligned} u^{n+1}-u^n &= r\big((1-\theta)Du^n\\ &\qquad +\theta Du^{n+1}\big). \end{aligned}\]Forward Euler uses the old slope (\(\theta=0\)). Backward Euler, also called fully implicit Euler, uses the new slope (\(\theta=1\)). Crank–Nicolson gives the two slopes equal weight (\(\theta=\tfrac12\)). Each choice uses the same spatial difference.
Refresher on solving a grid row
Move all terms at the new time to the left. Each row can then contain a new value at its own node and at either adjacent interior node. A matrix whose nonzero entries lie on the main diagonal and the two adjacent diagonals is called tridiagonal. Boundary values are given, so they need no columns in the matrix.
The old values determine the right-hand side. The lesson on linear systems explains why these rows must hold at the same time.
Choose which schemes can take the step
- Choose the schemes you expect to keep every interior perturbation from growing from one step to the next.
- After you check, move Step to see the same initial profile evolve under each rule.
The exact heat flow with this nonnegative initial profile and zero excess at the ends stays nonnegative. This is the minimum principle for the heat equation. A negative value at the center is a numerical undershoot. The corner of the tent contributes short-wavelength components, and some of those switch sign each step under Crank–Nicolson. Backward Euler damps those components more strongly in this run.
The lowest temperature and the length of the whole perturbation vector are different measurements. The stability verdict refers to the discrete Euclidean norm over interior nodes. The table shows the center and both extrema so you can see what stability permits locally.
Two ways to measure the error
Use a unit rod with diffusivity one, zero excess at both ends, and a smooth start \(u(x,0)=\sin(\pi x)\). Keep the final time \(T\) fixed and use equal time steps. For time error, compare with the exact evolution on your chosen space grid. For total error, compare with the exact heat equation on the continuous rod. Both measurements use the absolute difference at the center.
The reference values and the goals open after you answer.
- Choose the number of space intervals and time steps to compare two errors at the same final time.
- Use the readout to meet each error goal. Next goal sets up a fresh run.
Where the two references come from
The sine’s second spatial derivative is \(-\pi^2\) times the sine. It keeps the same shape under heat flow, with a time-dependent scale. At the center the sine is one, so the exact center value at \(T\) is \(e^{-\pi^2 T}\).
The continuous-time space grid instead uses \(\lambda_h=4\sin^2(\pi h/2)/h^2\) in place of \(\pi^2\). This follows by taking the second difference of the sampled sine. At the center the grid reference is \(e^{-\lambda_hT}\). If you increase the count of time steps on a fixed grid, the time error tends to zero even though the space grid still uses \(\lambda_h\).
Since \(\sin z\lt z\) for \(0\lt z=\pi h/2\), \(\lambda_h\lt\pi^2\). The grid solution decays more slowly than the continuous one. With the positive Crank–Nicolson multipliers in this explorer, each time step damps this mode more than the exact space-grid evolution over that step. Those two effects can partially cancel. A smaller time error can therefore come with a larger total error.
Refine space and time together
On each row below, halve \(h\) and quarter \(\Delta t\) to reach the next row. The final time stays fixed. The total error goes down along this particular sequence.
The sine also gives a limit argument. As \(h\) tends to zero, \(\sin z/z\) tends to one at \(z=\pi h/2\), so \(\lambda_h\) tends to \(\pi^2\). The Crank–Nicolson multiplier for this mode is \((1-s/2)/(1+s/2)\) with \(s=\lambda_h\Delta t\). Its logarithm divided by \(s\) tends to minus one as \(s\) tends to zero. Raising the multiplier to \(T/\Delta t\) therefore gives the exact heat-equation amplitude in the joint limit.
Why time error shrinks on a fixed grid
For small positive \(s\), the exact grid multiplier has logarithm \(-s\). Crank–Nicolson subtracts \(\log(1+s/2)\) from \(\log(1-s/2)\). The quadratic terms cancel, so the difference from \(-s\) is \(O(s^3)\). Backward Euler has logarithm \(-\log(1+s)\), whose difference from \(-s\) is \(O(s^2)\).
On a fixed grid \(s\) is proportional to \(\Delta t\), and log multipliers add over \(T/\Delta t\) steps. At fixed \(T\) the resulting amplitude errors for this sine are therefore \(O(\Delta t^2)\) for Crank–Nicolson and \(O(\Delta t)\) for backward Euler.
Follow a single mode through the solve
Use a uniform grid with \(N\ge2\) intervals, fixed zero excess at the two ends, constant \(\kappa\gt0\), and \(\Delta t\gt0\). For backward Euler and Crank–Nicolson, a step cannot increase the Euclidean norm \(\|v\|_2\) of an interior perturbation \(v\) that evolves by the homogeneous update. The norm is the square root of the sum of the squares of its interior values.
The matrix \(D\) is real and symmetric. Extend a vector \(v\) with zero at both endpoints. Here \(v^\mathsf{T}\) is its transpose. Expanding the squares gives
\[\begin{aligned} v^\mathsf{T}Dv &=-\sum_{j=0}^{N-1} (v_{j+1}-v_j)^2 . \end{aligned}\]If the sum vanishes, all the differences vanish and the endpoint value gives \(v=0\). So every eigenvalue of \(D\) is negative, and by the spectral theorem \(D\) has an orthonormal basis of eigenvectors. Fix one such vector \(w\), write \(Dw=-\mu w\), and call the coefficient of \(w\) in the perturbation \(v^n\) its amplitude \(a^n\). Use \(s=r\mu\). The one-step factor \(g\) sends \(a^n\) to \(g a^n\). Because the basis is orthonormal, \(\|v^n\|_2^2\) is the sum of the squared amplitudes, so it is enough to show \(|g|\le1\) for every mode.
Pick the valid statement at each line. The coefficient question is about the scalar equation itself, even when the current amplitude is zero. The last line restricts attention to the modes with \(s\gt2\).
Why the three curves differ
On this grid the sine modes \(w_j=\sin(k\pi j/N)\), with \(k\) from \(1\) to \(N-1\), meet both boundary conditions. Substituting into \(D\) gives \(\mu=4\sin^2(k\pi/(2N))\). For forward Euler the mode factor is \(1-s\), so every mode factor has magnitude at most one precisely when the largest \(s\) is at most two. The See run’s step violates that bound.
In a linear problem with fixed coefficients the implicit step is one tridiagonal solve. A nonlinear implicit equation can require iterations, such as Newton's method for a scalar equation. Those iterations solve the equation for a single new time level.
Compute an implicit step
Work through a right-hand side, a coupled solve, a sign change, a physical rod, and an error calculation. Enter a decimal. Each problem shows its accepted absolute error and has hints and a worked solution.
Further reading
- J. Crank and P. Nicolson, “A practical method for numerical evaluation of solutions of partial differential equations of the heat-conduction type,” Mathematical Proceedings of the Cambridge Philosophical Society (1947).