A simple method for the heat equation 23.2 involves approximating the timederivative∂/∂t by the scaled forward difference in time, k−1 t, and the secondorder space derivative ∂2/∂x2 by t
Trang 1Fig 23.2 Finite difference grid{ jh, ik} N x , N t
j =0,i=0 Points are spaced at a distance
of h apart in the x-direction and k apart in the t-direction.
A simple method for the heat equation (23.2) involves approximating the timederivative∂/∂t by the scaled forward difference in time, k−1 t, and the secondorder space derivative ∂2/∂x2 by the scaled second order central difference in
whereν := k/h2is known as the mesh ratio.
Suppose that all approximate solution values at time level i , {U i
j}N x
j=0, are
known Now note that U i+1
0 = a((i + 1)k) and U i+1
N x = b((i + 1)k) are given by
the boundary conditions (23.4) Equation (23.7) then gives a formula for
comput-ing all other approximate values at time level i + 1, that is, {U i+1
j }N x−1
j=1 Since we
Trang 2Fig 23.3 Stencil for FTCS Solid circles indicate the location of values that must be known in order to obtain the value located at the open circle.
are supplied with the time-zero values, U0j = g( jh) from (23.3), this means that
the complete set of approximations{U i
j}N x , N t
j =0,i=0can be computed by stepping
for-ward in time The method defined by (23.7) is known as FTCS, which stands for
forward difference in time, central difference in space Figure 23.3 illustrates the
stencil for FTCS Here, the solid circles indicate the location of values U i j−1, U i j and U i j+1that must be known in order to obtain the value U i j+1located at the opencircle
We may collect all the interior values at time level i into a vector,
Trang 3Here, FU i denotes a matrix–vector product.
Computational example Figure 23.4 illustrates a numerical solution produced
by FTCS on the problem of Figure 23.1, with T = 3 We chose N x = 14 and
N t = 199, so h = π/14 ≈ 0.22 and k = 3/199 ≈ 0.015, giving ν ≈ 0.3 The
numerical solution appears to match the exact solution, shown in Figure 23.1.Computing the worst-case grid error, max0≤ j≤N x ,0≤i≤N t |U i
j − u( jh, ik)|,
pro-duced 0.0012, which confirms the close agreement As can be seen from
Figure 23.4, we used a grid where k is much smaller than h – we divided the axis into only 15 points, compared with 200 points on the t-axis In Figure 23.5
x-we show what happens if x-we try to correct this imbalance Here, x-we reduced N t
to 94, so k ≈ 0.032 and ν ≈ 0.63 We see that the numerical solution has veloped oscillations that render it useless as an approximation to u (x, t) Taking
de-smaller values of N t , that is, larger timesteps k, leads to more dramatic
oscilla-tions In Section 23.7 we develop some theory that explains this behaviour Wefinish this section by deriving an alternative method that is more computationallyexpensive, but does not suffer from the type of instability seen in Figure 23.5.♦
Replacing the forward difference in time in FTCS by a backward differencegives
k−1∇tU i j − h−2δ2
x U i j = 0,
Trang 4initial and boundary conditions (23.5) Here N x = 14 and N t = 199, so ν ≈ 0.3.
or, in more detail,
It is convenient to write this as a process that goes from time level i to i+ 1, that
is, to increase the time index by 1, which allows the method to be written
j=1 Using the vector notation (23.8), Exercise 23.4 asks you to show
that the recurrence (23.10) for BTCS may be written
BU i+1= Ui + qi , for 0 ≤ i ≤ N t − 1, (23.11)
Trang 5initial and boundary conditions (23.5) Here N x = 14 and N t = 94, so ν ≈ 0.63.
where the matrix B has the form
Trang 6Fig 23.6 Stencil for BTCS Solid circles indicate the location of values that must be known in order to obtain the value located at the open circle.
The formulation (23.11) reveals that, given U i , we may compute U i+1by
solv-ing a system of linear equations This is a standard problem in numerical analysis,see Section 23.9 for references
Computational example Figure 23.7 gives the BTCS numerical solution for
the problem in Figure 23.1, with T = 3 We used N x = 14 and N t = 9, so
h = π/14 ≈ 0.22 and k = 3/9 ≈ 0.33, giving ν ≈ 6.6 The numerical solution
agrees qualitatively with the exact solution in Figure 23.1, and we found thatthe worst-case grid error, max0≤ j≤N x ,0≤i≤N t |U i
j − u( jh, ik)|, was a respectable
where all functions∂u/∂t, ∂2u /∂t2, etc., are evaluated at x = jh, t = ik Since u
satisfies the PDE (23.2), we have
Trang 723.7 Von Neumann stability and convergence 247
initial and boundary conditions (23.5) Here N x = 14 and N t = 9, so ν ≈ 6.6.
The expansion (23.14) shows that the local accuracy of FTCS behaves as O (k) + O(h2) Hence, FTCS may be described as first order in time and second order in space.
For BTCS, the local accuracy is defined as
with the functions evaluated at x = jh, t = ik Exercise 23.5 asks you to fill
in the details This shows that BTCS has the same order of local accuracy asFTCS
23.7 Von Neumann stability and convergence
A fundamental, and seemingly modest, requirement of a finite difference method
is that of convergence – the error should tend to zero as k and h are decreased to
zero It turns out that convergence is quite a subtle issue One aspect that must be
Trang 8addressed is the choice of norm in which convergence is measured; in the limit
k → 0, h → 0, we are dealing with infinite-dimensional vector spaces, so we lose
the property that ‘all norms are equivalent’
There is, however, a wonderful and very general result, known as the Lax alence Theorem, which states that a method converges if and only if its local ac-
Equiv-curacy tends to zero as k → 0, h → 0 and it satisfies a stability condition The
particular stability condition to be satisfied depends on the norm in which gence is measured We do not have the space to go into any detail on this matter,but readers with a feel for Fourier analysis may appreciate that the following sta-
conver-bility definition is related to the L2norm
Definition A finite difference method generating approximations U i j is stable in
the sense of von Neumann if, ignoring initial and boundary conditions, under the
substitution U i j = ξ i eiβ jh it follows that1 |ξ| ≤ 1 for all βh ∈ [−π, π] Here i
denotes the unit imaginary number ♦
To illustrate the idea, taking FTCS in the form (23.7) and substituting U i j =
Forβh ∈ [−π, π] the quantity sin2(1βh) takes values between 0 and 1, and hence
stability in the sense of von Neumann for FTCS is equivalent to
ν ≤ 1
1 A more general definition allows|ξ| ≤ 1 + Ck for some constant C, but our simpler version suffices here.
Trang 923.8 Crank–Nicolson 249Returning to our previous computations, we see that a stable value of ν ≈ 0.3
was used for FTCS in Figure 23.4, whereas Figure 23.5 went beyond the stabilitylimit, withν ≈ 0.63 In practice, FCTS is only useful for ν ≤ 1
2 If we consider
refining the grid, that is reducing h and k to get more accuracy, then we do so while
respecting this condition It is typical to chooseν, say ν = 0.45, and consider the limit h → 0 with fixed mesh ratio k/h2 = ν In this regime, k tends to zero much more quickly than h.
Exercise 23.6 asks you to show that BTCS is unconditionally stable, that is,
stability in the sense of von Neumann is guaranteed for allν > 0 This is
consis-tent with Figure 23.7, where a relatively large value ofν did not give rise to any
j = 0.
This finite difference formula has an appealing symmetry However, we have duced points that are not on the grid We may overcome this difficulty by applyingthe time averaging operator,µ t, on the right-hand term, to get a new method
This is Crank–Nicolson The stencil is shown in Figure 23.8 Because of its
inher-ent symmetry, the method has local accuracy O (k2) + O(h2) Exercise 23.8 asks
you to confirm this Crank–Nicolson has two features in common with BTCS.First, it is implicit, requiring a system of linear equations to be solved in order to
compute Ui+1from Ui The equations may be written
Trang 10Fig 23.8 Stencil for Crank–Nicolson Solid circles indicate the location of ues that must be known in order to obtain the value located at the open circle.
Trang 1123.9 Notes and references 251see Exercise 23.9 Second, it is stable in the sense of von Neumann for allν > 0,
see Exercise 23.10 The extra order of local accuracy in time makes it a popularchoice Exercise 23.11 gives an alternative derivation of the method
Computational example Recall that the BTCS computation in Figure 23.7
pro-duced a worst-case grid error of 0.055 Switching to Crank–Nicolson, we find
that the error reduces to 0.0019, which reflects the higher order of local accuracy
23.9 Notes and references
This chapter was designed to give only the most cursory introduction to finitedifferences Excellent, accessible texts that give much more detail and, in par-ticular, describe methods for solving the linear systems such as (23.11) and(23.19), and also do justice to the Lax Equivalence Theorem, include (Iserles,1996; Mitchell and Griffiths, 1980; Morton and Mayers, 1994; Strikwerda,1989) A freely available work of similarly high quality is the unpublished
text, Finite Difference and Spectral Methods for Ordinary and Partial ential Equations, 1996, by Lloyd N Trefethen, which is downloadable from
Differ-http://web.comlab.ox.ac.uk/oucl/work/nick.trefethen/pdetext.html
Details of how to transform the Black–Scholes PDE (8.15) into standard heatequation form (23.2) can be found, for example, in (Nielsen, 1999, Section 6.7)
and (Wilmott et al., 1995, Section 5.4).
Finite difference methods represent the most conceptually straightforward proach to solving a PDE numerically, and they appear to be the most popularchoice in the mathematical finance community However, it is worth pointing outthat there are other areas of science and engineering where numerical methods forPDEs have reached a greater level of maturity, and in many cases other techniques,
ap-most notably finite element methods, have found considerable favour.
E X E R C I S E S
23.1. Show that ∇ = ∇; that is, for any sequence {y m}, ∇ ym = ∇ym.
Similarly, establish the following identities relating finite difference ators:
oper-∇ = ∇ − ,
∇ = δ2,
0 = µδ,
0 = δµ,
Trang 122= δ2E ,
2= Eδ2.
23.2. Verify the Taylor series expansions in Table 23.1.
23.3. Verify that FTCS, (23.7), may be written in the form (23.9).
23.4. Verify that BTCS, (23.10), may be written in the form (23.11).
23.5. Using Table 23.1, show that the local accuracy of BTCS, defined in
(23.15), satisfies (23.16)
23.6. By copying the analysis that led to (23.17), show that BTCS is stable
in the sense of von Neumann for allν > 0.
23.7. Show that Crank–Nicolson, (23.18), can be expressed as
Deduce that the method is stable for allν > 0.
23.11. Suppose we take the average of the FTCS equation (23.9) and the
Show that this method is Crank–Nicolson (The second order accuracy
in time may now be understood by observing that averaging the local
accuracy expansions (23.14) and (23.16) causes the O (k) term to vanish.)
23.10 Program of Chapter 23 and walkthrough
The program ch23 implements BTCS for the heat equation (23.2) with initial and boundary ditions (23.5), and plots the solution in the style of Figure 23.7 It is listed in Figure 23.9 After initializing parameters, we set up the Nx-1 by Nx-1 array B, which has the form displayed in (23.12).
Trang 13con-23.10 Program of Chapter 23 and walkthrough 253
%CH23 Program for Chapter 23
Fig 23.9 Program of Chapter 23: ch23.m.
This is done with eye, diag and ones The command eye(Nx-1,Nx-1) sets up an identity matrix
Trang 14
two-diag(ones(Nx-2, 1),1) and diag(ones(Nx-2, 1),-1) correspond to
respectively The Nx-1 by Nx-1 array U is used to store the numerical solution; successive columns
hold the solution Uiin (23.8) at successive time levels The initial condition is inserted into the first column with U(:,1) = sin([dx:dx:L-dx]’); We then enter a for loop that steps forward in time Generally, if A and b are compatible two- and one-dimensional arrays, respectively, then A\b computes the solution x to the linear system A*x = b It follows that the line x = B\U(:,i); solves the required system (23.11), and U(:,i+1) = x; assigns this solution to the next column of U Note
that qi ≡ 0 in (23.11) because of the zero boundary conditions The line U = [bc;U;bc]; pads out
U by adding a row of zeros at the top and bottom, corresponding to those zero boundary conditions.
P R O G R A M M I N G E X E R C I S E S
P23.1 Using colon subarray notation, as inch16, or otherwise, alter ch23 so thatFTCS is used Toy with the stability constraintν ≤ 1
2
P23.2 Implement Crank–Nicolson on the heat equation and compare its accuracy
with that of FTCS and BTCS
Quotes
In order to solve this differential equation
you look at it till a solution occurs to you.
G E O R G E P O L Y A ´ , 1887–1985, source http://math.furman.edu/˜mwoodard/mquot.html Numerical theory for PDEs of evolution is sometimes presented in a deceptively simple way.
On the face of it, nothing could be more straightforward:
discretize all spatial derivatives by finite differences
and apply a reputable ODE solver,
without paying heed to the fact that, actually,
one is attempting to solve a PDE.
This nonsense has, unfortunately, taken root in many textbooks and lecture courses, which, not to mince words, propagate shoddy mathematics and poor numerical practice Reputable literature is surprisingly scarce,
considering the importance and depth of the subject.
A R I E H I S E R L E S (Iserles, 1996)
Trang 1523.10 Program of Chapter 23 and walkthrough 255 Spelling note #1: the name is ‘Nicolson’, not ‘Nicholson’.
L L O Y D N T R E F E T H E N, Finite Difference and Spectral Methods for Ordinary and
Partial Differential Equations, 1996; see Section 23.9.
Trang 17Finite difference methods for the Black–Scholes PDE
O U T L I N E
• Black–Scholes PDE in reverse time
• initial and boundary conditions
24.2 FTCS, BTCS and Crank–Nicolson for Black–Scholes
The Black–Scholes PDE (8.15) is typically augmented with a final time tion – examples that we have seen include (8.16), (8.25), (17.1) and (19.2) Since
condi-convention (and every book on numerical PDEs) dictates that problems should be
specified in initial time condition form, we make the change of variable τ = T − t.
In this wayτ represents the time to expiry and runs from T to 0 when t runs from
0 to T Under this transformation the Black–Scholes PDE (8.15) becomes
∂V
∂τ −12σ2S2∂2V
∂ S2 − r S ∂V ∂ S + rV = 0. (24.1)
In this section we focus on European calls and puts The t = T condition for a
European call, (8.16), becomes theτ = 0 condition
C (S, 0) = max(S(0) − E, 0). (24.2)Similarly, the European put condition (8.25) changes to
P (S, 0) = max(E − S(0), 0). (24.3)
257
Trang 18Turning to boundary conditions, the European call and put involve the PDE on the
domain S ∈ [0, ∞] This presents a difficulty We must represent this range by a finite set of points A reasonable fix is to truncate the domain to S ∈ [0, L], where
L is some suitably large value Using (8.17) and (8.18), this gives call boundary
conditions
C (0, τ) = 0 and C (L, τ) = L. (24.4)Similarly, from (8.26) and (8.27) we obtain
P (0, τ) = Ee −rτ and P (L, τ) = 0 (24.5)for a European put
We are now able to use a grid{ jh, ik} N x , N t
j =0,i=0, as shown in Figure 23.2 Letting
denote the numerical solution at time level i , we have V0 specified by the
ini-tial data (24.2) or (24.3) and the boundary values V0i and V N i
x for all 1≤ i ≤ Nt
specified by the boundary conditions (24.4) or (24.5)
To obtain a generalized version of FTCS for the PDE (24.1) we use the fullcentral difference operator from Table 23.1 for the∂V/∂ S term and evaluate the
V term at ( jh, ik) to get the difference equation