A Critique of the Crank Nicolson Scheme Strengths and Weaknesses for Financial Instrument Pricing

Daniel J. Duffy c Datasim Component Technology BV 2004

Summary solution of a very simple system of linear equations (namely, a tridiago- nal system) at every time level. In this article we apply the Method (FDM) to the Black The Crank Nicolson method has become one of the most popular Scholes equation. In particular, we analyse the famous Crank Nicolson finite difference schemes for approximating the solution of the Black method that is very popular in financial . Unfortunately, the Scholes equation and its generalisations (see for example, Tavella 2000, method does not always produce accurate results and it is the objective Bhansali 1998). The method is essentially a second-order approximation of this article to enumerate the problems and then to propose more to the time that appears in the Black Scholes equation and this robust finite difference schemes. More detailed accounts of the current property, plus the fact that the method is stable and is easy to program problem can be found in Duffy 2001 and Duffy 2004. makes it very appealing in practical applications. Numerous articles and publications in the financial engineering literature use Crank Nicolson as the de-facto scheme for time discretisation. Unfortunately, the method 1 A short History of Crank Nicolson breaks down in certain situations and there are better and more robust in Financial Engineering alternatives that have been documented in the and computational fluid dynamics literature. To this end, we wish to discuss The Crank Nicolson finite difference scheme was invented by John the shortcomings of the method and how they can be resolved. Crank and Phyllis Nicolson. They originally applied it to the heat equa- tion and they approximated the solution of the on some finite grid by approximating the in space x and time t by 2 What is Crank Nicolson, really? finite differences. Much earlier, Richardson devised a finite difference The one-factor Black Scholes equation for a derivative quantity V depend- scheme that was easy to compute but was numerically unstable and ing on an underlying S is given by thus useless. The instability was not recognized until Crank, Nicolson and others carried out lengthy numerical calculations. In short, the ∂V 1 ∂ 2V ∂V − + σ 2S2 + rS − rV = 0 (1) Crank Nicolson method is numerically stable and it only requires the ∂t 2 ∂S2 ∂S

68 Wilmott magazine TECHNICAL ARTICLE 3

In general, this equation must be augmented by other boundary and ini- Then the Crank Nicolson method is defined as follows: tial conditions in order to ensure a unique solution. In some cases it may   1 1 be possible to come up with an exact solution to this problem but in the n+ n+ n+1 n 2 2 V − V  V + − V −  most general cases we must resort to some kind of approximate method. − j j + rjS  j 1 j 1  In this article we discuss the Finite Difference Method and it is based on k 2S the tactic of replacing the continuous derivatives in (1) by divided differ-   1 1 1 n+ n+ n+ ences defined on a discrete mesh (see Richtmyer 1967). 2 − 2 + 2 (5) 1  Vj+1 2Vj Vj−1  In order to motivate the Crank Nicolson scheme let us first consid- + σ 2j2S2   2 S2 er the following fully implicit scheme that we define by replacing deriva- 1 tives with respect to S by three-point divided differences and the n+ = 2 derivative with respect to t by one-sided differences. The scheme is τ Vj given by Again, this is a system that can be posed in the form (3) and hence can be n+1 n n+1 n+1 solved by standard matrix solver techniques at each time level. V − V V + − V − − j j + rjS j 1 j 1 The Crank Nicolson method has gained wide acceptance in the finan- k 2S cial literature and it seems to be the de-facto finite difference scheme for n+1 n+1 n+1 1 V + − 2V + V − (2) one-factor and two-factor Black Scholes equations. It has second order + σ 2j2S2 j 1 j j 1 2 S2 accuracy in the parameter k and is stable. Unfortunately, it has been known for some considerable time (Il’in 1969) that centred differencing = n+1 rVj schemes in space combined with averaging in time (what essentially CN is in this context) lead to spurious oscillations in the approximate solu- In general, the values of V at time level n are known and the values at tion. These oscillations have nothing to do with the physical or financial time level n + 1 need to be calculated. Rewriting (2) gives the new form problem that the scheme is approximating.   an+1 Vn+1 + bn+1 Vn+1 + cn+1Vn+1 = Fn+1  j j−1 j j j j+1 j 3 The Problems with Crank Nicolson:   where    the Details  n+1 = 1 2 2 − krj  aj 2 σ j k 2 We now give a detailed discussion of Crank Nicolson and when it breaks n+1 (3)  b =− 1 + σ 2j2k + r down or fails to live up to its perceived expectations.  j     cn+1 = 1 σ 2j2k + krj  j 2 2 3.1 A Critique of Crank-Nicolson  n+1 =− n Fj Vj The Crank Nicolson method has become a very popular finite difference scheme for approximating the Black Scholes equation. This is a tridiagonal scheme that we solve at each time level using stan- This equation is an example of a convection-diffusion equation and it has dard matrix solvers, for example LU decomposition (see Isaacson 1966, been known for some time that centred-difference schemes are inappro- Duffy 2004). The fully implicit scheme has a number of desirable fea- priate for approximating it (Il’in 1969, Duffy 1980). In fact, many inde- tures. First, it is stable and there is no restriction on the relative sizes of pendent discoveries of novel methods have been made in order to solve the time mesh size k and the space mesh size S. Furthermore, no spuri- difficult convection-diffusion problems in fluid dynamics, atmospheric ous oscillations are to be seen in the solution or its  (as is the case with pollution modelling, semiconductor equations, the Fokker-Planck equa- some other methods). A disadvantage is that it is only first order accurate tion and groundwater transport (Morton 1996). in k. On the other hand, this can be rectified by using extrapolation and The main problem is that traditional finite difference schemes start to this results in a second-order scheme. oscillate when the coefficient of the second derivative (the diffusion term) is The Crank Nicolson is a variation of (2) but in this case we take aver- very small or when the coefficient of the first derivative (the convection ages of V at levels n and n + 1 when approximating the derivative with term) is large (or both). In this case, the mesh size h in the space direction respect to t. We define the quantity must be smaller than a certain critical value if we wish to avoid these oscil- lations. This problem has been known since the 1950’s (see de Allen 1955).   + 1 1 n 2 n+1 n We now discuss the Crank Nicolson from a number of viewpoints. For V ≡ V + V (4) ^ j 2 j j convenience and generality reasons, we cast the Black Scholes equation

