30

Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Embed Size (px)

Citation preview

Page 1: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Solving the Black Scholes Equation using a

Finite Di�erence Method

Daniel Hackmann

12/02/2009

1

Page 2: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

1 Introduction

This report presents a numerical solution to the famous Black-Scholes equation.Although a closed form solution for the price of European options is available,the prices of more complicated derivatives such as American options requirenumerical methods. Practitioners in the �eld of �nancial engineering often haveno choice but to use numerical methods, especially when assumptions aboutconstant volatility and interest rate are abandoned. [1]

This report will focus primarily on the solution to the equation for Europeanoptions. It �rst presents a brief introduction to options followed by a derivationof the Black Scholes equation. Then it will introduce the �nite di�erence methodfor solving partial di�erential equations, discuss the theory behind the approach,and illustrate the technique using a simple example. Finally, the Black-Scholesequation will be transformed into the heat equation and the boundary-valueproblems for a European call and put will be solved. A brief analysis of theaccuracy of the approach will also be provided.

2 A brief introduction to options

A �nancial derivative is a �nancial product that derives its value from the valueof another �nancial asset called the underlying asset. The derivatives of interestin this report are European option contracts. An European option contract is anagreement between two parties that gives one party the right to buy or sell theunderlying asset at some speci�ed date in the future for a �xed price. This righthas a value, and the party that provides the option will demand compensationat the inception of the option. Further, once initiated, options can be tradedon an exchange much like the underlying asset.

The options under consideration in this report fall into two classes: calls andputs. A European call option on a stock gives the buyer the right but not theobligation to buy a number of shares of stock (the underlying asset for stockoptions) for a speci�ed price (E) at a speci�ed date (T ) in the future. If theprice of the stock (S) is below the exercise price, the call option is said to be�out of the money� whereas a call option with an exercise price below the stockprice is classi�ed as �in the money�. The value of the option is thus a functionof S and time, and its payo� ,which describes the option's value at date T , isgiven by

C(S, T ) = max(S − E, 0) (1)

The graph below illustrates the payo� for a European call option with exerciseprice E = 25.

2

Page 3: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

0 10 20 30 40 500

10

20

30

40

50

S

Payoff for a European Call

C

A European put option gives the buyer the right to sell a number of shares ofstock for a speci�ed price at a speci�ed time. The payo� which describes a putoption's value at time T is given by

P (S, T ) = max(E − S, 0) (2)

The graph below illustrates the payo� for a European put option with exerciseprice E = 25.

0 10 20 30 40 500

10

20

30

40

50

S

Payoff for a European Put

P

European options are some of the simplest �nancial derivatives. They are in-teresting, because their valuation proved to be di�cult until 1973. Before that,there was no generally accepted model that could give an options trader the

3

Page 4: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

value of an option before expiry. The answer was provided by solving the Black-Scholes di�erential equation. The derivation of Fischer Black, Myron Scholesand Robert Merton's di�erential equation follows in the next section.

3 The Black Scholes analysis

In order to develop a model for the price of a stock option, it is necessary to �rstdevelop a model for the price of the stock itself. Economic theory and historicaldata suggest that stock returns are composed of two components. First, thevalue of a stock will increase with time at a rate µ known as the drift rate.Second, at any time the value of the stock is subject to random variability. Thisvariability is expressed by a random variable Z with certain special properties.

The notion that a stock's value will necessarily increase over time is due to theexpectation that a company will, in the long run, generate a return for investors.This return is measured as a percentage of the value of the investment, so thatthe expected absolute return is dependent on the price of the stock. The pricechange of a risk-less stock in a time interval ∆t could thus be modeled as follows:

∆S = Sµ∆t (3)

It is clear, however, that no stock is risk-less. Risk is modeled by the stochasticterm Z which has the following two properties:

1. ∆Z = ε√

∆t where ε is a standard normal random variable, i.e. ε ∼N(0, 1).

2. The value of ∆Z in time interval ∆t is independent of 4Z in any othertime interval.

These two properties describe Z as a random variable that follows a Wienerprocess. Notice that for n time steps:

E[n∑i=1

∆Zi] = 0 (4)

V ar(n∑i=1

∆Zi) = n∆t (5)

Thus Z is a random variable whose expected future value depends only onits present value, and whose variability increases as more time intervals areconsidered. The �rst property is consistent with an economic theory called theweak form of market e�ciency that states that current stock prices re�ect allinformation that can be obtained from the records of past stock prices. Thesecond property shows that uncertainty about the value of Z increases as one

4

Page 5: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

looks further into the future. This is intuitively appealing, as more eventsa�ecting the stock price are anticipated in longer time intervals. For a moredetailed discussion of this concept see. [6]

The �rst property of Z implies that if ∆t represents one unit of time, V ar(∆Z) =1. To re�ect the risk of a particular stock, the variability of ∆Z needs to beadjusted. That is, it must be scaled by a quantity which is an estimate of thevariability of S in ∆t. This quantity is σS where σ is the standard deviation ofS during ∆t expressed as a percentage. Thus σS∆Z is a random variable withstandard deviation σS. It is now possible to model the behaviour of a stockprice as follows:

∆S = µS∆t+ σS∆Z (6)

As ∆t→ 0 this becomes:dS = µSdt+ σSdZ (7)

Formally, (7) implies that S follows an Ito process.

The Black-Scholes analysis assumes that stock prices behave as just demon-strated. Further assumptions of the analysis are as follows:

1. Investors are permitted to short sell stock. That is, it is permitted to bor-row stock with the intent to sell and use the proceeds for other investment.Selling an asset without owning it is known as having a short position inthat asset, while buying and holding an asset is known as having a longposition.

2. There are no transaction costs or taxes.

3. The underlying stock does not pay dividends.

4. There are no arbitrage opportunities. That is, it is not possible to makerisk free investments with a return greater than the risk free rate.

5. Stock can be purchased in any real quantity. That is, it is possible to buyπ shares of stock or 1/100 shares of stock.

6. The risk free rate of interest r is constant.

