Quickly add a free MyWikiBiz directory listing!
MyWikiBiz, Author Your Legacy — Thursday December 12, 2013
In the mathematical subfield 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, implicit in time, and 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 to the square of space step is large (typically larger than 1 / 2). 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 central difference in space, and the trapezoidal rule in time, giving second-order convergence in time. Equivalently, it is the average of forward Euler and backward Euler in time. For example, in one dimension, if the partial differential equation is
The function F must be discretized spatially with a central difference.
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, avoiding a costly full matrix inversion.
Example: 1D diffusion
The Crank-Nicolson method is often applied to diffusion problems. As an example, for linear diffusion,
whose Crank-Nicolson discretization is then:
or, letting :
A quasilinear equation, such as (this is a minimalistic example and not general)
would lead to a nonlinear system of algebraic equations which could not be easily solved as above; however, it is possible in some cases to linearize the problem by using the old value for a, that is instead of . Other times, it may be possible to estimate using an explicit method and maintain stability.
Example: 1D diffusion with advection for steady flow, with multiple channel connections
This is a solution usually employed for many purposes when there's a contamination problem in streams or rivers under steady flow conditions but the only information is given in one dimension. Sometimes is needed some kind of info or data about the behavior in the cross section so this is one of many ways to get some extra data without getting into a model of two or three dimensions.
What is modeled here is the concentration of a solute contaminant in water for example. This problem is composed by three parts the known diffusion equation (Dx chosen as constant), plus an advective component which means the system is evolving in space due to a velocity field (Ux which in this case we choose as constant). The third part of the equation is due to a lateral interaction between longitudinal channels (k).
where C is the concentration of the contaminant subscripts N & M correspond to previous and next channel.
The Crank-Nicolson scheme of solution (knowing i as position in space & j as time interval) comes like this:
Now we create the following constants that will be helpful doing the algebra:
replacing <1>,<2>,<3>,<4>,<5>,<6>, α, β & λ into <0> and putting the terms for the new time in the left (j+1) and the term for the present time in the right (j) we get this expression:
in the case we are trying to model the first channel, it can only be in contact with the following channel (M), so the expression is simplified by something like this:
in the same way if the model is for the last channel, it can only be in contact with the previous channel (N), so the expression is simplified by something like this:
in order to solve this kind linear of system of equations we must now see that boundary conditions must be given first to the beginning of the channels:
: initial condition for the channel at present time step
: initial condition for the channel at next time step
: initial condition for the previous channel to the one analized at present time step
: initial condition for the next channel to the one analized at present time step
and for the last cell of the channels (z) we must see that the most convenient condition becomes an adiabatic one which means
condition satisfied if and only if (regardless of a null value)
Now let's see what happens if the problem is solved (in a matrix form) using 3 channels and 5 nodes (including the initial boundary condition) we can express this as a linear system problem like this one:
now we must realize that AA and BB should be arrays made of 4 different subarrays (remember that only three channels are considered for this example but it covers the main part discussed above).
where the elements mentioned above correspond to the next arrays and an additional 4x4 full of zeros. Must be noted that the AA and BB arrays had size 12x12:
The d vector is just for the assignment of the boundary conditions. In this example is a 12x1 vector:
One must the iterate the following equation to solve the system for any time
Example: 2D diffusion
When extending into two dimensions on a uniform Cartesian grid, the derivation is similar and the results may lead to a system of band-diagonal equations rather than tridiagonal ones. The two-dimensional heat equation
can be solved with the Crank-Nicolson discretization of
assuming that a square grid is used so that Δx = Δy. This equation can be simplified somewhat by rearranging terms and using the CFL number
For the Crank-Nicolson numerical scheme, a low CFL number is not required for stability, however it is required for numerical accuracy. We can now write the scheme as:
Application in financial mathematics
Because a number of other phenomena can be modeled with the heat equation (often called the diffusion equation in financial mathematics), the Crank-Nicolson method has been applied to those areas as well. Particularly, the Black-Scholes option pricing model's differential equation can be transformed into the heat equation, and thus option pricing numerical solutions can be obtained with the Crank-Nicolson method. The importance of that comes from the extensions of the option pricing model that are not able to be represented with a closed form analytic solution; they can still offer numerical solutions. However, for non-smooth final conditions (which happen for most financial instruments), the Crank-Nicolson method is not satisfactory as numerical oscillations are not damped. For vanilla options, this results in oscillation in the gamma value around the strike price. Therefore, special damping initialization steps are necessary (e.g., fully implicit finite difference method).
- Crank J. and Nicolson P. (1947) "A practical method for numerical evaluation of solutions of partial differential equations of the heat conduction type". Proceedings of the Cambridge Philosophical Society 43, 50–64.
- Wilmott P., Howison S., Dewynne J. (1995) The Mathematics of Financial Derivatives:A Student Introduction. Cambridge University Press.