Chapter 5 Finite Difference Methods
Math6911 S08, HM Zhu 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 Chapter 5 Finite Difference Methods
5.1 Finite difference approximations
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, j∆S) • We are interested in the values of f(t, S) at mesh points (i ∆t, j∆S), denoted as
fi,j = fit,jS( ∆∆) 5 Math6911, S08, HM ZHU The mesh for finite-difference approximation
fi,j = fit,jS( ∆∆) S Smax=M∆S ? j ∆S
t i ∆t T=N ∆t 6 Math6911, S08, HM ZHU Black-Scholes Equation for a European option with value V(S,t)
∂V 1σ ∂ 2V ∂V + 2S 2 + rS − rV = 0 (5.1) ∂t 2 ∂ 2S ∂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
Math6911, S08, HM ZHU Finite difference approximations
The basic idea of FDM is to replace the partial derivatives by approximations obtained by Taylor expansions near the point of interests
For example, ∂+∆−+∆−f ()S,t f ()()S,t t f S,t f ()()S,t t f S,t =≈lim ∂∆tt∆→t 0 ∆ t for small ∆t, using Taylor expansion at point () S,t () ()()∂fS,t 2 fS,tt+∆ = fS,t + ∆ t + O()() ∆ t ∂t 8 Math6911, S08, HM ZHU Forward-, Backward-, and Central- difference approximation to 1st order derivatives
central backward forward
tt− ∆ t tt+ ∆
∂+∆−ft,S( ) ft( t,S) ft,S( ) Forward: ≈+∆Ot() ∂∆tt () ∂−−∆f t,S f() t,S f t ( t,S ) Backward: ≈+∆Ot() ∂∆tt () ∂+∆−−∆f t,S f()() t t,S f t t,S 2 Central: ≈+∆Ot()() ∂∆tt2 Symmetric Central-difference approximations to 2nd order derivatives
2 ∂+∆−+−∆f( t,S) f( t,S S) 2 f( t,S) f( t,S S) 2 ≈+∆OS()() ∂S 2 ()∆S 2
Use Taylor's expansions for ft,S( +∆ S) and ft,S( −∆ S) ()around point t,S : () ft,S+∆ S = ? ()+ ft,S−∆ S = ?
10 Math6911, S08, HM ZHU Finite difference approximations
∂∂ffff− ff− Forward Difference:≈≈i,j++11 i,j, i,j i,j ∂∆tt ∂∆ SS ∂∂ffff−− ff Backward Difference: ≈≈i,j i−−11 ,j, i,j i,j ∂∆∂∆ttSS ∂∂ffff−− ff Central Difference: ≈≈i+−11 ,j i ,j, i,j +− 11 i,j ∂∆∂∆ttSS22 As to the second derivative, we have: 2 ∂ f ⎛⎞ffffi,j+−11−− i,j i,j i,j 2 ≈ ⎜⎟−∆S ∂S ⎝⎠∆∆SS
fffi,j+−11−+2 i,j i,j = 2 ()∆S 11 Math6911, S08, HM ZHU Finite difference approximations
• Depending on which combination of schemes we use in discretizing the equation, we will have explicit, implicit, or Crank-Nicolson methods • We also need to discretize the boundary and final conditions accordingly. For example, for European Call, Final Condition:
fN,j =∆−= max() j S K ,0 , for j 0 , 1 ,...,M Boundary Conditions:
⎪⎧ fi,0 = 0 , for i,,...,N= 0 1 ⎨ −−∆rN() i t ⎩⎪ fSKei,M=− max 12 Math6911, S08, HM ZHU where SMS.max =∆ Chapter 5 Finite Difference Methods
5.2.1 Explicit Finite-Difference Method
Math6911 S08, HM Zhu Explicit Finite Difference Methods
∂∂ff1 ∂2 f In ++rSσ 22 S = rf , at point ( i ∆∆ t, j S ), set ∂∂tS2 ∂ S2 ∂ f ff− backward difference: ≈ i,j i−1 ,j ∂∆tt ∂f ff− central difference: ≈ i,j+−11 i,j , ∂∆SS2 and ∂ 2 f ff+−2 f ≈==∆i,j+−11 i,j i,j ,rf rf,S jS ∂∆SS22 i,j Math6911, S08, HM ZHU Explicit Finite Difference Methods
Rewriting the equation, we get an explicit scheme: *** fafbfcfi−−11 ,j=++ j i,j j i,j j i,j + 1 (5.2) where 1 atjrj* =∆()σ 22 − j 2 * ()22 btjrj =−∆1 σ + 1 ctjrj* =∆()22 + j 2 σ for iN-,N-,...,, == 1210 and j 12, , ..., 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
1. Starting with the final values fN,j , we apply (5.2) to solve
fjN,j−1 for 1≤≤M. − 1 We use the boundary condition
to determine ff. N, − 10 and N-,M 1
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 Chapter 5 Finite Difference Methods
5.2.2 Numerical Stability
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: yfx= () where yx is to evaluated given an input . Let xxx* =+δδ for small change x. If hen fx()* is near fx,() 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 ill- conditioned 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:
* fx()− fx()δ x ≤≠Cfx()()0 fx() x where C is called condition number of this problem. If C is large, the problem is ill-conditioned.
24 Math6911, S08, HM ZHU Floating Point Number & Error
Let x be any real number. e Infinite decimal expansion : x = ± .x1x2 xd 10 e Truncated floating point number : x ≈ fl()x = ± .x1x2 xd 10
where x1 ≠ 0, 0 ≤ xi ≤ 9, d : an integer, precision of the floating point system e : an bounded integer () Floating point or roundoff error : fl x − x
25 Math6911, S08, HM ZHU 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 100 where d = 3. () Floating point error : fl x − x = −0.0003 () Error propagation : fl x 2 − x2 = 0.00040011
26 Math6911, S08, HM ZHU Numerical Stability or Instability
Stability ensures if the error between the numerical soltuion and the exact solution remains bounded as numerical computation progresses.
* That is, fx() (the solution of a slightly perturbed problem) is near fx* ()( the computed solution . )
() Stability concerns about the behavior offfit,jSi,j −∆∆ as numerical computation progresses for fixed discretization
steps ∆∆t and S. 27 Math6911, S08, HM ZHU Convergence issue
Convergence of the numerical algorithm concerns about the behavior of ffit,jSt,i,j −∆∆() as ∆∆→ 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 well- conditioned and the algorithm is stable
** ⎫ Stable: fx()≈ fx( ) ⎪ fx* ≈ fx ()* ⎬ () () Well-conditioned: fx≈ fx()⎭⎪
29 Math6911, S08, HM ZHU Chapter 5 Finite Difference Methods
5.2.3 Financial Interpretation of Numerical Instability
Math6911 S08, HM Zhu Financial Interpretation of instability (Hall, page 423-4)
If ∂∂fS and ∂2 fS ∂2 are assumed to be the same at ( i,j +1 ) as they are at (i, j ), we obtain equations of the form: ˆ fafbfcfi,j=++ˆˆ ji,j+−11 ji,j + 1 ji,j ++ 11 (5.3) where
1 ⎛⎞1122 1 aˆ j = ⎜⎟∆−∆=tjσπ trj d 1 +∆rt⎝⎠221 +∆ rt 11 bjtˆ =−∆=()1 22σπ j 11+∆rt +∆ rt 0
11⎛⎞1122 ctjtrjˆ j =∆+∆=⎜⎟u 11+∆rt⎝⎠22σπ +∆ rt for i == N -1210 , N - , ..., , and j 12 , , ..., 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
Check if the mean and variance of the Expected value of the increase in asset price during ∆ t:
E[]∆=−∆SSrjStrStππdu + 0 0 +∆ π = ∆ ∆= ∆ Variance of the increment: ⎡⎤2 2222 2 2 2 E⎣⎦∆=−∆()SSd + 0 0 +∆ ()u = σσjSt()∆∆=∆ St ππσσ π 2 2 22 222 22 Var[]∆= E⎣⎦⎡⎤ ∆ − E ∆= []StrSt ∆−() ∆ ≈ St ∆ which is coherent with geometric Brownian motion in a risk-neutral world
Math6911, S08, HM ZHU Change of Variable
Define ZlnS.= The B-S equation becomes ∂∂∂fff⎛⎞σσ222 +−⎜⎟rrf +2 = ∂∂∂tZZ⎝⎠22 The corresponding difference equation is
22 ffi,j++++−+++−++11111111111−−−+ i,j⎛⎞ f i,j f i,j f i,j2 f i,j f i,j +−⎜⎟rr +2 =fi,j ∆∆∆tZZ⎝⎠22σσ 2 or *** fi,j=++αβγ ji,jfff+−11 ji,j + 1 ji,j ++ 11 ()54 .
34 Math6911, S08, HM ZHU Change of Variable
whereα
22 * 1 ⎡⎤⎛⎞σσ∆∆tt j =−−+⎢⎥⎜⎟r 2 βσ1222+∆rt⎣⎦⎝⎠ ∆ Z ∆ Z
* 1 ⎛⎞∆t 2 j =−⎜⎟1 2 1γ+∆rt⎝⎠ ∆ Z ⎡⎤⎛⎞22 * 1 σσ∆∆tt j =−+⎢⎥⎜⎟r 2 1222+∆rt⎣⎦⎝⎠ ∆ Z ∆ Z It can be shown that it is numerically most efficient if ∆Z =∆3 t.
35 Math6911, S08, HM ZHU
σ Reduced to Heat Equation
Get rid of the varying coefficients S and S² by using
change of variables: 1 1 − ()k −1 x− ()k +1 2τ S = Ee x ,t = T − 2 2 ,V ()S,t = Ee 2 4 u()x, τ σ ⎛ 1 ⎞ k = r ⎜ σ 2 ⎟ ⎝ 2 ⎠ Equation (5.1) becomes heat equation (5.5): τ ∂∂uu2 = 2 (5.5) ∂τ ∂ x for − ∞
Explicit Finite Difference Method
m With un = u()n x,mδ , this involves solving a system of finite difference equations of the form : α m+1 m m m m un − un un+1 − 2un + un−1 2 + O()δτα = 2 + O()()δx δτ δx() α α δτ 2 Ignoring terms of O()δτ and O()δx (), we can approximat e this by δ m+1 m m m un = un+1 + ()1− 2 un + un−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 ααδτ 11 i) Stable if 0<=2 ≤ ; ii) Unstable if > ()δx 22 Convergenceα : 1 If 0<≤, then the explicit finite-difference approximation 2 converges to the exact solution as , x0→ m (in the sense that uunxmn →→()δδτ, as , δτδ x 0) () δτ δ Rate of Convergence is O δτ 38 Math6911, S08, HM ZHU Chapter 5 Finite Difference Methods
5.3.1 Implicit Finite-Difference Method
Math6911 S08, HM Zhu Implicit Finite Difference Methods
∂∂ff1 ∂2 f In ++rSσ 22 S = r f , we use ∂∂tS2 ∂ S2 f ff− forward difference: ∂ ≈ iij+1,j , tt∂ ∆
f ffij,,+−11− ij central difference: ∂≈ , SS2∆ ∂ ∂ and ∂ 2 f ff+−2 f ≈=ij,,+−11 ij ij ,,rfrf SS22∆ i,j
Math6911, S08, HM ZHU Implicit Finite Difference Methods
Rewriting the equation, we get an implicit scheme:
afjij,,,−++111++ bf jij cf jij = f i,j (5.6) where 1 atjrj = ∆−()σ 22 + j 2 ()22 btjrj =+∆1 σ + 1 ctjrj=− ∆()22 + j 2 σ for i== N-,N-1210 ,...,, and j 12 , ,...,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
Equation (5.6) can be rewritten in matrix form:
Cfii=+ f+1 b i ()57. where fbii and are (M − 1) dimensional vectors TT fbii,i,i,i,Mi==−−⎣⎡ f,f,f123 ,f−− 1⎦⎣⎤⎡ , af,,, 10 i,00 ,,c 0 Mi,M 1 f ⎦⎤ and C is (MM−× 1) ( − 1) symmetric matrices
⎡⎤bc1100 ⎢⎥abc 0 ⎢⎥222
C = ⎢⎥0 ab33 ⎢⎥ ⎢⎥ cM −2 ⎢⎥ ⎣⎦00 abMM−−11 Implementation
1. Starting with the final values fN,j , we need to solve a
linear system (5.7) to obtain fjMN,j−1 for 1≤ ≤− 1 using LU factorization or iterative methods. We use the
boundary condition to determine ff. N, − 10 and N-,M 1
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 Implicit vs Explicit Finite Difference Methods
ƒ i +1, j +1 ƒi , j +1
ƒi , j ƒ ƒi , j ƒi +1, 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
• 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 Other Points on Finite Difference Methods
• It is better to have ln S rather than S as the underlying variable in general • Improvements over the basic implicit and explicit methods: – Crank-Nicolson method, average of explicit and implicit FD methods, trying to achieve • Truncation error: O((∆t)2 ) • Stability: always
Math6911, S08, HM ZHU Chapter 5 Finite Difference Methods
5.3.2 Solving a linear system using direct methods
Math6911 S08, HM Zhu Solve Ax=b
A x=b
Various shapes of matrix A
Lower triangular Upper triangular General
51 Math6911, S08, HM ZHU 5.3.2.A Triangular Solvers
Math6911 S08, HM Zhu Example: 3 x 3 upper triangular system
⎡4 6 1⎤⎡x1 ⎤ ⎡100⎤ ⎢0 1 1⎥⎢x ⎥= ⎢ 10 ⎥ ⎢ ⎥⎢ 2 ⎥ ⎢ ⎥ ⎣⎢0 0 4⎦⎥⎣⎢x3 ⎦⎥ ⎣⎢ 20 ⎦⎥
⇒ x3 = 20 / 4 = 5
⇒ x2 =10 − x3 = 5
⇒ 4x1 =100 − x3 − 6* x2 = 65
∴x1 = 65 4 53 Math6911, S08, HM ZHU Solve an upper triangular system Ax=b
⎛ x ⎞ ⎜ 1 ⎟ ⎜ x2 ⎟ ()0 0 a a = a x + a x = b ,i =1,…,n ii in ⎜ ⎟ ii i ∑ ij j i ⎜ ⎟ j>i ⎜ ⎟ ⎝ xn ⎠
⇒ xn = bn ann ⎛ ⎞ x = ⎜b − a x ⎟ a ,i =1, n −1 i ⎜ i ∑ ij j ⎟ ii ⎝ 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
Math6911 S08, HM Zhu To solve Ax=b for general form A
= *
To solve Ax = b : Solve two triangular systems : Suppose A = LU. Then 1) solve z from Lz = b Ax = LUx = b 2) solve x from Ux = z ⇓ z
57 Math6911, S08, HM ZHU 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
⎡ ⎤ ⎡a11 a12 a13 ⎤ 1 0 0 ⎡a11 a12 a13 ⎤ ⎢ a ⎥ ⎢ a a a a ⎥ − 21 1 0 ⎢a a a ⎥ = 0 a − 21 12 a − 21 13 ⎢ ⎥⎢ 21 22 23 ⎥ ⎢ 22 23 ⎥ ⎢ a11 ⎥ ⎢ a11 a11 ⎥ ⎣⎢a31 a32 a33 ⎦⎥ ⎣⎢ 0 0 1⎦⎥ ⎣⎢a31 a32 a33 ⎦⎥ ⇓ 58 Math6911, S08, HM ZHU E 21A Gauss Elimination = *
2) Zero a31 ⎡ ⎤ ⎡⎤ ⎡⎤⎢ ⎥ ⎢⎥aa11 12 a 13 aa 11 12 a 13 100⎢⎥⎢ ⎥ ⎢⎥ aaaa⎢ aa aa⎥ ⎢⎥0100⎢⎥aa−−=−−21 1221 13 0 aa 21 12 21 13 ⎢⎥22 23⎢ 22 23 ⎥ ⎢⎥ aa11 11 aa 11 11 a ⎢⎥⎢ ⎥ ⎢⎥− 31 01 ⎢ ⎥ ⎣⎦⎢⎥aa31 32 a 33 aaaa 31 12 31 13 ⎣⎦⎢⎥a11 ⎢ 0 aa32−− 33 ⎥ ⎣ aa11 11 ⎦
⇓ ⎡⎤aaa11 12 13 = ⎢⎥0 aa E 31 E 21A ⎢⎥22 23 ⎣⎦⎢⎥0 aa 32 33 59 Math6911, S08, HM ZHU Gauss Elimination = *
3) Zero a 32 ⎡⎤ ⎡ ⎤ ⎢⎥100⎡⎤aaa ⎢ aa a ⎥ ⎢⎥11 12 13 ⎢ 11 12 13 ⎥ 0100⎢⎥aa = 0 a a ≡ U ⎢⎥⎢⎥22 23 ⎢ 22 23 ⎥ ⎢⎥aaaaa ⎢⎥0 ⎢ ⎥ ⎢⎥32⎣⎦ 32 33 ⎢ 32 23 ⎥ 01−− 00a 33 ⎣⎦⎢⎥aa 22 ⎣⎢ 22 ⎦⎥ ⇓
E 32 E 31 E 21A = U ⇓
lower triangular 60 Math6911, S08, HM ZHU Gauss Elimination = *
⎡ ⎤ ⎢ ⎥ Claim 1: ⎢ 100⎥ ⎢ ⎥ a 21 EEE32 31 21 =−⎢ 10⎥ ⎢ a11 ⎥ ⎢ aa ⎥ ⎢ −−31 32 1 ⎥ ⎣ aa11 22 ⎦ Claim 2: ⎡ ⎤ ⎢ ⎥ ⎢ 100⎥ ⎢ ⎥ −1 a21 ()EEE32 31 21 = ⎢ 10⎥ ⎢ a11 ⎥ ⎢ aa ⎥ ⎢ 31 32 1⎥ 61 Math6911, S08, HM ZHU ⎣ aa11 22 ⎦ LU Factorization = *
Therefore, through Gauss Elimination, we have
E 32 E 31 E 21A = U −1 A = ()E 32 E 31 E 21 U A = LU
It is called LU factorization. When A is symmetric, ALL= T which is called Cholesky Decomposition
62 Math6911, S08, HM ZHU To solve Ax=b for general form A
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
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
% build the matrix A A = [2, -1, 0; -1, 2, -1; 0, -1, 2]
% build the vector b ⎡ 2 −1 ⎤⎡x1 ⎤ ⎡0⎤ x_true = [1:3]'; ⎢ ⎥ b = A * x_true; ⎢−1 2 −1⎥ x =⎢0⎥ ⎢ ⎥⎢ 2 ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ % lu decomposition of A ⎣ −1 2 ⎦⎣x3 ⎦ ⎣4⎦ [l, u] = lu(A) % solve z from lz = b where z = ux z = l\b;
% solve x from ux = z x = u\z 64 Math6911, S08, HM ZHU General Gauss Elimination
row i a row j- ji ∗row i aii
65 Math6911, S08, HM ZHU What if we have zero or very small diagonal elements?
Somtimes, we need to permute rows of A so that Gauss eliminatio n can be computed or computed stably, i.e., PA = LU. This is called partial pivoting. For example ⎡0 1⎤ A = ⎢ ⎥ ⎣2 3⎦ ⎡0 1⎤⎡0 1⎤ ⎡2 3⎤ PA = ⎢ ⎥⎢ ⎥ = ⎢ ⎥ ⎣1 0⎦⎣2 3⎦ ⎣0 1⎦ ⎡0.0001 1⎤ ⎡ 1 0⎤⎡0.0001 1 ⎤ A = ⎢ ⎥ = ⎢ ⎥⎢ ⎥ = LU ⎣ 1 1⎦ ⎣10,000 1⎦⎣ 0 - 9999 ⎦ ⎡0 1⎤⎡0.0001 1⎤ ⎡ 1 0⎤⎡1 1 ⎤ PA = ⎢ ⎥⎢ ⎥ = ⎢ ⎥⎢ ⎥ = LU 66 Math6911, S08, HM⎣ 1ZHU 0⎦⎣ 1 1⎦ ⎣0.0001 1⎦⎣0 .9999 ⎦ Can we always have A = LU?
No! If det()A()11: k , : 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
5.4.1 Crank-Nicolson Method
Math6911 S08, HM Zhu Explicit Finite Difference Methods
∂∂ff1 ∂2 f With ++rSσ 22 S = rf , ∂∂tS2 ∂ S2 we can obtain an explicite form: ff− i,j+1 i,j+∆=Ot() ∆t
ffi,++11j −+−i, +− 11j 1 22 2 ffi, ++ 11j i, +− 11j 2 fi, + 1j −∆rj S − j() ∆ S 2 22∆∆SSσ 2 ++∆rfi,j+1 O()() S
Math6911, S08, HM ZHU Implicit Finite Difference Methods
∂∂ff1 ∂2 f With ++rSσ 22 S = r f , ∂∂tS2 ∂ S2 we can obtain an implicit form : ff− i,j+1 i,j+∆=Ot() ∆t
ff−+−1 2 ff2 f −∆rj Si,j +−11i,j −22 j() ∆ S i,j +− 11i,j i,j 22∆∆SSσ 2
2 ++rfi,j O()() ∆ S
Math6911, S08, HM ZHU Crank-Nicolson Methods: average of explicit and implicit methods (Brandmarte, p485)
ffi,j+1 − i,j 2 +∆=Ot(()) ∆t
rj∆ S ⎛⎞ffi,j++11−− i,j +− 11 ff i,j + 1 i,j − 1 −+⎜⎟ 22⎝⎠∆∆SS 2
1 22 2 ⎛⎞ffi,j++11+− i,j +− 1122 ffff i,j + 1 i,j + 1 +− i,j − 1 i,j −∆σ jS()⎜⎟22 + 4 ⎝⎠∆∆SS
r 2 +++∆()ffOSi,j+1 i,j ()() 2
Math6911, S08, HM ZHU Crank-Nicolson Methods
Rewriting the equation, we get an Crank-Nicolson scheme:
−+−−=αβγji,jfff−+11()1 j i,j ji,j () αβγji,jfff+−11++1 j i,j + 1 + ji,j ++ 11 (5.5) where
∆ t 22 j = ()jrj− ασ4
∆t 22 j =− ()σ jr+ γσβ 2 ∆t 22 j =+()jrj 4 for i == N -1210 , N - , ..., , and j 12 , , ..., 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:
Mf121ii=+ Mf+ b where fbii and are (M −1 ) dimensional vectors T fii,i,i,i,M= ⎣⎦⎡⎤f,f,f123 ,f− 1 , T b ⎡⎤ff,,0 f f =+⎣⎦αγ10()(i, i+−+ 10 , M 1 i,M + i 1 ,M ) and MM12 and are (M −11)×− (M ) symmetric matrices
⎡⎤100−−βγ11 ⎢⎥−−αβγ10 ⎢⎥222
M1 = ⎢⎥0 3 ⎢⎥α ⎢⎥ − M −2 ⎢⎥ ⎣⎦001 −−MM−−11
αβγ Implementation
and
⎡⎤100+ βγ11 ⎢⎥αβγ10+ ⎢⎥222
M2 = ⎢⎥0 3 ⎢⎥α ⎢⎥ M −2 ⎢⎥ ⎣⎦001 MM−−11+
αβγ
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 Example: Barrier Options
Barrier options are options where the payoff depends on whether the underlying asset’s price reaches a certain level during a certain period of time.
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
We compare Crank-Nicolson Method for a European down-
and-out put, where T = 5/12 yr, S0=$50, K = $50, Sb=$50 σ=40%, r = 10%.
What are the boundary conditions for S?
79 Math6911, S08, HM ZHU Example: Barrier Option
We compare Crank-Nicolson Method for a European down-
and-out put, where T = 5/12 yr, S0=$50, K = $50, Sb=$50 σ=40%, r = 10%.
Boundary conditions are ft,S( max)==00 and ft,S( b )
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
Math6911 S08, HM Zhu 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 1 n p ⎛ p ⎞ x ≡ ⎜ x ⎟ ()p = 2 is the Euclidean norm p ∑ i ⎝ i=1 ⎠ x ≡ max x ∞ i 1≤i≤n
− For example, v = [2 4 -1 3]. v = ?, v = ?, v = ? 82 1 ∞ 2 Math6911, S08, HM ZHU Matrix Norms - Similarly, a matrix norm is a function mapping A ∈ℜm×n 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 ∈ℜm×n - Various commonly used matrix norms 1 m n 2 Ax ⎛ 2 ⎞ A ≡sup p A ≡ ⎜ a ⎟ p F ⎜∑∑ ij ⎟ x≠0 x p ⎝ i==11j ⎠ m n A ≡ max a A ≡ max a 1 ∑ ij ∞ ∑ ij 1ρ≤ j≤n i=1 1≤i≤m j=1 Aρ ≡ ()AT A , the spectral norm, where 2 λ ()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 = ? A = ? 1 F
84 Math6911, S08, HM ZHU Basic Properties of Norms
Let A, B ∈ℜn×n and x,y ∈ℜn . Then 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 ℜℜnmn × are equivalent. That is, if • and • are norms ( ) αβ nn on ℜ∃>,c,c then 12 0 such that for all x ∈ℜ , we have
cc12 xxx ≤≤
Condition Number of A Matrix:,C.≡∈ℜ A A−×1 where Ann 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
- vectors xk converges to x ⇔ x k − x converges to 0
- matrix A k → 0 ⇔ A k − 0 → 0
87 Math6911, S08, HM ZHU Appendix B.
Basic Row Operations
Math6911 S08, HM Zhu Basic row operations = *
Three kinds of basic row operations: 1) Interchange the order of two rows or (equations)
⎡010 ⎤⎡ a11 a12 a13 ⎤ ⎡a 21 a22 a23⎤ ⎢ ⎥⎢ ⎥ ⎢ ⎥ 100a a a = a a a ⎢ ⎥⎢ 21 22 23⎥ ⎢ 11 12 13 ⎥
⎣⎢001 ⎦⎥⎣⎢ a 31 a32 a33⎦⎥ ⎣⎢a 31 a32 a33⎦⎥
89 Math6911, S08, HM ZHU Basic row operations = *
2) Multiply a row by a nonzero constant
⎡c 00⎤⎡ a11 a12 a13 ⎤ ⎡ca 11 ca12 ca13⎤ ⎢ ⎥⎢ ⎥ ⎢ ⎥ 010a a a = a a a ⎢ ⎥⎢ 21 22 23⎥ ⎢ 21 22 23 ⎥
⎣⎢001 ⎦⎥⎣⎢ a 31 a32 a33⎦⎥ ⎣⎢ a31 a32 a33 ⎦⎥
3) Add or subtract rows
⎡ 100⎤⎡ a11 a12 a13⎤ ⎡ a11 a12 a13 ⎤ ⎢ ⎥⎢ ⎥ ⎢ ⎥ −110a a a = a − a a −a a −a ⎢ ⎥⎢ 21 22 23⎥ ⎢ 21 11 22 12 23 13⎥
⎣⎢ 001⎦⎥⎣⎢ a 31 a32 a33⎦⎥ ⎣⎢ a31 a32 a33 ⎦⎥ 90 Math6911, S08, HM ZHU