With these assumptions, one can begin to consider the value of a call or a putoption. The following section will use V (S, t) to denote the value of the option inorder to emphasize that the analysis is independent of the form of the �nancialasset under consideration. As long as the value of the asset depends only on Sand t this analysis holds. To understand the form that V (S, t) will take it isnecessary to use a result from stochastic calculus known as Ito's Lemma. Thisstates that if x follows a general Ito process

dx = a(x, t)dt+ b(x, t)dZ (8)

5

Page 6: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

and f = f(x, t) , then

df =(∂f

∂xa(x, t) +

∂f

∂t+

12∂2f

∂x2(b(x, t))2

)dt+

∂f

∂xb(x, t)dZ (9)

Applying Ito's lemma to the function V (S, t) yields

dV =(∂V

∂SµS +

∂V

∂t+

12∂2V

∂S2σ2S2

)dt+

∂V

∂SσSdZ (10)

This rather complicated expression is di�cult to solve for V , especially sinceit contains the stochastic term dZ . The revolutionary idea behind the BlackScholes analysis is that one can create a portfolio consisting of shares of stock andderivatives that is instantaneously risk-less, and thus eliminates the stochasticterm in (10). The instantaneously risk-less portfolio at time t consists of one

long position in the derivative and a short position of exactly∂V

∂Sshares of the

the underlying stock. The value of this portfolio is given by

Π = V − ∂V

∂SS (11)

and the instantaneous change of Π is

dΠ = dV − ∂V

∂SdS (12)

Combining (7), (10), and (12) one obtains

dΠ = −∂V∂S

dS +(∂V

∂SµS +

∂V

∂t+

12∂2V

∂S2σ2S2

)dt+

∂V

∂SσSdZ

dΠ = −dVdS

(µSdt+ σSdZ) +(∂V

∂SµS +

∂V

∂t+

12∂2V

∂S2σ2S2

)dt+

∂V

∂SσSdZ

dΠ =(∂V

∂t+

12∂2V

∂S2σ2S2

)dt (13)

As anticipated, the change in the instantaneously risk-less portfolio is not de-pendent on the stochastic term dZ . It should be noted that in order for theportfolio to maintain its risk-less property it must be rebalanced at every point

in time as∂V

∂Swill not remain the same for di�erent values of t . Thus shares will

need to be bought and sold continuously in fractional amounts as was stipulatedin the assumptions.

6

Page 7: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Since this portfolio is risk-less, the assumption that there are no arbitrage op-portunities dictates that it must earn exactly the risk free rate. This impliesthat the right hand side of (13) is equal to rΠdt where r represents the risk freerate of return. Setting the right hand side of (13) equal to rΠdt and using (11)one obtains the famous Black-Scholes partial di�erential equation:

∂V

∂t+

12∂2V

∂S2σ2S2 +

∂V

∂SrS − rV = 0 (14)

As mentioned in the introduction, for both European calls and puts, analyticsolutions for V (S, t) have been found. In order to solve the problem for eitheroption, one �rst needs to specify boundary and �nal conditions. These areobtained by making �nancial arguments about the behaviour of C(S, t) andP (S, t) at time T and for extreme values of S . Final conditions have alreadybeen introduced in section 2. At time T the option is either in or out of themoney, and is thus either worthless or has a positive value. Also, should Sever reach a price of 0, it is clear from (7) that dS must equal 0, so thatno further change in S is possible. This implies that the call option will notbe exercised and C(0, t) = 0 , while the put will surely be exercised and willhave a value of P (0, t) = Ee−r(T−t) . The term e−r(T−t) is added in this lastexpression to express the present value of the exercise price at time T − t .This is necessary, because P (0, T ) will surely be worth E , which is equivalentto Ee−r(T−t) invested at the risk free rate for a period of T − t . Finally, asS → ∞ the call option will almost certainly be exercised, so that C(S, t) ∼S − Ee−r(T−t) , while it becomes very unlikely that the put option will beexercised so that P (S, t)→ 0 . Here ∼ is used in the context of order notation,

so that f(x) ∼ g(x) as x→ a⇐⇒ limx→af(x)g(x)

= 1 .[7]

To summarize, the boundary conditions for a European call are given by

C(S, T ) = max(S − E, 0) , S > 0 (15)

C(0, t) = 0 , t > 0 (16)

C(S, t) ∼ S − Ee−r(T−t) as S →∞ , t > 0 (17)

While the boundary conditions for the European put are given by

P (S, T ) = max(E − S, 0) , S > 0 (18)

P (0, t) = Ee−r(T−t) , t > 0 (19)

P (S, t)→ 0 as S →∞ , t > 0 (20)

7

Page 8: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Two features of these problems make them di�cult to solve directly. The �rstis that instead of posing an initial condition with respect to time, the prob-lems present a �nal condition given by equations (15) and (18). Secondly, theboundary conditions given by (17) and (18) depend on t .

4 Finite di�erence methods

Finite di�erence methods involve approximations of the derivative at points ofinterest in the domain of the solution of a di�erential equation. In simple cases,the derivative of a function of one variable can be approximate near a point xby using the de�nition of the derivative

df(x)dx

= limh→0

f(x+ h)− f(x)h

because when h is small one expects that

df(x)dx

≈f(x+ h)− f(x)

h(21)

In equations with more than one variable, and for derivatives of higher order,derivatives can instead be approximated by a Taylor series expansion. In partic-ular, if one was interested in obtaining an approximation for the �rst derivativeof f with respect to x near the point (x, y) one would proceed as follows

f(x+ h, y) = f(x, y) +∂f(x, y)∂x

· h+O(h2)

∂f(x, y)∂x

≈ f(x+ h, y)− f(x, y)h

(22)

where O(h) represents the order of the remaining terms in the series. Theapproximation of the derivative given in (22) is called the forward di�erence

because it approximates∂f

∂xwhen a small quantity, h , is added to the x co-

