Professional Documents
Culture Documents
FDM Intro PDF
FDM Intro PDF
Methods
References
2
Math6911, S08, HM ZHU
Outline
3
Math6911, S08, HM ZHU
Finite-difference mesh
Aim to approximate the values of the continuous function
f(t, S) on a set of discrete points in (t, S) plane
Divide the S-axis into equally spaced nodes at distance
S apart, and, the t-axis into equally spaced nodes a
distance t apart
(t, S) plane becomes a mesh with mesh points on
(i t, jS)
We are interested in the values of f(t, S) at mesh points
(i t, jS), denoted as
fi , j = f ( it, j S )
?
j S
i t
Math6911, S08, HM ZHU
T=N t
t
6
(5.1)
= lim
f ( S ,t + t ) f ( S ,t )
f ( S ,t + t ) f ( S ,t )
t
t
t
for small t, using Taylor expansion at point ( S ,t )
t 0
f ( S ,t + t ) = f ( S ,t ) +
f ( S ,t )
t
t + O ( t )
)
8
forward
f ( t,S )
Forward:
Backward:
Central:
t
f ( t,S )
t
f ( t,S )
t
f ( t + t,S ) f ( t,S )
t + t
t t
+ O ( t )
t
f ( t,S ) f ( t t,S )
+ O ( t )
t
f ( t + t,S ) f ( t t,S )
2t
+ O ( t )
Symmetric Central-difference
approximations to 2nd order derivatives
2 f ( t,S )
S
( S )
+ O ( S )
,
t
t
fi , j fi 1, j
f
Backward Difference:
,
t
t
fi +1, j fi 1, j
f
Central Difference:
,
t
2t
As to the second derivative, we have:
fi , j +1 fi , j
f
S
S
fi , j fi , j 1
f
S
S
fi , j +1 fi , j 1
f
S
2S
2 f fi , j +1 fi , j fi , j fi , j 1
S
2
S
S
S
fi , j +1 2 fi , j + fi , j 1
=
2
S
( )
Math6911, S08, HM ZHU
11
fi ,0 = 0
, for i = 0 ,1,...,N
r ( N i ) t
fi ,M = S max Ke
where Smax = M S.
12
t
t
f i , j +1 f i , j 1
f
central difference:
,
S
2S
and
f i , j + 1 + f i , j 1 2 f i , j
2f
, r f = rf i , j , S = j S
2
2
S
S
Math6911, S08, HM ZHU
(5.2)
where
(
(
1
t (
2
)
)
+ rj )
1
a = t 2 j 2 rj
2
2 2
*
b j = 1 t j + r
*
j
c =
*
j
S
Smax=MS
x
(j+1)S
jS
(j-1)S
0
Math6911, S08, HM ZHU
x
x
(i-1)t it
T=N t
Implementation
1. Starting with the final values f N , j , we apply (5.2) to solve
f N 1, j for 1 j M 1. We use the boundary condition
to determine f N 1,0 and f N -1,M .
2. Repeat the process to determine f N 2 , j and so on
17
Math6911, S08, HM ZHU
Example
We compare explicit finite difference solution for a
European put with the exact Black-Scholes formula, where
T = 5/12 yr, S0=$50, K = $50, =30%, r = 10%.
Black-Scholes Price: $2.8446
EFD Method with Smax=$100, S=2, t=5/1200: $2.8288
EFD Method with Smax=$100, S=1, t=5/4800: $2.8406
18
Math6911, S08, HM ZHU
Example (Stability)
We compare explicit finite difference solution for a European
put with the exact Black-Scholes formula, where T = 5/12 yr,
S0=$50, K = $50, =30%, r = 10%.
Black-Scholes Price: $2.8446
19
Math6911, S08, HM ZHU
Numerical Accuracy
The problem itself
The discretization scheme used
The numerical algorithm used
21
Math6911, S08, HM ZHU
Conditioning Issue
( )
22
Math6911, S08, HM ZHU
Conditioning Issue
Conditioning issue is related to the problem itself, not to the
specific numerical algorithm; Stability issue is related to the
numerical algorithm
One can not expect a good numerical algorithm to solve an illconditioned problem any more accurately than the data
warrant
But a bad numerical algorithm can produce poor solutions
even to well-conditioned problems
23
Math6911, S08, HM ZHU
Conditional Issue
( )
f ( x ) f x*
f ( x)
x
x
( f ( x ) 0)
24
Math6911, S08, HM ZHU
xd
10 e
xd 10 e
where x1 0, 0 xi 9,
d : an integer, precision of the floating point system
e : an bounded integer
Error Propagation
When additional calculations are done, there is an
accumulation of these floating point errors.
Example : Let x = 0.6667 and fl ( x ) = 0.667 10 0
where d = 3.
Floating point error : fl ( x ) x = 0.0003
Error propagatio n : fl ( x ) x = 0.00040011
2
26
Math6911, S08, HM ZHU
( )
Convergence issue
Convergence of the numerical algorithm concerns about
the behavior of fi , j f ( it, jS ) as t, S 0 for fixed
values ( it, jS ) .
For well-posed linear initial value problem,
Stability Convergence
(Lax's equivalence theorem, Richtmyer and Morton, "Difference
Methods for Initial Value Problems" (2nd) 1967)
28
Math6911, S08, HM ZHU
Numerical Accuracy
These factors contribute the accuracy of a numerical solution.
We can find a good estimate if our problem is wellconditioned and the algorithm is stable
( )
f ( x) f ( x)
Well-conditioned: f ( x ) f ( x )
Stable: f * ( x ) f x*
29
Math6911, S08, HM ZHU
i +1 , j 1
i +1 , j
i +1 , j +1
where
1
1 1
1
2 2
d
t j t r j =
1 + r t 2
2
1 + r t
1
1
2 2
b =
0
1 j t =
j
1 + r t
1 + r t
1
1 1
1
2 2
u
c j =
t j + t r j =
2
1 + r t 2
1 + r t
for
i = N - 1, N - 2 , ..., 1, 0 and j = 1, 2 , ..., M - 1 .
Math6911, S08, HM ZHU
a j =
i +1, j +1
i , j
i +1, j
d
i +1, j 1
Var [ ] = E 2 E 2 [ ] = 2 S 2 t r 2 S 2 ( t ) 2 S 2 t
2
Change of Variable
2
2 Z 2 Z
t
The corresponding difference equation is
fi +1, j fi , j
t
2
2
2 Z
2
Z
or
fi , j = *j f i +1, j 1 + *j fi +1, j + *j f i +1, j +1
(5.4)
34
Change of Variable
where
2
2
t
*
j =
+
r
1 + r t
2 2Z 2 Z 2
t 2
1
*j =
1
2
1 + r t Z
2
2
t
*
j =
+
r
2
1 + r t
2 2 Z 2 Z
u 2u
=
x2
(5.5)
36
u nm +1 u nm
u nm+1 2u nm + u nm1
2
+ O ( ) =
+ O (x )
2
(x )
this by
u nm +1 = u nm+1 + (1 2 )u nm + u nm1
1 2
T
+
2
where =
,
for
and
0
1
-N
n
N
m
,
,...M
=
=
(x )2
1
1
; ii) Unstable if >
i) Stable if 0 < =
2
2
( x ) 2
Convergence:
1
If 0 < , then the explicit finite-difference approximation
2
converges to the exact solution as , x 0
(in the sense that unm u ( n x, m ) as , x 0)
Rate of Convergence is O ( )
Math6911, S08, HM ZHU
38
S
2S
and
f i , j + 1 + f i , j 1 2 f i , j
2f
, rf = rf i , j
2
2
S
S
Math6911, S08, HM ZHU
(5.6)
where
)
)
+ rj )
1
a j = t 2 j 2 + rj
2
2 2
b j = 1 + t j + r
cj
(
1
= t (
2
S
Smax=MS
(j+1)S
jS
(j-1)S
0
Math6911, S08, HM ZHU
(i-1)t it (i+1)t
T=N t
Implementation
Equation (5.6) can be rewritten in matrix form:
( 5.7 )
Cfi = fi +1 + bi
fi = fi ,1 , fi ,2 , fi ,3 , fi ,M 1 ,bi = a1 fi ,0 ,0 , 0 ,
and C is (M 1) (M 1) symmetric matrices
b1
a
2
C=0
c1
b2
a3
c2
b3
0
aM 1
0
0
cM 2
bM 1
, 0 , cM 1 fi ,M
Implementation
1. Starting with the final values f N , j , we need to solve a
linear system (5.7) to obtain f N 1, j for 1 j M 1
using LU factorization or iterative methods. We use the
boundary condition to determine f N 1,0 and f N -1,M .
2. Repeat the process to determine f N 2 , j and so on
44
Math6911, S08, HM ZHU
Example
We compare implicit finite difference solution for a
European put with the exact Black-Scholes formula, where
T = 5/12 yr, S0=$50, K = $50, =30%, r = 10%.
Black-Scholes Price: $2.8446
IFD Method with Smax=$100, S=2, t=5/1200: $2.8194
IFD Method with Smax=$100, S=1, t=5/4800: $2.8383
45
Math6911, S08, HM ZHU
Example (Stability)
We compare implicit finite difference solution for a European
put with the exact Black-Scholes formula, where T = 5/12 yr,
S0=$50, K = $50, =30%, r = 10%.
Black-Scholes Price: $2.8846
46
Math6911, S08, HM ZHU
i +1, j +1
i , j
i +1, j
i +1, j 1
i , j +1
i , j
i , j 1
Implicit Method
Explicit Method
Math6911, S08, HM ZHU
(always stable)
i +1, j
Solve Ax=b
A x=b
Various shapes of matrix A
Lower triangular
Upper triangular
General
51
4 6 1 x1 100
0 1 1 x = 10
2
0 0 4 x3 20
x3 = 20 / 4 = 5
x2 = 10 x3 = 5
4 x1 = 100 x3 6 * x2 = 65
x1 = 65 4
Math6911, S08, HM ZHU
53
(0
0 aii
x1
x2
ain ) = aii xi + aij x j = bi ,i = 1, , n
j >i
x
n
xn = bn ann
xi = bi aij x j aii ,i = 1,
j >i
n 1
54
Implementation
Function x = UpperTriSolve(A, b)
n = length(b);
x(n) = b(n)/A(n,n);
for i = n-1:-1:1
sum = b(i);
for j = i+1:n
sum = sum - A(i,j)*x(j);
end
x(i) = sum/A(i,i);
end
55
Math6911, S08, HM ZHU
To solve Ax = b :
Suppose A = LU. Then
Ax = LUx = b
57
Math6911, S08, HM ZHU
Gauss Elimination
0 0 a11
1 0a21
a
0 1 31
E 21 A
a12
a22
a32
a13 a11
a23 = 0
a33 a
31
a12
a21 a12
a22
a11
a32
a13
a21 a13
a23
a11
a33
58
Gauss Elimination
2) Zero a31
a31
a11
a11
0 0
1 0 0
0 1 a31
a12
a22
a21 a12
a11
a32
E 31 E 21 A
a11
a13
a
a
12
13
a21 a13
a21 a13
a21 a12
a23
a23
= 0 a22
a11
a11
a11
a33
a31 a12
a31 a13
a33
0 a32
a11
a11
Gauss Elimination
3) Zero a32
1
0
1
0
0 a32
a22
0 a11
0 0
a12
a22
a32
a13 a11
a23 = 0
a33
0
a12
a22
0
a13
a23
U
a32 a23
a33
a22
E 32 E 31 E 21 A = U
lower triangular
Math6911, S08, HM ZHU
60
Gauss Elimination
Claim 1:
E 32 E 31 E 21
Claim 2:
( E 32 E 31 E 21 )
Math6911, S08, HM ZHU
1
a 21
a1 1
a 31
a1 1
1
a 21
=
a11
a 31
a11
0
1
a 32
a 22
0
1
a 32
a 22
61
LU Factorization
A = LU
To solve Ax = b becomes
1) Use Gauss elimination to make A upper triangular, i.e.
L1Ax = L1b Ux = z
2) Solve x from Ux = z
This suggests that when doing Gauss elimination, we can do it
to the augmented matrix [A b] associated with the linear system.
63
Math6911, S08, HM ZHU
An exercise
2 1
x1 0
1 2 1 x = 0
1 2 x3 4
64
row i
row j -
a ji
aii
row i
65
Math6911, S08, HM ZHU
1
3
0 1 0 1 2 3
PA =
=
1
0
2
3
0
1
1
0 0.0001
0.0001 1 1
=
= LU
A=
- 9999
1 10,000 1 0
1
0 1
1
0 1 0.0001 1 1
=
= LU
PA =
1
1 0.0001 1 0 .9999
Math6911, S08, HM 1
ZHU 0
66
No!
If det ( A (1:k,1:k ) ) 0 for k =1,...,n-1,
then A Rnxn has an LU factorization.
Proof:
See Golub and Loan, Matrix Computation, 3rd edition
67
Math6911, S08, HM ZHU
+ O ( t ) =
f i +1 , j +1 f i +1 , j 1
+ rf i +1 , j + O
Math6911, S08, HM ZHU
2S
(( S ) )
2
1 2 2
2 f i + 1 , j + 1 + f i + 1 , j 1 2 f i + 1 , j
j ( S )
S2
2
+ O ( t ) =
f i , j +1 f i , j 1
+ rf i , j + O
Math6911, S08, HM ZHU
2S
(( S ) )
2
1 2 2
2 f i , j + 1 + f i , j 1 2 f i , j
j ( S )
S2
2
fi+1, j fi, j
+ O ( t ) =
2
t
rjS fi+1, j +1 fi+1, j 1 fi, j +1 fi, j 1
2
2S
2S
fi, j +1 + fi, j 1 2 fi, j
1 2 2
2 fi +1, j +1 + fi +1, j 1 2 fi +1, j
j ( S )
+
2
2
S
S
4
r
2
+ ( fi+1, j + fi, j ) + O ( S )
2
Math6911, S08, HM ZHU
Crank-Nicolson Methods
R e w ritin g th e e q u a tio n , w e g e t a n C ra n k -N ic o ls o n s c h e m e :
(
)f
+ (1 + ) f
j f i , j 1 + 1
j f i + 1 , j 1
i,j
i +1 , j
j f i , j +1 =
+ j f i +1 , j +1
(5 .5 )
w h e re
t
2 j 2 rj
4
t
2 j2 + r
j =
2
t
j=
2 j 2 + rj
4
fo r i = N - 1 , N - 2 , ..., 1 , 0 a n d j = 1 , 2 , ..., M - 1 .
j=
S
Smax=MS
(j+1)S
jS
(j-1)S
0
Math6911, S08, HM ZHU
(i-1)t it (i+1)t
T=N t
Implementation
Equation (5.5) can be rewritten in matrix form:
M1fi = M 2fi +1 + b
where fi and bi are (M 1) dimensional vectors
fi = fi ,1 , fi ,2 , fi ,3
, fi ,M 1 ,
b = 1 ( fi ,0 + fi +1,0 ) , 0
, M 1 ( fi ,M + f i +1,M )
1
2
2
M1 = 0
3
M 2
1 M 1
0
0
M 1
Implementation
and
0
0
1
1 + 1
1
0
+
2
2
2
M2 = 0
3
M 2
0
0 M 1 1 + M 1
75
Math6911, S08, HM ZHU
Example
We compare Crank-Nicolson Methods for a European put
with the exact Black-Scholes formula, where T = 5/12 yr,
S0=$50, K = $50, =30%, r = 10%.
Black-Scholes Price: $2.8446
CN Method with Smax=$100, S=2, t=5/1200: $2.8241
CN Method with Smax=$100, S=1, t=5/4800: $2.8395
76
Math6911, S08, HM ZHU
Example (Stability)
We compare Crank-Nicolson Method for a European put with
the exact Black-Scholes formula, where T = 5/12 yr, S0=$50,
K = $50, =30%, r = 10%.
Black-Scholes Price: $2.8446
CN Method with Smax=$100, S=1.5, t=5/1200: $3.1370
CN Method with Smax=$100, S=1, t=5/1200: $2.8395
77
Math6911, S08, HM ZHU
78
Math6911, S08, HM ZHU
79
Math6911, S08, HM ZHU
80
Math6911, S08, HM ZHU
Appendix A.
Matrix Norms
Vector Norms
- Norms serve as a way to measure the length of a vector or a matrix
- A vector norm is a function mapping x n to a real number x s.t.
x > 0 for any x 0; x = 0 iff x = 0
c x = c x for any c
x + y x + y for any x, y n
- There are various ways to define a norm
p
xi
i =1
max xi
n
x
x
1 i n
= ?, v 2 = ?
82
Matrix Norms
- Similarly, a matrix norm is a function mapping A mn to a real number A s.t.
A > 0 for any A 0; A = 0 iff A = 0
c A = c A for any c
A + B A + B for any A, B mn
- Various commonly used matrix norms
A
Ax
sup
x0
A 1 max
1 j n i =1
aij
i =1 j =1
m
ij
max
1 i m
a
j =1
ij
(B ) max{k : k is an eigenvalue of B}
An Example
2 4 1
A= 3 1 5
2 3 1
A
=?
A1 =?
A 2 =?
A
=?
84
Let A, B
nn
and x, y . Then
n
1. x 0; and x = 0 x = 0
2. x + y x + y
3. x = x where is a real number
4. Ax A x
5. AB A B
85
Math6911, S08, HM ZHU
c2 x
Convergence
87
Math6911, S08, HM ZHU
Appendix B.
1 0 0a21
0 0 1a31
a12
a22
a32
a23
a13
a33
89
Math6911, S08, HM ZHU
0 1 0a21 a22
0 0 1a31 a32
ca13
a23
a33
1
1
0
a
a
a
a22 a12
22
23 = a21 a11
21
0 0 1a31 a32 a33 a31
a32
a13
a23 a13
a33
90