# Convergence and Stability of Explicit and Implicit Schemes in the Simulation of the Heat Equation
## 4 Explicit Methods: Centered, Forward and Backward in Time Differences
### Direct Finite Difference of First Order
#### 4.1.5 Implicit Method: Crank-Nicolson (CN)  
In numerical analysis, the Crank-Nicolson (CN) method is a finite difference method used for the numerical solution of partial differential equations, such as the heat equation. It is a second order method in time, implicit and numerically stable.  
For diffusive equations (and for many other types of equations), it can be shown that the CN method is unconditionally stable. However, the approximate solutions may still contain some spurious oscillations, depending on the relationship between the temporal and spatial spacings (Figure 5).  
The FTSC and BTSC schemes have a truncation error in time of O (\(\Delta t\)). When very accurate solutions in time are needed, the CN scheme has significant advantages. The CN scheme is no more difficult to implement than the BTSC scheme, and has time truncation error of order O(\(\Delta t^{2}\)). The CN scheme is implicit and stable [1; 18; 21]. The left-hand side of the heat equation is approximated differently from that used in the FTSC scheme. The right side of the heat equation is approximated by the average of the difference evaluated at the current and previous time.  
Truncation errors in this order-of-magnitude approximation O (\(\Delta t^{2}\)) + O (\(\Delta x^{2}\)). In contrast to Equation (14), with Equation (15) the fact that it is not possible to rearrange to obtain an algebraic formula for \(\varnothing_{n}(i)\) in terms of its neighbors \(\varnothing_{n}\), \(\varnothing_{n}\) (\(i+1\)),\(\varnothing_{n}\) (\(i-1\)) y \(\varnothing_{n-1}\) (or simply adding 1 to each spatial subscript in Equation (15)) shows that \(\varnothing_{n}\) (\(i+1\)), depends on \(\varnothing_{n}\) (\(i+2\)), and \(\varnothing_{n}(i)\). Thus, Equation (15) is a system of equations for the values of \(\O\) at the internal nodes of the spatial grid (\(i=2\), \(3\),..., N \(-1\)).  
\[\frac{\varnothing(x_{i},t_{n+1})-\varnothing(x_{i},t_{n})}{\Delta t}=\frac{1}{ 2}[d(x_{i},t_{n+1})+d(x_{i},t_{m})] \tag{15}\]  
The approximation error for the explicit schematic is O (\(\Delta t+\Delta x^{2}\)) and the implicit Crack Nicolson scheme has an error of the order of O (\(\Delta t^{2}+\Delta x^{2}\)). If the solution of the equation tends to the solution of the original differential equation when \(\Delta t\to 0\) and \(\Delta x\to 0\), the scheme in differences is convergent [1; 4]. If the computational error produced at a certain time step decreases or at least does not increase when moving to the next time step, the scheme is stable.  
For example, in the case of diffusion (I), the Crank-Nicolson discretization is:  
\[\frac{\varnothing_{1}^{m+1}-\varnothing_{i}^{m}}{\Delta t}=\frac{\alpha}{2( \Delta x)^{2}}\Big{(}\Big{(}\varnothing_{i+1}^{m+1}-\varnothing_{i}^{m+1}+ \varnothing_{i-1}^{m+1}\Big{)}+\big{(}\varnothing_{i+1}^{m}-\varnothing_{i}^{m }+\varnothing_{i-1}^{m}\big{)}\Big{)} \tag{16}\]  
The Crank-Nicolson scheme is implicit, and one must solve a system of equations for the variable \(\O\) at each time step. The system of equations is identical to transient problems in one spatial dimension, and the difference in computational cost is not significant. How  
Figure 5: Crank-Nicolson scheme. Unknown values are indicated with black circles and known values with white circles.  
ever, for transient problems with two or three spatial dimensions, the computational effort per forward time step is much larger than the computational effort per centered time step of difference. However, the stability is higher than forward. In problems in one, two, or three dimensions, CN generally provides a computational advantage [38].