Wilmott magazine 69 as a generic parabolic initial in the domain for example:

D = (A, B)X(0, T) where A < B: −α(T−t) σ(t) = σ0e

∂u ∂ 2u ∂u where σ0 and α are given constants. Lu ≡− + σ(x, t) + µ(x, t) + b(x, t)u = f (x, t) in D ∂t ∂x2 ∂x We speak of a singular perturbation problem associated with problem (6) = ∈ (6) u(x, 0) ϕ(x), x (A, B) when the coefficient of the second derivative is small (see Duffy 1980). In u(A, t) = g0(t), u(B, t) = g1(t), t ∈ (0, T) this case traditional finite difference schemes perform badly at the boundary layer situated at x = 0. In fact, if we formally set volatility to zero In this case the time variable t corresponds to increasing time while the in equation (7) we get a so-called weakly stable difference scheme (see space variable x corresponds to the underlying asset price S. We specify Peaceman 1977) that approximate the first-order hyperbolic equation Dirichlet boundary conditions on a finite space interval and this is a ∂u ∂u common situation for to several kinds of exotic options, for example bar- − + µ + bu = f ∂t ∂x rier options. Actually, the system (6) is more general than the original Black Scholes equation. This has the consequence that the initial errors in the scheme are not dis- sipated and hence we can expect oscillations especially in the presence of 3.2 How are Derivatives approximated? rounding errors. We need other one-sided schemes in this degenerate case There are two kinds of independent variables associated with the one-fac- (Peaceman 1977, Duffy 1977). tor Black Scholes as can be seen in (6). These correspond to the x and t 3.3 Boundary Conditions variables. We concentrate on the x direction for the moment. We discre- tise in this direction using centred differences at the point (jh, nk): In general, we distinguish three kinds of boundary conditions:  2 n − n + n • Dirichlet (as seen in the system (6))  ∂ u u + 2u u −  ∼ j 1 j j 1 • Neumann conditions ∂x2 h2 • Robin conditions  n n  ∂u u + − u −  ∼ j 1 j 1 ∂x 2h The last two boundary conditions involve the first derivative of the unknown u at the boundaries. We must then decide on how we are going Using this knowledge we can apply the Crank-Nicolson method to (6), to approximate this derivative. We can choose between first-order accu- namely: rate one-sided schemes and ghost points (Thomas 1998) that produce a sec-  1 1 1 ond-order approximation to the first derivative. We must thus be aware  n+ n+ n+  n+1 − n 1 2 − 2 + 2  uj uj n+ uj+1 2uj uj−1 of the fact that the low-order accuracy at the boundary will adversely  − + σ 2  k j h2 impact the second-order accuracy in the interior of the region of interest.  1 1 To complicate matters, some models have a boundary condition involv- n+ n+ 1 2 2 (7) n+ u + − u −  2 j 1 j 1 ing the second derivative of u or even a ‘linearity’ boundary condition  + µ  j 2h (see Tavella 2000).   1 1 1  n+ n+ n+ Finally, the boundary conditions may be discontinuous. We may + 2 2 = 2 bj uj fj resort to nonuniform meshes to accommodate the discontinuities. This strategy will also destroy the second-order accuracy of the Crank- A bit of simple arithmetic allows us to rewrite (7) in the standard form: Nicolson method. The conclusion is that the wrong discrete boundary n n+1 + n n+1 + n n+1 = n conditions adversely affect the accuracy of the finite difference scheme. aj uj−1 bj uj cj uj+1 Fj (8) n 3.4 Initial Conditions Fj known quantity It is well-known that discontinuous initial conditions adversely impact Of course, this system of equations can be posed in the form of a matrix the accuracy of finite difference schemes (see Smith 1978). In particular, system. A number of researchers have examined such systems in con- the solution of the difference schemes exhibits oscillations just after t = 0 junction with convection-diffusion equations (for example, Farrell 2000, but the solution becomes more smooth as time goes on. This has conse- Morton 1996). A critical observation is that if the coefficient an appearing j quences for options pricing applications because in general the initial in is not positive then the resulting solution will show oscillatory behav- condition (this is in fact a payoff function) is not always smooth. For iour at best or produce non-physical solutions at worst. example, the payoff function for a European call is: This will give problems in general for Black Scholes applications where the volatility is a decaying function of time (see van Deventer 1997), C = max(S − K, 0)