ordinate of the point (x, y) . One can also obtain the backward di�erence byconsidering the Taylor series expansions for f(x− h, y) or the central di�erenceby combining the results of the forward and backward di�erences. To computeapproximations for second derivatives, one has the Taylor expansions:

f(x+h, y) = f(x, y)+∂f(x, y)∂x

h+12∂2f(x, y)∂x2

h2 +16∂3f(x, y)∂x3

h3 +O(h4) (23)

f(x−h, y) = f(x, y)− ∂f(x, y)∂x

h+12∂2f(x, y)∂x2

h2− 16∂3f(x, y)∂x3

h3 +O(h4) (24)

8

Page 9: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Upon adding (23) and (24) one obtains

∂2f(x, y)∂x2

≈ f(x+ h, y)− 2f(x, y) + f(x− h, y)h2

(25)

With these results, it is now possible to consider a basic example to demonstratehow this method works.

Example: The heat equation with �nite boundary condi-

tions

The heat equation in one spatial variable x is a partial di�erential equationwhich models the distribution of heat in a thin wire over time t. Consider thefollowing problem

∂U

∂t= k2 ∂

2U

∂x2(26)

0 < x < 1, t > 0

U(x, 0) = sinπx

U(0, t) = U(1, t) = 0

where∂U

∂tand

∂2U

∂x2are the �rst and second partial derivatives of the tempera-

ture U(x, t) with respect to time and space respectively and k is a constant.1 Tobegin the �nite di�erence approximation one must choose a rectangular regionin the domain of U(x, t) and partition it into points of interest to form a grid.The length of the rectangle along the x axis is determined by the boundaryconditions. For this example one would choose the interval [0, 1]. For t thechoice must consider the initial condition, so the length in t will be the interval[0, T ] . Let T = 0.16 and divide the intervals for x and t into M = 5 and N = 2equally spaced increments of ∆x = 0.2 and ∆t = 0.08 respectively. The goal isto approximate the value of the function U at the (M − 1)× (N) = 8 points ofinterest in the domain [0, 1]× [0, 0.16] . These points are referred to as the �nitedi�erence mesh and have coordinates (xi, tj) where i and j are indices for thetime and space increments. With the approximation of the derivative obtainedin (22) and (25) one can estimate (26) by

U(x, t+ ∆t)− U(x, t)∆t

= k2U(x+ ∆x, t)− 2U(x, t) + U(x−∆x, t)(∆x)2

(27)

1Example taken from [3] but solved independently using code in Appendix A

9

Page 10: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

To simplify (27), one can label the unknown quantities U(xi, tj) with uji fori = 1, 2, 3, 4 and j = 1, 2 and write

uj+1i =

k2∆t(∆x)2

(uji+1 − 2uji + uji−1

)+ uji (28)

The equality in (28) is known as the explicit method of approximating the solu-tion to (26). The term explicit is used to describe the nature of the relationshipof the uji with respect to time. Speci�cally, one can express the term uj+1

i ex-plicitly in terms of the approximations of U at time tj , the time immediatelyprior to tj+1 . Although the explicit method is the easiest to implement com-putationally, convergence to a solution depends on the ratio of ∆t and ∆x2 .

Note that the forward di�erence was used in (27) to approximate∂U

∂t. Had the

backward di�erence been used instead, (28) would have the fully-implicit form

uji = uj+1i − k2∆t

(∆x)2(uj+1i+1 − 2uj+1

i + uj+1i−1

)(29)

This method is more di�cult to implement computationally, but does not de-pend on the ratio of ∆t and ∆x2 for convergence. Note that with this approachapproximations of U at time tj+1 cannot be explicitly expressed in terms of ap-proximations of U at time tj . A third approach that converges independentlyof the ratio of ∆t and ∆x2 and faster than both (28) and (29), relies on takinga weighted average of the expressions for (28) and (29). This yields

uj+1i = ∆tk2

[αuji+1 − 2uji + uji−1

(∆x)2+ (1− α)

uj+1i+1 − 2uj+1

i + uj+1i−1

(∆x)2

]+ uji (30)

When α =12(30) becomes the Crank-Nicolson approximation. Returning to

the example (26), for k2 = 1 this yields

3uj+1i = −uji + uji+1 + uji−1 + uj+1

i+1 + uj+1i−1 (31)

which represents a linear system of 8 equations in 8 unknowns. Solving thissystem requires constructing a matrix and solving the following equation forthe uji

3 −1 0 0 0 0 0 0−1 1 −1 0 −1 3 −1 00 −1 3 −1 0 0 0 00 0 −1 1 0 0 −1 31 −1 0 0 3 −1 0 0−1 3 −1 0 0 0 0 00 −1 1 −1 0 −1 3 −10 0 −1 3 0 0 0 0

u11

u12

u13

u14

u21

u22

u23

u24

=

10

Page 11: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

− sin(0.2π) + sin(0.4π) + sin(0)0

− sin(0.6π) + sin(0.8π) + sin(0.4π)00

− sin(0.4π) + sin(0.6π) + sin(0.2π)0

− sin(0.8π) + sin(π) + sin(0.6π)

When compared with the known solution for the problem, U(x, t) = eπ

2t sin(πx), which can be obtained using a separation of variables technique, the approx-imation is valid up to 2 decimal places for most values of x. The results com-paring the numerical approximation to the exact solution are presented be-low. Considering that these approximations are generally conducted with a fargreater number of steps and smaller increments for both x and t these resultsare encouraging.

xi u1i U(xi, 0.08) Di�.

0.2 0.26287 0.26688 0.0040120.4 0.42533 0.43182 0.0064930.6 0.42533 0.43182 0.0064930.8 0.26287 0.26688 0.004012

xi u2i U(xi, 0.16) Di�.

0.2 0.11756 0.12117 0.0036170.4 0.19021 0.19606 0.0058520.6 0.19021 0.19606 0.0058520.8 0.11756 0.12117 0.003617

The following section will demonstrate the theoretical validity of the Crank-Nicholson method.

5 Theoretical basis for the �nite di�erence ap-

proach

