Beruflich Dokumente
Kultur Dokumente
Abstract
In this project we present nite dierence methodologies (FD) to solve a one-dimensional parabolic partial derivation equation (PDE). This presentation is intended mainly for pedagogical purposes. We present only the core: equations needed for coding a FD solver and some guidance.
Contents
1 Finite-Dierence Discretization 2 Boundary conditions 2.1 Dirichlet boundary conditions . . . . . . . . . . . . . . . . . . 2.2 Neumann boundary conditions . . . . . . . . . . . . . . . . . . 2.3 Mixed boundary conditions . . . . . . . . . . . . . . . . . . . 3 Solving Matrix Equation 4 Interpolation 5 Free Boundary Problem 6 Implementation Strategy 7 Conclusions Bibliography 1 3 3 4 4 4 4 5 5 5 6
Finite-Dierence Discretization
We consider a general form of the one-dimensional parabolic equation (PDE) given by: V (x, t) 2 V (x, t) V (x, t) = a(x, t) + b(x, t) + c(x, t)V (x, t) + f (x, t) (1.1) t x2 x 1
We approximate PDE (1.1) in the bounded domain [xmin , xmax ][tmin , tmax ]. Let us denote Lh Vik := bk ak i k k k k Vi+1 2Vik + Vi1 + i Vi+1 Vi1 + ck Vik , i 2 h 2h (1.3)
(Vik+1 Vik ) = Lh Vik+1 + (1 )Lh Vik + fik+1 + (1 )fik . l We note that if = 0 we get the explicit nite-dierence scheme, = 0.5 we get the Crank-Nicolson implicit nite-dierence scheme, = 1 we get the fully implicit nite-dierence scheme.
(1.4)
When = 0.5 the method error is O(h2 , l2 ). Otherwise, the method error is O(h2 , l). The explicit method has disadvantage of certain stability conditions. The implicit methods are absolutely stable. Applying Lh for PDE (1.1), we get Vik+1 Vik = lak+1 (1 )lak i i k+1 k+1 k k Vi+1 2Vik+1 + Vi1 + Vi+1 2Vik + Vi1 + h2 h2 lbk+1 (1 )lbk i i k+1 k+1 k k + Vi+1 Vi1 + Vi+1 Vi1 + lck+1 Vik+1 + (1 )lck Vik + i i 2h 2h k+1 k + lfi + (1 )lfi . (1.5) Simplifying, we obtain a general form of theta-scheme discretization lak+1 lbk+1 2lak+1 lak+1 lbk+1 i i i i k+1 + Vi1 + 1 + lck+1 Vik+1 + i2 i h2 2h h2 h 2h (1 )lak (1 )lbk 2(1 )lak i i i k = Vi1 + 1 + (1 )lck Vik i 2 2 h 2h h (1 )lak (1 )lbk i i k + + Vi+1 + lfik+1 + (1 )lfik . h2 2h (1.6) 2
k+1 Vi+1
We introduce lak lbk i i, h2 2h k 2la Bik = 2i + lck , i h k k lb lai Cik = 2 + i , h 2h k Ri = (lfik+1 + (1 )lfik ). Ak = i Substituting these into (1.6), we get
k+1 k+1 Ak+1 Vi1 + (1 Bik+1 )Vik+1 Cik+1 Vi+1 i k k k = (1 )Ak Vi1 + (1 + (1 )Bik )Vik + (1 )Cik Vi+1 + Ri , i
(1.7)
(1.8)
i = 0, . . . , N. Thus we have N 1 equations with N + 1 unknowns. Two equations come from boundary conditions.
Boundary conditions
Boundary condition play an important role in FD discretization. We consider three most typical conditions.
2.1
k k We assume that V0k ja VN are given: V0k = 1 (tk ) and VN = 2 (tk ). The algorithm is as follows
[i = 0] V0k+1 = 1 (tk+1 )
k+1 k+1 k k [i = 1] (1 B1 )V1k+1 C1 V2k+1 = (1 + (1 )B1 )V1k + (1 )C1 V2k k + Ak+1 V0k+1 + (1 )Ak V0k + R1 1 1 [i = 2, ..., N 2] equation (1.8) k+1 k+1 k+1 [i = N 1] Ak+1 VN 2 + (1 BN 1 )VN 1 N 1 k+1 k+1 k k k k k k = (1 )Ak 1 VN 2 + (1 + (1 )BN 1 )VN 1 + CN 1 VN + (1 )CN 1 VN + RN 1 N k [i = N ] VN = 2 (tk )
2.2
[i = 0] V0k+1 = 1 + 1 V1k+1
k+1 k+1 [i = 1] (1 Ak+1 + 1 B1 )V1k+1 C1 V2k+1 1 k k k = ((1 )1 Ak + 1 + (1 )B1 )V1k + (1 )C1 V2k+1 + (R1 + 1 Ak+1 + (1 )1 Ak ) 1 1 1 [i = 2, ..., N 2] equation (1.8) k+1 k+1 k+1 k+1 [i = N 1] Ak+1 VN 1 + (1 BN 1 2 CN 1 )VN 1 N 1 k k k k = (1 )Ak 1 VN 2 + (1 + (1 )BN 1 + (1 )2 CN 1 )VN 1 N k+1 k k + (RN 1 + 2 CN 1 + (1 )2 CN 1 ) k k [i = N ] VN = 2 + 2 VN 1
2.3
We assume that V = 0. It follows that x2 k k k V0k = 2V1k V2k and VN = 2VN 1 VN 2 . The algorithm is as follows [i = 0] V0k+1 = 2V1k+1 V2k+1
k+1 k+1 [i = 1] (2Ak+1 + 1 B1 )V1k+1 + (Ak+1 C1 )V2k+1 1 1 k k k = (2(1 )Ak + 1 + (1 )B1 )V1k + ((1 )Ak + (1 )C1 )V2k + R1 1 1 [i = 2, ..., N 2] equation (1.8) k+1 k+1 k+1 k+1 k+1 [i = N 1] (Ak+1 + CN 1 )VN 2 + (1 BN 1 2CN 1 )VN 1 N 1 k k k k k k = ((1 )Ak 1 (1 )CN 1 )VN 2 + (1 + (1 )BN 1 + 2(1 )CN 1 )VN 1 + RN 1 N k k k [i = N ] VN = 2VN 1 VN 2
When > 0, we have to solve the matrix equation. The matrix has the tridiagonal form, which makes it possible to use explicit expressions for solving it. Another way is the Successive Over-Relaxation method (SOR).
Interpolation
In general, the point x0 , which we are interested in, is located in the solution domain [xmin , xmax ] somewhere between nodes xk1 and xk . This means that 4
we have to use interpolation. Two possible choices are piecewise linear and cubic spline interpolation.
One of the examples of the free boundary value problem is an American option: we must solve a PDE with an unknown boundary. At every time step, we must update the Vik with Vik := max Vik , payo(xi , k) , i = 1, ..., N 1. (5.1)
Implementation Strategy
To code the Finite-Dierence Solver in C++, we use the advances of the object oriented programming: classes and inheritance. We code two base (abstract) classes: one for solving PDE-s with constant coecients and another for PDE-s with time-dependent coecients. In each class, there are dened several pure virtual functions (they have to be specied by the derived class): ones return the values of coecients a(x, t), b(x, t), and c(x, t) for given values of x and t; others return initial values and option payos. Derive classes specify the space variable x (for example, a stock price or interest rate), xmin , xmax , h = dx, and so on as well as the functional form of coecients, initial condition and payos.
Conclusions
FD is a powerful methods for solving PDEs. It is worthwhile implementing in the presence of time-dependent coecients and boundary value problems. We used our implemented FD solvers for a number of PDE-s arising in mathematical nance: 1) the Black-Scholes PDE, 2) the Black-Scholes PDE with discrete dividends, 3) the Black-Scholes PDE for barrier options, 4) PDEs for the equilibrium term structure models (CIR, Vasicek), 5) the Hull-White PDE with a time-dependent long-term mean, 6) the PDE with a local volatility function for vanilla and barrier options. We compared numerical solutions with some known analytical formulas and found that the FD discretization leads to reliable and accurate results. 5
By presenting and coding the nite-dierence methodologies, we found the following sources to be especially useful.
References
[1] Flannery B, Press W, Teukolsky S and Vetterling W, (1992), Numerical recipes in C: The Art of Scientic Computing, Cambridge University Press. [2] Thomas W, (1995), Numerical partial dierential equations: nite difference methods, New York. [3] Wilmott W, (2000), Paul Wilmott on Quantitative Finance, John Wiley and Sons.