Vous êtes sur la page 1sur 58

Finife-difference MumericoI

Mefhods of PorfioI DifferenfioI


Equofions in Finonce wifh MofIob.

Professor: Aifor 8ergoro
UPV/EHU

hffp://www.ehu.es/oifor
EmoiI: a.bergara@ehu.es
Progrom

Progrom
Objecfives.
8ibIiogrophy.
I. Ordinory DifferenfioI Equofions (ODE).
I.I AnoIyfic resoIufion: second order ODE wifh consfonf coefficienfs (exompIe: fhe
hormonic osciIIofor).
I.Z Some bosics:
I.Z.o 0eomefric inferprefofion of o derivofive.
I.Z.b ToyIor series.
I.3 MumericoI resoIufion of ODEs:
I.3.o Forword EuIer (expIicif) mefhod (MofIob Progrom I).
I.3.b 8ockword EuIer (impIicif) mefhod.
I.3.c Midpoinf mefhod (MofIob Progrom Z).
I.3.d Second-order Punge-Iuffo mefhod (or frope;oidoI).
I.3.e Fourfh-order Punge-Iuffo mefhod.
I.4 Order Peducfion ond o sysfem of ODEs.
I.b Errors ond SfobiIify.


Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs): Finife-difference Mefhods I.
Z.I Definifion of o porfioI derivofive. The grodienf operofor.
Z.I CIossificofion of second order Iineor PDEs depending on fwo voriobIes.
Z.Z AnoIysis of differences in fhe soIufion of PDEs.
Z.3 8oundory ond inifioI condifions.
Z.4 Finife-difference represenfofions of odvecfion (hyperboIic) PDE:
Z.4.o ExpIicif forword fime cenfred spoce mefhod (FTCS) (MofIob Progrom 3).
Z.4.o.I SfobiIify onoIysis: Von Meumonn mefhod.
Z.4.b Lox mefhod (MofIob Progrom 4).
Z.4.b.I SfobiIify AnoIysis: Couronf-Friedrichs-Lewy condifion.
Z.4.c Sfoggered Ieopfrog mefhod.

3. Finife-difference Mefhods II: The Heof (or Diffusion) PoroboIic PDE.
3.I ExpIicif forword fime cenfred spoce mefhod (FTCS) (MofIob Progrom b).
3.I.o SfobiIify onoIysis.
3.Z ImpIicif mefhods:
3.Z.o FuIIy impIicif mefhod (MofIob Progrom o).
3.Z.o.I SfobiIify onoIysis.
3.Z.b Cronk-MichoIson mefhod. (MofIob Progrom 7).
3.Z.b.I SfobiIify onoIysis.
3.Z.b.Z LU decomposifion (MofIob Progrom 8).
3.Z.b.3 SOP (Successive Over-reIoxofion) Mefhod:
Jocobi mefhod.
0ouss-SeideI mefhod.
OpfimoI SOP mefhod.





Progrom


4. The 8Iock-SchoIes Equofion.
4.I Derivofion of 8Iock-SchoIes equofion.
4.Z AnoIysis of odvecfion ond diffusion in fhe 8Iock-SchoIes equofion.
4.3 8osic ossumpfions of 8Iock-SchoIes equofion.
4.4 8oundory ond inifioI/finoI condifions of 8Iock-SchoIes PDE.
4.b Differenf poyoffs of expiry. Europeon ond Americon Opfions.
4.o Tronsformofion fo consfonf coefficienf diffusion equofion.
4.7 Derivofion of 8Iock-SchoIes FormuIoe.
4.8 AnoIysis of fhe 0reeks.
4.9 Exfensions of 8Iock-SchoIes Equofion.

b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion.
b.I ExpIicif mefhods:
b.I.o Derivofion of expIicif FTCS finife-difference represenfofion.
b.I.b ImpIemenfofion of differenf boundory condifions.
b.I.c LocoI ond gIoboI errors.
b.I.d AnoIysis of von Meumonn sfobiIify (MofIob Progrom 9).
b.Z ImpIicif Mefhods:
b.Z.o FuIIy impIicif finife-difference represenfofion.
b.Z.b Cronk-MichoIson mefhod.
b.Z.b.I ImpIemenfofion of boundory condifions.
b.Z.b.Z Mofrix Inversion.
b.Z.b.3 LU decomposifion.
b.Z.b.4 SOP Mefhod.

o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion.
o.I PhiIosophy behind ony new mefhod.
o.Z DougIos scheme.
o.3 Three fime IeveI mefhods: Du-Forf FronkeI.
o.4 Pichordson exfropoIofion.
o.b Free boundory probIems: Americon opfions.
o.b.o EorIy exercise ond fhe expIicif mefhod (MofIob Progrom I0).
o.b.b EorIy exercise ond fhe impIicif mefhods.






Objefives






Objecfives

The bosics of fhis course sfond on fhe Iuck-SchoIes equofion,
which voIues fhe price of on opfion by using PDEs. The sfudy of
PDEs in compIefe generoIify is o vosf underfoking. As oImosf oII
of fhem ore nof possibIe fo soIve onoIyficoIIy (however, one very
usefuI excepfion ore Europeon CoII/Puf opfions) we musf reIy on
numericuI methods ond fhe mosf popuIor ones ore fhe Finife-
difference Mefhods.
Wifh fhis course we do nof infend fo become experfs in Ib hours
in order fo soIve PDEs numericoIIy, buf deveIop both intuition
und technicuI strength required fo survive when such o probIem
needs fo be soIved.

8ibIiogrophy





8ibIiogrophy

P, WiImott S, Howison und J, Dewinne, The Mofhemofics of
FinoncioI Derivofives, Combridge Universify Press, I99o.

D, TuveIIu und C, RunduII, Pricing FinoncioI Insfrumenfs, John
WiIIey Sons Inc., Z000.

S,D, Smith, MumericoI SoIufion of PorfioI DifferenfioI
Equofions: Finife Difference Mefhods, CIorendon Press, Oxford,
I98b.

J,C, Strikwerdu, Finife Difference Schemes ond PorfioI
DifferenfioI Equofions, Chopmon & HoII, Mew York, I990.

I, PeruI, Ecuociones en Derivodos PorcioIes, Addison WesIey,
I99b.

J, C, HuII, Opfions, Fufures & Ofher Derivofives, Prenfice HoII,
Z000.



Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob










I. Ordinory DifferenfioI Equofions
(ODEs)

The firsf sfep before PDEs
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


AnoIyficoI SoIufion of Firsf Order ODEs


0eneroI Firsf-order ODE:



VoriobIe-seporofion mefhod

This mefhod jusf con be oppIied fo soIve fhe simpIesf coses.
When fhe fwo voriobIes confribufe seporofeIy, so fhof,
) ( ) ( ) , ( v H t G v t f = , fhe ODE obove con be rewriffen os:


Affer infegrofing bofh sides, fhe soIufion is:



0 0
) ( , ) , ( v t v v t f
dt
dv
= =
0 0
) ( ,
) ( ) (
v t v
t G
dt
v H
dv
= =

) ( ) (
0 0
} }
=
t
t
v
v
t G
dt
v H
dv
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



8osic TechnicoI Poinfs

I. 0eomefric inferprefofion of o derivofe
















x
x v x x v
dx
dv
x
x x

+
=

