In numerical analysis, the Crank–Nicolson method is a finite difference method used for numerically solving the heat equation and similar partial differential equations. It is a second-order method in time. It is implicit in time and can be written as an implicit Runge–Kutta method, and it is numerically stable. The method was developed by John Crank and Phyllis Nicolson in the mid 20th century. ∂ C ∂ t = D x ∂ 2 C ∂ x 2 − U x ∂ C ∂ x − k ( C − C N ) − k ( C − C M ) {displaystyle {frac {partial C}{partial t}}=D_{x}{frac {partial ^{2}C}{partial x^{2}}}-U_{x}{frac {partial C}{partial x}}-k(C-C_{N})-k(C-C_{M})} (1) ∂ C ∂ t ⇒ C i j + 1 − C i j Δ t {displaystyle {frac {partial C}{partial t}}Rightarrow {frac {C_{i}^{j+1}-C_{i}^{j}}{Delta t}}} (2) ∂ 2 C ∂ x 2 ⇒ 1 2 ( Δ x ) 2 ( ( C i + 1 j + 1 − 2 C i j + 1 + C i − 1 j + 1 ) + ( C i + 1 j − 2 C i j + C i − 1 j ) ) {displaystyle {frac {partial ^{2}C}{partial x^{2}}}Rightarrow {frac {1}{2(Delta x)^{2}}}left((C_{i+1}^{j+1}-2C_{i}^{j+1}+C_{i-1}^{j+1})+(C_{i+1}^{j}-2C_{i}^{j}+C_{i-1}^{j}) ight)} (3) ∂ C ∂ x ⇒ 1 2 ( ( C i + 1 j + 1 − C i − 1 j + 1 ) 2 ( Δ x ) + ( C i + 1 j − C i − 1 j ) 2 ( Δ x ) ) {displaystyle {frac {partial C}{partial x}}Rightarrow {frac {1}{2}}left({frac {(C_{i+1}^{j+1}-C_{i-1}^{j+1})}{2(Delta x)}}+{frac {(C_{i+1}^{j}-C_{i-1}^{j})}{2(Delta x)}} ight)} (4) C ⇒ 1 2 ( C i j + 1 + C i j ) {displaystyle CRightarrow {frac {1}{2}}(C_{i}^{j+1}+C_{i}^{j})} (5) C N ⇒ 1 2 ( C N i j + 1 + C N i j ) {displaystyle C_{N}Rightarrow {frac {1}{2}}(C_{Ni}^{j+1}+C_{Ni}^{j})} (6) C M ⇒ 1 2 ( C M i j + 1 + C M i j ) . {displaystyle C_{M}Rightarrow {frac {1}{2}}(C_{Mi}^{j+1}+C_{Mi}^{j}).} (7) In numerical analysis, the Crank–Nicolson method is a finite difference method used for numerically solving the heat equation and similar partial differential equations. It is a second-order method in time. It is implicit in time and can be written as an implicit Runge–Kutta method, and it is numerically stable. The method was developed by John Crank and Phyllis Nicolson in the mid 20th century. For diffusion equations (and many other equations), it can be shown the Crank–Nicolson method is unconditionally stable. However, the approximate solutions can still contain (decaying) spurious oscillations if the ratio of time step Δt times the thermal diffusivity to the square of space step, Δx2, is large (typically larger than 1/2 per Von Neumann stability analysis). For this reason, whenever large time steps or high spatial resolution is necessary, the less accurate backward Euler method is often used, which is both stable and immune to oscillations. 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, if the partial differential equation is then, letting u ( i Δ x , n Δ t ) = u i n {displaystyle u(iDelta x,,nDelta t)=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 (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 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. The Crank–Nicolson method is often applied to diffusion problems. As an example, for linear diffusion, applying a finite difference spatial discretization for the right hand side, the Crank–Nicolson discretization is then : or, letting r = a Δ t 2 ( Δ x ) 2 {displaystyle r={frac {aDelta t}{2(Delta x)^{2}}}} : given that the terms on the right-hand side of the equation are known, this is a tridiagonal problem, so that u i n + 1 {displaystyle u_{i}^{n+1},} may be efficiently solved by using the tridiagonal matrix algorithm in favor of a much more costly matrix inversion.