Professional Documents
Culture Documents
Objective
We seek the function V (S,t) satisfying the PDE
V V V2 2
rS rV 0
t S 2 S 2
subject
to the constraints
S 0,
t 0,T
V(S,T)g(S)
where g, the terminal boundary condition, is the payoff at maturity of the option whose value will be
given by V. We require that the underlying follow geometric Brownian motion. For the purposes of this
development, we will assume that it does not pay dividends, and that both the risk-free rate and the
underlyings volatility are constant over the life of the option, although in practice finite-difference methods
are capable of handling all of these elaborations of the GBM model.
The general strategy is to use a change of variables to transform the PDE into one thats more tractable.
Analytic solutions to the PDE depend upon the observation that it can be transformed into the heat equation
in a function u(x, )
u 2 u
x 2
subject to the constraints
x ,
0, f
u(x,0)f (x)
..where f, the initial boundary condition, is g from the original formulation of the problem suitably
transformed.
Although the heat equation does have an analytic solution for a large class of boundary conditions f, most
such solutions require at least some degree of numerical estimation in order to be evaluated. Finite
difference methods of solving the equation are reasonably fast and easily extensible, particularly to the free-
boundary problems encountered with American options, where closed-form solutions are virtually never
available.
Change of Variables
There are several ways to transform the BS-PDE into the heat equation, or a relative thereof. In practice
there are a variety of considerations that inform what change of variables is appropriate for a given
application.
For the sake of illustration, this document uses a change of variables that completely transforms the BS-
PDE into the heat equation. Although it may not seem particularly clean or intuitively appealing, this
choice turns out to have a number of desirable properties, not the least of which is that it results in the
simplest possible PDE for our numerical solver to work on.
S
x ln
K
2
(Tt)
2
V(S,t) axb
u(x,) e
K
where:
2
r
a 2
2
2r
b 2 a2
and K is an arbitrary positive constant, usually chosen to be the strike price of the option.
Once the problem has been transformed into the heat equation, we use algebraic methods to solve it
numerically. This involves splitting the finite time interval 0, f into M equal subintervals of length ,
resulting in a discretized time domain with M+1 nodes. We also split the spatial dimension into equal
subintervalsN intervals of length x, giving rise to a spatial discretization with N+1 nodes.
Since the spatial domain is actually infinite, we must choose endpoints xleft and xright at which V(S,t) is
known to an acceptable degree of accuracy in advance. These values become a priori side boundary
conditions. The result is a rectangular domain of (N+1)(M+1) nodes, of which the nodes at =0 and those at
x=xleft and x=xright have known u-values. The algorithm will step through this domain in , solving for the
unknown u-values at the interior nodes at each time step, and after M iterations will produce the u-values at
f, corresponding to the time at which we wish to price the option. Along the way, it will produce estimates
of the options value at many different choices of S and t, a fact that can be made use of in calculating the
delta, gamma, and theta of the option as well.
Recall from Taylor polynomials that the first and second derivatives of a locally well-behaved function f
can be expressed at x using the following finite differences, with h some positive number:
To find the unknown value u(x,), the forward Euler method uses the known values at three other nodes:
u(x-x,-), u(x,-), and u(x+x,-). That is, the values required are those from the previous time
step at the corresponding node in space, and both of the adjacent spatial nodes. With this choice, we arrive
at the following equations:
u 2 u
x 2
u(x, ) u(x, ) u(x x, ) 2u(x, ) u(x x, )
x 2
u(x, ) u(x x, ) (1 2 )u(x, ) u(x x, )
where
x 2
This value is sometimes called the Courant constant.
It can be shown that the forward Euler method of pricing an option is equivalent to using a trinomial tree to
price it. That is, the method above is quite similar to taking risk-neutral expectations of three possible
outcomes to price the option at each node. This provides an intuitive sensealthough by no means a
rigorous explanationof the stability requirement for the forward Euler method when it is applied to the
heat equation: must be less than . Clearly, any value greater than this assigns a negative risk-neutral
probability to the middle transition, a condition that one might anticipate causing problems.
f
M
With , this determines x:
x
It is desirable to have the x-value corresponding to our spot price on the mesh; otherwise, we will be forced
to interpolate at the end to find our option price. So we calculate x0 under our change of variables:
S
x 0 ln 0
K
We now need to set the extreme ends of the spatial domain. No choice here is ideal: A pricing radius thats
too small will result in errors due to poor approximations at the side boundaries; a pricing radius thats too
large will result in a pricer that does far more computation than is actually required. What constitutes too
small or too large is a function primarily of the volatility of the underlying and the maturity of the
option.
To be conservative, we will insist that the extreme ends of the spatial domain be no less than D away from
the closer of x0 or the origin (the x-value associated with our strike). Thus, our spatial domain will be
asymmetric for anything but at-the-money options. A reasonable, safe choice of D is ln(4), although more
tailoring can be done, if desired, to increase execution speed.
Under our choice of D, we first calculate initial estimates of the endpoints:
left min(x 0,0) D
x
right max(x 0 ,0) D
x
These, however, may not lie precisely on the mesh. We also wish to keep track of the number of intervals to
each side of our x0Nleft and Nright, so we determine the endpoints of our spatial domain by:
x0xleft
Nleft 1
x
xleft x0Nleftx
xright x0
Nright 1
x
where [y] indicates the Heaviside step function, which returns the greatest integer less than or equal to y.
We make the assumption that the S-value corresponding to xleft is sufficiently far out of the money that the
probability that it expires in the money is 0. Thus, the left-side boundary condition is simply
u(x left , ) 0
We make the assumption that the S-value corresponding to xright is sufficiently far in the money that the
probability that it expires out of the money is 0. It is easy to see that a put under this assumption struck at
the same K has value 0, and thus from put-call parity the value of the call is simply that of a forward
contract struck at K
r(Tt)
V(Sright,t) Sright Ke
2
r 2
xright
Ke Ke axrightb
u(xright,) e
K
x 2r2 ax b
u(xright,) e e e
right right
Step 3: Iteration and Solution
Solution proceeds as outlined above; pseudocode is provided below to illustrate the method in more detail.
This pseudocode imagines that u-values are stored in a matrix U with N+1 rows, indexed from i=0,,N,
corresponding to the spatial nodes, and M+1 columns, indexed from j=0,,M, corresponding to the time
nodes. Under this arrangement, we use the boundary conditions above to populate the column vector at i=0
(initial boundary condition) and the row vectors at j=0 (boundary condition at xleft) and j=N (boundary
condition at xright).
From a speed standpoint, this method of storing information is not optimal; for large M, the memory
required to store the matrix U is prohibitive, leading to performance lags. A more efficient method is to
store the current iteration as a vector which is overwritten at each time step, but for the sake of clarity, the
pseudocode below retains the pricing information at every node in the domain.
// Declare matrix Us dimensions and populate its edges with boundary condition information
dim U(N+1, M+1)
// calculate V, the value of the option at time 0 and the current spot
output: V = K U(Nleft, M) exp(-ax0 - bf)
-----------------------------------------------
The backward Euler method uses the known value at u(x,-) to set up an equation involving the three u-
values u(x-x,), u(x,), and u(x+x,). Usually all three of these values will be unknown; the exception
occurs at the first interior node along the spatial coordinate on each side, where one of these values is
known from a side boundary condition. The values are related by the central finite-difference
approximation of the second derivative at , rather than - as in forward Euler. With this choice, we
arrive at the following equations:
u 2u
x 2
u(x, ) u(x, ) u(x x, ) 2u(x, ) u(x x, )
x 2
u(x x, ) (1 2 )u(x, ) u(x x, ) u(x, )
This equation can be formulated for each of N-1 interior spatial nodes at every time stepi.e., all the
spatial nodes except those at the side boundaries. If we define u to be the column vector of unknown u-
values at the interior spatial nodes at time , we have a vector of length N-1. Analogously, define u(-) to
be the vector of known u-values at the interior spatial nodes at time -; this vector is also of length N-1.
Then we may write the system implied by the N-1 equations of the form above as
Au( ) u( ) c( )
A is the N-1 x N-1 matrix of coefficients, and c() is
u(x left , )
0
M
0
u(x , )
right
That is, its only nonzero entries are at the top and bottom, arising from the known contributions of the two
side boundary conditions being moved to the other side of the equation.
It is tridiagonal, symmetric, and strictly diagonally dominated. Symmetry and diagonal domination
guarantee that A is a real positive definite matrix: All its eigenvalues are real and positive, and thus of
course its determinant is positive, so A is invertible, meaning that our equation will have a unique solution.
Even more important from the standpoint of speed, A can be decomposed into factors easily. As we will
see, the decomposition can be accomplished in O(N) operations, and since A remains the same for each
time step, the decomposition need only be done once. In turn, the fact that the matrix can be decomposed
this way means that our solution of this equation at each time step can be accomplished in O(N) operations,
making it at least comparable to the explicit method above in terms of solution time.
The idea is to write A as the product of a lower-triangular matrix Lt and an upper-triangular matrix Ut. This
decomposition is unique under certain constraints; to make our factorization easier to use, we will require
that the diagonal elements of Lt all equal 1.
We will omit any discussion of how LU decomposition is done for general matrices; in the case of a
tridiagonal matrix which is diagonally dominated, each of the factors is banded in the same fashion as our
original matrix A, and no elaborations such as pivoting are required to produce the factorization. Thus, the
factorization can be represented in three vectors of values:
In the pseudocode below, these vectors are calculated from A; each is indexed beginning at 0:
// Begin the decomposition by populating the first diagonal entry of the upper-triangular factor
Ut_d(0) = A(0,0)
Note that in the example above, since the matrix is symmetric with the same coefficients in each row, the
result could be achieved by passing the function two constant values: 1+2 and , corresponding to the
diagonal and off-diagonal elements of A. In this case, the vector U_offd need not be calculated at all, since
every entry will equal . The pseudocode above, however, will work with a greater range of tridiagonal
matrices, such as those found under other changes of variables.
Once the factorization is done, the factors will be used in every iteration. The convenience of having A
factored as LtUt is that the system Ax = b can be solved instead as LtUtx = b in two passes: First, by
finding the vector y such that Lty = b, then by solving Utx = y. The structure of the factors is such that the
whole process can be accomplished in the same number of operations as a single matrix multiplication, by
using forward substitution to solve the first equation, then backward substitution to solve the second.
The side boundary conditions for the European put are analogous those for the call. At xright, the option is
considered to be certain to expire out of the money; at xleft, it is considered certain to expire in the money.
This leads to the equations:
u(xright,)0
2 x ax b
2 r
u(xleft,)e e e
left left
Step 3: Iteration and Solution
Solution proceeds in the manner already described. The pseudocode below once again stores all the nodal
values of u in a matrix U with N+1 and M+1 columns, indexed starting at 0, with the initial column and the
top and bottom rows populated using the boundary conditions.
This pseudocode also includes the slight speed improvement to LU decomposition suggested above, where
all the entries in each diagonal of the coefficient matrix are known to be constant.
// Declare matrix Us dimensions and populate its edges with boundary condition information
dim U(N+1, M+1)
// LU decomposition
dim Lt_offd(N-2)
dim Ut_d(N-1)
dim Ut_offd(N-2)
// calculate V, the value of the option at time 0 and the current spot
output: V = K U(Nleft, M) exp(-ax0 - bf)
-----------------------------------------------
One such methodCrank Nicolsonassigns equal weight to the two approximations, and is sometimes
referred to as a fully centered method. It writes the PDE at the point u(x, t-/2), using linear
interpolations in of all derivatives, and thus involves the six points u(x-x,-), u(x,-), and u(x+x,-
(all known), along with u(x-x,), u(x,), and u(x+x,) (all unknown). In effect, this leads to a method
that is an average of the forward and backward Euler methods, with the advantage that the Crank Nicolson
method is, unlike forward Euler, unconditionally stable. Nevertheless, the contribution of backward Euler
does show up in spurious oscillations when the Courant constant is chosen to be greater than , so in
practice Crank Nicolson is usually used only after an initial smoothing step.
Since it involves the solution of a linear system at each time step, the iteration method used with Crank
Nicolson is essentially the same as that used with backward Euler, with slightly different coefficient and
constant matrices:
u 2u
x 2
u(x, ) u(x, ) 1 u(x x, ) 2u(x, ) u(x x, )
2 x 2
1 u(x x, ) 2u(x, ) u(x x, )
2 x 2
u(x x, ) (1 )u(x, ) u(x x, )
2 2
u(x x, ) (1 )u(x, ) u(x x, )
2 2
If we express this system as in the form Au() = b(), then the matrices are as follows:
A is:
1 2 0
1
2 2
1 O
2
0 O O
b() is:
2 u(x left , ) (1 )u(x left x, ) 2 u(x left 2x, ) 2 u(x left , )
u(x left x, ) (1 )u(x left 2x, ) u(x left 3x, )
2 2
M
u(x right 3x, ) (1 )u(x right 2x, ) u(x right x, )
2 2
u(x 2x, ) (1 )u(x x, ) u(x , ) u(x , )
2 right right
2
right
2
right
and u() is, as before, the vector of function values we seek at the interior nodes at time .
Since the matrix A is also symmetric positive definite, the methods outlined above for backward Euler will
also serve, with very slight adjustments, for the Crank Nicolson method as well. The main change is that
the vector on the right-hand side of the equation must be recalculated from u(-) at each time step, before
forward and backward substitution are used to solve the system. Because this is only a small extension of
the backward Euler method outlined in detail above, pseudocode for the Crank Nicolson method is not
included.
The most commonand easiest to illustratecase in which numerical methods are necessary is when the
option can be exercised during its lifeeither at any time, for an American option; or else at a preset
selection of times, for a Bermudan option. Aside from the need to make sure the exercise times fall on the
mesh in , both types of options can be priced by making only minor changes to the methods already
outlined.
S 0,
t 0,T
V(S,T)g(S)
V(S,t)g(S)
where g(S) is the intrinsic value of the optionthe value if it is exercised immediately. The value of our
American option must satisfy one of the following relations; either:
V V 2 2V
rS rV 0
t S 2 S 2
or else:
V(S,t) g(S)
Thus, there are two distinct regions we will encounter in pricing the option. In one, the continuation region,
the option obeys the Black-Scholes PDE, and its value is greater than the intrinsic value of the option. In
the other, the early exercise region, it does not obey the Black-Scholes PDE, but its value is simply equal to
This suggests a straightforward way of adapting a finite-difference pricer to American options. By whatever
method, at each time step we arrive at a vector of values of the option using the Black-Scholes PDE and the
values from the prior time step. By checking each of these values against the intrinsic value of the option
and taking the larger value at each node, we can model optimal early-exercise behavior and arrive at a good
approximation of the options value. This method does converge to the solution of the free-boundary
problem above as our mesh grows finer, and has the additional benefit of discovering where the boundary
between the early exercise and continuation regions lies.
If we consider only vanilla optionscalls and putsthen the matter becomes even simpler, since it can be
shown that the value of an American call and a European call are the same, since early exercise of a call is
never optimal. Thus, the only case we need to consider here is an American put.
Using our change of variables and the payoff of a put, we can arrive at the following description of our
option value Vee within the early exercise region:
Vee (S,t) g(S) K S
K Ke x axb
uee (x, ) e
K
uee (x, ) (1 e x )e ax b
Clearly, the check for early exercise need only be performed for x < 0 in the case of a put.
Note that, when pricing American puts, this function also becomes the boundary condition at xleft, since it is
strictly greater than the left-hand boundary condition used to price the European put above. As always, it is
important to choose a pricing radius large enough to be sure that this serves as a good approximation of the
left-hand valuesin this case, that xleft lies well within the early exercise region for all .