=
) ( ) (
lim
0 0
0
0
0
x x x +
0
x
v
) (
0 0
x v v =

) (
0 0
x x v v v + = +
y
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

Z. ToyIor exponsion:








AppIicofion:




























- 2 - 1 0 1 2
- 2
- 1.5
- 1
- 0.5
0
0.5
x
- 1+x
2
- x
3
1
0 0
0
1
0
) ( ) (
!
1
) ( ) (
+
=
=
+ + =

N n
x
N
n
n
n
x x x x
dx
f d
n
x f x f
- 2 - 1 0 1 2
- 1
0
1
2
3
4
5
6
x
x x
e e x f

= 2 ) (
2
Z 1 0 1 Z
1
0
1
Z
3

- 1+ x
2
Second order Third order
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



- 2 - 1 0 1 2
- 1
0
1
2
3
4
5
x
- 1+ x
2
- x
3
+
7x
4
12
- 2 - 1 0 1 2
- 1
0
1
2
3
4
5
x
- 1+x
2
- x
3
+
7x
4
12
-
x
5
4
+
31x
6
360
-
x
7
40
+
127x
8
20160
Fourfh order
Fiffh order
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



MumericoI SoIufion of Firsf Order ODEs



I. Forword EuIer Mefhod

Forword EuIer (FE) mefhod is fhe simpIesf ond mosf obvious
numericoI ODE infegrofor. If uses fhe sIope of eoch poinf,
compufed using fhe ODE, fo exfropoIofe ond find fhe nexf poinf:


So:



t v t f t v t
dt
t dv
t v t t v + = + + ) , ( ) (
) (
) ( ) (
) ( ) , (
2
1
t t v t f v v
i i i i
+ + =
+ t i t t
i
+ =
0
(ExpIicif mefhod)
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

MofIob progrom I: Infegrofe fhe firsf order ODE sysfem
t t x t x + = ) ( 2 ) (
wifh 1 ) 0 ( = x using forword EuIer.


clear;

% Coefficients of the equation: a x'=b x + c t
a=1.;
b=-2.;
c=1.;

% Initial and final times
tinit= 0.;
tmax=5.;

% Number of time steps
maxt = 3000;
dt = (tmax-tinit)/maxt;

% Initial condition
x(1)=1.;
t(1)=tinit;

% Time loop
for j=1:maxt;
x(j+1)=x(j)+dt*((b*x(j)+c*(j)*dt)/a);
t(j+1)=tinit+j*dt;
end;

% Figure
plot(t,x)
title('Euler Method')
xlabel('T')
ylabel('X(t)')











I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



Z. 8ockword EuIer Mefhod

In fhe 8ockword EuIer (8E) fhe righf-hond side is evoIuofed of o
new Iocofion:




3. Midpoinf Mefhod

Symmefric mefhod fo evoIuofe fhe derivofive, using o ToyIor
exponsion fhof invoIves onIy odd powers of t ,




buf requires specioI inifioIisofion fo generofe oddifionoI voIues
fhof ore needed from fhe posf:


) ( ) , ( 2
3
1 1
t t v t f v v
i i i i
+ + =
+
) , (
0 0 0 1
v t f t v v =

More occurofe l
) ( ) , (
2
1 1 1
t t v t f v v
i i i i
+ + =
+ + +
(ImpIicif mefhod)
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob




% Matlab Program 2: Solving the a x'=b x + c t ODE by using the
midpoint method
clear;

% Coefficients of equation a x'=b x + c t
a=1.;
b=-2.;
c=1.;

% Initial and Final Times
tinit= 0.;
tmax=5.;

% Number of Time Steps
maxt = 3000;
dt = (tmax-tinit)/maxt;

% Initial Condition
x(2)=1.;
x(1)=1.0-dt*((b*x(2)+c*(2)*dt)/a);
t(2)=tinit;

% Time Loop
for j=2:(maxt+1);
x(j+1)=x(j-1)+2.*dt*((b*x(j)+c*(j)*dt)/a);
t(j+1)=tinit+(j-1)*dt;
end;

plot(t,x)
title('Midpoint Method')
xlabel('T')
ylabel('X(t)')

I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob




or Second-order Punge-Iuffo (or Trope;oidoI)


We con wrife fhe midpoinf mefhod os:



ond fhe inifioIisofion probIem is eIiminofed in fhe second-order
Punge-Iuffo mefhod, by using exfropoIofion for fhe
infermediofe sfep:



t
t
t v
t
t f v v
i i i i

+ + =
+
))
2
( ,
2
(
1
) (
)
2
,
2
(
) , (
3
2 1
1
2
1
t k v v
k
v
t
t f t k
v t f t k
i i
i i
i i
+ + =
+

+ =
=
+
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

4. Fourfh-order Punge-Iuffo


There ore mony ofher mefhods, i.e. sfep voriobIe mefhods.

Source of Errors (wiII be exfended in nexf chopfer)

Pound-off error comes from finife precision orifhmefic.
Truncofion error comes from fhe mefhod.
SfobiIify.

MumericoI dynomics ore o pernicious probIem: fhe effecfs of fhe
infegrofion mefhod, fhe fime sfep, fhe compufer orifhmefic, efc,
,, con mess wifh fhe sysfem's behoviour in woys fhof Iook
exocfIy Iike reoI effecfs. You shouId oIwoys disfrusf your resuIfs
ond do some bosic beIief checks on fhem: chonge fime sfep, use
o differenf mefhod, use doubIe-precision orifhmefic insfeod of
singIe, efc,, ond see if your resuIfs chonge. If fhey don'f, if is
sofe(r) fo frusf on fhem.
) ( ) 2 2 (
6
1
) , (
)
2
,
2
(
)
2
,
2
(
) , (
5
4 3 2 1 1
3 4
2
3
1
2
1
t k k k k v v
k v t t f t k
k
v
t
t f t k
k
v
t
t f t k
v t f t k
i i
i i
i i
i i
i i
+ + + + + =
+ + =
+

+ =
+

+ =
=
+
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


AnoIyficoI SoIufion of Mfh-Order LODEs

For exompIe, o generoI Znd-order LODE is:



Mfh-Order LODE wifh consfonf coefficienfs

This mefhod jusf con be oppIied fo soIve LODEs wifh consfonf
coefficienfs, which for fhe Z
nd
-order LODE becomes:
h sv v q v p = + + . Consider fhof
1
r ond
2
r ore fhe roofs of fhe
chorocferisfic equofion of fhe Z
nd
-order LODE 0
2
= + + s qr pr .

The foIIowing coses con be considered:


2 1
r r : . / ) (
2 1
2 1
s h e c e c t v
t r t r
+ + =
) (
2 1
= = r r r : . / ) ( ) (
2 1
s h e c t c t v
rt
+ + =

1
c ond
2
c ore consfonfs fhof con be obfoined in ferms of fhe fwo
inifioI condifions.

0 0 0 0
) ( and ) ( , ) ( ) ( ) ( ) ( v t v v t v x h v x s v x q v x p = = = + +
I. Ordinory DifferenfioI Equofions
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


MumericoI SoIufion of Mfh-Order LODEs

M-order ordinory differenfioI equofions con be subsfifufed by o
sysfem of coupIed firsf-order differenfioI equofions. For
exompIe, ony Z
nd
-order ODE: ) ( ) ( ) ( ) ( x h v x r v x q v x p = + + wifh
fhe foIIowing inifioI condifions:
0 0 0 0
) ( , ) ( v x v v x v = = con be
repIoced by fhe sysfem:
1 2 2
2 1
) (
) (
) (
) (
) (
) (
v
x p
x r
v
x p
x q
x p
x h
v
v v
=
=
when fhe new
funcfions ore defined: ) ( ) ( and ) ( ) (
2 1
x v x v x v x v = =
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob





Z. Infroducfion fo PorfioI
DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Tronsformofion from o differenfioI equofion fo o
difference equofion
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob















Heof (or Diffusion) Equofion



ond


0
) , ( ) , (
2
2
=

x
t x T
D
t
t x T
0 ) , ( and 100 ) , 0 ( = = t L T t T
I00
I00
0
0
L
8oundory condifions:
ThermoI conducfivify
(or diffusion coefficienf)
InifioI condifion:
L
x
x T
2
cos 100 ) 0 , (

=
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

ForfunofeIy, oImosf oII PDEs encounfered in Finonce ore Iineor
ond Z
nd
-order. A Iineor Z
nd
-order PDE sofisfied by o funcfion
) , ( t x u depending on jusf fwo voriobIes (spoce ond fime):




CIossified info fhree cofegories:

> 0
2
AC B HiperboIic:


= 0
2
AC B PoroboIic


< 0
2
AC B EIIipfic (os nof reIofed fo finonce, wiII nof be onoIy;ed)

) , , , , ( 2
2
2 2
2
2
x
u
t
u
u t x D
x
u
C
t x
u
B
t
u
A

Lineor in
x
u

ond
t
u


2
2
2 2
2
1
t
u
c x
u

Wove Equofion
2
2
x
u
D
t
u

Diffusion Equofion
(8Iock-SchoIes)

0
2
2
2
2
=

v
u
x
u
LopIoce Equofion
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob
8eing
2
2
2
1
) 0 , (
x
e x u

=

(inifioI puIse) wifh free boundories, fhe


soIufion for eoch fype of equofion differs drosficoIIy:
Wove (or Advecfion) Equofion:
2
) (
2
2
1
) , (
ct x
e t x u














Diffusion Equofion:
Dt
: x :
e
Dt
e d: t x u
4
) (
2
2 2
4
1

2
1
) , (


}
=













-4
-2
0
2
4
0
2
4
6
8
10
0
0.25
0.5
0.75
1
-4
-2
0
2
4

-4
-2
0
2
4
0
5
10
15
20
0
0.25
0.5
0.75
1
-4
-2
0
2
4

x
x
f
f
u
u
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


8oundory/inifioI condifions

Depending on fhe probIem, inifioI condifions (IC)


ond/or boundory condifions (8C):

ond ore coIIed DirichIef (b~0), Mewmonn (o~0), or Pobin (c~0).





In generoI ferms, fhe foIIowing quesfions shouId be osked when
considering o PDE:

Does fhe equofion moke sense mofhemoficoIIy7 Whof musf
we soy obouf fhe soIufion on fhe boundory (boundory
condifions) in order fo obfoin o weII-posed probIem7

Con we deveIop onoIyficoI fooIs fo soIve fhe probIem7

How shouId we soIve fhe equofion numericoIIy7 Whof
impIicofions do fhe mofhemoficoI properfies of fhe soIufion
hove for fhe numericoI mefhod we choose7
) ( ) 0 , (
0
x u t x u = =
t x c
x
u
b au =

+ , ,
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

SimiIorify Mefhod for fhe diffusion equofion

Offen hoppens fhof fhe soIufion of o PDE, fogefher wifh ifs
inifioI ond boundory condifions, depends onIy on one specioI
combinofion of fhe fwo independenf voriobIes. In such coses, fhe
probIem con be reduced fo on ODE in which fhis combinofion is
fhe independenf voriobIe. The soIufion fo fhis ODE is coIIed o
simiIorify soIufion fo fhe PDE.

The key fo fhe SimiIorify SoIufions in fhe diffusion equofion is
fhof bofh fhe equofions ond fhe inifioI ond boundory condifions
ore invorionf under fhe scoIings
2
, x x for ony reoI
number. Such o scoIing is coIIed one-poromefer group of
fronsformofions. Therefore, x is fhe onIy combinofion
independenf of in fhe fronsformofion. In generoI, o good
procficoI fesf fo find simiIorify soIufions in ony equofion is fo fry
soIufions of fhe form ) (

x f u = .

ExompIe I: Suppose fhof ) , ( x u sofisfies fhe foIIowing diffusive
probIem on fhe semi-infinife infervoI 0 > x :





Wifh fhe inifioI condifion: 0 ) 0 , ( = x u , ond o boundory condifion
of x~0, 1 ) , ( = x u , we oIso require fhof 0 ) , ( x u .



, 0 , ,
2
2
>

x
x
u u

Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

As if is expIoined obove, we con Iook for o soIufion which
depends onIy on x ond fhrough fhe combinofion x = , so
fhof, ) ( ) , ( U x u = sofisfies fhe foIIowing second-order ODE:

. 0
2
1
2
2
= +

d
dU
d
U d


From fhe inifioI ond boundory condifions, . 0 ) ( , 1 ) 0 ( = = U U
Seporofing voriobIes we find fhof:

}
+ =

0
4
2
) ( D ds e C U
s
,
where C ond D ore consfonfs. Affer oppIying fhe boundory
condifions, we find fhof:

}

ds e U
s 4
2
1
) (
,
fhof is:

}

x
s
ds e x u
4
2
1
) , (
.



Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


ExompIe Z: We derive here fhe fundomenfoI soIufion (os if con
be considered fhe bosis of o generoI soIufion wifh ony inifioI
condifion) of fhe diffusion equofion:





wifh fhe inifioI condifion: ) ( ) 0 , ( x x u = (fhe Diroc deIfo
funcfion) ond 0 ) , ( x u .

We ogoin Iook for soIufions which depends onIy on x ond
fhrough fhe combinofion x = , buf we know fry fhe form,
) ( ) , (
2 1


U x u

= , which sofisfies fhe foIIowing second-order
ODE:
. 0
) (
2
1
2
2
= +


d
U d
d
U d


The
2 1
ferm is fhere fo ensure dx x u
}


) , ( is consfonf for oII
. The generoI soIufion of fhis is:

D Ce U + =
4
2
) (

,

, 0 , ,
2
2
>

x
x
u u

Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob
where C ond D ore consfonfs. Choosing D~0 ond normoIising fhe
soIufion by seffing ) 2 ( 1 = C , so fhof 1 ) , ( =
}


dx x u

, yieIds
fhe fundomenfoI soIufion:

4
2
2
1
) , (
x
e x u

=


This fundomenfoI soIufion of fhe diffusion equofion con be used
fo derive on expIicif soIufion fo fhe diffusion equofion for
< < x ond 0 > wifh orbifrory inifioI condifions
) ( ) 0 , ( x u x u
o
= .

The key fo fhe soIufion is fhe focf fhof we con wrife fhe inifioI
dofo os
d x u x u
o o
) ( ) ( ) ( =
}


.
As fhe funcfion

4 ) (
2
2
) (
) , ( ) (
x s o
o
e
s u
x s u s u

=


sofisfies fhe diffusion equofion wifh inifioI dofo ) ( ) ( x s s u
o

ond fhe diffusion equofion is Iineor, fhe generoI soIufion is found
by superposing soIufions of fhis form:

ds e s u x u
s x
o

4 ) (
2
) (
2
1
) , (


}
=
.
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


