UNIHIVE

Study Hub UNIPORT MTH 492

MTH 492 · Numerical Methods

The heat equation: implicit and Crank-Nicolson schemes

Backward differences in time, unconditional stability, and solving a tridiagonal system each step.

Our notes

2 min read

The fully implicit (backward) scheme

Take the space difference at the new time level:
−r uᵢ₋₁ⁿ⁺¹ + (1 + 2r) uᵢⁿ⁺¹ − r uᵢ₊₁ⁿ⁺¹ = uᵢⁿ

  • Each step needs a tridiagonal solve (Thomas algorithm), cheap.
  • Unconditionally stable: any r works. Error O(k + h²).

Crank-Nicolson

Average the explicit and implicit space differences (centre in time):
−(r/2) uᵢ₋₁ⁿ⁺¹ + (1 + r) uᵢⁿ⁺¹ − (r/2) uᵢ₊₁ⁿ⁺¹ = (r/2) uᵢ₋₁ⁿ + (1 − r) uᵢⁿ + (r/2) uᵢ₊₁ⁿ

  • Unconditionally stable and second order in time and space: O(k² + h²).
  • The usual choice for diffusion problems.

Worked example

Same problem as the explicit scheme (u_t = u_xx, u(x, 0) = sin πx, ends at zero), h = 0.25, r = 1, so k = 0.0625: one step reaches the time the explicit scheme needed two steps for.
With r = 1 the right side is ½(uᵢ₋₁ + uᵢ₊₁) (the (1 − r)uᵢ term vanishes):

  • Node 1: ½(0 + 1) = 0.5
  • Node 2: ½(0.70711 + 0.70711) = 0.70711
  • Node 3: 0.5

The system (by symmetry u₁ = u₃):
2u₁ − ½u₂ = 0.5 and −u₁ + 2u₂ = 0.70711 (the second from −½u₁ + 2u₂ − ½u₃).
From the first: u₂ = 4u₁ − 1. Then −u₁ + 8u₁ − 2 = 0.70711, so u₁ = 0.38673, u₂ = 0.54692.

Crank-NicolsonExplicit (two steps)Exact
x = 0.5, t = 0.06250.54690.50000.5396

Crank-Nicolson is more accurate with half the steps.

A caution

With large r, Crank-Nicolson stays stable but can show slowly decaying oscillations near sharp initial data (like a sudden temperature jump). Fixes: a few implicit steps at the start, or a smaller r.

Comparing the three

SchemeStabilityAccuracyWork per step
Explicitr ≤ ½O(k + h²)very little
ImplicitalwaysO(k + h²)one tridiagonal solve
Crank-NicolsonalwaysO(k² + h²)one tridiagonal solve

In two space dimensions

The implicit system is no longer tridiagonal. The ADI (alternating direction implicit) method splits each step into two half-steps, implicit in x then in y, each a set of tridiagonal solves.

Exams usually ask

  • Set up the Crank-Nicolson equations for one step and solve them.
  • Compare explicit, implicit and Crank-Nicolson schemes.

Common mistake

Leaving out the boundary values when writing the first and last equations. They appear on both sides (old and new levels) unless they are zero.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All MTH 492 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.