The focus of this section is to demonstrate the validity of the methods used toobtain the solutions found in section 6. Since these results were achieved usingthe Crank-Nicolson approximation, this will be the primary method of interest.Additionally, it will be shown why the Crank-Nicolson approach is sometimespreferred to the simpler explicit scheme.

11

Page 12: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

To verify that �nite di�erence approximations are an accurate method of esti-mating the solution to the heat equation, it is necessary to establish that theyare convergent. An approximation is said to be convergent if its values approachthose of the analytic solution as ∆x and ∆t both approach zero.[5] Since conver-gence is di�cult to prove directly, it is helpful to use an equivalent result knownas the Lax Equivalence Theorem. It states that a consistent �nite di�erencemethod used to solve a well-posed linear initial value problem is convergent ifand only if it is stable. This introduces two new terms: consistent and stable.

1. Consistent: A method is consistent if its local truncation error T ji → 0 as∆x→ 0 and ∆t→ 0 . Local truncation error is the error that occurs whenthe exact solution U(xi, tj) is plugged into the di�erence approximationat each point of interest. For example, in (30) with α = 1

2

T ji (∆x,∆t) = U(xi, tj+1)

− k24t2

[U(xi+1, tj)− 2U(xi, tj) + U(xi−1, tj)

(4x)2

+U(xi+1, tj+1)− 2U(xi, tj+1) + U(xi−1, tj+1)

(4x)2

]− U(xi, tj) (32)

2. Stable: A method is stable if errors incurred at one stage of the approxi-mation do not cause increasingly larger errors as the calculation continues.

It is known that the Crank-Nicolson method is both consistent and stable inapproximating solutions to the heat equation. To demonstrate consistency, onemust proceed as in (32) and enter the exact solution into the di�erence equationfor the Crank-Nicolson scheme. Here the exact solution is given by the fullTaylor series expansion of U .

T ji (∆x,∆t) = U(xi, tj) +∂U(xi, tj)

∂t∆t+O((4t)2)

− k24t2 (4x)2

»U(xi, tj) +

∂U(xi, tj)

∂x∆x+

∂2U(xi, tj)

2∂x2(∆x)2 +O((4x)3)− 2U(xi, tj)

+ U(xi, tj)−∂U(xi, tj)

∂x∆x+

∂2U(xi, tj)

2∂x2(∆x)2 +O((4x)3)

+ U(xi, tj+1) +∂U(xi, tj+1)

∂x∆x+

∂2U(xi, tj+1)

2∂x2(∆x)2 +O((4x)3)

− 2U(xi, tj+1) + U(xi, tj+1)− ∂U(xi, tj+1)

∂x∆x

+∂2U(xi, tj+1)

2∂x2(∆x)2 +O((4x)3)

–− U(xi, tj) (33)

12

Page 13: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Upon simpli�cation (using the fact∂2U

∂x2=∂U

∂t) one obtains

T ji (∆x,∆t) =

„∂U(xi, tj)

∂t(1− k

2

2

)− k2

2

∂U(xi, tj+1)

∂t

«∆t