70 Wilmott magazine ^ 71 3 (9) (11) (10) (13) (12) so that the 1 ρ ). − 1 B J , ) − j A J x 1 ( ( f − ∈ ,..., ) ) J 1 B x = x ( ,..., , . j f f 1 = A , that is 1 1 ( j = ), = ,..., j + − x j 1 u x x ( 0 for ) , 2 2 | b h x e e σ = k ( ≤ f µ , 2 in j | b j = f J ) = 1 j , 1 x + b ( β x x 0 ,..., = β b 1 − − j coth e e ), = = = dx = U , du j 0 k j x j h ) ) 0 b ) σ + − uniformly stableuniformly . x U B = B µ 2 x x j 1 0 ( TECHNICAL ARTICLE TECHNICAL µ( ( h are positive constants. We now approxi- + e e j σ max u β D µ( u j 1 2 = µ α> dx = du 1 α µ U , µ , β = = + j 0 0 0 ρ µ ≥ J x D β + β 2 = u j ) j U |+ 2 + J µ x 1 coth and U = ), µ dx d = , j U 2 β u − 0 ) ) x h ) + 2 j σ coth x β 2 D will be used when developing fitted difference A j A dx d µ ( ,µ( ( σ( + U , u σ( σ u = 0 0 ρ |+| D − 0 = = β 0 D are given continuous functions, and are given ≥ β j h σρ U j + σ = ) b ρ D x 0 h j is the hyperbolic cotangent function defined cotangent is the by hyperbolic |≤| ρ U j σ( x and U | µ is a so-called fitting (this 1 factor in to is equal identically factor , ρ coth σ The solution of scheme (12) is The solution of scheme (12) where solutions of (9) and (10) are identical at the mesh-points. Some easy arith-theeasy at Some identical mesh-points. are (10) and (9) of solutions that metic shows where The fitting factor is defined by: (11) The fitted difference scheme that approximates boundary value problem: We We now state the following fundamental results (see Il’in 1969, Duffy 1980). the case of the centred difference scheme. We now choose schemes for variable coefficient problems. In particular, we discuss the problem: following where mate (9) by the (9) by difference scheme definedmate as follows: Here we assume that where ) ) 0 0 ( ( 0 1 g g K K = = ≤ > ) ) S S 0 0 , , , , 0 1 A B ( ( u u is the stock price. Its derivative is given = S ≡ ≡ : S C ) ) ∂ ∂ B A ϕ( ϕ( with each other. By we mean compatibility, that the magazine is the strike price and compatibility conditions compatibility compatible K is continuous as we approach is thecontinuous as we boundaries, sat- thenmust we ) t Failure Failure to take these conditions into account in a finite difference This derivative is discontinuous and in general we can expect to get to expect can we general in and discontinuous is derivative This , x ( Wilmott scheme will lead to inaccuracies at the corner points of the out. On the damped upside, theinterest. discontinuities are quickly region of solution is smooth at the corners (A, 0) and (B, 0) of the region of inter- of theregion of 0) (B, and 0) the(A, cornerssmoothat is solution est and we thus demand that the solution is the same irrespective of the direction from which we approach the corners. If we assume that bad accuracy at the points of discontinuity (in this case, at the strike price where at-the-money issues play an important role). It is possible to determine mathematically what the accuracy is in some special thatus things are show experiments numerical but (Smithcases 1978) going wrong as well. Of course, if the option price is mated there badly is not approxi- much hope of getting good approximations to the delta and gamma. This statement is borne out in practice. Another source of annoyance is that the boundary and initial conditions may not be by the jump function: theby jump Fitted Finite Difference Schemes 4.1 Schemes Difference Class of Robust A new Exponentially fitted schemes are stable, have good convergence proper- ties and do not produce spurious oscillations. In order to motivate what an exponentially fitted difference scheme is, let us look at the simple 4 An Introduction to Exponentially 3.5 Stability Proving of stability theory Neumann uses theMuch of the prove von literature to finite difference schemes (Tavella 2000). This theory was developed by of fatherthemathematician, Hungarian-American a Neumann, von John the modern computer and probably one of the greatest brains of the twentieth speaking, century. Strictly the von Neumann approach is only valid for constant coefficient, linear initial value problems. The Black Scholes equation does not fall under this category. Furthermore, much work has been done in the engineering field to prove stability in other ways, for example using the maximum principle and matrix theory the for stability Neumann von of discussion A Duffy 1980). 1996, (Morton constant coefficient, linear convection-diffusion equation can be found in Thomas 1998. u where isfy the Furthermore, scheme (12) is monotone in the sense that the matrix rep- We replace the derivatives in this operator by their corresponding divid- h resentation of (12) ed differences and we define the fitted operator Lk by = Un+1 − Un AU F h n j j n+1 n+1 n+1 n+1 n+1 n+1 L U ≡− + ρ D+ D− U + µ D U + b U (15) k j k j j j 0 j j j t t where U = (U1,...,UJ−1), F = (f1,...,fJ−1) and   Here we use the notation ...... 0 n+1   ϕ = ϕ(x , t + ) in general  ..  j j n 1  . a +   j,j 1    =  .. ..  and A  . a j,j .  (14)   µn+1h µn+1h  ..  n+1 j j  a j,j−1 .  ρ ≡ coth j 2 2σ n+1 . . j 0 .. .. We now formulate the fully-discrete scheme that approximates the ini- ρh j µj tial boundary value problem (6): a , − = − > 0 always j j 1 h2 2h { n} Find a discrete function Uj such that h 2ρj a =− + b < 0 always + j,j 2 j h n = n 1 = − = − h Lk Uj fj , j 1,...,J 1, n 0,...,N 1 ρ h µ j j n n a j,j+1 = + > 0 always U = g (t ), U = g (t ), n = 0,...,N (16) h2 2h 0 0 n J 1 n 0 = = − Uj ϕ(xj), j 1,...,J 1 produces positive solutions from positive input. Sufficient conditions for a difference scheme to be monotone have This is a two-level implicit scheme. We wish to prove that scheme (16) been investigated by many authors in the last 30 years; we mention the is stable and is consistent with the initial boundary value problem (6). work of Samarski 1976 and Stoyan 1979. We prove stability of (16) by the so-called discrete maximum principle Stoyan also produced stable and convergent difference schemes for instead of the von Neumann stability analysis. The von Neumann the convection-diffusion equation producing results and conclusions approach is well known but the discrete maximum principle is more gen- that are similar to the author’s work (see Duffy 1980). eral and easier to understand and to apply in practice. It is also the de- Let u and U be the solutions of (11) and (12), respectively. Then facto standard technique for proving stability of finite difference and finite element schemes (see Morton 1996, Farrell 2000). |u(xj) − Uj|≤Mh n h n ≤ Lemma 1 Let the discrete function wj satisfy Lk wj 0 in the interior of the mesh where M is a positive constant that is independent of h and σ (Il’in (1969). n ≥ with wj 0 on the boundary . The conclusion is that the fitted scheme (12) is stable, convergent and n ≥ ∀ = = Then wj 0, j 0,...,J; n 0,...,N. produces no oscillations. In particular, the scheme ‘degrades gracefully’ h n ≤ to a well-known stable schemes when σ tends to zero. Proof: We transform the inequality Lk wj 0 into an equivalent vector n = t n n inequality. To this end, define the vector W (w1,...,wJ−1). Then the inequality Lhwn ≤ 0 is equivalent to the vector inequality 5 Exponentially Fitted Schemes k j for the Black Scholes Equation AnW n+1 ≥ W n (17) We discretise the rectangle [A, B] × [0, T] as follows: where   ...... A = x < x <...

72 Wilmott magazine ^ 73 3 1 1 uses the + + n n j j f f 0 = = 1 → 1 1 + + + n µ j n n j j f U U 1 1 = + + 1 n n 0 0 j j + b b n j U + + n h j 1 n µ> µ< j σ ) ) + 1 1 µ 2 n j 1 if if + + b − n n j j h h 1 2 2 U U + µ µ 1 coth = h h 0 − − + − + h x n 1 1 j 1 n j 0 2 + + → U + n n µ j j − = U U µ 0 → D ( ( coth h σ + → 1 1 x σ TECHNICAL ARTICLE TECHNICAL lim σ µ 2 D + + n n 0 1 j j = + µ µ → n x lim j n j σ + + coth ρ 0 n n j j h + 2 U U → µ n j lim σ 0 U − − k k → 1 1 − lim σ + + k n n 1 j j + U U n j − − U − , , 0 0 (pure convection/drift) (pure diffusion/volatility) µ> µ< We We shall see that the ‘limiting’ difference schemes are well-known These limiting cases reassure us that the fitted method behaves well schemes and this is reassuring. To examine the first extreme case must we know what the limiting properties of the hyperbolic cotangent function are: 7 Exponential Fitting and Exotic Options and European exotic and plain of range a themethodapplied to have We American applied type it options. have various to we In kinds particular, Inserting this result theinto firstus gives the in equation first-order(16) scheme These are so-called implicit upwind schemes and are stable and conver- scheme fittedthethat conclude thus We 1993). Dautray (Duffy1977, gent degrades to an acceptable scheme in the limit. The case the equation reduces to (16) Then the first in system equation This is a standard approximation to pure diffusion problems and such textbooks. numerical analysis standard in schemes can be found values. ‘extreme’ parameter for 6 Volatility Problems with Small We now examine some ‘extreme’ cases in system (16). In particular, we examine the cases use the formula We formula (18) is inde- M and Crank x is non-singular n . A σ . σ and ) k ¯ D k k , k and  h n j 1 + k k  U − , h  k n ( j h h min n ± j h 2 µ M 0 + 2 µ + 0 for all j and n has non-positive off-diagonal ele- m n j + ≥ b  n β N + ≤ |≤ + n 1 2 j A n j n − n j 2 h − j ρ β N U ) h ρ w n  n j h k 2 mon ρ − L A N in D for all j and n h |≤− − − ( 2 ) n j =− n    t U |≤ | n |≤ j , j n j j = n = = w j x U f ( n | | n n j j j t r s u max | be the solutions of (6) and (16), respectively. be the solutions of (6) and (16), max max . } n j σ which proves the result. which proves U be the solution of scheme (16) and suppose that (16) be the solution of scheme { . Furthermore, ¯ } Q  n j and U in k { and magazine on , 0 ) h t 0 Let , ≥ is a constant thatis a constant is independent of x ≥ n ( j Define barrier function the discrete n u j w M w In particular, In it particular, is a scheme powerful for the Black-Scholes equation and its generalisations. techniques. and implementation Summarising, the of the advantages fitted scheme are: Let Then This result shows that convergence is assured regardless of the is assured regardless size of that convergence This result shows Then . No classical centred scheme example, differencing(for in • all values of for stable It is uniformly •(6). of solution exact the to converges solution Its oscillation-free. is It • It is easily programmed, especially if we use object-oriented design Wilmott and its inverse is positive: and its inverse σ Hence Then Proof: Using this result in (17) gives the desired result. gives Using this result in (17) Lemma 2 It is easy to show that the matrix pendent of where ments, has strictly positive diagonal elements and is irreducibly diago- nally dominant. Hence (see Varga 1962 pages 84-85) Nicolson in time) have error bounds of the form (18) where of barrier options (see Topper 1998, Haug 1998), for example: We now transform (19) to a first order system by defining a new vari- able v. The new transformed set of equations is given by: • Double barrier call options • Single barrier call options ∂u • Equations with time-dependent volatilities (for example, a linear a = v ∂ function of time) x ∂v ∂u • Asymmetric plain vanilla power call options = − cu− S • Asymmetric capped power call options ∂x ∂t (20) u(x, 0) = g(x) We have compared our results with those in Haug 1998 and Topper

1998 and they compare favourably (Mirani 2002). The main difference α0u(0, t) + α1v(0, t) = g0(t) between these types lies in the specific payoff functions (initial condi- β u(1, t) + β v(1, t) = g (t) tions) and boundary conditions. Since we are working with a specific 0 1 1 kind of parabolic problem these functions must be specified by us. For example, for a double barrier option we must give the value of the option We now see that we have to do with a first order system of equations with at these barriers while for a single barrier option we define the ‘down’ no derivatives on the boundaries! barrier at S = 0. Summarising, the exponentially fitted finite difference We now need to introduce some notation. First, we define average scheme gives good approximations to the option price and delta of the values for x and t coordinates as follows: above exotic option types. We have compared the results with Monte 1 Carlo, Haug 1998 and Topper 1998. ± = + ± xj 1/2 2 (xj xj 1) 1 t ± = (t + t ± ) 8 Uniform Approximation of the Greeks n 1/2 2 n n 1 It is well known by now that CN produces bad approximation to option and for general nets (in principle the approximations to u and v) by delta and gamma (see for example, Zvan 1997, Cooney 1999). Thus, we n = 1 n + n need to devise schemes that do give uniform approximation to option φj±1/2 2 (φj φj±1) sensitivities, especially in the vicinity of the strike price K. The exponen- ± ± φn 1/2 = 1 (φn + φn 1) tially fitted scheme (16) is a good candidate and more information can be j 2 j j found in Duffy 2001 and Cooney 1999. Finally, we define notation for divided differences in the x and t direc- 8.1 Is there more Hope? The Keller Scheme tions as follows:

In this section however, we give a short overview of the Box Scheme − − D φn = h 1(φn − φn ) (Keller 1971) that resolves many of the problems associated with Crank x j j j j−1 − n = −1 n − n−1 Nicolson. In short, we reduce the second-order Black Scholes equation to Dt φj kn (φj φj ) a system of first-order equations containing at most first-order deriva- tives. We then approximate the first derivatives in x and t by averaging in We are now ready for the new scheme. To this end, we use one-sided dif- a box. We motivate the box scheme by examining the generic parabolic ference schemes in both directions while taking averages and we thus initial boundary value problem in the space interval (0,1): solve for both u and v simultaneously at each time level: ∂u ∂ ∂u = a + cu+ S , 0 < x < 1, t > 0 an D− un = vn ∂t ∂x ∂x j−1/2 x j j−1/2 = − n−1/2 = − n − n−1/2 n−1/2 − n−1/2 u(x, 0) g(x), 0 < x < 1 (19) Dx vj Dt uj−1/2 cj−1/2 uj−1/2 Sj−1/2 (21) α u(0, t) + α a(0, t)u (0, t) = g (t) 0 1 x 0 1 ≤ j ≤ J, 1 ≤ n ≤ N β0u(1, t) + β1a(1, t)ux(1, t) = g1(t) The corresponding boundary and initial conditions are: Here u is the (unknown) solution to the problem that satisfies the self- adjoint equation in (19) and it must also satisfy the initial and boundary n + n = n conditions (note the latter contain derivatives of the unknown at the α0u0 α1v0 g0 1 ≤ n ≤ N (22) n + n = n boundaries of the interval).In general, the coefficients in (19) are func- β0uJ β1vJ g tions of both x and t.

74 Wilmott magazine ^ 75 3 by MSc Designing and McGraw-Hill Irwin , Proc. Cambridge Philos. (ISBN: 0-470-85509-6). Quart. J. Mech. Appl. Math., The AWK Programming Language Trans. Am. Math. 82, 421–439 On the Numerical Solution of Heat Conduction TECHNICAL ARTICLE TECHNICAL Ph.D. thesis Trinity College Dublin A practical method for numerical evaluation of solu- Relaxation Methods applied to determining the motion, , M.Sc. Thesis Trinity College Dublin, Ireland Mathematical Analysis and Numerical Methods for Uniform Numerical Methods for Problems with Initial and , Volume 6. Springer-Verlag Berlin On the Approximation of linear Operational Differential Equations Benchmarking the Black Scholes Equation by Finite Differences Benchmarking the Black Scholes Equation by Finite Pricing and Managing Exotic and Hybrid Options Designing and Implementing Financial Instrument Pricing using C++ Robust and Accurate Finite Difference Methods in Option Pricing: One Uniformly Convergent Difference Schemes for Problems with a Small Finite Elements for Mixed Initial Boundary Value Problems for Boole Press, Dublin, Ireland as it were. , working report Datasim www.datasim-component.com A modest proposal would be to robust investigate and effective alter- Duffy, D. 2004 Duffy, D. 2001 Duffy, D. 1980 van Deventer, D. R., K. Imai 1997 Financial Risk Analytics, McGraw-Hill Chicago Doolan, E. P. et al 1980 Douglas, J. and Rachford, H.H. 1955 Duffy, D. 1977 Dautray, R., J. L. Lions 1993 Cooney, M. 1999 Crank, J., and P. Nicolson, 1947 Crouzeix, M. 1975 Aho, A., Kernighan, B. and Weinberger, P. 1988 de Allen, D., R. Southwell 1955 Bhansali 1998 V. John Wiley and Sons Chichester Factor Models Parameter in the Leading Derivative Hyperbolic Systems of Equations Science and Technology Boundary Layers Equations in Two and Three Dimensions the Runge-Kutta Method, Doctorate Thesis, Paris VI University, France Library Series New York thesis Trinity College Dublin tions of partial differential equations of the heat-conduction type Soc., 43, 50-67, re-published in: John Crank 80th birthday special issue Adv. Comput. Math. 6 (1997) 207–226 Addison-Wesley in two dimensions, of a viscous fluid past a fixed cylinder 129–145 REFERENCES natives natives to the Crank Nicolson schemes. This will hopefully theimprove pool FDM gene Acknowledgements Permission to use some of the text in this article has been given by John Wiley publishers and is based on Daniel Duffy’s book The Author Daniel Duffy works for Datasim (www.datasim.nl), an Amsterdam-based and 1979 since IT in working been has He softwaredeveloper. and trainer with object-oriented technology since He 1987. received his M.Sc. and PhD theses (in numerical analysis) from Trinity College, Dublin. At pres- ent he is working on Finite Differences and C++ for instrument pricing at [email protected]. He can be contacted Implementing Financial Instrument Financial Implementing using C++ Pricing (24) (23) with second- x J ≤ j 1 2 1 2 − − ! ≤ n 0 n 1 n t g g 1 , = = =

2 1 2 1 2 / 1 − − n 0 n J − j v v dx x 1 1

α β N dg + + 1 2 ≤ 1 2 1 2 − 0 j − − n n 0 n J a u u ≤ 0 0 = α β 1 Discontinuities at t 1 2 − 0 j v magazine infamous spurious oscillation problem. Hedging applications that use CN will run the off at values in the risk of inaccuracy pay func- tion where this function is not smooth (for example, the strike price) Sometimes uniform meshes are not sufficient to approximate the exact solution in a boundary layer (small volatility) or with nasty pay-off functions (for example, binary options or barriers options with discrete and intermittent barriers). A good discussion of how Crank Nicolson breaks down for barrier options is given in Tavella 2000. schemes with implicit fully example than Nicolson, for Crank better (Crouzeix 1975). or Runge-Kutta extrapolation Splitting (ADI) methods and Alternating Direction Operator Implicit (see Janenko Peaceman Sun 1977, 1971, 1999). In these cases we see time discretisation. one possibility for that Nicolson is just Crank The box scheme has a number of very scheme has a number properties, desirable namely: The box a) it is simple, efficient and easy to program b) it is unconditionally • The standard von Neumann stability analysis fail to predict the • Second-order accuracy is lost when using non-uniform meshes. • There are finite difference schemes that are just as good as, or even •predictor-corrector, use we problems, multi-factor and two-factor For Wilmott For piecewise smooth tactic: piecewise boundaryFor use the following conditions we stable stable c) it approximates u and its partial derivative in We have discussed the popular Crank Nicolson method from a number of number a from method Nicolson Crank popular the discussed have We viewpoints. In particular, we have made an inventory of the situations from our expectations: or where it deviates where it breaks down 9 Conclusions order order accuracy. For the Black Scholes equation this means that we spu- of trace withoutcan delta option the and price option both approximate rious oscillation as is experienced with Crank Nicolson d) Richardson extrapolation is applicable and yields two orders of accuracy improve- ment per extrapolation (with nonuniform nets!) e) It supports data, coef- ficients and solutions that are only piecewise smooth. In a financial set- ting it is able to model piecewise smooth payoff functions. We then define condition as follows: initial the approximate Of course we are assuming that the mesh points are sitting on the dis- continuities! f) TECHNICAL ARTICLE 1

Farrell, Paul et al 2000 Robust Computational Techniques for Boundary Layers Chapman and Hall/CC Bota Raton Godunov, S. and Riabenki. V.S. 1987 Difference Schemes, An Introduction to the under- lying Theory North-Holland Amsterdam Haug, E. 1998 The Complete Guide to Option Pricing Formulas McGraw-Hill New York Il’in, A.M. 1969 Differencing Scheme for a with a small parameter affecting the highest derivative Mat. Zametki 6, 237–248 Isaacson, E. and Keller, H. 1966 Analysis of Numerical Methods John Wiley & Sons NewYork Janenko, N.N. 1971 The Method of Fractional Steps Springer-Verlag Berlin Keller, H. 1968 Numerical Methods for Boundary-Value Problems Blaisdell Publishing Company Waltham MA Keller, Herbert 1971 A new Difference Scheme for Parabolic Problems. Numerical Solution of Partial Differential Equations-II, Synspade 1970 (B. Hubbard, ed.) Lam, D. C. L., R. B. Simpson 1976 Centered Differencing and the Box Scheme for Diffusion Convection Problems (1976). Journal of Computational 22, 486–500 Levin, Alexander Two-Factor Gaussian Term Structure: Analytics, Historical Fit and Stable Finite-Difference Pricing Schemes, Lecture held at Courant Institute, New York University May 2000 Mirani, R. 2002 Application of Duffy’s Finite Difference Method to Barrier Options, Working Paper Datasim Education BV Amsterdam Morton, K., Numerical Solution of Convection-Diffusion Equations 1996. Chapman and Hall, London UK Peaceman, D. 1977 Numerical Reservoir Simulation Elsevier Richtmyer, R.D. and Morton, K.W. 1967 Difference Methods for Initial-Value Problems Interscience Publishers (John Wiley) New York. Reprint edition (1994) Krieger Publishing Company Malabar Press, W., Flannery, B., Teukolsky, S. and Vetterling, W. 1989 Numerical Recipes Cambridge University Press Roscoe, D. F. 1975 New Methods for the Derivation of Stable Difference Representations J. Inst. Maths. Applics 16, 291–301 Samarski, A. A. 1976 Some Questions from the General Theory of Difference Schemes Amer. Math. Soc. Trans. (2), Vol. 105 Seydel, R. 2003 Tools for Computational Finance Springer Berlin Smith, G. D. 1978 Numerical Solution of Partial Differential Equations: Finite Difference Methods Oxford University Press Stoyan, Gisbert 1979 Monotone Difference Schemes for Diffusion-Convection Problems ZAMM 59, 361–372 Strang, G. and Fix, G. 1973 An Analysis of the Prentice-Hall Englewood Cliffs NJ Sun, Y. 1999 High Order Methods for evaluating Convertible Bonds Ph.D. thesis University of North Carolina Tavella, D. and Randall, C. 2000 Pricing Financial Instruments, The Finite Difference Method John Wiley & Sons New York Thomas, J.W. 1998 Numerical Partial Differential Equations, Volume I Finite Difference Methods Springer New York Topper, Juergen 1998 Finite Element Modeling of Exotic Options Internal Report University of Hannover ISSN 0949-9962 van Deventer, D. R., K. Imai 1997 Financial Risk Analytics McGraw-Hill Chicago Varga, R. 1962 Matrix Iterative Analysis, Prentice Hall Inc. Englewood Cliffs NJ Wilmott, P., Dewynne, J., and Howison, S. 1993 Option Pricing Oxford Financial Press UK W Wilmott, P. Derivatives 1998 John Wiley & Sons Chichester Zvan, R. et al 1997 Robust numerical Methods for PDE Models of Asian Options Journal of Computational Finance Volume 1/Number 2, Winter 1997/1998

76 Wilmott magazine