Documente Academic
Documente Profesional
Documente Cultură
References
1. Chapters 5 and 9, Brandimarte 2. Section 17.8, Hull 3. Chapter 7, Numerical analysis, Burden and Faires
2
Math6911, S08, HM ZHU
Outline
Finite difference (FD) approximation to the derivatives Explicit FD method Numerical issues Implicit FD method Crank-Nicolson method Dealing with American options Further comments
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 )
f ( S ,t + t ) = f ( S ,t ) +
Math6911, S08, HM ZHU
f ( S ,t ) t
t + O ( t )
)
8
t t
Forward: Backward: Central: f ( t,S ) t f ( t,S )
t + t
+ O ( t ) + O ( t ) + O ( t )
f ( t + t,S ) f ( t,S )
t f ( t,S ) f ( t t,S )
t f ( t,S ) t
t f ( t + t,S ) f ( t t,S ) 2t
( S )
+ O ( S )
Use Taylor's expansions for f ( t,S + S ) and f ( t,S S ) around point ( t,S ) : f ( t,S + S ) = ? + f ( t,S S ) = ?
10
Math6911, S08, HM ZHU
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
12
(5.2)
c =
* j
Math6911, S08, HM ZHU
( ( 1 t ( 2
) ) + rj )
S Smax=MS
(j+1)S j S (j-1)S
x x x x
0
Math6911, S08, HM ZHU
(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
EFD Method with Smax=$100, S=2, t=5/1200: $2.8288 EFD Method with Smax=$100, S=1.5, t=5/1200: $3.1414 EFD Method with Smax=$100, S=1, t=5/1200: -$2.8271E22
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
Suppose we have mathematically posed problem: y = f ( x) where y is to evaluated given an input x. Let x* = x + x for small change x. If hen f x* is near f ( x ) , then we call the problem is well - conditioned . Otherwise, it is ill-posed/ill-conditioned.
( )
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
The concept "near" can be measured by further information about the particular problem: f ( x ) f x* f ( x)
( )
x
x
( f ( x ) 0)
where C is called condition number of this problem. If C is large, the problem is ill-conditioned.
24
Math6911, S08, HM ZHU
xd
10 e xd 10 e
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 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
Stable: f * ( x ) f x* ( ) f ( x) f ( x) Well-conditioned: f ( x ) f ( x )
* *
29
Math6911, S08, HM ZHU
u 0
i +1, j +1 i +1, j
i , 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
Check if the mean and variance of the Expected value of the increase in asset price during t: E [ ] = S d + 0 0 + S u = rjS t = rS t Variance of the increment:
2 2 2 2 2 2 E 0 S S = j S t = S t = + + ( ) ( ) ( ) d 0 u 2 2 2 2 2 2 2 2 2 2 = S t r S t S t Var [ ] = E E ( ) [ ] 2
Change of Variable
Define Z = ln S. The B-S equation becomes f 2 f 2 2 f +r + = rf 2 2 Z 2 Z t The corresponding difference equation is fi +1, j fi , j t or
* fi , j = *j f i +1, j 1 + * f + j i +1, j j f i +1, j +1
Change of Variable
where
2 2 1 t t * j = + r 1 + r t 2 2Z 2 Z 2 t 2 1 * 1 = j 2 1 + r t Z 2 2 1 t t * j = + r 2 1 + r t 2 2 Z 2 Z
u 2u = x2
Math6911, S08, HM ZHU
(5.5)
36
this by
m +1 m m m ( ) 1 2 un u u = un + + +1 n n 1
Rate of Convergence is O ( )
Math6911, S08, HM ZHU
38
(5.6)
( 1 = t ( 2
) ) + rj )
S Smax=MS
(j+1)S j S (j-1)S
x x x x
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: Cfi = fi +1 + bi
( 5.7 )
T
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
IFD Method with Smax=$100, S=2, t=5/1200: $2.8288 IFD Method with Smax=$100, S=1.5, t=5/1200: $3.1325 IFD Method with Smax=$100, S=1, t=5/1200: $2.8348
46
Math6911, S08, HM ZHU
i , j +1 i , j i , j 1
Implicit Method (always stable)
i +1, j
The explicit finite difference method is equivalent to the trinomial tree approach: Truncation error: O(t) Stability: not always The implicit finite difference method is equivalent to a multinomial tree approach: Truncation error: O(t) Stability: always
48
Math6911, S08, HM ZHU
Solve Ax=b
Lower triangular
Upper triangular
General
51
4 6 1 x1 100 0 1 1 x = 10 2 20 x3 0 0 4
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
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
57
Gauss Elimination
Goal: Make A an upper triangular matrix through using fundamental row operations For example, to zero the elements in the lower triangular part of A 1) Zero a21
1 a 21 a11 0 0 0 a11 1 0a21 a 0 1 31 a12 a22 a32 a13 a11 a23 = 0 a33 a31 a12 a21 a12 a22 a11 a32 a13 a21 a13 a23 a11 a33
58
E 21 A
Gauss Elimination
2) Zero a31
1 0 a31 a11 a11 0 0 1 0 0 0 1 a31 a12 a22 a21 a12 a11 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 a11 a12 a13 = 0 a a 22 23 0 a32 a33
59
a32
E 31 E 21 A
Math6911, S08, HM ZHU
Gauss Elimination
3) Zero a32
1 0 1 0 0 a32 a22 0 a11 0 0 0 1 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
= 0 0 1
Claim 1:
E 32 E 31 E 21
1 a 21 a1 1 a 31 a1 1
0 1 a 32 a 22
Claim 2:
( E 32 E 31 E 21 )
Math6911, S08, HM ZHU
1 a 21 = a11 a 31 a11
0 1 a 32 a 22
0 0 1
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 2 1 2 x 3 4
% build the vector b x_true = [1:3]'; b = A * x_true; % lu decomposition of A [l, u] = lu(A) % solve z from lz = b where z = ux z = l\b; % solve x from ux = z x = u\z
64
row i
row j -
a ji aii
row i
65
Math6911, S08, HM ZHU
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
f i +1 , j +1 f i +1 , j 1
+ rf i +1 , j + O
Math6911, S08, HM ZHU
(( S ) )
2
f i , j +1 f i , j 1
+ rf i , j + O
Math6911, S08, HM ZHU
(( S ) )
2
fi+1, j fi, j
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
+ O ( t ) =
2
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
j f i + 1 , j 1
w h e re
( )f + (1 + ) f
j j
i,j
j f i , j +1 = + j f i +1 , j +1 (5 .5 )
i +1 , j
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 j S (j-1)S
x x x x x x
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 , , M 1 ( fi ,M + f i +1,M ) 0 M 2 1 M 1 0 0
T T
b= 1 ( fi ,0 + fi +1,0 ) , 0 1 1 1 1 2 2 M1 = 0 3 0
M 1
Implementation
and 0 0 1 1 + 1 1 0 + 2 2 2 M2 = 0 3 M 2 0 M 1 1 + M 1 0
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
Exact Price (Hall, p533-535): $0.5424 CN Method with Smax=$100, S=0.5, t=1/1200: $0.5414
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 x x
p
p xi i =1 max xi
n 1 i n
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
p
sup
x0
Ax x
m p
A A
aij i =1 j =1
m n
A 1 max
1 j n i =1
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 =? A 2 =? A
F
A1 =?
Math6911, S08, HM ZHU
=?
84
Let A, B
nn
and x, y . Then
n
All norms in n mn 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
Condition Number of A Matrix: C A A1 , where A nn . The condition number gives a measure of how close a matrix is close to singular. The bigger the C, the harder it is to solve Ax = b.
86
Math6911, S08, HM ZHU
Convergence
87
Math6911, S08, HM ZHU
Appendix B.
Three kinds of basic row operations: 1) Interchange the order of two rows or (equations)
0 1 0a11 1 0 0a21 0 0 1 a31 a12 a22 a32 a13 a21 a22 a23 = a11 a12 a33 a31 a32 a23 a13 a33
89
Math6911, S08, HM ZHU
3) Add or subtract rows 1 0 0 a11 a12 a13 a11 a12 1 1 0 a a a a22 a12 22 23 = a21 a11 21 a32 0 0 1 a31 a32 a33 a31
Math6911, S08, HM ZHU