+O((4t)2) +O((4t(4x)2) (34)

As (34) shows T ji → 0 as ∆x → 0 and ∆t → 0 which demonstrates that theCrank-Nicholson method is indeed consistent.

To demonstrate stability, it is easier to �rst consider the explicit method andthen apply a similar result to the Crank-Nicolson method.2 Notice that in thecase of the explicit method, one can write the di�erence equations in (28) as amatrix equation:26666664

uj+11

uj+12

.

.

.

uj+1M−1

37777775 =

26666664(1− 2r) r

r (1− 2r) r.

..r (1− 2r)

37777775

26666664

uj1uj2...

ujM−1

37777775 (35)

In (35) r =k2∆t(∆x)2

and it is assumed, for simplicity, that a change of variable

has been introduced to give boundary conditions uj0 = ujM = 0 . This is alwayspossible for �xed end boundary conditions. Let uj+1 be the vector on the lefthand side of (35), uj the vector on the right hand side, and A the coe�cientmatrix. Also note that u0 , the vector at t0, is given by the initial condition, sothat one can determine u at later times by solving (35) successively

u1 = Au0

u2 = Au1 = A2u0

...

uN = AuN−2 = A2uN−3 = ... = ANu0 (36)

In (36) superscripts on the u terms denote time increments while they denoteexponents on A . It can be demonstrated, that if an error is introduced at anypoint in this process, then the error propagates via the same iterative calcula-tion. For example, the error ej at time tj that is attributable to the error e0 attime t0 is given by

ej = Aje0 (37)

2Proof abbreviated from [5]

13

Page 14: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Further, it can be shown that A has distinct eigenvalues λ1, λ2, ..., λM−1 andthus has linearly independent eigenvectors x1, x2, ..., xM−1 . For constants,c1, c2, ..., cM−1 , it is then possible to write e0 as a linear combination of eigen-vectors

e0 = c1x1 + c2x2 + ...+ cM−1xM−1 (38)

Subsequently (37) becomes

ej = Aje0 =

M−1Xi=1

Ajcixi =

M−1Xi=1

ciAjxi =

M−1Xi=1

ciλjixi (39)

This demonstrates that errors will not increase with each iteration if |λi| ≤ 1for all i . That is, the explicit method is stable if the magnitude of the largesteigenvalue of the coe�cient matrix is smaller than one. The distinct eigenvaluesof A are given by

1− 4r sin2“mπ

2M

”, m = 1, 2, ...,M − 1

For stability, the following condition must hold

−1 ≤ 1− 4r sin2“mπ

2M

”≤ 1

This leads to the conclusion that r ≤ 12 in order for the explicit scheme to be

stable because the preceding implies that

r ≤ 1

2

0@ 1

sin2“mπ

2M

”1A

Since r =k2∆t(∆x)2

this demonstrates that stability and hence convergence of

the explicit method depends on the choice of ∆t and ∆x . For example, ifone wanted to double the space increments of a stable solution, one would berequired to quadruple the time increments in order to maintain stability. Thiscan lead to unnecessarily large and computationally intensive calculations.

The Crank-Nicolson scheme, by comparison, does not require restrictions on rfor stability. Writing (30) in matrix form with α = 1

2 and under the assumption

14

Page 15: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

that the boundary conditions are zero yields26666664(2 + 2r) r

r (2 + 2r) r.

..r (2 + 2r)

37777775

26666664

uj+11

uj+12

.

.

.

uj+1M−1

37777775 =

26666664(2− 2r) r

r (2− 2r) r.

..r (2− 2r)

37777775

26666664

uj1uj2...

ujM−1

37777775 (40)

This results in the matrix equation

Buj+1 = Auj (41)

If one performs the same analysis as for the explicit method with the coe�cientmatrix B−1A one �nds, as previously, that stability depends on the magnitudeof the eigenvalues. For B−1A these are given by

2− 4r sin

„mπ

2(M − 2)

«2 + 4r sin

„mπ

2(M − 2)

« , m = 1, 2, ...,M − 1 (42)

From (42) it is clear that the magnitude of the eigenvalues is less than oneregardless of the value of r. As a result the Crank-Nicolson method is stablewithout restrictions on the size of ∆t and ∆x . The preceding analysis has shownthat the Crank-Nicolson is a convergent and convenient method of approximat-ing the solution of the heat equation. Although it is not immediately obvious,this implies that the method is also useful in �nding a numerical solution to theBlack-Scholes equation.

6 Solution of the Black-Scholes equation

The previous section has demonstrated that �nite di�erence methods, the Crank-Nicholson method in particular, are valid approaches for approximating solu-tions to boundary value problems for the heat equation. As mentioned in theintroduction, the Black-Scholes equation can be transformed into the heat equa-tion, which is how closed form solutions are obtained. This also means that theresults of section 5 can be applied to solve the transformed equation. Both (14)and (26) are classi�ed as parabolic linear partial di�erential equations (PDE's)of second order. They di�er in that the heat equation is forward parabolic while(14) is backward parabolic. The distinction arises from the direction of the signof the second partial derivative with respect to space (S or x) and the sign of the

15

Page 16: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

derivative with respect to time. In forward parabolic equations the sign of thetwo derivatives is opposite when both terms are on one side of the equality, whilein backward parabolic equations the sign is the same. For the purposes of thisanalysis it su�ces to say that backward parabolic di�erential equations require�nal conditions in order to guarantee unique solutions, and forward di�erentialequations require initial conditions.

The closed form solution of the Black-Scholes PDE is obtained by transforming(14) into the heat equation on an in�nite interval.3 To do so, one must employa change of variables

S = Eex , t = T − τ/`

12σ´, C = Ev(x, τ) (43)

When these are substituted into (14) one gets a forward parabolic equation withone remaining dimensionless parameter k = r/

(12σ)

∂v

∂τ=∂2v

∂x2+ (k − 1)

∂v

∂x− kv

One further change of variable

v = e−12(k−1)x− 1

4(k+1)2τu(x, τ) (44)

then gives the heat equation one an in�nite interval.

∂u

∂τ=∂2u

∂x2, −∞ < x <∞ , τ > 0 (45)

This change of variables gives initial conditions for the call (15) and the put(18) respectively

u(x, 0) = max(e12(k+1)x − e

12(k−1)x, 0) (46)

u(x, 0) = max(e12(k−1)x − e

12(k+1)x, 0) (47)

It is worth noting that the boundary conditions no longer depend on time. Infact, �xed boundary conditions no longer apply at all. Instead the behaviour ofu as x approaches ±∞ becomes important. It can be shown that if u does notgrow too fast, a closed form solution to the transformed equation of a Europeancall can be found. By reversing the transformations, one �nds the formula forthe value of a call as presented in the 1973 paper by Black and Scholes [2], tobe

C(S, t) = SN(d1)− Ee−r(T−t)N(d2) (48)

where

d1 =log (S/E) +

`r + 1

2σ2´

(T − t)σ (T − t)

d2 =log (S/E) +

`r + 1

2σ2´

(T − t)σ (T − t)

3Full transformation found in [7]

16

Page 17: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

and N is cumulative normal density function. To obtain the formula for a put,the standard approach is to use a formula that relates the value of a put and acall, known as the put-call parity. This states

C − P = S − Ee−r(T−t)

From this one obtains the value of the European put

P (S, t) = Ee−r(T−t)N(−d2)− SN(−d1) (49)

To use the Crank-Nicholson method to solve the Black-Scholes equation for a putor a call one can proceed as in the example in section 4. The only complicationis that there are now no given boundaries for u in the x domain. That is,one must take an in�nite number of ∆x increments to solve the problem on anin�nite interval. Since this is not possible, one instead takes suitably large x+

and small x− values to approximate a boundary for the solution in x. A rule ofthumb for the size of x+ and x− is as follows

x− = min(x0, 0)− log(4)

x+ = max(x0, 0) + log(4) (50)

Here, 0 corresponds to the transformed strike price E and x0 to the transformedstock price for which the value of the option is being calculated. One then makesthe approximation that u behaves at these boundaries as it would as x→ ±∞which corresponds to S → 0 and S → ∞ in the �nancial variables. Using(16) and (17) and the change of variables (43) and (44) one has the followingtransformed boundaries for the call

u(x−, τ) = 0 (51)

u(x+, τ) = e12(k+1)x+

14(k+1)2τ − e

12(k−1)x+

14(k−1)2τ (52)

Using (19) and (20) with the same change of variables yields the transformedput boundaries

u(x−, τ) = e12(k−1)x+

14(k−1)2τ (53)

u(x+, τ) = 0 (54)

One can then proceed exactly as if this were the example in section 4, with oneadditional step which is to transform the approximated values of u into termsof V with the following transformation

V = E12(1+k)S

12(1−k)e

18(k+1)2σ2(T−t)u(log(S/E), 1

2σ2(T − t))

17

Page 18: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

The results for the solution of the call and the put are displayed below. 4 Thenumber of increments of tau is 200 with 4τ = 0.000225 while the number ofspace increments is equal to the size of the x interval determined by (50) dividedby 4x = 0.0225. The range for the number of space increments is between 130and 160. Selected results are presented for both the �in the money� and �out ofthe money� case for both the put and the call and for three di�erent dates tomaturity. In both cases, stock prices were chosen that were not too far �out ofthe money� because the comparison becomes somewhat meaningless when thecalculated values are worthless in �nancial terms. The �nancial parameters are:

E = 10 , σ = 0.3 , r = 0.04

Results for a Call

Time Rem. C-N at S = 5 Exact at S = 5 Di�. % Di�.

3 months 8.68E-07 5.59E-07 -3.08E-07 -55.1290

6 months 0.00032 0.00030 -0.00002 -6.2327

1 year 0.01083 0.01074 -0.00009 -0.8313

Time Rem. C-N at S = 15 Exact at S = 15 Di�. % Di�.

3 months 5.1011 5.1010 -6.72E-05 -0.0013

6 months 5.2195 5.2194 -4.64E-05 -0.0001

1 year 5.5003 5.5005 0.00011 0.0021

Results for a Put

Time Rem. C-N at S = 7.5 Exact at S = 7.5 Di�. % Di�.

3 months 2.4169 2.4167 -0.00026 -0.0109

6 months 2.3916 2.3914 -0.00018 -0.0075

1 year 2.3985 2.3985 -0.00005 -0.0019

Time Rem. C-N at S = 12.5 Exact at S = 12.5 Di�. % Di�.

4Matlab code for a call and a put are displayed in Appendix B and C respectively. Thismethod is not the most e�cient way to solve the problem. Speci�cally, for the call and the put,it builds approximately 30,000 x 30,000 square matrix and solves the matrix equation as in theexample of section 4 by using Matlab's �\� command for inverting the matrix. To build sucha large matrix, it is necessary to use the �sparse� command because most personal computerswill not store a matrix of this magnitude in memory. The �sparse� command tells Matlab tocompress the matrix by storing only the non-zero terms. For a matrix that consists mainlyof zeros, this greatly reduces the required memory although it can increase execution timefor matrix operations. A better approach to solving this problem would likely have been touse the iterative matrix procedure in (40) which requires inverting 200 150 x 150 tri-diagonalmatrices. At each step a more e�cient method than matrix inversion like the LU factorizationor a speci�c algorithm for tri-diagonal matrices could have been employed. This would havemade for a more e�cient process with faster execution time.

18

Page 19: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

Time Rem. C-N at S = 12.5 Exact at S = 12.5 Di�. % Di�.

3 months 0.04307 0.04307 1.62E-06 0.0038

6 months 0.14615 0.14640 0.00025 0.1730

1 year 0.34156 0.34190 0.00034 0.1002

This demonstrates that the approximation is always accurate to three decimalplaces. Naturally it could be improved by increasing the number and decreasingthe size of the space and time increments. A graph of all of the approximatedvalues for the call with half a year remaining to maturity is shown below. Thesevalues were calculated under the assumption that S = 15 which is where theapproximated solution should be least a�ected by the errors introduced by theapproximated boundary conditions. Despite this, the graph of the actual andapproximate solution are still close at large and small values of S indicatingthat the approximations at the boundary do not introduce large errors.

The next graph depicts the errors between the Crank-Nicolson approximationand the exact solution calculated for the same values of S and t . It demonstratesthat the Crank-Nicolson solution oscillates around the exact solution when S isnear the exercise price, and that the error is greatest in this vicinity as well. Thisis a well-known issue with the Crank-Nicolson approximation which is caused bythe non-smooth �nal condition. [4] In practice, this problem is often overcome byintroducing one or two smoothing steps using another approximation method,and beginning with the Crank-Nicolson approximation from there.

19

Page 20: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

7 Conclusion

This report has presented an introduction to two related topics: the Black-Scholespartial di�erential equation; and the method of �nite di�erences. It has demonstratedthat the �nite di�erence method is a useful, convergent, and relatively simple way toapproximate solutions to the heat equation. In particular, the Crank-Nicolson methodwas successfully applied to the transformed boundary value problems of the Europeancall and put options with results that were accurate to 3 decimal places. Finally, abrief analysis showed that errors were most pronounced, even at times before expiry,around the strike price where the �nal condition is not smooth.

20

Page 21: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

A Appendix: Matlab code heat equation exam-

ple

echo onformat shor t

% s t ep s o f x and t , m and n r e s p e c t i v e l ym=4;n=2;

% maximum va lues o f i n d i c e s c on s i d e r i ng +1M=m+1;N=n ;

% Upper and lower boundar ies o f x and t% r e s p e c t i v e l y and range o f x and t r e s p e c t i v e l ybx1=0;bx2=1;bt1=0;bt2 =0.16;rx=bx2−bx1 ;r t=bt2−bt1 ;

% s t ep s o f x and t and va lue s o f x and t f o r each stepix=rx/M;i t=r t /N;x1=bx1 : i x : bx2 ;t1=bt1 : i t : bt2 ;

% heat equat ion cons tant sw=1;y=( i t ∗w^2)/( ix ^2) ;z=y /2 ;

% dimensions f o r matrixk=m∗n ;

% gcd and lcmg1 = gcd (m, n ) ;l 1 = lcm (m, n ) ;

% index beg inn ingj =0;i =1;l =1;f =0;

% make matrix and vec to r f o r the equat ionsQ = ze ro s (k , 1 ) ;

21

Page 22: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

A = zero s (k , k ) ;

% populate matrixwhi l e l <= k

i f mod( l , l 1 ) == 1 & l>l1j = 0 + f ;

e l s e i f mod( l , l 1 ) ~= 1 & j == Nj = 0 ;

end ;i f l <= k & i == M

i = 1 ;end ;J = [ j +1, i ,(1+y ) ; j , i , ( y− 1 ) ; . . .j +1, i +1,−z ; j +1, i−1,−z ; j , i +1,−z ; j , i−1,−z ] ;f o r p = 1 :6

i f J (p , 1 ) == 0Q( l , 1 ) = Q( l , 1 ) + . . .s i n ( x1 ( J (p ,2)+1)∗ pi )∗(−1∗J (p , 3 ) ) ;

e l s e i f J (p , 1 ) ~= 0 & . . .J (p , 2 ) ~= 0 & J (p , 2 ) ~= MA( l , ( J (p ,1)−1)∗m + J(p , 2 ) ) = J (p , 3 ) ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) == 0 . . .| J (p , 1 ) ~= 0 & J (p , 2 ) == MQ( l , 1 ) = Q( l , 1 ) + 0 ;

end ;end ;j=j +1;i=i +1;i f gcd (m, n) > 1 & mod( l , l 1 ) == 0

f=f +1;end ;l=l +1;

end ;

% so l v e and d i sp l ay r e s u l t s vec to rS = ze ro s (k , 5 ) ;l =1;i=int32 ( 1 ) ;j=int32 ( 1 ) ;f o r j = 1 : n

f o r i = 1 :m;S( l , 1 ) = j ;S ( l , 2 ) = i ;S ( l , 4 ) = exp(−( p i ^2)∗ t1 ( j + 1 ) ) . . .∗ s i n ( x1 ( i +1)∗ pi )l=l +1;

end ;end ;S ( : , 3 ) = A\Q;f o r l = 1 : k

22

Page 23: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

S( l , 5 ) = S( l , 4 ) − S( l , 3 )end ;d i sp (S ) ;

echo o f f

23

Page 24: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

B Appendix: Matlab code European call solu-

tion

echo onformat shor t

% s t ep s o f x and t , m and n r e s p e c t i v e l ym=140;n=200;

% maximum va lues o f i n d i c e s c on s i d e r i ng +1M=m+1;N=n ;

% Upper and lower boundar ies o f x and t% r e s p e c t i v e l y and range o f x and t r e s p e c t i v e l ybx1=log (15/10) − (80∗0 .0225) ;bx2=log (15/10)+(62∗0 .0225) ;bt1=0;bt2 =0.045;rx=bx2−bx1 ;r t=bt2−bt1 ;

% s t ep s o f x and t and va lue s o f x and t f o r each stepix=rx/M;i t=r t /N;x1=bx1 : i x : bx2 ;t1=bt1 : i t : bt2 ;

%Black Scho l e s Varsr r =0.04;E=10;sigma=0.3;ak=r r / ( ( sigma ^2)/2) ;S1 = E∗exp ( x1 ) ;T1 = ( t1 /( ( sigma ^2)/2 ) ) ;

% heat equat ion cons tant sw=1;y=( i t ∗w^2)/( ix ^2) ;z=y /2 ;

% dimensions f o r matrixk=m∗n ;

% gcd and lcmg1 = gcd (m, n ) ;l 1 = lcm (m, n ) ;

24

Page 25: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

% index beg inningj =0;i =1;l =1;f =0;

% make matrix and vec to r f o r the equat ionsQ = ze ro s (k , 1 ) ;A = spar s e (k , k ) ;

% populate matrixwhi l e l <= k

i f mod( l , l 1 ) == 1 & l>l1j = 0 + f ;

e l s e i f mod( l , l 1 ) ~= 1 & j == Nj = 0 ;

end ;i f l <= k & i == M

i = 1 ;end ;J = [ j +1, i ,(1+y ) ; j , i , ( y−1); j +1, i +1,−z ; j +1, i−1,−z ; . . .j , i +1,−z ; j , i−1,−z ] ;f o r p = 1 :6

i f J (p , 1 ) == 0Q( l , 1 ) = Q( l , 1 ) + max( ( exp ( 0 . 5∗ ( ak +1 ) . . .∗x1 ( J (p,2)+1))− exp ( 0 . 5 . . .∗( ak−1)∗x1 ( J (p ,2)+1))) ,0)∗(−1∗ J (p , 3 ) ) ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) ~= 0 & J (p , 2 ) ~= MA( l , ( J (p ,1)−1)∗m + J(p , 2 ) ) = J (p , 3 ) ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) == 0Q( l , 1 ) = Q( l , 1 ) + 0 ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) == MQ( l , 1 ) = Q( l , 1 ) + ( ( exp ( x1 ( J (p , 2 )+ 1 ) ) . . .−exp(−ak∗ t1 ( J (p , 1 )+1) ) )∗ ( exp ( ( 0 . 5 ∗ ( ak − 1 ) . . .∗x1 ( J (p ,2 )+1))+(0 .25∗ ( ( ak +1)^2 ) . . .∗ t1 ( J (p ,1)+1)))))∗(−1∗ J (p , 3 ) ) ;

end ;end ;j=j +1;i=i +1;i f gcd (m, n) > 1 & mod( l , l 1 ) == 0

f=f +1;end ;l=l +1;

end ;

% so l v e and d i sp l ay r e s u l t s vec to rS = ze ro s (k , 8 ) ;S ( : , 5 ) = (A\Q) ;l =1;

25

Page 26: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

i=in t32 ( 1 ) ;j=int32 ( 1 ) ;f o r j = 1 : n

f o r i = 1 :m;S( l , 1 ) = j ;S ( l , 2 ) = i ;S ( l , 3 ) = T1( j +1);S( l , 4 ) = S1 ( i +1);S( l , 6 ) = S( l , 5 )∗E∗exp ((−0.5∗( ak−1)∗x1 ( i + 1 ) ) . . .+(−0.25∗(( ak+1)^2)∗ t1 ( j +1)) ) ;Ca l l = b l s p r i c e ( S1 ( i +1) ,E, rr ,T1( j +1) , sigma ) ;S( l , 7 ) = Cal l ;l=l +1;

end ;end ;f o r l = 1 : k

S( l , 8 ) = S( l , 7 ) − S( l , 6 ) ;end ;

c svwr i t e ( ' c a l l 4 . dat ' , S ) ;

echo o f f

26

Page 27: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

C Appendix: Matlab code European put solu-

tion

echo onformat shor t

% s t ep s o f x and t , m and n r e s p e c t i v e l ym=133;n=200;

% maximum va lues o f i n d i c e s c on s i d e r i ng +1M=m+1;N=n ;

% Upper and lower boundar ies o f x and t% r e s p e c t i v e l y and range o f x and t r e s p e c t i v e l ybx1=log (12 .5/10) − (72∗0 .0225) ;bx2=log (12 . 5/10 )+(62∗0 .0225) ;bt1=0;bt2 =0.045;rx=bx2−bx1 ;r t=bt2−bt1 ;

% s t ep s o f x and t and va lue s o f x and t f o r each stepix=rx/M;i t=r t /N;x1=bx1 : i x : bx2 ;t1=bt1 : i t : bt2 ;

%Black Scho l e s Varsr r =0.04;E=10;sigma=0.3;ak=r r / ( ( sigma ^2)/2) ;S1 = E∗exp ( x1 ) ;T1 = ( t1 /( ( sigma ^2)/2 ) ) ;

% heat equat ion cons tant sw=1;y=( i t ∗w^2)/( ix ^2) ;z=y /2 ;

% dimensions f o r matrixk=m∗n ;

% gcd and lcmg1 = gcd (m, n ) ;l 1 = lcm (m, n ) ;

27

Page 28: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

% index beg inningj =0;i =1;l =1;f =0;

% make matrix and vec to r f o r the equat ionsQ = ze ro s (k , 1 ) ;A = spar s e (k , k ) ;

% populate matrixwhi l e l <= k

i f mod( l , l 1 ) == 1 & l>l1j = 0 + f ;

e l s e i f mod( l , l 1 ) ~= 1 & j == Nj = 0 ;

end ;i f l <= k & i == M

i = 1 ;end ;J = [ j +1, i ,(1+y ) ; j , i , ( y−1); j +1, i +1,−z ; j +1, i−1,−z ; . . .j , i +1,−z ; j , i−1,−z ] ;f o r p = 1 :6

i f J (p , 1 ) == 0Q( l , 1 ) = Q( l , 1 ) + max( ( exp ( 0 . 5 ∗ . . .( ak−1)∗x1 ( J (p,2)+1))− exp ( 0 . 5 ∗ . . .( ak+1)∗x1 ( J (p ,2)+1))) ,0)∗(−1∗ J (p , 3 ) ) ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) ~= 0 & J (p , 2 ) ~= MA( l , ( J (p ,1)−1)∗m + J(p , 2 ) ) = J (p , 3 ) ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) == 0Q( l , 1 ) = Q( l , 1 ) + ( exp(−ak∗ t1 ( J (p , 1 )+ 1 ) ) . . .∗( exp ( ( 0 . 5 ∗ ( ak−1)∗x1 ( J (p , 2 )+ 1 ) ) . . .+(0 .25∗ ( ( ak+1)^2)∗ t1 ( J (p , 1 ) + 1 ) ) ) ) ) . . .∗(−1∗J (p , 3 ) ) ;

e l s e i f J (p , 1 ) ~= 0 & J (p , 2 ) == MQ( l , 1 ) = Q( l , 1 ) + 0 ;

end ;end ;j=j +1;i=i +1;i f gcd (m, n) > 1 & mod( l , l 1 ) == 0

f=f +1;end ;l=l +1;

end ;

% so l v e and d i sp l ay r e s u l t s vec to rS = ze ro s (k , 9 ) ;S ( : , 5 ) = (A\Q) ;l =1;

28

Page 29: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

i=in t32 ( 1 ) ;j=int32 ( 1 ) ;f o r j = 1 : n

f o r i = 1 :m;S( l , 1 ) = j ;S ( l , 2 ) = i ;S ( l , 3 ) = T1( j +1);S( l , 4 ) = S1 ( i +1);S( l , 6 ) = S( l , 5 )∗E∗exp ((−0.5∗( ak−1)∗x1 ( i + 1 ) ) . . .+(−0.25∗(( ak+1)^2)∗ t1 ( j +1)) ) ;[ Cal l , Put ] = b l s p r i c e ( S1 ( i +1) ,E, rr ,T1( j +1) , sigma ) ;S( l , 7 ) = Put ;l=l +1;

end ;end ;f o r l = 1 : k

S( l , 8 ) = S( l , 7 ) − S( l , 6 ) ;i f S ( l ,7)>(10^(−3))

S( l , 9 ) = S( l , 8 ) / S( l , 7 ) ;end ;

end ;

c svwr i t e ( ' put . dat ' , S ) ;

echo o f f

29

Page 30: Solving the Black Scholes Equation using a Finite Di ...math.yorku.ca/~dhackman/BlackScholes7.pdf · Solving the Black Scholes Equation using a ... equation will be transformed into

References

[1] Implementing �nite di�erence solvers for the black-scholes pde, 2009. URLhttp://faculty.baruch.cuny.edu/lwu/890/SpruillOnFiniteDifferenceMethod.doc.

[2] F. Black and M. Scholes. The pricing of options and corporate liabilities. The

Journal of Political Economy, 81:637�654, 1973.

[3] M. P. Coleman. An Introduction To Partial Di�erential Equations with Matlab.Chapman & Hall/CRC, 2005.

[4] M. Cooney. Report on the accuracy and e�ciency ofthe �tted methods for solving the black-scholes equationfor european and american options, November 2000. URLhttp://www.datasimfinancial.com/UserFiles/articles/BlackScholesReport2.ps.

[5] C. F. Gerald and P. O. Wheatley. Applied Numerical Analysis. Addison Wesley, 3edition, 1984.

[6] J. C. Hull. Options, Futures, and other Derivatives. Pearson Prentice Hall, 7edition, 2009.

[7] P. Wilmott, S. Howison, and J. Dewynne. The Mathematics of Financial Deriva-

tives. Cambridge University Press, 2008.

30