Professional Documents
Culture Documents
Methods
2
Math6911, S08, HM ZHU
Outline
3
Math6911, S08, HM ZHU
Chapter 5 Finite Difference
Methods
?
j ∆S
i ∆t T=N ∆t t
6
Math6911, S08, HM ZHU
Black-Scholes Equation for a
European option with value V(S,t)
∂V 1 2 2 ∂ 2V ∂V
+ σ S + rS − rV = 0 (5.1)
∂t 2 ∂ S
2
∂S
where 0 < S < +∞ and 0 ≤ t < T
with proper final and boundary conditions
Notes:
This is a second-order hyperbolic, elliptic, or parabolic,
forward or backward partial differential equation
Its solution is sufficiently well behaved ,i.e. well-posed
For example,
∂f ( S,t ) f ( S ,t + ∆t ) − f ( S ,t ) f ( S ,t + ∆t ) − f ( S ,t )
= lim ≈
∂t ∆t → 0 ∆t ∆t
for small ∆t, using Taylor expansion at point ( S ,t )
∂f ( S ,t )
f ( S ,t + ∆t ) = f ( S ,t ) +
∂t
(
∆t + O ( ∆ t )
2
)
8
Math6911, S08, HM ZHU
Forward-, Backward-, and Central-
difference approximation to 1st order
derivatives
central
backward forward
t − ∆t t t + ∆t
∂f ( t,S ) f ( t + ∆t,S ) − f ( t,S )
Forward: ≈ + O ( ∆t )
∂t ∆t
∂f ( t,S ) f ( t,S ) − f ( t − ∆t,S )
Backward: ≈ + O ( ∆t )
∂t ∆t
∂f ( t,S ) f ( t + ∆t,S ) − f ( t − ∆t,S )
Central:
∂t
≈
2∆t
(
+ O ( ∆t )
2
)
Symmetric Central-difference
approximations to 2nd order derivatives
∂f fi +1, j − fi , j ∂f fi , j +1 − fi , j
Forward Difference: ≈ , ≈
∂t ∆t ∂S ∆S
∂f fi , j − fi −1, j ∂f fi , j − fi , j −1
Backward Difference: ≈ , ≈
∂t ∆t ∂S ∆S
∂f fi +1, j − fi −1, j ∂f fi , j +1 − fi , j −1
Central Difference: ≈ , ≈
∂t 2∆t ∂S 2∆S
As to the second derivative, we have:
∂ 2 f ⎛ fi , j +1 − fi , j fi , j − fi , j −1 ⎞
≈⎜ − ⎟ ∆S
∂S 2
⎝ ∆S ∆S ⎠
fi , j +1 − 2 fi , j + fi , j −1
=
( )
2
∆ S 11
Math6911, S08, HM ZHU
Finite difference approximations
∂ f ∂f 1 2 2∂2f
In + rS + σ S = rf , at point (i ∆ t , j ∆ S ), set
∂t ∂S 2 ∂S 2
∂ f f i , j − f i −1 , j
backward difference: ≈
∂t ∆t
∂f f i , j +1 − f i , j −1
central difference: ≈ ,
∂S 2∆S
and
∂2f f i , j + 1 + f i , j −1 − 2 f i , j
≈ , r f = rf i , j , S = j ∆ S
∂S 2
∆S 2
2
for i = N - 1, N - 2 , ..., 1, 0 and j = 1, 2 , ..., M - 1 .
Math6911, S08, HM ZHU
Numerical Computation Dependency
S
Smax=M∆S
(j+1)∆S x
j∆S x x
(j-1)∆S x
0
0 (i-1)∆t i∆t T=N ∆t t
Math6911, S08, HM ZHU
Implementation
17
Math6911, S08, HM ZHU
Example
18
Math6911, S08, HM ZHU
Example (Stability)
19
Math6911, S08, HM ZHU
Chapter 5 Finite Difference
Methods
21
Math6911, S08, HM ZHU
Conditioning Issue
22
Math6911, S08, HM ZHU
Conditioning Issue
23
Math6911, S08, HM ZHU
Conditional Issue
24
Math6911, S08, HM ZHU
Floating Point Number & Error
26
Math6911, S08, HM ZHU
Numerical Stability or Instability
( )
Stable: f * ( x ) ≈ f x* ⎫
⎪
⎬ f ( x) ≈ f ( x)
*
Well-conditioned: f ( x ) ≈ f ( x ) ⎪⎭
*
29
Math6911, S08, HM ZHU
Chapter 5 Finite Difference
Methods
where
1 ⎛1 1 ⎞ 1
â j = ⎜ ∆ tσ j − ∆ t r j ⎟ = πd
2 2
1 + r ∆t ⎝ 2 2 ⎠ 1 + r ∆t
b̂ j =
1
1 + r ∆t
( 1 − σ j ∆t =
2 2
)
1
1 + r ∆t
π0
1 ⎛1 1 ⎞ 1
ĉ j = ⎜ ∆ tσ j + ∆ t r j ⎟ = πu
2 2
1 + r ∆t ⎝ 2 2 ⎠ 1 + r ∆t
for i = N - 1, N - 2 , ..., 1, 0 and j = 1, 2 , ..., M - 1 .
Math6911, S08, HM ZHU
Explicit Finite Difference Methods
ƒi +1, j +1
πu
π0
ƒi , j ƒi +1, j
πd
ƒi +1, j –1
These coefficients can be interpreted as probabilities times
a discount factor. If one of these probability < 0, instability
occurs.
Math6911, S08, HM ZHU
Explicit Finite Difference Method as
Trinomial Tree
Var [ ∆ ] = E ⎡⎣ ∆ 2 ⎤⎦ − E 2 [ ∆ ] = σ 2 S 2 ∆t − r 2 S 2 ( ∆t ) ≈ σ 2 S 2 ∆t
2
or
fi , j = α *j f i +1, j −1 + β *j fi +1, j + γ *j f i +1, j +1 (5.4)
34
Math6911, S08, HM ZHU
Change of Variable
where
1 ⎡ ⎛ σ 2
⎞ ∆t σ 2
∆t ⎤
αj =
*
⎢− ⎜ r − ⎟ + ⎥
1 + r ∆t ⎣ ⎝ 2 ⎠ 2∆Z 2 ∆Z 2 ⎦
1 ⎛ ∆t 2 ⎞
β *j = ⎜ 1 − σ ⎟
1 + r ∆t ⎝ ∆Z 2
⎠
1 ⎡ ⎛ σ 2
⎞ ∆ t σ 2
∆t ⎤
γj =
*
⎢⎜ r − ⎟ + 2⎥
1 + r ∆t ⎣⎝ 2 ⎠ 2 ∆ Z 2 ∆Z ⎦
It can be shown that it is numerically most efficient if ∆Z = σ 3∆t .
35
Math6911, S08, HM ZHU
Reduced to Heat Equation
∂ u ∂ 2u
= (5.5)
∂ τ ∂ x2
for − ∞ < x < +∞ and τ > 0 36
Math6911, S08, HM ZHU
Explicit Finite Difference Method
this by
u nm +1 = α u nm+1 + (1 − 2α )u nm + α u nm−1
⎛ 1 2 ⎞
δτ ⎜ σ T ⎟
where α = , for -N −
≤ n ≤ N +
and m = 0 ,
1 ,...M ⎜ = 2 ⎟
(δx )2 ⎜
⎜
δτ ⎟
⎟
Math6911, S08, HM ZHU ⎝ ⎠
Stability and Convergence
(P. Wilmott, et al, Option Pricing)
Stability:
The solution of Eqn (5.5) is
δτ 1 1
i) Stable if 0 < α = ≤ ; ii) Unstable if α >
(δ x ) 2
2
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 (δτ ) 38
Math6911, S08, HM ZHU
Chapter 5 Finite Difference
Methods
∂ f ∂f 1 2 2∂2f
In + rS + σ S = r f , we use
∂t ∂S 2 ∂S 2
∂ f f i +1,j − f i ,j
forw ard difference: ≈
∂t ∆t
∂ f f i , j + 1 − f i , j −1
central difference: ≈ ,
∂ S 2∆S
and
∂ 2f f i , j + 1 + f i , j −1 − 2 f i , j
≈ , rf = rf i , j
∂ S 2
∆S 2
2
for i = N - 1, N - 2 , ..., 1, 0 and j = 1, 2 , ..., M - 1 .
Math6911, S08, HM ZHU
Numerical Computation Dependency
S
Smax=M∆S
(j+1)∆S x
j∆S x x
(j-1)∆S x
0
0 (i-1)∆t i∆t (i+1)∆t T=N ∆t t
Math6911, S08, HM ZHU
Implementation
44
Math6911, S08, HM ZHU
Example
45
Math6911, S08, HM ZHU
Example (Stability)
46
Math6911, S08, HM ZHU
Implicit vs Explicit Finite Difference Methods
ƒi +1, j +1 ƒi , j +1
ƒi , j ƒi +1, j
ƒi , j ƒi +1, j
ƒi , j –1
ƒi +1, j –1
Implicit Method
Explicit Method
(always stable)
Math6911, S08, HM ZHU
Implicit vs Explicit Finite Difference
Method
A x=b
51
Math6911, S08, HM ZHU
5.3.2.A Triangular Solvers
⎡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
53
Math6911, S08, HM ZHU
Solve an upper triangular system Ax=b
⎛ x1 ⎞
⎜ ⎟
⎜ x2 ⎟
(0 0 aii 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, n −1
⎝ j >i ⎠
54
Math6911, S08, HM ZHU
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
5.3.2.B Gauss Elimination
= *
57
Math6911, S08, HM ZHU
Gauss Elimination = *
2) Zero a31
⎡ ⎤
⎡ ⎤
⎢ 1 ⎥ ⎡ a11 a12 a13 ⎤ ⎢ a11 a a
⎥
⎥ ⎢ ⎥
12 13
0 0 ⎢
⎢ ⎥ a21 a12 a21 a13 ⎥ ⎢ a21 a12 a21 a13 ⎥
⎢ 0 1 0⎥ ⎢ 0 a22 − a23 − = ⎢ 0 a22 − a23 − ⎥
⎢ ⎥⎢ a11 a11 ⎥ ⎢ a11 a11 ⎥
⎢ − a31 ⎢ ⎥
0 1 ⎥ ⎢⎣ a31 a32 a33 ⎥⎦ ⎢ a31 a12 a31 a13 ⎥
⎢⎣ a11 ⎥⎦ ⎢ 0 a32 − a33 − ⎥
⎣ a11 a11 ⎦
⇓ ⎡ a11 a12 a13 ⎤
E 31 E 21 A = ⎢⎢ 0 a22 a23 ⎥⎥
⎢⎣ 0 a32 a33 ⎥⎦
59
Math6911, S08, HM ZHU
Gauss Elimination = *
3) Zero a32
⎡ ⎤ ⎡ ⎤
⎢1 0 0 ⎥ ⎡ a11 a12 a13 ⎤ ⎢ a11 a12 a13 ⎥
⎢ ⎥⎢ ⎥ ⎢ ⎥
⎢0 1 0⎥ ⎢ 0 a22 a23 ⎥ = ⎢ 0 a22 a23 ⎥ ≡U
⎢ ⎥⎢ ⎢ ⎥
⎢0 − a32 ⎥ ⎣ 0 a32 a33 ⎥⎦ ⎢ a32 a23 ⎥
1 0 0 a33 −
⎢⎣ a22 ⎥⎦ ⎢⎣ a22 ⎥⎦
⇓
E 32 E 31 E 21 A = U
⇓
lower triangular 60
Math6911, S08, HM ZHU
Gauss Elimination = *
⎡ ⎤
⎢ ⎥
Claim 1: ⎢ 1 0 0⎥
⎢ a 21 ⎥
E 32 E 31 E 21 = ⎢− 1 0⎥
⎢ a1 1 ⎥
⎢ a 31 a 32 ⎥
⎢− − 1⎥
⎣ a1 1 a 22 ⎦
Claim 2: ⎡ ⎤
⎢ ⎥
⎢ 1 0 0⎥
⎢ a 21 ⎥
( E 32 E 31 E 21 )
−1
=⎢ 1 0⎥
⎢ a11 ⎥
⎢ a 31 a 32 ⎥
⎢ 1⎥ 61
Math6911, S08, HM ZHU
⎣ a11 a 22 ⎦
LU Factorization = *
E 32 E 31 E 21A = U
A = (E 32 E 31 E 21 ) U
−1
A = LU
To solve Ax = b becomes
1) Use Gauss elimination to make A upper triangular, i.e.
L−1Ax = L−1b ⇒ Ux = z
2) Solve x from Ux = z
63
Math6911, S08, HM ZHU
An exercise
% solve x from ux = z
x = u\z
64
Math6911, S08, HM ZHU
General Gauss Elimination
row i
a ji
row j - ∗ row i
aii
65
Math6911, S08, HM ZHU
What if we have zero or very small
diagonal elements?
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
Chapter 5 Finite Difference
Methods
∂ f ∂f 1 2 2∂2f
W ith + rS + σ S = rf ,
∂t ∂S 2 ∂S 2
∂ f ∂f 1 2 2∂2f
W ith + rS + σ S = r f,
∂t ∂S 2 ∂S 2
fi+1, j − fi, j
∆t
(
+ O ( ∆t ) =
2
)
rj∆S ⎛ fi+1, j +1 − fi+1, j −1 fi, j +1 − fi, j −1 ⎞
− ⎜ + ⎟
2 ⎝ 2∆S 2∆S ⎠
1 2 2 2 ⎛ fi +1, j +1 + fi +1, j −1 − 2 fi +1, j fi, j +1 + fi, j −1 − 2 fi, j ⎞
− σ j ( ∆S ) ⎜ + ⎟
4 ⎝ ∆S 2
∆S 2
⎠
r
+ ( fi+1, j + fi, j ) + O ( ∆S )
2
(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 :
(
− α j f i , j −1 + 1 − β )fj i,j − γ j f i , j +1 =
α j f i + 1 , j −1 + (1 + β ) f
j i +1 , j + γ j f i +1 , j +1 (5 .5 )
w h e re
∆t
α j=
4
σ 2 j 2 − rj( )
∆t
βj = −
2
σ 2 j2 + r ( )
∆t
γj=
4
σ 2 j 2 + rj( )
fo r i = N - 1 , N - 2 , ..., 1 , 0 a n d j = 1 , 2 , ..., M - 1 .
Math6911, S08, HM ZHU
Numerical Computation Dependency
S
Smax=M∆S
(j+1)∆S x x
j∆S x x
(j-1)∆S x x
0
0 (i-1)∆t i∆t (i+1)∆t T=N ∆t t
Math6911, S08, HM ZHU
Implementation
Equation (5.5) can be rewritten in matrix form:
M1fi = M 2fi +1 + b
where fi and bi are (M − 1) dimensional vectors
T
fi = ⎡⎣ fi ,1 , fi ,2 , fi ,3 , fi ,M −1 ⎤⎦ ,
and
⎡1 + β1 γ1 0 0 ⎤
⎢ α 1 + β γ 0 ⎥
⎢ 2 2 2 ⎥
M2 = ⎢ 0 α3 ⎥
⎢ ⎥
⎢ γ M −2 ⎥
⎢⎣ 0 0 α M −1 1 + β M −1 ⎥⎦
75
Math6911, S08, HM ZHU
Example
76
Math6911, S08, HM ZHU
Example (Stability)
77
Math6911, S08, HM ZHU
Example: Barrier Options
Types:
knock-out: option ceases to exist when the asset price reaches a barrier
Knock-in: option comes into existence when the asset price reaches a barrier
78
Math6911, S08, HM ZHU
Example: Barrier Option
79
Math6911, S08, HM ZHU
Example: Barrier Option
80
Math6911, S08, HM ZHU
Appendix A.
Matrix Norms
( )
A 2 ≡ ρ A T A , the spectral norm, where
ρ (B ) ≡ max{λk : λk is an eigenvalue of B}
An Example
⎡ 2 4 − 1⎤
⎢
A=⎢ 3 1 5⎥ ⎥
⎢⎣− 2 3 − 1⎥⎦
A ∞
=? A 2 =?
A1 =? A F
=?
84
Math6911, S08, HM ZHU
Basic Properties of Norms
n×n
Let A, B ∈ ℜ 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
Condition number of a square matrix
( )
All norms in ℜn ℜm×n are equivalent. That is, if • α and • β are norms
on ℜn , then ∃ c1 ,c2 > 0 such that for all x ∈ℜn , we have
c1 x α ≤ x β
≤ c2 x α
86
Math6911, S08, HM ZHU
Convergence
- matrix A k → 0 ⇔ A k − 0 → 0
87
Math6911, S08, HM ZHU
Appendix B.
89
Math6911, S08, HM ZHU
Basic row operations = *