information:highlighting, structural:reformatting, information:classification
Principle

The Crank–Nicolson method is based on the trapezoidal rule, giving second-order convergence in time. For linear equations, the trapezoidal rule is equivalent to the implicit midpoint method —the simplest example of a Gauss–Legendre implicit Runge–Kutta method—which also has the property of being a geometric integrator. For example, in one dimension, suppose the partial differential equation is ∂ u ∂ t = F (u, x, t, ∂ u ∂ x, ∂ 2 u ∂ x 2). {\displaystyle {\frac {\partial u}{\partial t}}=F\left(u,x,t,{\frac {\partial u}{\partial x}},{\frac {\partial ^{2}u}{\partial x^{2}}}\right).}

Letting u (i Δ x, n Δ t) = u i n {\displaystyle u(i\Delta x,n\Delta t)=u_{i}^{n}} and F i n = F {\displaystyle F_{i}^{n}=F} evaluated for i, n {\displaystyle i,n} and u i n {\displaystyle u_{i}^{n}}, the equation for Crank–Nicolson method is a combination of the forward Euler method at n {\displaystyle n} and the backward Euler method at n + 1 {\displaystyle n+1} (note, however, that the method itself is not simply the average of those two methods, as the backward Euler equation has an implicit dependence on the solution):

Note that this is an implicit method: to get the "next" value of u {\displaystyle u} in time, a system of algebraic equations must be solved. If the partial differential equation is nonlinear, the discretization will also be nonlinear, so that advancing in time will involve the solution of a system of nonlinear algebraic equations, though linearizations are possible. In many problems, especially linear diffusion, the algebraic problem is tridiagonal and may be efficiently solved with the tridiagonal matrix algorithm, which gives a fast O (N) {\displaystyle {\mathcal {O}}(N)} direct solution, as opposed to the usual O (N 3) {\displaystyle {\mathcal {O}}(N^{3})} for a full matrix, in which N {\displaystyle N} indicates the matrix size.