Mathematics / Crank-Nicolson Heat PDE
FREE TO EXPLORE
LABORATORY 36 · MATHEMATICS

Heat Equation Parabolic PDE: Crank-Nicolson Unconditional Stability

Implement the implicit Crank-Nicolson scheme for the one-dimensional unsteady heat conduction PDE ∂u/∂t = α ∂²u/∂x², demonstrate unconditional numerical stability, and verify second-order temporal and spatial convergence O(Δt² + Δx²). Explore interactive numerical methods, evaluate error attenuation and verify convergence orders.

COMPUTE · CONVERGE · ANALYSE

Your virtual mathematics laboratory.

GLOBAL PDE SOLUTION ERROR ||U - U_EXACT||_∞—
COMPUTATION STATUS

Ready to execute Step = 1.

1 step
Parabolic PDE manifold: ∂u/∂t = ∂²u/∂x² on x ∈ [0, π], t ∈ [0, 0.5] with Dirichlet boundaries u(0, t) = u(π, t) = 0

Adjust Step, then execute computation.

Mathematical operations are computed deterministically using 64-bit IEEE 754 precision. Residuals reflect ordinary least-squares regression across successive observations.

Numerical assumptions and limits

While Crank-Nicolson is A-stable, it is not L-stable: it does not damp stiff high-frequency error components as rapidly as backward Euler or BDF2. The simulation executes the implicit Crank-Nicolson scheme across coupled mesh spacings h = 0.20 / 2^{k-1} on the thermal diffusion PDE ∂u/∂t = ∂²u/∂x². The maximum error is measured against the exact fundamental Fourier mode u(x, t) = e^{-t} sin(x). The logarithmic regression ln(E) = α·ln(h) + ln(C) extracts the asymptotic order α = 2.000 with R² = 1.000000.

Computational tools & numerical modules.

One-Dimensional Thermal Bar Grid

Discretizes the continuous spatial domain [0, π] into N uniform sub-elements with node spacing Δx = π/N.

Crank-Nicolson Matrix Assembler

Assembles the tridiagonal system (I - 0.5 r δ_x²) u^{n+1} = (I + 0.5 r δ_x²) u^n where r = Δt / Δx².

Thomas Tridiagonal Solver

Inverts the strictly diagonally dominant implicit matrix at each time step in O(N) operations.

Von Neumann Stability Analyzer

Calculates the Fourier amplification factor G(k) = (1 - 2r sin²(kΔx/2)) / (1 + 2r sin²(kΔx/2)) showing |G| ≤ 1 for all r.

Exact Fourier Mode Evaluator

Computes exact decaying solution u(x, t) = e^{-t} sin(x) to evaluate exact spatial and temporal error fields.

Log-Log Asymptotic Slope Engine

Performs linear regression on (ln(h), ln(E_max)) to verify the theoretical second-order slope α = 2.000.

FOLLOW THE METHOD

A reason behind every step.

Implement the implicit Crank-Nicolson scheme for the one-dimensional unsteady heat conduction PDE ∂u/∂t = α ∂²u/∂x², demonstrate unconditional numerical stability, and verify second-order temporal and spatial convergence O(Δt² + Δx²). Standardized input settings: 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 step.

01

Define Parabolic Heat Diffusion Problem

Set up ∂u/∂t = ∂²u/∂x² on [0, π] with initial condition u(x, 0) = sin(x) and exact solution u(x, t) = e^{-t} sin(x).

02

Initialize Coupled Space-Time Mesh

For test levels k = 1 to 6, set spatial grid spacing h = Δx = 0.20 / 2^{k-1} and time step Δt proportional to h.

03

Formulate Crank-Nicolson Stencils

Construct tridiagonal matrices with diagonal 1 + r and off-diagonals -r/2 on the left, and diagonal 1 - r and off-diagonals r/2 on the right.

04

Execute Time Marching via TDMA

At each time step t_n → t_{n+1}, multiply current state by right matrix and solve tridiagonal system via the Thomas algorithm.

05

Measure Maximum Thermal Field Discrepancy

At final time t = 0.5, compute absolute errors |u(x_i, 0.5) - u_i^N| across all nodes and extract supremum error E_max.

06

Fit Second-Order Convergence Slope

Plot ln(E_max) versus ln(h) and compute the linear regression gradient to verify α = 2.000 with R² = 1.000000.

YOUR NOTEBOOK · 0 OBSERVATIONS

Turn measurements into mathematical insight.

See a complete example report ↗

Points are your recorded observations. The solid regression line validates Crank-Nicolson Heat PDE mathematical scaling.

LINEAR ASYMPTOTIC FIT · y = mx + b
ln(E_max) = α · ln(h) + ln(C)
#Grid Spacing Level (k) (step)Global PDE Solution Error ||u - u_exact||_∞ (error norm)Logarithmic Mesh Spacing ln(h)Logarithmic Global Error ln(E_max)Remove

No readings yet. Execute a computation and record it.

Calculate it yourself.

CHECK YOUR UNDERSTANDING

Explain what the mathematical metrics mean.

What is the stability restriction on the diffusion number r = α Δt / Δx² for the Crank-Nicolson scheme?

What is the theoretical order of accuracy of the Crank-Nicolson scheme in time and space?

What computational algorithm enables the 1D implicit Crank-Nicolson step to be solved in linear O(N) time?

What undesirable numerical artifact can occur in Crank-Nicolson when the grid parameter r = Δt / Δx² is chosen extremely large?