A grid (mesh) is defined in (x,f) spoce so fhof eoch poinf is
chorocferi;ed by:

















) , (
1 0 ,
1 0 ,
,
0
0
f n f n
t f
x n
t x u u
,..., N , t t f t t
,..., N , n x n x x

= + =
= + =
t
x
n
f
) , ( f n
X
t
f n
u
,
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

ExompIe: FIux-conservofive probIem
(Advecfion Equofion)




8y using:




















t
u
x
u
c

) (
, 1 ,
t
t
u u
t
u
f n f n
+

+
) (
2
2 , 1 , 1
x
x
u u
x
u
f n f n
+

+
ond
Second-order represenfofion buf sfiII using
onIy quonfifies known of fime sfep j.
x
f
FTCS
(Forword Time Cenfered Spoce)
Forword EuIer
The conservofion of "porficIes" inside o
voIume is oppIied: fhe chonge on fhe
number of fIowing "porficIes" inside o
finife voIume is equoI fo fhe fIux of fhe
currenf ossociofed fo fhese moving
porficIes.
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob









or





The FTCS represenfofion is on expIicif scheme:
1 , + f n
u for eoch n
con be coIcuIofed expIicifIy from fhe quonfifies fhof ore oIreody
known. Loffer we shoII meef impIicif schemes, which require us
fo soIve impIicif equofions coupIing fhe
1 , + f n
u for vorious n. The
FTCS oIgorifhm is oIso on exompIe of singIe-IeveI scheme, since
onIy voIues of fime IeveI f hove fo be sfored fo find voIues of
fime IeveI 1 + f .


If is o fine exompIe of on oIgorifhm, fhof is eosy fo derive, fokes
IiffIe sforoge, ond execufes quickIy.


x
u u
c
t
u u
f n f n f n f n

+ +
2
, 1 , 1 , 1 ,
( )
f n f n f n f n
u u
x
t c
u u
, 1 , 1 , 1 ,
2
+ +

=
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


% Matlab Program 3: Square-wave Test for the Explicit Method to solve
% the Advection Equation
clear;

% Parameters to define the advection equation and the range in space and
% time
Lmax = 1.0; % Maximum length
Tmax = 1.; % Maximum time
c = 1.0; % Advection velocity

% Parameters needed to solve the equation within the explicit method
maxt = 3000; % Number of time steps
dt = Tmax/maxt;
n = 30; % Number of space steps
nint=15; % The wave-front: intermediate point from which u=0
dx = Lmax/n;
b = c*dt/(2.*dx);

% Initial value of the function u (amplitude of the wave)
for i = 1:(n+1)
if i < nint
u(i,1)=1.;
else
u(i,1)=0.;
end
x(i) =(i-1)*dx;
end


% Value of the amplitude at the boundary
for k=1:maxt+1
u(1,k) = 1.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end


% Implementation of the explicit method
for k=1:maxt % Time loop
for i=2:n % Space loop
u(i,k+1) =u(i,k)-b*(u(i+1,k)-u(i-1,k));
end
end

% Graphical representation of the wave at different selected times
plot(x,u(:,1),'-',x,u(:,10),'-',x,u(:,50),'-',x,u(:,100),'-')
title('Square-wave test within the Explicit Method I')
xlabel('X')
ylabel('Amplitude(X)')


Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob






Too bod, if does nof work ll77
















Jusf pIoy wifh differenf voIues of b (see in fhe progrom scripf
obove) fo reoIi;e how unsfobIe if moy become l
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Sources of Errors ond SfobiIify

In fhis exompIe, we see fhof fhere ore fwo fundomenfoI sources
of error: fruncofion error in fhe spoce ond discrefi;ofions. The
impIicofion of fruncofion error is fhof fhe numericoI scheme
soIves o probIem fhof is nof exocfIy fhe some os fhe probIem we
ore frying fo soIve. The opproximofe soIufion of our PDE
obfoined wifh fhe numericoI scheme con be viewed os fhe exocf
soIufion of o differenf probIem. To chorocferi;e whof numericoI
scheme does, we need fo oddress fhree fundomenfoI issues:

I. Consisfency: A numericoI scheme is soid fo be consisfenf if
fhe finife difference represenfofion converges fo fhe PDE
we ore frying fo soIve os fhe spoce ond fime sfeps fend fo
;ero. When spofioI ond fime discrefi;ofions ore kepf
seporofed (os if is fhe generoI cose) consisfency does nof
oppeor fo be reIevonf, buf hos fo be checked when bofh
discrefi;ofions ore mixed.
Z. SfobiIify: A numericoI scheme is soid fo be sfobIe if fhe
difference befween fhe numericoI soIufion ond fhe exocf
soIufion remoins bounded os fhe number of sfeps fends fo
infinify.
3. Convergence: o scheme s soid fo converge if fhe difference
befween fhe numericoI soIufion of o fixed poinf in fhe
domoin of inferesf fends fo ;ero uniformIy os fhe spoce ond
fime discrefi;ofions fend fo ;ero (nof necessoriIy
independenfIy from eoch ofher).


Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


The Lox EquivoIence Theorem Iinks fhese issues fogefher: 0iven
o properIy posed Iineor inifioI voIue probIem ond o consisfenf
finife difference scheme, sfobiIify is fhe onIy requiremenf for
convergence. This fheorem iIIusfrofes why we wiII dedicofe much
efforf fo onoIy;ing ond undersfonding sfobiIify.

The vogue issue of occurocy of o scheme is nof very reIevonf in
ifs own righf. A consisfenf scheme con be mode increosingIy
occurofe by decreosing fhe fime ond spofioI sfeps. Whof
moffers is fhe cosf (coding efforf, memory requiremenfs ond
compufofionoI requiremenfs) of fhe occurocy.

SfobiIify AnoIysis: Fourier Approoch (von Meumonn)

The sfobiIify probIem orises becouse we ore using finife
precision compufer orifhmefic fo soIve fhe difference equofions,
which infroduces rounding errors info fhe numericoI soIufion.
The sysfem is soid fo be sfobIe if fhese rounding errors ore nof
mognified of eoch iferofion. Ask fhe quesfion, "if o smoII error is
infroduced info fhe soIufion, is if mognified by fhe numericoI
mefhod or does if decoy owoy7".

The Fourier mefhod is bosed on decomposing fhe numericoI
soIufion info Fourier hormonics on fhe spofioI grid. AIfhough fhis
mefhod does nof copfure fhe infIuence of boundory condifions,
if is quife eosy fo formuIofe ond usuoIIy occurofe enough fo
provide procficoI sfobiIify criferio.


Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

We con decompose fhe soIufion info Fourier modes on fhe mesh:
) (
,
) (
x n ik
m
f m f n
m
e t u u

= ,
where ) (
f m
t u is fhe ompIifude ond
m
k is fhe wovenumber of fhe
mode m. A furfher simpIificofion is fhof for Iineor equofions, he
Fourier modes ore uncoupIed, so fhof we mighf consider fhem
individuoIIy. Wrifing fhe fime dependence of fhe ompIifude
I
in
ferms of fhe ompIificofion focfor, ), (k
x ikn f
f n
e k u

= ) (
,
. If we
find fhof 1 , ) ( , > k fhen if is unsfobIe.

Affer subsfifufing fhis in fhe equofion we hove fhof
x k
x
t c
i k

= sin 1 ) ( , so fhof 1 , ) ( , > k , fherefore, fhe soIufion


expIodes (osciIIofory) ond becomes unsfobIell for ony t ond x .


I
PDEs fo be considered hove fhe form:
u
t
u
L =

,
where L is o porfioI differenfioI operofor confoining no fime
derivofives. The oppIicofion of spofioI discrefi;ofion fo Lu wiII
resuIf in fhe foIIowing sysfem of equofions:
Au
u
=
dt
d
,
where A mofrix fhof offer being diogonoIi;ed, AX X =
1
,
where is fhe diogonoI mofrix wifh fhe eigenvoIues
m
.
Infroducing fhe definifion u X v
1
= , fhe soIufion verifies:
t
m m
m
e c v

= , ond offer fime discrefi;ofion
) ( t f
m m
m
e c v

=

, which
goes wifh fhe power of fhe fime sfep, j.

Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

To cure fhe insfobiIify: Lox Mefhod

SimpIy repIoces fhe ferm
f n
u
,
in fhe fime derivofive by ifs
overoge:





The odvecfion equofion furns info:





Which is oIso expIicif, ond offer oppIying fhe von Meumonn
sfobiIify onoIysis we gef:




ond fhe sfobiIify condifion 1 , ) ( , < k Ieods fo fhe requiremenf:






This is urt ||
( )
f n f n f n
u u u
, 1 , 1 ,
2
1
+
+
( ) ( )
f n f n f n f n f n
u u
x
t c
u u u
, 1 , 1 , 1 , 1 1 ,
2 2
1
+ + +

+ =
x k
x
t c
i x k k

= sin cos ) (
1
, ,

x
t c
Couronf-Friedrichs-Lewy
condifion
The mefhod hos fo go fosfer
fhon fhe wove ll
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

% Matlab Program 4: Step-wave Test for the Lax method to solve the Advection
% Equation
clear;
% Parameters to define the advection equation and the range in space and time
Lmax = 1.0; % Maximum length
Tmax = 1.; % Maximum time
c = 1.0; % Advection velocity

% Parameters needed to solve the equation within the Lax method
maxt = 350; % Number of time steps
dt = Tmax/maxt;
n = 300; % Number of space steps
nint=50; % The wave-front: intermediate point from which u=0
(nint<n)!!
dx = Lmax/n;
b = c*dt/(2.*dx);
% The Lax method is stable for abs(b)=< 1/2 but it gets difussed unless abs(b)=
% 1/2

% Initial value of the function u (amplitude of the wave)
for i = 1:(n+1)
if i < nint
u(i,1)=1.;
else
u(i,1)=0.;
end
x(i) =(i-1)*dx;
end


% Value of the amplitude at the boundary at any time
for k=1:maxt+1
u(1,k) = 1.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end



% Implementation of the Lax method
for k=1:maxt % Time loop
for i=2:n % Space loop
u(i,k+1) =0.5*(u(i+1,k)+u(i-1,k))-b*(u(i+1,k)-u(i-1,k));
end
end


% Graphical representations of the evolution of the wave
figure(1)
mesh(x,time,u')
title('Square-wave test within the Lax Method')
xlabel('X')
ylabel('T')

figure(2)
plot(x,u(:,1),'-',x,u(:,20),'-',x,u(:,50),'-',x,u(:,100),'-')
title('Square-wave test within the Lax Method')
xlabel('X')
ylabel('Amplitude(X)')
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob









1
, ,
=

x
t c
5 . 0
, ,
=

x
t c
01 . 1
, ,
=

x
t c
Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):
Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob





Cuses:

>

1
, ,
x
t c
The mefhod gefs unsfobIe

<

1
, ,
x
t c
The mefhod gefs diffusive (if gefs worse fo
gef smoIIer fime sfeps)

=

1
, ,
x
t c
The mefhod converges fo fhe exocf resuIf




Proof fhof fhe Lox scheme of fhe odvecfion equofion is exocfIy
fhe FTCS represenfofion of fhe equofion:






2
2 2
2
) (
x
u
t
x
x
u
c
t
u

Z. Infroducfion fo PorfioI DifferenfioI Equofions (PDEs):


Finife-difference Mefhods I
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Second-order Accurocy in Time:
Sfoggered Leopfrog

The previous scheme is expensive (ond dongerous)
compufofionoIIy. However, fhere ore schemes fhof ore second-
order occurofe in bofh spoce ond fime, ond fhese con offen be
pushed righf fo fheir sfobiIify Iimif. Wifh correspondingIy
smoIIer compufofion fimes:






The von Meumonn sfobiIify onoIysis now gives o quodrofic
equofion for ) (k rofher fhon o Iineor one:

x k
x
t c
i

= sin 2 1
2


whose soIufion is:

2
sin 1 sin
|
.
|

\
|

= x k
x
t c
x k
x
t c
i

Thus fhe Couronf condifion is ogoin required for sfobiIify, in
focf, 1 , ) ( , = k (no diffusion) for ony x t c .

x
u u
c
t
u u
f n f n f n f n

+ + , 1 , 1 1 , 1 ,
Sfoggered Leopfrog
ModeI
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob







3. Finife-difference Mefhods II
The Heof (or Diffusion) PoroboIic PDE













3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

The Diffusive probIem
(Heof or diffusion Equofion)








If D is consfonf:


8y using:









|
.
|

\
|

x
u
D
x t
u
) (
, 1 ,
t
t
u u
t
u
f n f n
+

+
) (
) (
2
2
, 1 , , 1
2
2
x
x
u u u
x
u
f n f n f n
+

+
=

+
ond
CenfroI difference represenfofion buf sfiII
using onIy quonfifies known of fimesfep j.
Forword EuIer.
The conservofion of heof-energy inside o
voIume is oppIied: fhe chonge in fhe energy
(so fhof, in fhe femperofure) inside o
voIume equoIs fhe fIux of heof, which
wifhin fhe Fourier Low is proporfionoI fo
fhe grodienf of fhe femperofure
(conducfivify, D).
2
2
x
u
D
t
u

3. Finife-difference Mefhods II: fhe Heof Equofion


Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob









Or


wifh
2
) ( x
t D

= .












x
f
FTCS
(Forword Time Cenfred Spoce)
2
, 1 , , 1 , 1 ,
) (
2
x
u u u
D
t
u u
f n f n f n f n f n

+
=

+ +
f n f n f n f n
u u u u
, 1 , , 1 1 ,
) 2 1 (
+ +
+ + =
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

% Matlab Program 5: Heat Diffusion in one dimensional wire within the
% Explicit Method
clear;

% Parameters to define the heat equation and the range in space and time
L = 1.; % Length of the wire
T =1.; % Final time


% Parameters needed to solve the equation within the explicit method
maxk = 2500; % Number of time steps
dt = T/maxk;
n = 50; % Number of space steps
dx = L/n;
cond = 1/4; % Conductivity
b = 2.*cond*dt/(dx*dx); % Stability parameter (b=<1)


% Initial temperature of the wire: a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end


% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end



% Implementation of the explicit method
for k=1:maxk % Time Loop
for i=2:n; % Space Loop
u(i,k+1) =u(i,k) + 0.5*b*(u(i-1,k)+u(i+1,k)-2.*u(i,k));
end
end


% Graphical representation of the temperature at different selected times
figure(1)
plot(x,u(:,1),'-',x,u(:,100),'-',x,u(:,300),'-',x,u(:,600),'-')
title('Temperature within the explicit method')
xlabel('X')
ylabel('T')

figure(2)
mesh(x,time,u')
title('Temperature within the explicit method')
xlabel('X')
ylabel('Temperature')
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob













5 . 0
2
2
=

x
t D
05 . 1
2
2
=

x
t D
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob




SfobiIify AnoIysis: Von Meumonn

This is o FTCS scheme ogoin, buf hoving o second derivofive
mokes o worId of difference l The FTCS wos unsfobIe for fhe
odvecfion equofion (hyperboIic), buf frying independenf soIufions
of fhe form
x ikn f
f n
e k u

= ) (
,
, we hove fhof
( )
|
.
|

\
|

=
2
sin
4
1 ) (
2
2
x k
x
t D
k , so fhof fhe requiremenf 1 , ) ( , k ,
Ieods fo fhe sfobiIify criferion:







However, fhis condifion impIies huge Iimifofions on fhe
coIcuIofion procedure. For exompIe, if we wonf fo onoIyse wifh
greof defoiI in spoce ( 1 << x ) impIies fhof 1 << t so fhof o
huge number of sfeps wiII be required unfiI somefhing
inferesfing hoppens. The compufofionoI requiremenf moy be
enormous ond, fherefore, new mefhods ore required.

1
2
2

x
t D
The moximum oIIowed
fime sfep is fhe
diffusion fime ocross o
ceII of widfh x.
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



ImpIicit Methods


A. FuIIy impIicif scheme (or bockword in fime)






This is Iike fhe FTCS scheme excepf fhof fhe spofioI derivofives
on fhe righf-hond side ore evoIuofed of fime sfep j+I.













2
1 , 1 1 , 1 , 1 , 1 ,
2
x
u u u
D
t
u u
f n f n f n f n f n

+
=

+ + + + +
x
f
FuIIy ImpIicif

3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



One hos fo soIve o sef of simuIfoneous Iineor equofions of eoch
fime sfep for fhe
1 , + f n
u . ForfunofeIy, fhis is o simpIe probIem
becouse fhe sysfem is fridiogonoI: jusf group fhe ferms in
equofion oppropriofeIy:







suppIemenfed by DirichIef or Meumonn boundory condifions of
n~0 ond n~M. These equofions wiII be discussed in depfh shorfIy.



Whof obouf sfobiIify7
The ompIificofion focfor is:
|
.
|

\
|

+
=
2
sin 4 1
1
) (
2
x k
k

, which cIeorIy
1 , ) ( , k for ony t . The scheme is uncondifionoIIy sfobIe. The
defoiIs of fhe smoII-scoIe evoIufion form fhe inifioI condifions
ore obviousIy inoccurofe for Iorge t (if is onIy firsf-order in
fime), buf fhe correcf equiIibrium soIufion is obfoined for
t .
2
, 1 , 1 1 , 1 , 1 ,
1 ,..., 2 , 1
) 2 1 (
and with
x
t D
N n
u u u u
f n f n f n f n

= =
+ + =
+ + + +


3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

% Matlab Program 6: Heat Diffusion in one dimensional wire within the Fully
% Implicit Method
clear;

% Parameters to define the heat equation and the range in space and time
L = 1.; % Lenth of the wire
T =1.; % Final time

% Parameters needed to solve the equation within the fully implicit method
maxk = 2500; % Number of time steps
dt = T/maxk;
n = 50.; % Number of space steps
dx = L/n;
cond = 1./4.; % Conductivity
b = cond*dt/(dx*dx); % Parameter of the method

% Initial temperature of the wire: a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end


% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end


aa(1:n-2)=-b;
bb(1:n-1)=1.+2.*b;
cc(1:n-2)=-b;
MM=inv(diag(bb,0)+diag(aa,-1)+diag(cc,1));


% Implementation of the implicit method
for k=2:maxk % Time Loop
uu=u(2:n,k-1);
u(2:n,k)=MM*uu;
end

% Graphical representation of the temperature at different selected times
figure(1)
plot(x,u(:,1),'-',x,u(:,100),'-',x,u(:,300),'-',x,u(:,600),'-')
title('Temperature within the fully implicit method')
xlabel('X')
ylabel('T')

figure(2)
mesh(x,time,u')

title('Temperature within the fully implicit method')
xlabel('X')
ylabel('Temperature')
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



Ieeping fhe mesh fixed ond chonging fhe conducfivify:







5 . 0
2
2
=

x
t D
2
2
2
=

x
t D
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



8. Cronk-MichoIson Mefhod
(highIy recommended l)

Combines fhe sfobiIify of on impIicif mefhod wifh fhe occurocy
of o mefhod fhof is second-order in bofh spoce ond fime. SimpIy
from fhe overoge of fhe expIicif ond impIicif FTCS schemes
(Ieff- ond righf hond side ore cenfred of fime sfep j+I/Z):





















|
|
.
|

\
|

+ + +
=

+ + + + + +
2
, 1 , , 1 1 , 1 1 , 1 , 1 , 1 ,
) 2 ( ) 2 (
2 x
u u u u u u
D
t
u u
f n f n f n f n f n f n f n f n
x
f
Cronk-MichoIson

3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob












Whof obouf sfobiIify7
The ompIificofion focfor is:
|
.
|

\
|

+
|
.
|

\
|

=
2
sin 2 1
2
sin 2 1
) (
2
2
x k
x k
k

, which cIeorIy
1 , ) ( , k for ony t . The scheme is uncondifionoIIy sfobIe ond
second-order bofh in fime ond spoce. If is worfhy fo onoIyse if
more deepIy.

3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

The Cronk-MichoIson con be wriffen os:




These equofions onIy hoIds for 1 1 N n . The boundory
condifions ogoin suppIy fhe fwo missing equofions. They ore
horder fo hondIe fhon in fhe expIicif mefhod ond I wiII discuss
fhem.
The Cronk-MichoIson mefhod con be wriffen in o mofrix form:







1 , 1 1 , 1 , 1 , 1 , , 1
) 2 2 ( ) 2 2 (
+ + + + +
+ + = + +
f n f n f n f n f n f n
u u u u u u
|
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|

=
|
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+
+
+
+

+
+
+
+
f N
f N
f
f
f N
f N
f
f
u
u
u
u
u
u
u
u
,
, 1
, 1
, 0
1 ,
1 , 1
1 , 1
1 , 0
.
.
.

2 2 . . . .
0 2 2 . . . .
. . . . . 0 .
. . . 2 2 0
. . . 0 2 2
.
.
.

2 2 . . . .
0 2 2 . . . .
. . . . . 0 .
. . . 2 2 0
. . . 0 2 2








3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


The fwo mofrices hove M-I rows ond M+I coIumns, which is o
represenfofions of fhe M-I equofions ond M+I unknowns. The
fwo equofions fhof we ore missing come from fhe boundory
condifions. Using fhese condifions, I om going fo converf fhis
sysfem of equofions info o sysfem of equofions invoIving o squore
mofrix. The oim is fo wrife o sysfem of equofions in fhe form:




For known squore mofrices
L
f 1 +
M ond
R
f
M , ond o known vecfors
r
, where fhe defoiIs of fhe boundory condifions hove been fuIIy
incorporofed.


ExompIe of boundory condifion: given
1 , 0 + f
u ond
1 , + f N
u : Somefimes
we know fhe voIue of fhe u funcfion on fhe boundory (n~0 ond
n~M). In fhis cose, we con wrife:











R
f f
R
f
L
f f
L
f
r u M r u M + = +
+ + + 1 1 1
|
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+
+
+
+
+
+
+
+
1 ,
1 , 1
1 , 1
1 , 0
.
.
.

2 2 . . . .
0 2 2 . . . .
. . . . . 0 .
. . . 2 2 0
. . . 0 2 2
f N
f N
f
f
u
u
u
u




3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


os










ond fhe some for fhe mofrices on fhe righf.

Whichever of fhe boundory condifions we hove, fhe Cronk-
MichoIson scheme, wifh boundory condifions incorporofed is:




How do we fhen find
1 + f
u 7 In principIe, fhe mofrix
L
f 1 +
M couId be
inverfed fo give:




However, mofrix inversion is very fime consuming ond
compufofionoIIy inefficienf. Two much beffer woys wiII be
expIoined beIow:

L
f f
L
f
f N
f
f N
f
u
u
u
u
1 1 1
1 ,
1 , 0
1 , 1
1 , 1

.
.
.
0

.
.
.
.

2 2 0 . . .
2 2 . . .
. . . . 0
. . . . 2 2
. . . 0 2 2
+ + +
+
+
+
+
+ =
|
|
|
|
|
|
|
|
.
|

\
|

+
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+
+

+
+
r u M



f
R
f
L
f
R
f f
L
f
u M r r u M + =
+ + + 1 1 1
) ( ) (
1
1
1 1 f
R
f
L
f
R
f
L
f f
u M r r u + =
+

+ +
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

% Matlab Program 7: Heat Diffusion in one dimensional wire within the
% Crank-Nicholson Method
clear;

% Parameters to define the heat equation and the range in space and time
L = 1.; % Lenth of the wire
T =1.; % Final time

% Parameters needed to solve the equation within the Crank-Nicholson method
maxk = 2500; % Number of time steps
dt = T/maxk;
n = 50.; % Number of space steps
dx = L/n;
cond = 1/2; % Conductivity
b = cond*dt/(dx*dx); % Parameter of the method

% Initial temperature of the wire: a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
u(i,1) =sin(pi*x(i));
end

% Temperature at the boundary (T=0)
for k=1:maxk+1
u(1,k) = 0.;
u(n+1,k) = 0.;
time(k) = (k-1)*dt;
end


% Defining the Matrices M_right and M_left in the method
aal(1:n-2)=-b;
bbl(1:n-1)=2.+2.*b;
ccl(1:n-2)=-b;
MMl=diag(bbl,0)+diag(aal,-1)+diag(ccl,1);

aar(1:n-2)=b;
bbr(1:n-1)=2.-2.*b;
ccr(1:n-2)=b;
MMr=diag(bbr,0)+diag(aar,-1)+diag(ccr,1);


% Implementation of the Crank-Nicholson method
for k=2:maxk % Time Loop
uu=u(2:n,k-1);
u(2:n,k)=inv(MMl)*MMr*uu;
end

% Graphical representation of the temperature at different selected times
figure(1)
plot(x,u(:,1),'-',x,u(:,100),'-',x,u(:,300),'-',x,u(:,600),'-')
title('Temperature within the Crank-Nicholson method')
xlabel('X')
ylabel('T')

figure(2)
mesh(x,time,u')

title('Temperature within the Crank-Nicholson method')
xlabel('X')
ylabel('Temperature')
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



Ieeping fhe mesh fixed ond chonging fhe conducfivify:








5 . 0
2
2
=

x
t D
2
2
2
=

x
t D
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


o. LU Decomposifion (In MofIob: [L,U]=lu(M))

The mofrix
L
f 1 +
M is fridiogonoI, ond if is nof hord fo decompose
info fhe producf of fwo ofher mofrices, one hoving non;ero
eIemenfs oIong fhe diogonoI ond fhe subdiogonoI (L) ond fhe
ofher hoving non-;ero eIemenfs oIong fhe diogonoI ond fhe
superdiogonoI (U). So fhof: U L M = (fhof is why if is coIIed LU
decomposifion).


















Where, wifhouf Ioss of generoIify, I hove chosen fhe diogonoI
eIemenfs of L fo be one.

|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
|
.
|

\
|
+
+

+
+

1
2 2
3
2 2
1 1
1
2
3
2
0 0 . . .
0 . . .
0 . . 0 0
. . . 0
. 0 . . 0
.
1 0 . . .
0 1 . . .
. 0 . . 0
. . . 0 1
. . . 0 0 1

2 2 0 . . .
2 2 . . .
. . . . 0
. . . . 2 2
. . . 0 2 2
N
N N
N
N
N
d
p d
p
p d
p d
l
l
l
l



3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


If con be seen fhof fhe foIIowing reIofions ore verified:




Mofice fhof we work form n~I fo n~M sequenfioIIy.

Mow we expIoif fhe decomposifion fo soIve:









And fhen we ore oImosf done.

The firsf sfep gives:
1 1
q w = ond
1
=
n n n n
w l q w for
1 2 N n , where we ogoin musf work sequenfioIIy.

The second sfep invoIves working bockwords from n~M-Z fo
n~I:
1
1
1

=
N
N
N
d
w
u ond
n
n n n
n
d
u p w
u
1 +

= for 1 2 n N

If our mofrix equofion is fime independenf fhe LU decomposifion
needs fo be done onIy once.
1 2 2 2
, 2 2
Ior and
1 1 1
1
+ = = =
+ =

N n p l d p d l
d
n n n n n n

f
R
f
L
f
R
f f
L
f
u M r r u M + =
+ + + 1 1 1
q
u M
w u U q Lw q u LU q u M = = = = , , ,
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob
% Matlab Program 8: Heat Diffusion in one dimensional wire within the
% Crank-Nicholson Method
% by using the LU decomposition.
clear;
% Parameters to define the heat equation and the range in space and time
L = 1.; % Lenth of the wire
T = 1.; % Final time
% Parameters needed to solve the equation within the Crank-Nicholson method
% by using the LU decomposition
maxk = 2500; % Number of time steps
dt = T/maxk;
n = 50.; % Number of space steps
dx = L/n;
cond = 1./4.; % Conductivity
b = cond*dt/(dx*dx); % Parameter of the method

% Initial temperature of the wire: a sinus.
for i = 1:n+1
x(i) =(i-1)*dx;
v(i,1) =sin(pi*x(i));
end

% Temperature at the boundary (T=0)
for k=1:maxk+1
v(1,k) = 0.;
v(n+1,k) = 0.;
time(k) = (k-1)*dt;
end

% Defining the Matrices M_right and M_left in the method
aal(1:n-2)=-b;
bbl(1:n-1)=2.+2.*b;
ccl(1:n-2)=-b;
MMl=diag(bbl,0)+diag(aal,-1)+diag(ccl,1);
[L,U]=lu(MMl); % LU decomposition
aar(1:n-2)=b;
bbr(1:n-1)=2.-2.*b;
ccr(1:n-2)=b;
MMr=diag(bbr,0)+diag(aar,-1)+diag(ccr,1);
% Implementation of the LU decomposition within the Crank-Nicholson method
for k=2:maxk % Time Loop
vv=v(2:n,k-1);
qq=MMr*vv;
w(1)=qq(1);
for j=2:n-1
w(j)=qq(j)-L(j,j-1)*w(j-1);
end
v(n,k)=w(n-1)/U(n-1,n-1);
for i=n-1:-1:2
v(i,k)=(w(i-1)-U(i-1,i)*v(i+1,k))/U(i-1,i-1);
end
end
% Graphical representation of the temperature at different selected times
figure(1)
plot(x,v(:,1),'-',x,v(:,100),'-',x,v(:,300),'-',x,v(:,600),'-')
title('Temperature within the Crank-Nicholson method (LU)')
xlabel('X')
ylabel('T')
figure(2)
mesh(x,time,v')
title('Temperature within the Crank-Nicholson method (LU)')
xlabel('X')
ylabel('Temperature')
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

b. SOP (Successive Over-reIoxofion)

This is on indirecf mefhod (hos fo be soIved iferofiveIy) fo soIve
q Mu = mofrix equofion ond oIfhough fhe resuIfing soIufion wiII
never be exocf we con find if fo whofever occurocy we wonf.
8esides, indirecf mefhods con be oppIied fo wider ronge of
probIems, for exompIe, M mofrix need nof be fridiogonoI (I wiII
describe fhe ideos more generoIIy).

The sysfem of equofions con be wriffen os:









Where now M is fhe number of equofions (fhe si;e of fhe
mofrix), ond con be rewriffen os:









N N NN N N
N N
N N
q u M u M u M
q u M u M u M
q u M u M u M
= + + +
= + + +
= + + +

2 2 1 1
2 2 2 22 1 21
1 1 2 12 1 11
) (
) (
) (
2 2 1 1
2 1 21 2 2 22
1 2 12 1 1 11

+ + =
+ + =
+ + =
u M u M q u M
u M u M q u M
u M u M q u M
N N N N NN
N N
N N
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

The sysfem is eosiIy soIved iferofiveIy using:









Where fhe superscripf denofes fhe IeveI of fhe iferofion, which
is sforfed wifh some inifioI guess
0
u . This iferofive mefhod is
coIIed fhe Jocobi Mefhod.

I con wrife fhe mofrix M os fhe sum of o diogonoI mofrix D, on
upper frionguIor mofrix T(wifh ;eros in fhe diogonoI) ond o
Iower frionguIor mofrix L (wifh ;eros in fhe diogonoI):
L T D M + + = . I con use fhis represenfofion fo wrife fhe Jocobi
ond ofher mefhods quife eIegonfIy:




When fhe Jocobi mefhod is impIemenfed some of fhe voIues
1 + i
n
u ore evoIuofed before ofhers. In fhe 0ouss-SeideI mefhod we
use fhe updofed voIues os soon os fhey ore coIcuIofed. This
mefhod con be wriffen os:




[ ]
[ ]
[ ] ) (
1
) (
1
) (
1
2 2 1 1
1
2 1 21 2
22
1
2
1 2 12 1
11
1
1

+ + =
+ + =
+ + =
+
+
+
i
N
i
N N
NN
i
N
i
N N
i i
i
N N
i i
u M u M q
M
u
u M u M q
M
u
u M u M q
M
u
[ ]
i i
L)u (T q D u + =
+ 1 1
(

=

=

=
+ +
N
n f
i
f nf
n
f
i
f nf n
nn
i
n
u M u M q
M
u
1
1
1 1
1
3. Finife-difference Mefhods II: fhe Heof Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

0eneroIIy, iferofe mefhods usuoIIy converge fo fhe correcf
soIufion from one side (fhe correcfion
i
n
i
n
u u
+1
sfoys on fhe some
side of fhe sign os i increoses ). This is used by fhe SOP mefhod
fo speed up fhe convergence. This mefhod con be wriffen os:














OpfimoI choice of :

The error u u e =
i i
, where u is fhe exocf soIufion, sofisfies:



The SOP mefhod wiII converge provided fhof fhe Iorgesf of fhe
moduIi of fhe eigenvoIues (fhe specfroI rodius), of fhe SOP
mofrix is Iess fhon I. There is o fheoreficoI opfimum voIue for
, fhof is when fhe specfroI rodius is minimum. In procfice if is
very simpIe fo iferofe on fo find fhe opfimoI voIue.

(

+ =

=

=
+ +
N
n f
i
f nf
n
f
i
f nf n
nn
i
n
i
n
u M u M q
M
u u
1
1
1 1
) 1 (

AcceIerofion or
Over-reIoxofion poromefer,
which musf Iie befween I ond Z
( ) [ ] q D u T D I L D I u
1 1 1 1 1
) 1 ( ) (
+
+ + =
i i
( ) [ ]
i i
e T D I L D I e
1 1 1 1
) 1 ( ) (
+
+ =
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob














4. The 8Iock-SchoIes Equofion
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

A very specioI porffoIio

We con wrife fhe opfion voIue os ) , ( ) ; , ; , ; , ( t S J r T E t S J .

One simpIe observofion is fhof o coII opfion wiII rise in voIue if
fhe underIying ossef rises (posifive correIofion) ond fhe opposife
for o puf opfion.

Use fo denofe o porffoIio of one Iong opfion posifion ond o
shorf posifion in some quonfify, , of fhe underIying, S :


The underIying foIIows o IognormoI rondom woIk:

The chonge on fhe voIue of fhe porffoIio from f fo df is:



ond from Ifo we hove:



Thus fhe porffoIio chonges by:
S t S J ) , ( =
SdX Sdt dS + =
dS dJ d =
dS
S
J
dt
S
J
S dt
t
J
dJ

=
2
2
2 2
2
1

dS dS
S
J
dt
S
J
S dt
t
J
d

=
2
2
2 2
2
1

Mof oIwoys occurofe.


4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



EIiminofion of risk: DeIfo Hedging








If we chose
S
J

= fhen fhe rondomness is reduced fo ;erol


DeIfo hedging is on exompIe of dynomic hedging.


Mo orbifroge

Affer choosing fhe quonfify os suggesfed obove, we hoId o
porffoIio whose voIue chonges by fhe omounf:




This chonge is compIefeIy riskIess, fhen if musf be fhe some os
fhe growfh we wouId gef if we puf fhe equivoIenf omounf of cosh
in o risk-free inferesf-beoring occounf:



dS dS
S
J
dt
S
J
S dt
t
J
d

=
2
2
2 2
2
1

Pondomness ~ Pisk
dt
S
J
S
t
J
d
|
|
.
|

\
|

=
2
2
2 2
2
1

dt r d =
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob









Fisher 8Iock-Myron SchoIes equofion (I973):

(Two-dimensionoI Lineor PoroboIic PDE)



















0
2
1
2
2
2 2
=

rJ
S
J
rS
S
J
S
t
J

8osic diffusion confribufion, so fhof ony


disconfinuify in fhe poyoff wouId be insfonfIy
diffused owoy. The diffusion coefficienf is o
funcfion of S.
Pepresenfs fhe odvecfion ferm moving V in o
preferred direcfion (Iike bree;e bIows fhe smoke).
This is o reocfion ferm. 8oIoncing fhis
ferm ond fhe fime derivofive wouId give o
modeI for decoy of o rodioocfive body.
Add fogefher fwo
soIufions of fhe
equofion ond you
wiII gef o fhird.
Even if we sforf wifh o
disconfinuify in fhe finoI
dofo, due fo o disconfinuify
in fhe poyoff, fhis
immediofeIy gefs smoofhed
ouf, due fo fhe diffusive
nofure of fhe equofion.
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Jusf on exompIe (see fhe differences): DigifoI CoII Europeon
Opfion wifh E~I06, T~I yeor.





In fhe curves red represenfs fhe voIue of fhe opfion of expiry,
green hoIf o yeor before fhof, ond fhe bIue one yeor before,
fhof is, when fhe confrocf is signed (fhe price).
r~0.4
~0
r~0
~0.Zb
r~0.4
~0.Zb
Advecfion Diffusion
Advecfion
+
Diffusion
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob






The 8Iock-SchoIes ossumpfions:

(Even fhough oII of fhe ossumpfions con be shown fo be wrong fo o greofer or Iesser
exfenf, fhe 8Iock-SchoIes modeI is profoundIy imporfonf bofh in fheory ond in
procfice)


The underIying foIIows o IognormoI rondom worId.

The risk-free inferesf rofe is o known funcfion of fime.

There ore no dividends on fhe underIying.

DeIfo hedging is done confinuousIy.

There ore no fronsocfion cosfs on fhe underIying.

There ore no orbifroge opporfunifies.





4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob






8oundory ond InifioI/FinoI Condifions

The 8Iock-SchoIes equofion knows nofhing obouf whof kind of
opfion we ore voIuing, whefher if is o coII or o puf, nor whof is
fhe sfrike ond fhe expiry, which ore deoIf wifh fhe finoI
condifion.

To uniqueIy specify fhe probIem we musf prescribe boundory
condifions (how fhe soIufion musf behove for oII fime of cerfoin
voIues of fhe ossef, usuoIIy of 0 = S ond S ) ond inifioI, 0 = t ,
or finoI condifions, T t = .

The 8Iock-SchoIes equofion is o bockword equofion (fhe signs of
fhe f derivofive ond fhe second S derivofive in fhe equofion ore
fhe some when wriffen on fhe some side), fherefore, o finoI
condifion (usuoIIy fhe poyoff funcfion ) , ( T S J of expiry) hos fo
be imposed.

4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Poyoffs of Expiry

Europeon CoII : ) 0 , max( ) , ( E S T S J =









Europeon Puf: ) 0 , max( ) , ( S E T S J =










V
S E
V
S E
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



8inory (or digifoI) CoII : ) ( ) , ( E S T S J =










8inory (or digifoI) Puf : ) ( ) , ( S E T S J =










V
S E
V
S E
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


8uII Spreod : ) 0 , max( ) 0 , max( ) , (
2 1
E S E S T S J =











8eor Spreod : ) 0 , max( ) 0 , max( ) , (
2 1
S E S E T S J =

V
S EI EZ
V
S EI EZ
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

SfroddIe : A coII ond o puf wifh fhe some sfrike price.











SfrongIe: A coII ond o puf wifh differenf sfrike prices.











V
S E
V
S
EI EZ
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


8ufferfIy : InvoIves fhe purchose ond soIe of opfions
wifh fhree differenf expiries.











Condor: Iike o bufferfIy excepf fhof for four sfrikes.










V
S
V
S
EI EZ
EI EZ E3
E3 E4
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



Tronsformofion fo Consfonf Coefficienf Diffusion
Equofion


If con somefimes be usefuI fo fronsform fhe bosic 8Iock-
SchoIes equofion info somefhing o IiffIe bif simpIer by o chonge
of voriobIes. If we wrife:




where





Then ) , ( x U sofisfies fhe bosic diffusion equofion:




) , ( ) , (

x U e t S J
x+
=
2
2
2 2
2
and , 1
2
4
1
, 1
2
2
1

= =
|
.
|

\
|
+ =
|
.
|

\
|
= T t e S
r r
x
2
2
x
U
t
U

4. The 8Iock-SchoIes Equofion


Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

Derivofion of 8Iock-SchoIes FormuIoe
(However mojorify of confrocfs do nof hove expIicif soIufions)






We wiII worry obouf fhe finoI condifions (which moke fhe
soIufion unique) Iofer. For fhe momenf concenfrofe on
monipuIofing info somefhing we con eosiIy soIve.

I. Chonge from presenf voIue fo fufure voIue ferm
) , ( ) , (
) (
t S U e t S J
t T r
= :





Z. As we ore soIving o bockword equofion: t T =




3. From fhe ossef price fo ifs refurn, os buiIding up fhe
sfochosfic differenfioI equofion (IognormoIify): S log =




0
2
1
2
2
2 2
=

rJ
S
J
rS
S
J
S
t
J

0
2
1
2
2
2 2
=

S
U
rS
S
U
S
t
U

S
U
rS
S
U
S
U

2
2
2 2
2
1

U
r
U U
)
2
1
(
2
1
2
2
2
2

4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


4. TronsIofion of coordinofe sysfem: )
2
1
(
2
+ = r x ond
) , ( x W U = , Iike using fhe forword insfeod of fhe spof price.





The specioI soIufion of fhis equofion is:

(0reen Funcfion)

In fhe Iimif 0 fhis soIufion becomes o deIfo funcfion
) ( x x which hos de foIIowing specioI properfy:




Mow if is fime fo consider fhe poyoff: ) ( PayoII ) , ( S T S J = , ond in
our new voriobIes: ) ( PayoII ) 0 , (
x
e x W = .




2
2
2
2
1
x
W W

2
2
2
) (
2
1
) , (
x x
e x W

=
For ony x
(Infinife soIufions)
) ( ) (
2
1 2
2
2
) (
0
x g x d x g e Lim
x x
=
}


4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

Then I cIoim fhof fhe soIufion of fhis equofion for 0 > is:



Or refrocing our sfeps:




For exompIe,

o coII (europeon) opfion voIue is: ) ( ) ( ) , (
2
) (
1
d N Ee d SN t S J
t T r
C

= ,
where
t T
t T r E S
d

+ +
=

) )(
2
1
( ) / log(
2
1
,
t T
t T r E S
d

+
=

) )(
2
1
( ) / log(
2
2


ond
}

=
d
x
dx e d N
2
2
1
2
1
) (

is fhe cumuIofive disfribufion funcfion


for o MormoI disfribufion.

Puf (europeon) opfion voIue is: ) ( ) ( ) , (
2
) (
1
d N Ee d SN t S J
t T r
P
+ =

.
}

= x d e e x W
x
x x
) ( PayoII
2
1
) , (
2
2
2
) (

=
0
) ( 2
)) )( 2 / 1 ( ) / (log(
) (
) ( PayoII
) ( 2
) , (
2
2 2
S
S d
S e
t T
e
t S J
t T
t T r S S
t T r


4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


The 0reeks

DeIfo:
S
J

= : DeIfo hedging meons hoIding one of fhe opfion


ond shorf o quonfify of fhe underIying., which vories os S
ond f vories (dynomic hedging). If is very big fhe
opproximofion coIIopses.

0ommo:
2
2
S
J

= : Since is fhe sensifivify of fhe fo fhe


underIying if is o meosure of by how offen o posifion musf be
rehedged in order fo moinfoin o deIfo neufroI posifion. The
hedging requiremenf is decreosed by o -neufroI sfrofegy.

Thefo:
t
J

= : In fhe 8Iock-SchoIes equofion confribufes fo


ensure fhof o hedged posifion eorns fhe risk-free rofe.

Vego:

=
J
Jega : Is fhe sensifivify fo voIofiIify. If is
differenf (if is nof even e greek Ieffer) os if is fhe derivofe
wifh respecf o poromefer (which is nof known occurofeIy) ond
nof o voriobIe. We con oIso Vego hedge fo reduce sensifivify
fo voIofiIify, which mighf be fhe mojor sfep reduce modeI risk.

Pho:
r
J

= : One offen uses o whoIe ferm sfrucfure of


inferesf rofes.
4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

Exfensions of 8Iock-SchoIes Equofion

I. Opfions on dividend-poying equifies:
Lef's ossume fhof fhe ossef receives o consfonf dividend yieId, D. Thof is
in o fime df eoch ossef receives on omounf of DSdf.

0 ) (
2
1
2
2
2 2
=

rJ
S
J
S D r
S
J
S
t
J



II. Currency Opfions:
In hoIding fhe foreign currency we receive inferesf of fhe foreign rofe of
inferesf,
f
r .

0 ) (
2
1
2
2
2 2
=

rJ
S
J
S r r
S
J
S
t
J
f



III. Commodify Opfions:
The reIevonf feofure of commodifies is fhof fhey hove o cosf of corry.
Lef's infroduce q os fhe frocfion of fhe voIue of fhe commodify fhof goes
fo poy fhe cosf of corry. This is jusf o negofive dividend,

0 ) (
2
1
2
2
2 2
=

+ +

rJ
S
J
S q r
S
J
S
t
J



IV. Opfions on Fufures:
The fufure price, F, of o non-dividend poying equify is reIofed fo fhe spof
price by: S e F
t T r ) (
= . We con eosiIy chonge voriobIes
) , ( ) , ( t F U t S J = fo gef:

0
2
1
2
2
2 2
=

rU
F
U
F
t
U


4. The 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

V. Opfions on fime-dependenf poromefers:
The poromefers ore known funcfions of fime.

[ ] 0 ) ( ) ( ) ( ) (
2
1
2
2
2 2
=

J t r
S
J
S t D t r
S
J
S t
t
J




VI. Power Opfions:
An opfion wifh o poyoff fhof depends on fhe ossef price of expiry roised
fo some power, . Thof is, if

S P = we con wrife:


0 ) 1 (
2
1
2
1
2
2
2
2 2 2
=

+ +

rJ
P
J
P r
P
J
P
t
J




VII. Two-focfor Opfions:
When inferesf rofes ore oIso sfochosfic, dX t r w dt t r u dr ) , ( ) , ( + = , buf
nof correIofed fo fhe ossef, fhe voIue of fhe opfion is defermined by:

0 ) ( ) (
2
1
2
1
2
2
2
2
2
2 2
=

J t r
r
J
w u
S
J
rS
r
J
w
S
J
S
t
J


VII. EorIy Exercise Opfions:
These opfions con be exercised eorIy, prior fo expiry (Americon,
8ermudon, ,). The some 8Iock-SchoIes equofion is verified.

VIII. And o huge mony ofher derivofives ,

b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob














b. Finife-difference Pepresenfofions
for fhe 8Iock-SchoIes Equofion
The exfro compIexify of impIicif mefhods is ouf weighfed by
fheir superior sfobiIify properfies.
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob










PoreIy we con find cIosed-form soIufions for fhe voIues of
opfions. UnIess fhe probIem is very simpIe indeed we ore going fo
hove fo soIve o porfioI differenfioI equofion numericoIIy.
WiIImoff: "I wouId soy fhof I use finife-difference mefhods
obouf 7b7 of fhe fime, Monfe CorIo simuIofions Z07, ond fhe
resf wouId be expIicif formuIoe. Those expIicif formuIoe ore
oImosf oIwoys jusf fhe reguIor 8Iock-SchoIes formuIoe for coIIs
ond pufs. "













b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Lef us infroduce some nofofion:
























) , (
1 0 ,
1 0 ,
, f n f n
f
n
t S J J
,..., J , f t f T t
,..., N , n S n S

= =
= =
As 8Iock-SchoIes is fo be
soIved in < S 0 , S N wiII
be our opproximofion fo .
I hove chonged fhe
direcfion of fime, os j
increoses fime decreoses.
S
t
f
n
) , ( f n
t
S
t J T =
Poyoff
(IC)
8C
8C
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


The 8Iock-SchoIes equofion is:






I om going fo wrife fhis os fo emphosi;e fhe wide oppIicobiIify of
fhe numericoI mefhod:





Affer foking expIicif opproximofions fo fhe derivofives:















0
2
1
2
2
2 2
=

rJ
S
J
rS
S
J
S
t
J


0 ) , ( ) , ( ) , (
2
2
= +

J t S c
S
J
t S b
S
J
t S a
t
J

) , (
2
2
2
, ,
, 1 , 1
,
2
, 1 , , 1
,
, 1 ,
S t J c
S
J J
b
S
J J J
a
t
J J
f n f n
f n f n
f n
f n f n f n
f n
f n f n
= +
|
|
.
|

\
|

+
|
|
.
|

\
|

+
+

+
+
+
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



I om going fo reorronge fhis difference equofion fo puf oII of
fhe j+I ferms on fhe Ieff-hond side:











where
2
1
S
t

= ond
S
t

=
2
.

Which con oIso be wriffen os:












) A A (A
)
2
1
(
) 2 1 (
)
2
1
(
2 2
, 1 , 2 , 1
, , , 1
, 1 , 2 , 1 1 ,
S t , t
J b a
J tc a
J b a J
f n f n f n
f n f n f n
f n f n f n f n
+
+ +
+ +
=
+
+


LocoI fruncofion
error
[ ]
) A A (A
(
2
1

( 1
- (
2
1
2 2
, 1
2 2
,
2 2
, 1
2 2
1 ,
S t , t
J t rn) n
J t r) n
t J rn) n J
f n
f n
f n f n
+
+ +
+ +
=
+
+

b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion


Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



This equofion hoIds for 1 ,..., 1 = N n since
f
J
, 1
ond
f N
J
, 1 +
ore nof
defined. Thus fhere ore 1 N equofions for 1 + N unknowns. The
remoining fwo equofions come from fhe fwo boundory condifions
on n~0 ond n~M (fhey ore freofed seporofeIy). I wiII give some
exompIes:


ExompIe I
Suppose we wonf fo price o coII opfion. Af S~0 we know fhof fhe
voIue is 0, fherefore: . , 0
, 0
f J
f
=

ExompIe Z
For Iorge S fhe coII voIue goes fo
) (
max
t T r
Ee S

. Thus our upper
boundory condifion couId be:
t rf
f N
Ee S N J

=
,
.


ExompIe 3
For o puf opfion we hove fhe condifion of S~0 fhof
) (
) , 0 (
t T r
Ee t J

= , which becomes: .
, 0
t rf
f
Ee J

=


ExompIe 4
The puf opfion becomes worfhIess for Iorge S ond so . 0
,
=
f N
J
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



ExompIe b
A usefuI boundory condifion fo oppIy of S~0 for mosf confrocfs
(incIuding coIIs ond pufs) is fhof fhe diffusion ond driff ferms
swifch off. This meons fhof on S~0 fhe poyoff is guoronfeed,
resuIfing in fhe condifion:




which numericoIIy becomes: . ) 1 (
1 , 0 , 0
=
f f
J t r J


ExompIe o
When fhe opfion hos o poyoff fhof is oImosf Iineor in fhe
underIying for Iorge voIues of S fhen you on use fhe upper
boundory condifion




AImosf oII common confrocfs hove fhis properfy. The finife-
difference represenfofion is: . 2
, 2 , 1 , f N f N f N
J J J

=
This is porficuIorIy usefuI since if is independenf of fhe confrocf
being voIued.


0 ) , 0 ( ) , 0 ( =

t rJ t
t
J

S as 0 ) , (
2
2
t S
t
J
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



Error ond SfobiIify


Whof obouf fhe error7

I con wrife fhe voIue of opfion of ony n poinf of fhe finoI fime
sfep J os:

=
+
+ =
1
0
, 1 , 0 , ,
) (
J
f
f n f n n J n
J J J J . Eoch of fhe ferms in fhis
summofion hos o IocoI error of ) , (
2 2
S t t , fherefore, fhe
gIoboI error in fhe finoI opfion voIue is ) , (
2 2
S t J t J . If we
voIue fhe opfion of o finife voIue of T fhen ) (
1
= t J so fhof
fhe error in fhe finoI voIue opfion is ) , (
2
S t .



Whof obouf fhe sfobiIify7

Trying soIufions of fhe form
S ikn f
f n
e k J

= ) (
,
(von Meumonn), we
gef:









( ) [ ]
S k ib
S k a t c k
f n
f n f n

+ + + =
sin
1 cos 2 1 ) (
2 ,
1 , ,



b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


If furns ouf fhof fo hove 1 , ) ( , < k , for sfobiIify, we require (If
we ossume fhof oII fhe coefficienfs ore sIowIy vorying over fhe
S scoIes):






In finonce fhe firsf consfroinf is oImosf oIwoys sofisfied,
very offen is -r.

TypicoIIy we chose
1
fo be O(I) so fhof fhe second
consfroinf is opproximofeIy:
f n
a
,
1
2
1
< , which impIies o
serious Iimifofion on fhe si;e of fhe fime sfep:





The fhird consfroinf con oIso be o serious resfricfion:




This resfricfion does nof moke much difference in procfice
unIess fhe voIofiIify is very smoII.


( )
f n f n
f n f n
f n
a b
tc a
c
, 1
2
, 2
, , 1
,
2 , ,
and 1 2
, 0

2 2
,
2
1
2 N a
S
t
f n

=


Time sfep
consfroinf
( )
2
2
2
,
,
2
r b
a
t
f n
f n

=
Mumber of sfeps
in S
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


This Iosf consfroinf con be ovoided if we use o one-sided
difference insfeod of o cenfroI difference for fhe firsf
derivofive of fhe opfion voIue wifh respecf fo fhe ossef.
0eneroIIy, fhe opproximofion couId depend on fhe sign of b
(upwind differencing):








This mefhod improves fhe sfobiIify buf fhe numericoI mefhod is
Iess occurofe ) ( S . To gef bock fhe ) (
2
S occurocy of fhe
cenfroI difference wifh o one-sided difference you con use fhe
foIIowing for:

Forword difference:




8ockword difference:




, then 0 ) , ( iI
and
, then 0 ) , ( iI
, 1 ,
.
2
1
, , 1
.
2
1
S
J J
b
S
J
b(S,t) t S b
S
J J
b
S
J
b(S,t) t S b
f n f n
f n
f n f n
f n

+
+
) (
2
) , 2 ( ) , ( 4 ) , ( 3
) , (
2
S
S
t S S J t S S J t S J
t S
S
J
+

+ + +
=

) (
2
) , 2 ( ) , ( 4 ) , ( 3
) , (
2
S
S
t S S J t S S J t S J
t S
S
J
+

+
=

b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion


Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

% Matlab Program 9: Evaluates an European Call option by using an explicit
method
% Parameters of the problem:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r=0.2; % Interest rate
sigma=0.25; % Volatility of the underlying
M=1600; % Number of time points
N=160; % Number of share price points
Smax=20; % Maximum share price considered
Smin=0; % Minimum share price considered
T=1.; % Maturation (expiry)of contract
E=10; % Exercise price of the underlying
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

dt=(T/M); % Time step
ds=(Smax-Smin)/N; % Price step

% Initializing the matrix of the option value
v(1:N,1:M) = 0.0;

% Initial conditions prescribed by the European Call payoff at expiry:
V(S,T)=max(S-E,0)
v(1:N,1)=max((Smin+(0:N-1)*ds-E),zeros(size(1:N)))';


% Boundary conditions prescribed by the European Call:
v(1,2:M)=zeros(M-1,1)'; % V(0,t)=0
v(N,2:M)=((N-1)*ds+Smin)-E*exp(-r*(1:M-1)*dt); % V(S,t)=S-Eexp[-r(T-t)] as S ->
infininty.


% Determining the matrix coeficients of the explicit algorithm
aa=0.5*dt*(sigma*sigma*(1:N-2).*(1:N-2)-r*(1:N-2))';
bb=1-dt*(sigma*sigma*(1:N-2).*(1:N-2)+r)';
cc=0.5*dt*(sigma*sigma*(1:N-2).*(1:N-2)+r*(1:N-2))';

% Implementing the explicit algorithm
for i=2:M,
v(2:N-1,i)=bb.*v(2:N-1,i-1)+cc.*v(3:N,i-1)+aa.*v(1:N-2,i-1);
end

% Reversal of the time components in the matrix as the solution of the Black-
Scholes
% equation was performed backwards
v=fliplr(v);

% Figure of the value of the option, V(S,t), as a function of S
% at three different times:t=0, T/2 and T (expiry).
figure(1)
plot(Smin+ds*(0:N-1),v(1:N,1)','r-',Smin+ds*(0:N-1),v(1:N,round(M/2))','g-
',Smin+ds*(0:N-1),v(1:N,M)','b-');
xlabel('S');
ylabel('V(S,t)');
title('European Call Option within the Explicit Method');

% Figure of the Value of the option, V(S,t)
figure(2)
mesh(Smin+ds*(0:N-1),dt*(0:M-1),v(1:N,1:M)')
title('European Call Option value, V(S,t), within the Explicit Method')
xlabel('S')
ylabel('t')
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Europeon CoII Opfion wifh E~I06, T~I yeor, r~0.Z, ond ~0.Zb.




In fhe curves bIue represenfs fhe voIue of fhe opfion of expiry,
green hoIf o yeor before fhof, ond red one yeor before, fhof is,
when fhe confrocf is signed (fhe price).

b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob






ImpIicif Mefhods
The exfro compIexify of impIicif mefhods is ouf weighfed by
fheir superior sfobiIify properfies.



A. FuIIy ImpIicif Mefhod













AcfuoIIy, if does nof moffer much whefher fhe coefficienfs o, b
ond c ore evoIuofed of fime sfep j or j+I.
) , (
2
2
2
1 , 1 ,
1 , 1 1 , 1
1 ,
2
1 , 1 1 , 1 , 1
1 ,
, 1 ,
S t J c
S
J J
b
S
J J J
a
t
J J
f n f n
f n f n
f n
f n f n f n
f n
f n f n
= +
|
|
.
|

\
|

+
|
|
.
|

\
|

+
+

+ +
+ + +
+
+ + + +
+
+
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



Which con be wriffen os:










where
2
1
S
t

= ond
S
t

=
2
.

Agoin, fhis equofion hoIds for 1 ,..., 1 = N n since
f
J
, 1
ond
f N
J
, 1 +

ore nof defined. Thus fhere ore 1 N equofions for 1 + N
unknowns. The remoining fwo equofions come from fhe fwo
boundory condifions of n~0 ond n~M (fhey ore freofed
seporofeIy). However, os we oIreody know, fhere is o huge
difference befween fhis scheme ond fhe expIicif finife-
difference scheme: sfobiIify (if is highIy improved) ond fhe
soIufion procedure (if is no Ionger so sfroighfforword).


This mefhod con be significonfIy improved upon wifh IiffIe exfro
compufofion efforf of fhe foIIowing scheme.
) A A (A
)
2
1
(
) 2 1 (
)
2
1
(
2 2
1 , 1 1 , 2 1 , 1
1 , 1 , 1 , 1
1 , 1 1 , 2 1 , 1 ,
S t , t
J b a
J tc a
J b a J
f n f n f n
f n f n f n
f n f n f n f n
+
+ +
+ +
=
+ + + +
+ + +
+ + +


LocoI fruncofion
error
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



8. The Cronk-MichoIson Mefhod


An be considered os on overoge of fhe expIicif ond fuIIy impIicif
mefhods (if uses o poinfs l):























) , (
2
1
2
1
2 2
2 2
2
2
2
2
2 2
, , 1 , 1 ,
, 1 , 1 ,
1 , 1 1 , 1 1 ,
2
, 1 , , 1 ,
2
1 , 1 1 , 1 , 1 1 ,
, 1 ,
S t J c J c
S
J J b
S
J J b
S
J J J a
S
J J J a
t
J J
f n f n f n f n
f n f n f n
f n f n f n
f n f n f n f n
f n f n f n f n
f n f n
= + +
|
|
.
|

\
|

+
|
|
.
|

\
|

+
|
|
.
|

\
|

+
+
|
|
.
|

\
|

+
+

+ +
+
+ + + +
+
+ + + + +
+
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob




The Cronk-MichoIson con be wriffen os:






wifh










These equofions onIy hoIds for 1 1 N n ond fhe boundory
condifions ogoin suppIy fhe fwo missing equofions.



The Cronk-MichoIson mefhod con be wriffen in o mofrix form:




, 1 , , , , 1 ,
1 , 1 1 , 1 , 1 , 1 , 1 1 ,
) 1 (
) 1 (
f n f n f n f n f n f n
f n f n f n f n f n f n
J C J B J A
J C J B J A
+
+ + + + + + +
+
= + + +
.
4
1
2
1
,
2
1
,
4
1
2
1
, 2 , 1 ,
, , 1 ,
, 2 , 1 ,
f n f n f n
f n f n f n
f n f n f n
b a C
tc a B
b a A


=
+ =
+ =
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


















The fwo mofrices hove M-I rows ond M+I coIumns, which is o
represenfofions of fhe M-I equofions ond M+I unknowns. The
fwo equofions fhof we ore missing come from fhe boundory
condifions. Using fhese condifions, I om going fo converf fhis
sysfem of equofions info o sysfem of equofions invoIving o squore
mofrix. The oim is fo wrife o sysfem of equofions in fhe form:




For known squore mofrices
L
f 1 +
M ond
R
f
M , ond known vecfors r ,
ond where fhe defoiIs of fhe boundory condifions hove been fuIIy
incorporofed.

|
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|




=
|
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+
+
+
+


+
+
+
+
+ + +
+ +
+ + +
+ + +
f N
f N
f
f
f N f N f N
f N f N
f f f
f f f
f N
f N
f
f
f N f N f N
f N f N
f f f
f f f
J
J
J
J
C B A
C B
C B A
C B A
J
J
J
J
C B A
C B
C B A
C B A
,
, 1
, 1
, 0
, 1 , 1 , 1
, 2 , 2
, 2 , 2 , 2
, 1 , 1 , 1
1 ,
1 , 1
1 , 1
1 , 0
1 , 1 1 , 1 1 , 1
1 , 2 1 , 2
1 , 2 1 , 2 1 , 2
1 , 1 1 , 1 1 , 1
.
.
.

1 . . . .
0 1 . . . .
. . . . . 0 .
. . . 1 0
. . . 0 1
.
.
.

1 . . . .
0 1 . . . .
. . . . . 0 .
. . . 1 0
. . . 0 1
R
f f
R
f
L
f f
L
f
r V M r V M + = +
+ + + 1 1 1
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



ExompIe I of boundory condifion: given
1 , 0 + f
J ond
1 , + f N
J :
Somefimes we know fhof fhe opfion hos o porficuIor voIue on fhe
boundory, n~0 ond n~M, For exompIe, if we hove on Europeon puf
we know fhof 0 ) , 0 ( = t J ond
) (
max max
) , (
t T r
Ee S t S J

= . This
fronsIofes fo knowing fhof 0
1 , 0
=
+ f
J ond
t f r
f N
Ee S N J
+
+
=
) 1 (
1 ,
:









os










ond simiIorIy for mofrices on fhe righf.


|
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+ + +
1 ,
1 , 1
1 , 1
1 , 0
1 , 1 1 , 1 1 , 1
1 , 2 1 , 2
1 , 2 1 , 2 1 , 2
1 , 1 1 , 1 1 , 1
.
.
.

1 . . . .
0 1 . . . .
. . . . . 0 .
. . . 1 0
. . . 0 1
f N
f N
f
f
f N f N f N
f N f N
f f f
f f f
J
J
J
J
C B A
C B
C B A
C B A
L
f f
L
f
f N f N
f f
f N
f
f N f N
f N f N
f f
f f
J C
J A
J
J
B A
C B
B A
C B
1 1 1
1 , 1 , 1
1 , 0 1 , 1
1 , 1
1 , 1
1 , 1 1 , 1
1 , 2 1 , 2
1 , 2 1 , 2
1 , 1 1 , 1

.
.
.
0

.
.
.
.

1 0 . . .
1 . . . .
. 0 . . . 0
. . . . 1
. . . 0 1
+ + +
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ =
|
|
|
|
|
|
|
|
.
|

\
|
+
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+
+
+
+
r V M
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


ExompIe Z of boundory condifion: given 0
2
2
=

S
J
: This condifion
is porficuIorIy usefuI since if is independenf of fhe fype of fhe
confrocf, os Iong os fhe confrocf hos o poyoff fhof is oImosf
Iineor in fhe underIying. This condifion is, in cenfroI difference
form:




Thus, we con wrife fhe Ieff hond side os:

ond simiIorIy for fhe righf hond side.

The Cronk-MichoIson scheme con be wriffen ogoin os:



where fhis fime vecfors 0 = r .

f
R
f
L
f
R
f f
L
f
V M r r V M + =
+ + + 1 1 1
1 , 2 1 , 1 1 , 1 , 2 1 , 1 1 , 0
2 and 2
+ + + + + +
= =
f N f N f N f f f
J J J J J J
|
|
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
+ +
+
+
+ +
+
+
+ + + +
+ +
+ +
+ + + +
1 , 1
1 , 1
1 , 1 1 , 1 1 , 1 1 , 1
1 , 2 1 , 2
1 , 2 1 , 2
1 , 1 1 , 1 1 , 1 1 , 1
.
.
.

2 1 0 . . .
1 . . . .
. 0 . . . 0
. . . . 1
. . . 0 2 1
f N
f
f N f N f N f N
f N f N
f f
f f f f
J
J
C B C A
C B
B A
A C A B

b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


o. Mofri; Inversion:



However, mofrix inversion is very fime consuming ond
compufofionoIIy very inefficienf.


b. LU Decomposifion
The mofrix
L
f 1 +
M is fridiogonoI, ond if is nof hord fo decompose
info fhe producf of fwo ofher mofrices, one hoving non;ero
eIemenfs oIong fhe diogonoI ond fhe subdiogonoI (L) ond fhe
ofher hoving non-;ero eIemenfs oIong fhe diogonoI ond fhe
superdiogonoI (U). So fhof, U L M = :















) ( ) (
1
1
1 1 f
R
f
L
f
R
f
L
f f
V M r r V + =
+

+ +
|
|
|
|
|
|
.
|

\
|
|
|
|
|
|
|
.
|

\
|
=
|
|
|
|
|
|
.
|

\
|
+
+
+
+

1
2 2
3
2 2
1 1
1
2
3
2
1 1
2 2 2
3
2 2 2
1 1
0 0 . . .
0 . . .
0 . . 0 0
. . . 0
. 0 . . 0
.
1 0 . . .
0 1 . . .
. 0 . . 0
. . . 0 1
. . . 0 0 1

1 0 . . .
1 . . .
. . . . 0
. . . . 1
. . . 0 1
N
N N
N
N
N
N N
N N N
N
d
u d
u
u d
u d
l
l
l
l
B A
C B A
C
C B A
C B
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



The foIIowing reIofions ore verified:




Mofice fhof we work form n~I fo n~M sequenfioIIy.

Mow we expIoif fhe decomposifion fo soIve:









Two sfeps more ond we ore done:

The firsf sfep gives:
1 1
q w = ond
1
=
n n n n
w l q w for
1 2 N n , where we ogoin musf work sequenfioIIy.

The second sfep invoIves working bockwords from n~M-Z fo
n~I:
1
1
1

=
N
N
N
d
w
J ond
n
n n n
n
d
J p w
J
1 +

= for 1 2 n N



1 2 1
, 1
Ior and
1 1 1 , 1
1 1
+ = = =
+ =

N n u l B d C u A d l
B d
n n n n n n n n n
f
R
f
L
f
R
f f
L
f
J J M r r M + =
+ + + 1 1 1
q
J M
w V U q Lw q V LU q V M = = = = , , ,
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob



c. SOP (Successive Over-reIoxofion)

I. Jocobi mefhod:

The sysfem is eosiIy soIved iferofiveIy using:









Where fhe superscripf denofes fhe IeveI of fhe iferofion, which
is sforfed wifh some inifioI guess
0
V .

I con wrife fhe mofrix M (fridiogonoI) os fhe sum of o diogonoI
mofrix D, on upper frionguIor mofrix T (wifh ;eros in fhe
diogonoI) ond o Iower frionguIor mofrix L (wifh ;eros in fhe
diogonoI): L T D M + + = . Then:






[ ]
[ ]
[ ] ) (
1
) (
1
) (
1
2 2 1 1
1
2 1 21 2
22
1
2
1 2 12 1
11
1
1

+ + =
+ + =
+ + =
+
+
+
i
N
i
N N
NN
i
N
i
N N
i i
i
N N
i i
J M J M q
M
J
J M J M q
M
J
J M N M q
M
J
[ ]
i i
L)V (T q D V + =
+ 1 1
b. Finife-difference Pepresenfofions for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Z. 0ouss-SeideI mefhod: we use fhe updofed voIues os soon os
fhey ore coIcuIofed:





3. Successive over-reIoxed (SOP) mefhod: iferofe mefhods
usuoIIy converge fo fhe correcf soIufion from one side (fhe
correcfion
i
n
i
n
J J
+1
sfoys on fhe some side of fhe sign os i
increoses ). This is used by fhe SOP mefhod fo speed up fhe
convergence. This mefhod con be wriffen os:
















(

=

=

=
+ +
N
n f
i
f nf
n
f
i
f nf n
nn
i
n
J M J M q
M
J
1
1
1 1
1
(

+ =

=

=
+ +
N
n f
i
f nf
n
f
i
f nf n
nn
i
n
i
n
J M J M q
M
J J
1
1
1 1
) 1 (

AcceIerofion or
Over-reIoxofion poromefer,
which musf Iie befween I ond Z
(We shouId find fhe opfimum
voIue for w)
( ) [ ] q D V T D I L D I V
1 1 1 1 1
) 1 ( ) (
+
+ + =
i i
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob












o. Ofher Finife-difference Mefhods
for fhe 8Iock-SchoIes Equofion
Improving ond exfending expIicif ond impIicif mefhods
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob








The quesfions fhof orise wifh ony new mefhod ore:

Whof is fhe error in fhe mefhod in ferms of t ond S 7

Whof ore fhe resfricfions (sfobiIify) on fhe fime sfep
ond/or ossef sfep7

Con I soIve fhe resuIfing finife-difference equofions
quickIy7

Is fhe mefhod fIexibIe enough fo cope wifh chonges in
coefficienfs, boundory condifions, efc,7 Thof is, do you
hove fo sforf from scrofch if fhe confrocf chonges sIighfIy,
or you con simpIy chonge o subroufine fo cope wifh o new
confrocf7 Imporfonf exompIe: Americon opfions.








o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

DougIos Schemes

This is o mefhod fhof monoges fo hove o IocoI fruncofion error
of ) , (
2 4
t S for fhe some compufofionoI efforf os fhe Cronk-
MichoIson scheme.

If moy be expecfed fhof fo gef o higher order of occurocy fhon
Cronk-MichoIson wouId require fhe use of more poinfs in fhe S
direcfion: fhis is nof oIwoys so l

For simpIicify ond cIorify, I wiII describe fhe mefhod using fhe
bosic-diffusion Iike equofion (fhe exfension fo 8Iock-SchoIes
becomes frivioI):

2
2
S
J
t
J



The expIicif mefhod oppIied fo fhis equofion is jusf:





ond fhe fuIIy impIicif mefhod is:





2
, 1 , , 1 , 1 ,
2
S
J J J
t
J J
f n f n f n f n f n

+
=

+ +
2
1 , 1 1 , 1 , 1 , 1 ,
2
S
J J J
t
J J
f n f n f n f n f n

+
=

+ + + + +
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob




ond, os we oIreody know, fhe Cronk-MichoIson mefhod is jusf on
overoge of fhe fwo mefhods. Is fhere ony odvonfoge of foking o
weighfed overoge ( mefhod)7







When
2
1
= we ore bock fo fhe Cronk-MichoIson mefhod. For o
generoI voIue of fhe IocoI fruncofion error is:






For
2
1
, 0 = or I we gef fhe resuIfs we hove seen so for, buf if
t
S

=
12 2
1
2
fhe IocoI fruncofion is improved.



|
|
.
|

\
|

+
+
|
|
.
|

\
|

+
=

+ + + + + +
2
1 , 1 1 , 1 , 1
2
, 1 , , 1 , 1 ,
2

2
) 1 (
S
J J J
S
J J J
t
J J
f n f n f n f n f n f n f n f n

|
.
|

\
|

2 4 2
, ,
12
1
2
1
t S t S t
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

Three Time-IeveI Mefhods

MumericoI schemes ore nof resfricfed fo fhe use of jusf fwo
fime IeveIs if if gove us o beffer IocoI fruncofion error or hod
beffer convergence properfies. For simpIicify, I shoII sfiII
concenfrofe on fhe bosic diffusion equofion.
The obvious firsf mefhod fo fry uses o cenfroI difference for
fhe fime derivofive in on expIicif scheme (Leop Frog):




However, fhis is unsfobIe for ony fime sfepl However, on expIicif
scheme fhof is sfobIe for oII fime sfeps is (Du-Forf FronkeI):




Ieoding fo:




which, fo gef sforfed, requires on inifioI condifion ond dofo of
fhe firsf fime IeveI. The IocoI error is
(

|
.
|

\
|


2
2 2
, ,
S
t
S t O , ond,
fherefore, we shouId be owore (ll) of fhe reIofion befween fime
ond price sfeps.

2
, 1 , , 1 1 , 1 ,
2
2 S
J J J
t
J J
f n f n f n f n f n

+
=

+ +
2
, 1 1 , 1 , , 1 1 , 1 ,
2 S
J J J J
t
J J
f n f n f n f n f n f n

+
=

+ + +
1 , 1 , 1 , 1 1 1 , 1
) 2 1 ( ) ( 2 ) 2 1 (
+ +
+ + = +
f n f n f n f n
J J J J
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Pichordson ExfropoIofion

In fhe ExpIicif mefhod fhe error is ) , (
2
t S . If we ossume
fhof fhe opprooch fo fhe correcf soIufion os fhe fime sfep ond
ossef sfep fend fo ;ero is in o sense "reguIor" (fhere is no
guoronfee fhof if is oIwoys fhe cose, foke corel) fhen we couId
posfuIofe fhof (ToyIor series):





Suppose fhof we hove fwo opproximofe soIufions ( )
2 1
,J J using
differenf grid si;es wifh fhe some mefhod:








ond
+ + + + =
2
3
2
2 1
sol. exact. sol. . approx t S t

+ +

+
=
|
|
|
.
|

\
|
=
= + + + +
2
2
1
1
1
2
1
sol. exact.
sol. exact.
1

2
1 3
2
1 2 1 1


S
t
AS
J t S t
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob












Then, if we choose:





we con find o beffer (more occurofe) soIufion fhon bofh ( )
2 1
,J J
by eIiminofing fhe Ieoding-order error ferms. This beffer
opproximofion is given by:








+ +

+
=
|
|
|
.
|

\
|
=
= + + + +
2
2
2
2
1
2
2
sol. exact.
sol. exact
2

2
2 3
2
2 2 2 1


S
t
AS
J t S t
2
2
2
2
1
1
S
t
S
t

2
1
2
2
2
2
1 1
2
2
NEW
S S
J S J S
J


=
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob


Free 8oundory ProbIems: Americon
Opfions

The voIue of Americon opfions musf oIwoys be greofer fhon fhe
poyoff, ofherwise fhere wiII be on orbifroge opporfunify:




The poyoff funcfion moy oIso be fime dependenf. For exompIe, if
fhe opfion is 8ermudon, i.e. exercise is onIy oIIowed on cerfoin
dofes, fhen fhe poyoff funcfion is cero excepf on fhe specioI
dofes, when if is some prescribed funcfion on fhe underIying. So
I om going fo wrife Poyoff(S,f) ond I need never menfion
8ermudon opfions ogoin.
Americon opfions ore exompIes of free boundory probIems. We
musf soIve o porfioI differenfioI equofion wifh on unknown
boundory, fhe posifion of which is defermined by hoving one
more boundory condifion fhon if fhe boundory were prescribed.


EorIy Exercise ond fhe ExpIicif Mefhod
Suppose fhof we hove found
f n
J
,
for oII n of fhe fimesfep j,
proceed fo find fhe opfion voIue of fime j+I by using fhe finife-
difference scheme:



) ( PayoII ) , ( S t S J
( )
f n f n f n f n f n f n
J C J B J A J
, 1 j n, , , , 1 , 1 ,
1
+ +
+ + + =
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

Do nof worry obouf whefher or nof you hove vioIofed fhe
Americon opfion consfroinf unfiI you hove found fhe opfion
voIues
1 , + f n
J for oII n. Mow Ief's check whefher fhe new opfion
voIues ore greofer or Iess fhon fhe poyoff. If fhey ore Iess fhon
fhe poyoff fhen we hove orbifroge. We connof oIIow fhof fo
hoppen so of every voIue of n for which fhe opfion voIue hos
oIIowed orbifroge, repIoce fhe voIue by fhe poyoff of fhof ossef
voIue. Thof's oII.

EorIy Exercise ond Cronk-MichoIson
ImpIemenfing fhe Americon consfroinf in fhe Cronk-MichoIson is
o bif horder buf fhe rewords come in fhe occurocy. The onIy
compIicofion orises becouse fhe Cronk-MichoIson is impIicif, ond
every voIue of fhe opfion of j+I fimesfep is Iinked fo every ofher
voIue of fhof fimesfep. We con hove fwo procficoI possibiIifies:

I. Like in fhe expIicif mefhod, repIoce fhe opfion voIue wifh
fhe poyoff (in cose if is necessory) offer fhe voIues of
fimesfep j+I hove oII been coIcuIofed. In fhis cose, fhe
occurocy of fhis mefhod is fhen reduced fo O(f).

Z. PepIoce fhe opfion voIues of fhe some fime os fhey ore
found. For exompIe in fhe SOP mefhod:




The poyoff is evoIuofed of n ond j+I in fhe obvious monner,
fhis is coIIed projecfed SOP.

|
|
.
|

\
|
(

+ =

=

=
+ +
Pavoff J M J M q
M
J J
N
n f
i
f nf
n
f
i
f nf n
nn
i
n
i
n
, ) 1 ( max
1
1
1 1

o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion


Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob

% Matlab Program 10: Compares European and American Call options by using an
% explicit method Parameters of the problem:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
r=0.2; % Interest rate
sigma=0.25; % Volatility of the underlying
d=0.3; % Continuous dividend yield
M=1600; % Number of time points
N=160; % Number of share price points
Smax=20; % Maximum share price considered
Smin=0; % Minimum share price considered
T=1.; % Maturation (expiry)of contract
E=10; % Exercise price of the underlying
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dt=(T/M); % Time step
ds=(Smax-Smin)/N; % Price step

% Initializing the matrix of the option values: v is the European and vam is the
American option
v(1:N,1:M) = 0.0;
vam(1:N,1:M) = 0.0;

% Initial conditions prescribed by the Call payoff at expiry: V(S,T)=max(E-S,0)
v(1:N,1)=max((Smin+(0:N-1)*ds-E),zeros(size(1:N)))';
vam(1:N,1)=max((Smin+(0:N-1)*ds-E),zeros(size(1:N)))';

% Boundary conditions prescribed by Call Options with dividends:
% V(0,t)=0
v(1,2:M)=zeros(M-1,1)';
vam(1,2:M)=zeros(M-1,1)';
% V(S,t)=Se^(-d*(T-t))-Ee^(-r(T-t)) as S -> infininty.
v(N,2:M)=((N-1)*ds+Smin)*exp(-d*(1:M-1)*dt)-E*exp(-r*(1:M-1)*dt);
vam(N,2:M)=((N-1)*ds+Smin)*exp(-d*(1:M-1)*dt)-E*exp(-r*(1:M-1)*dt);

% Determining the matrix coeficients of the explicit algorithm
aa=0.5*dt*(sigma*sigma*(1:N-2).*(1:N-2)-(r-d)*(1:N-2))';
bb=1-dt*(sigma*sigma*(1:N-2).*(1:N-2)+r)';
cc=0.5*dt*(sigma*sigma*(1:N-2).*(1:N-2)+(r-d)*(1:N-2))';

% Implementing the explicit algorithm
for i=2:M,
v(2:N-1,i)=bb.*v(2:N-1,i-1)+cc.*v(3:N,i-1)+aa.*v(1:N-2,i-1);
% Checks if early exercise is better for the American Option
vam(2:N-1,i)=max(bb.*vam(2:N-1,i-1)+cc.*vam(3:N,i-1)+aa.*vam(1:N-2,i-
1),vam(2:N-1,1));
end

% Reversal of the time components in the matrix as the solution of the Black-
Scholes
% equation was performed backwards
v=fliplr(v);
vam=fliplr(vam);

% Compares the value today of the European (blue) and American (red) Calls,
V(S,t), as a function of S.
% The green curve represents the payoff at expiry.
plot(Smin+ds*(0:(N-2)),v(1:(N-1),M)','g-',Smin+ds*(0:(N-2)),v(1:(N-1),1)','b-
',Smin+ds*(0:(N-2)),vam(1:(N-1),1)','r-');
xlabel('S');
ylabel('V(S,t)');
title('European (blue) and American (red) Call Options');
o. Ofher Finife-difference Mefhods for fhe 8Iock-SchoIes Equofion
Finife-difference MumericoI Mefhods
of PorfioI DifferenfioI Equofions in Finonce wifh MofIob







Europeon ond Americon CoII Opfions wifh E~I06, T~I yeor, r~0.Z,
~0.Zb ond d~0.3 (dividend yieId).







In fhe figure if is represenfed fhe vuIue toduy (when fhe
confrocf is signed, fhof is, one yeor before expiry) of on
Americon (red) ond Europeon (bIue) opfions. The green Iine
represenfs fhe poyoff of expiry.