You are on page 1of 90

# 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

1 Finite difference approximations Math6911 S08.Chapter 5 Finite Difference Methods 5. HM Zhu .

S08. S) plane becomes a mesh with mesh points on (i ∆t. denoted as fi . the t-axis into equally spaced nodes a distance ∆t apart • (t. S) on a set of discrete points in (t. HM ZHU . j∆S) • We are interested in the values of f(t. j∆S). and. S) plane • Divide the S-axis into equally spaced nodes at distance ∆S apart. j = f ( i∆t.Finite-difference mesh • Aim to approximate the values of the continuous function f(t. j ∆S ) 5 Math6911. S) at mesh points (i ∆t.

HM ZHU T=N ∆t t 6 . j = f ( i∆t. S08. j ∆S ) Smax=M∆S S ? j ∆S i ∆t Math6911.The mesh for finite-difference approximation fi .

forward or backward partial differential equation Its solution is sufficiently well behaved .t) ∂V 1 2 2 ∂ 2V ∂V + σ S + rS − rV = 0 2 ∂ S ∂t 2 ∂S where 0 < S < +∞ and 0 ≤ t < T with proper final and boundary conditions Notes: This is a second-order hyperbolic.1) .Black-Scholes Equation for a European option with value V(S. well-posed Math6911. HM ZHU (5.i.e. or parabolic. S08. elliptic.

t ) ∂t ∆t ∆t for small ∆t.t ) ∂t ∆t + O ( ∆ t ) ( 2 ) 8 . using Taylor expansion at point ( S . HM ZHU ∂f ( S .t + ∆t ) − f ( S .t ) ∆t → 0 = lim f ( S .t + ∆t ) = f ( S .t ) f ( S . S08.t ) ≈ f ( S .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.t ) + Math6911. ∂f ( S.t + ∆t ) − f ( S .

S ) − f ( t − ∆t.S ) − f ( t − ∆t.Forward-. Backward-.S ) ≈ ∆t f ( t.S ) ∂t ∂f ( t.S ) ≈ ≈ t t + ∆t + O ( ∆t ) + O ( ∆t ) + O ( ∆t ) f ( t + ∆t. and Centraldifference approximation to 1st order derivatives central backward forward t − ∆t Forward: Backward: Central: ∂f ( t.S ) ∂t ∂f ( t.S ) − f ( t.S ) ∂t ∆t f ( t + ∆t.S ) 2∆t ( 2 ) .

S − ∆S ) ( ∆S ) 2 + O ( ∆S ) ( 2 ) Use Taylor's expansions for f ( t.S + ∆S ) and f ( t.S ) : f ( t. S08.S ) ∂S 2 ≈ f ( t.S ) + f ( t.S − ∆S ) around point ( t. HM ZHU .S + ∆S ) − 2 f ( t.S + ∆S ) = ? + f ( t.Symmetric Central-difference approximations to 2nd order derivatives ∂ 2 f ( t.S − ∆S ) = ? 10 Math6911.

j + fi .Finite difference approximations fi +1. j − fi −1. HM ZHU 11 . j +1 − fi . ∂t 2∆t As to the second derivative. we have: fi . ∂t ∆t fi +1. j −1 ∂f ≈ ∂S 2∆S ∂ 2 f ⎛ fi . j − fi . j − fi . j +1 − fi . S08. j − fi −1. j fi . j −1 ∂f ≈ ∂S ∆S fi . j +1 − 2 fi . j − fi . ∂t ∆t fi . j −1 ⎞ ≈⎜ − ⎟ ∆S 2 ∆S ∆S ∂S ⎝ ⎠ fi . j −1 = 2 ∆ S ( ) Math6911. j ∂f Forward Difference: ≈ . j ∂f ≈ ∂S ∆S fi . j ∂f Central Difference: ≈ . j ∂f Backward Difference: ≈ . j +1 − fi .

.. implicit. 12 Math6911...0 = 0 .Finite difference approximations • Depending on which combination of schemes we use in discretizing the equation. For example. Final Condition: f N ...1. 0 ) .M Boundary Conditions: ⎧ ⎪ fi . we will have explicit. or Crank-Nicolson methods • We also need to discretize the boundary and final conditions accordingly.. j = max ( j ∆S − K .. S08. for European Call. for i = 0 . HM ZHU .1.N ⎨ − r ( N − i ) ∆t ⎪ ⎩ fi . for j = 0 .M = S max − Ke where Smax = M ∆S.

Chapter 5 Finite Difference Methods 5.2.1 Explicit Finite-Difference Method Math6911 S08. HM Zhu .

j + 1 + f i . ∂S 2∆S and f i . j −1 ∂f ≈ central difference: . set 2 ∂t ∂S 2 ∂S f i . S08. S = j ∆ S 2 2 ∂S ∆S Math6911. j − f i −1 . j +1 − f i .Explicit Finite Difference Methods ∂ f ∂f 1 2 2∂2f In + rS + σ S = rf . r f = rf i . j ∆ S ). HM ZHU . j ∂ f backward difference: ≈ ∂t ∆t f i . at point (i ∆ t . j −1 − 2 f i . j . j ∂2f ≈ .

we get an explicit schem e: f i −1 .. .Explicit Finite Difference Methods Rewriting the equation. 2 . N . j + c*j f i ..2 ..2) c = * j Math6911. .. j +1 where 1 a = ∆ t σ 2 j 2 − rj 2 2 2 * b j = 1 − ∆t σ j + r * j (5.1.1 .. 0 and j = 1. j = a *j f i .. HM ZHU ( ( 1 ∆ t (σ 2 2 j 2 ) ) + rj ) for i = N . j −1 + b*j f i . S08. . M . 1.

S08. HM ZHU 0 (i-1)∆t i∆t T=N ∆t t .Numerical Computation Dependency S Smax=M∆S (j+1)∆S j∆ S (j-1)∆S x x x x 0 Math6911.

j for 1 ≤ j ≤ M − 1. j . j and so on 17 Math6911. HM ZHU .2) to solve f N −1. S08. We use the boundary condition to determine f N −1.0 and f N -1. Starting with the final values f N .Implementation 1. 2. we apply (5.M . Repeat the process to determine f N − 2 .

∆S=2.8446 EFD Method with Smax=\$100. ∆t=5/4800: \$2. S0=\$50. r = 10%. K = \$50. Black-Scholes Price: \$2. S08.8406 18 Math6911. ∆t=5/1200: \$2.Example We compare explicit finite difference solution for a European put with the exact Black-Scholes formula. σ=30%. where T = 5/12 yr. ∆S=1.8288 EFD Method with Smax=\$100. HM ZHU .

r = 10%.5. HM ZHU . ∆S=1. ∆S=1. ∆t=5/1200: -\$2.8271E22 19 Math6911. S08. K = \$50. σ=30%. Black-Scholes Price: \$2. S0=\$50. ∆S=2. ∆t=5/1200: \$2.Example (Stability) We compare explicit finite difference solution for a European put with the exact Black-Scholes formula. where T = 5/12 yr. ∆t=5/1200: \$3.1414 EFD Method with Smax=\$100.8446 EFD Method with Smax=\$100.8288 EFD Method with Smax=\$100.

2.Chapter 5 Finite Difference Methods 5. HM Zhu .2 Numerical Stability Math6911 S08.

Numerical Accuracy • The problem itself • The discretization scheme used • The numerical algorithm used 21 Math6911. HM ZHU . S08.

HM ZHU . it is ill-posed/ill-conditioned. If hen f x* is near f ( x ) .conditioned . then we call the problem is well . ( ) 22 Math6911.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. S08. Otherwise.

Conditioning Issue • Conditioning issue is related to the problem itself. HM ZHU . S08. 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. not to the specific numerical algorithm.

HM ZHU . 24 Math6911. If C is large.Conditional Issue The concept "near" can be measured by further information about the particular problem: f ( x ) − f x* f ( x) ( ) ≤C δx x ( f ( x ) ≠ 0) where C is called condition number of this problem. the problem is ill-conditioned. S08.

HM ZHU Infinite decimal expansion : x = ± .x1 x2 where x1 ≠ 0. S08.x1 x2 xd 10 e xd 10 e e : an bounded integer . Truncated floating point number : x ≈ fl ( x ) = ± .Floating Point Number & Error Let x be any real number. precision of the floating point system Floating point or roundoff error : fl ( x ) − x 25 Math6911. d : an integer. 0 ≤ xi ≤ 9.

there is an accumulation of these floating point errors. Example : Let x = − 0. HM ZHU . Floating point error : fl ( x ) − x = −0.0003 Error propagatio n : fl ( x ) − x = 0.6667 and fl ( x ) = −0.Error Propagation When additional calculations are done.00040011 2 2 26 Math6911.667 10 0 where d = 3. S08.

Stability concerns about the behavior of fi . S08. That is. 27 Math6911.Numerical Stability or Instability Stability ensures if the error between the numerical soltuion and the exact solution remains bounded as numerical computation progresses. j − f ( i∆t. f x* (the solution of a slightly perturbed problem) is near f * ( x )( the computed solution) . HM ZHU ( ) . j∆S ) as numerical computation progresses for fixed discretization steps ∆t and ∆S.

HM ZHU .Convergence issue Convergence of the numerical algorithm concerns about the behavior of fi . For well-posed linear initial value problem. "Difference Methods for Initial Value Problems" (2nd) 1967) 28 Math6911. j∆S ) as ∆t. j∆S ) . Richtmyer and Morton. S08. j − f ( i∆t. Stability ⇔ Convergence (Lax's equivalence theorem. ∆S → 0 for fixed values ( i∆t.

S08. HM ZHU . 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.Numerical Accuracy • These factors contribute the accuracy of a numerical solution.

HM Zhu .3 Financial Interpretation of Numerical Instability Math6911 S08.Chapter 5 Finite Difference Methods 5.2.

j ) as they are at ( i..1 . j j i +1 .. j −1 j i +1 . we obtain equations of the form : ˆ f ˆ f ˆ f f =a +b +c (5. M .. 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 ˆ bj = π0 1 − σ j ∆t = 1 + r ∆t 1 + r ∆t 1 1 ⎛1 1 ⎞ 2 2 ˆj = πu c ⎜ ∆ tσ j + ∆ t r j ⎟ = 2 1 + r ∆t ⎝ 2 ⎠ 1 + r ∆t for i = N . N . .j j i +1 . 1. S08. HM ZHU ˆ j= a ( ) . 0 and j = 1.3) i. 2 .. j ). . Math6911..2 . page 423-4) If ∂ f ∂ S and ∂ 2 f ∂ S 2 are assum ed to be the sam e at ( i + 1..Financial Interpretation of instability (Hall.1.

S08. j πd ƒi +1. j +1 ƒi +1. instability occurs.Explicit Finite Difference Methods πu π0 ƒi +1. If one of these probability < 0. j ƒi . HM ZHU . Math6911. j –1 These coefficients can be interpreted as probabilities times a discount factor.

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 [ ∆ ] = −∆S π d + 0π 0 + ∆S π u = rj∆S ∆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

which is coherent with geometric Brownian motion in a risk-neutral world

Math6911, S08, HM ZHU

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

⎛ σ 2 ⎞ fi +1, j +1 − f i +1, j −1 σ 2 f i +1, j +1 − 2 fi +1, j −1 + fi +1, j +1 +⎜r − + = rfi , j ⎟ 2 2 ⎠ 2 ∆Z 2 ∆Z ⎝ (5.4)
34

Math6911, S08, HM ZHU

Change of Variable

where
2 2 ⎡ ⎛ ⎞ 1 σ t σ ∆ ∆t ⎤ * αj = + ⎢− ⎜ r − ⎥ ⎟ 1 + r ∆t ⎣ ⎝ 2 ⎠ 2∆Z 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 ⎦

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 τ 4 S = Ee x , t = T − 2τ σ 2 , V (S , t ) = E e 2 u ( x, τ )
⎛1 2⎞ k =r ⎜ σ ⎟ ⎝2 ⎠ Equation (5.1) becomes heat equation (5.5):

∂ u ∂ 2u = ∂ τ ∂ x2
Math6911, S08, HM ZHU

(5.5)
36

for − ∞ < x < +∞ and τ > 0

Explicit Finite Difference Method
m With u n = u (n δx,m δ τ ), this involves solving a system of

finite difference equations of the form :
m +1 m m m m 2 un un u u − un − + 2 +1 n n −1 + O (δτ ) = + O (δx ) 2 δτ (δx )

(

)

Ignoring terms of O (δτ ) and O (δx ) , we can approximat e
2

(

)

this by
m +1 m m m ( ) 1 2 un u u α α = α un + − + +1 n n −1

⎛ 1 2 T σ ⎜ δτ − + 2 ⎜ where α = , for and 0 1 -N n N m , ,...M ≤ ≤ = = δτ (δx )2 ⎜ ⎜ ⎝ Math6911, S08, HM ZHU

⎞ ⎟ ⎟ ⎟ ⎟ ⎠

δ x → 0) Rate of Convergence is O (δτ ) Math6911. ii) Unstable if α > i) Stable if 0 < α = 2 2 (δ x ) 2 Convergence: 1 If 0 < α ≤ .5) is δτ 1 1 ≤ . mδτ ) as δτ . S08. et al. Wilmott. Option Pricing) Stability: The solution of Eqn (5.δ x → 0 m (in the sense that un → u ( nδ x. HM ZHU 38 . then the explicit finite-difference approximation 2 converges to the exact solution as δτ .Stability and Convergence (P.

3.Chapter 5 Finite Difference Methods 5.1 Implicit Finite-Difference Method Math6911 S08. HM Zhu .

≈ ∂ S 2∆S and f i . we use 2 ∂t ∂S 2 ∂S f i +1. j −1 ∂ f central difference: . j −1 − 2 f i . j + 1 + f i . HM ZHU . rf = rf i . j 2 2 ∂ S ∆S Math6911.j ∂ f ≈ forw ard difference: ∂t ∆t f i . S08. j ∂ 2f ≈ .j − f i . j + 1 − f i .Implicit Finite Difference Methods ∂ f ∂f 1 2 2∂2f In + rS + σ S = r f .

.. HM ZHU (5.j +1 = f i +1.. 0 and j = 1.6) ( ( 1 = − ∆ t (σ 2 2 j 2 ) ) + rj ) for i = N .j −1 + b j f i. N . 2 .. . .1 .1.. M ..Implicit Finite Difference Methods Rewriting the equation.2 . 1.j + c j f i. S08.. j where 1 a j = ∆ t −σ 2 j 2 + rj 2 2 2 b j = 1 + ∆t σ j + r cj Math6911. we get an implicit scheme: a j f i.

Numerical Computation Dependency S Smax=M∆S (j+1)∆S j∆ S (j-1)∆S x x x x 0 Math6911. HM ZHU 0 (i-1)∆t i∆t (i+1)∆t T=N ∆t t . S08.

M −1 ⎤ ⎦ . fi .2 .0 .Implementation Equation (5.7 ) T where fi and bi are (M − 1) dimensional vectors fi = ⎡ ⎣ fi . fi . and C is (M − 1) × (M − 1) symmetric matrices ⎡ b1 ⎢a ⎢ 2 C=⎢0 ⎢ ⎢ ⎢ ⎣0 c1 b2 a3 0 c2 b3 0 aM −1 0 ⎤ 0 ⎥ ⎥ ⎥ ⎥ cM − 2 ⎥ bM −1 ⎥ ⎦ .0 .3 . fi .M ⎤ ⎦ T . −cM −1 fi .6) can be rewritten in matrix form: Cfi = fi +1 + bi ( 5. 0 .1 . 0 .b i = ⎡ ⎣ − a1 fi .

HM ZHU . j and so on 44 Math6911. we need to solve a linear system (5. 2.7) to obtain f N −1. Repeat the process to determine f N − 2 . j for 1 ≤ j ≤ M − 1 using LU factorization or iterative methods.Implementation 1. Starting with the final values f N . j . We use the boundary condition to determine f N −1.0 and f N -1. S08.M .

∆t=5/4800: \$2. S0=\$50. S08. where T = 5/12 yr. Black-Scholes Price: \$2. ∆S=2.8383 45 Math6911. r = 10%. HM ZHU .8194 IFD Method with Smax=\$100. σ=30%. ∆S=1.8446 IFD Method with Smax=\$100. K = \$50.Example We compare implicit finite difference solution for a European put with the exact Black-Scholes formula. ∆t=5/1200: \$2.

Example (Stability) We compare implicit finite difference solution for a European put with the exact Black-Scholes formula. S0=\$50.8846 IFD Method with Smax=\$100. ∆S=1.8288 IFD Method with Smax=\$100. HM ZHU . K = \$50. ∆S=1. ∆t=5/1200: \$2. r = 10%. S08. Black-Scholes Price: \$2.5. ∆S=2. ∆t=5/1200: \$3.8348 46 Math6911. σ=30%. where T = 5/12 yr.1325 IFD Method with Smax=\$100. ∆t=5/1200: \$2.

j +1 ƒi . j ƒi +1. S08.Implicit vs Explicit Finite Difference Methods ƒi +1. j –1 Explicit Method Math6911. j –1 Implicit Method (always stable) ƒi +1. HM ZHU ƒi . j . j +1 ƒi . j ƒi . j ƒi +1.

HM ZHU . S08.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.

trying to achieve • Truncation error: O((∆t)2 ) • Stability: always Math6911. HM ZHU . S08. average of explicit and implicit FD methods.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.

2 Solving a linear system using direct methods Math6911 S08.3. HM Zhu .Chapter 5 Finite Difference Methods 5.

S08.Solve Ax=b A x=b Various shapes of matrix A Lower triangular Upper triangular General 51 Math6911. HM ZHU .

3.A Triangular Solvers Math6911 S08.2.5. HM Zhu .

S08. HM ZHU 53 .Example: 3 x 3 upper triangular system ⎡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.

i = 1. n j >i ⎜ ⎟ ⎜x ⎟ ⎝ n⎠ ⇒ xn = bn ann ⎛ ⎞ ⎟ aii .Solve an upper triangular system Ax=b (0 0 aii ⎛ x1 ⎞ ⎜ ⎟ ⎜ x2 ⎟ ain )⎜ ⎟ = aii xi + ∑ aij x j = bi . HM ZHU n −1 54 . xi = ⎜ b − a x ∑ i ij j ⎜ ⎟ > j i ⎝ ⎠ Math6911.i = 1. … . S08.

for i = n-1:-1:1 sum = b(i). for j = i+1:n sum = sum . end x(i) = sum/A(i. b) n = length(b). S08. HM ZHU .j)*x(j).A(i.i). x(n) = b(n)/A(n.Implementation Function x = UpperTriSolve(A. end 55 Math6911.n).

3. HM Zhu .B Gauss Elimination Math6911 S08.2.5.

Then Ax = LUx = b ⇓ z Math6911.To solve Ax=b for general form A = * To solve Ax = b : Suppose A = LU. HM ZHU Solve two triangular systems : 1) solve z from Lz = b 2) solve x from Ux = z 57 . S08.

S08. HM ZHU E 21 A .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 0⎥⎢a21 ⎥⎢ 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 ⇓ Math6911.

S08.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. HM ZHU .

S08.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. 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. HM ZHU −1 ⎡ ⎢ ⎢ 1 ⎢ a 21 =⎢ ⎢ a11 ⎢ a 31 ⎢ ⎣ a11 0 1 a 32 a 22 ⎤ ⎥ 0⎥ ⎥ 0⎥ ⎥ ⎥ 1⎥ ⎦ 61 . S08.

A = LLT which is called Cholesky Decomposition 62 Math6911. through Gauss Elimination. HM ZHU .LU Factorization = * Therefore. When A is symmetric. we have E 32 E 31 E 21A = U A = (E 32 E 31 E 21 ) U −1 A = LU It is called LU factorization. S08.

S08. 63 Math6911. i. we can do it to the augmented matrix [A b] associated with the linear system. HM ZHU .e. L−1Ax = L−1b ⇒ Ux = z 2) Solve x from Ux = z This suggests that when doing Gauss elimination.To solve Ax=b for general form A To solve Ax = b becomes 1) Use Gauss elimination to make A upper triangular.

HM ZHU . -1. 0.An exercise % build the matrix A A = [2. b = A * x_true. 0. S08. % lu decomposition of A [l. -1. % solve x from ux = z x = u\z 64 Math6911. -1. -1. 2] ⎡ 2 −1 ⎤⎡ x1 ⎤ ⎡0 ⎤ ⎢− 1 2 − 1⎥⎢ x ⎥ = ⎢0 ⎥ ⎢ ⎥⎢ 2 ⎥ ⎢ ⎥ ⎥ ⎢ ⎢ −1 2 ⎥ x 3 ⎣ ⎦⎢ ⎦ ⎣ ⎦ ⎣4⎥ % build the vector b x_true = [1:3]'. u] = lu(A) % solve z from lz = b where z = ux z = l\b. 2.

HM ZHU .General Gauss Elimination row i row j - a ji aii ∗ row i 65 Math6911. S08.

we need to permute rows of A so that Gauss eliminatio n can be computed or computed stably.9999 ⎦ 1⎦ ⎣10.0001 1⎤ ⎡ 1 =⎢ = LU A=⎢ ⎥ ⎥ ⎢ ⎥ . HM ZHU 0 ⎦ ⎣ ⎣1 ⎡0 A=⎢ ⎣2 66 . For example 1⎤ 3⎥ ⎦ ⎡ 0 1 ⎤ ⎡ 0 1 ⎤ ⎡ 2 3⎤ PA = ⎢ =⎢ ⎥ ⎢ ⎥ ⎥ 1 0 2 3 0 1 ⎣ ⎦⎣ ⎦ ⎣ ⎦ 1 ⎤ 0 ⎤ ⎡ 0.0001 1⎤ ⎡ 1 =⎢ = LU PA = ⎢ ⎥ ⎢ ⎥ ⎥ ⎢ ⎥ 1 1⎦ ⎣ 0. S08.9999 ⎦ Math6911. PA = LU.What if we have zero or very small diagonal elements? Somtimes.000 1 ⎦ ⎣ 0 ⎣ 1 0 ⎤ ⎡1 1 ⎤ ⎡ 0 1 ⎤ ⎡ 0. i.. This is called partial pivoting.e.0001 1 ⎦ ⎣ 0 .0001 ⎡ 0.

then A ∈ Rnxn has an LU factorization. Proof: See Golub and Loan.Can we always have A = LU? No! If det ( A (1:k. 3rd edition 67 Math6911.. HM ZHU . S08.n-1. Matrix Computation...1:k ) ) ≠ 0 for k =1..

4.Chapter 5 Finite Difference Methods 5.1 Crank-Nicolson Method Math6911 S08. HM Zhu .

j − σ j ( ∆S ) ∆ S2 2 f i +1 . j ∆t − rj ∆ S + O ( ∆t ) = 2∆S 1 2 2 2 f i + 1 . j + 1 + f i + 1 . j +1 − f i +1 . j + O Math6911. j − f i . HM ZHU (( ∆S ) ) 2 . j −1 + rf i +1 . S08.Explicit Finite Difference Methods ∂ f ∂f 1 2 2∂2f + rS + σ S = rf . W ith 2 ∂t ∂S 2 ∂S we can obtain an explicite form : f i +1 . j −1 − 2 f i + 1 .

j −1 + rf i . W ith 2 ∂t ∂S 2 ∂S we can obtain an im plicit form : f i +1 . j + O Math6911. HM ZHU (( ∆S ) ) 2 . j − σ j ( ∆S ) ∆ S2 2 f i . j −1 − 2 f i .Implicit Finite Difference Methods ∂ f ∂f 1 2 2∂2f + rS + σ S = r f. j +1 − f i . S08. j ∆t − rj ∆ S + O ( ∆t ) = 2∆S 1 2 2 2 f i . j + 1 + f i . j − f i .

j +1 − fi+1. j −1 ⎞ − + ⎜ ⎟ 2 ⎝ 2∆S 2∆S ⎠ fi. j −1 fi. p485) fi+1. j +1 − fi. j ∆t rj∆S ⎛ fi+1. j +1 + fi. j ) + O ( ∆S ) 2 Math6911. j − fi. HM ZHU + O ( ∆t ) = 2 ( ) ( ) . j − σ j ( ∆S ) ⎜ + ⎟ 2 2 ∆S ∆S 4 ⎝ ⎠ r 2 + ( fi+1. j ⎞ 1 2 2 2 ⎛ fi +1. j + fi. S08. j −1 − 2 fi +1.Crank-Nicolson Methods: average of explicit and implicit methods (Brandmarte. j +1 + fi +1. j −1 − 2 fi.

S08. j −1 w h e re ( )f + (1 + β ) f j j i... α j= ( ) ( ) ( ) Math6911.2 . 2 .5 ) i +1 . j +1 (5 . j −1 + 1 − β α j f i + 1 . . 0 a n d j = 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 ..j − γ j f i . 1 .. . M ..1 . N . HM ZHU . j +1 = + γ j f i +1 . 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 .Crank-Nicolson Methods R e w ritin g th e e q u a tio n .

Numerical Computation Dependency S Smax=M∆S (j+1)∆S j∆ S (j-1)∆S x x x x x x 0 Math6911. S08. HM ZHU 0 (i-1)∆t i∆t (i+1)∆t T=N ∆t t .

1 .Implementation Equation (5.3 .M + f i +1. fi .0 ) .M −1 ⎤ ⎦ . fi . fi .2 .γ M −1 ( fi .5) can be rewritten in matrix form: M1fi = M 2fi +1 + b where fi and bi are (M − 1) dimensional vectors fi = ⎡ ⎣ fi .M ) ⎤ ⎦ 0 ⎤ ⎥ ⎥ ⎥ ⎥ −γ M − 2 ⎥ 1 − β M −1 ⎥ ⎦ 0 0 T T b=⎡ ⎣α1 ( fi . . 0 ⎡1 − β1 −γ 1 ⎢ −α − β 1 2 2 ⎢ M1 = ⎢ 0 α3 ⎢ ⎢ ⎢ ⎣ 0 and M1 and M 2 are (M − 1) × (M − 1) symmetric matrices γ2 0 −α M −1 .0 + fi +1.

S08.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. HM ZHU .

8395 76 Math6911.8446 CN Method with Smax=\$100.Example We compare Crank-Nicolson Methods for a European put with the exact Black-Scholes formula. ∆t=5/1200: \$2. where T = 5/12 yr. S0=\$50. S08. ∆S=1. Black-Scholes Price: \$2. HM ZHU . r = 10%. ∆t=5/4800: \$2. σ=30%. K = \$50. ∆S=2.8241 CN Method with Smax=\$100.

S0=\$50. ∆S=1. K = \$50.8446 CN Method with Smax=\$100.1370 CN Method with Smax=\$100.8395 77 Math6911. r = 10%. ∆t=5/1200: \$3.Example (Stability) We compare Crank-Nicolson Method for a European put with the exact Black-Scholes formula. Black-Scholes Price: \$2. ∆S=1. HM ZHU . S08.5. σ=30%. ∆t=5/1200: \$2. where T = 5/12 yr.

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. HM ZHU . 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.

K = \$50. Sb=\$50 σ=40%. S08. where T = 5/12 yr. r = 10%. S0=\$50.Example: Barrier Option We compare Crank-Nicolson Method for a European downand-out put. HM ZHU . What are the boundary conditions for S? 79 Math6911.

∆t=1/1200: \$0. HM ZHU .Sb ) = 0 Exact Price (Hall. r = 10%. where T = 5/12 yr. Boundary conditions are f ( t.S max ) = 0 and f ( t. S08. p533-535): \$0. Sb=\$50 σ=40%.5414 80 Math6911. S0=\$50. ∆S=0.5424 CN Method with Smax=\$100. K = \$50.5.Example: Barrier Option We compare Crank-Nicolson Method for a European downand-out put.

HM Zhu .Appendix A. Matrix Norms Math6911 S08.

S08. x = 0 iff x = 0 • c x = c x for any c ∈ ℜ • x + y ≤ x + y for any x.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.Vector Norms . • x > 0 for any x ≠ 0. y ∈ ℜ n .1 3]. HM ZHU − For example. v 1 = ?. v ∞ 82 . v = [2 4 . v 2 = ? Math6911.t.There are various ways to define a norm x x p ∞ ⎛ p⎞ ≡ ⎜ ∑ xi ⎟ ⎠ ⎝ i =1 ≡ max xi n 1≤ i ≤ n 1 p (p = 2 is the Euclidean norm ) = ?.

• A > 0 for any A ≠ 0.Similarly. A = 0 iff A = 0 • c A = c A for any c ∈ ℜ • A + B ≤ A + B for any A.Various commonly used matrix norms A p ≡ sup x≠0 Ax x m p p A A F ⎛ ≡⎜ ⎜ ∑∑ aij ⎝ i =1 j =1 m n 2 ⎞ ⎟ ⎟ ⎠ 1 2 A 1 ≡ max 1≤ j ≤ n i =1 ∑a ij ∞ ≡ max 1≤ i ≤ m ∑a j =1 n ij A 2 ≡ ρ A T A . a matrix norm is a function mapping A ∈ ℜ m×n to a real number A s. where ρ (B ) ≡ max{λk : λk is an eigenvalue of B} ( ) . the spectral norm.t.Matrix Norms . B ∈ ℜ m×n .

HM ZHU =? 84 .An Example ⎡ 2 4 − 1⎤ ⎢ ⎥ A=⎢ 3 1 5⎥ ⎢ ⎣− 2 3 − 1⎥ ⎦ A =? A 2 =? A F ∞ A1 =? Math6911. S08.

x + y ≤ x + y 3. B ∈ ℜ n×n and x. AB ≤ A B 85 Math6911. S08. HM ZHU . Ax ≤ A x 5. y ∈ ℜ .Basic Properties of Norms Let A. x ≥ 0. α x = α x where α is a real number 4. Then n 1. and x = 0 ⇔ x = 0 2.

HM ZHU . the harder it is to solve Ax = b. then ∃ c1 . S08.Condition number of a square matrix All norms in ℜn ℜm×n are equivalent. where A ∈ℜn×n .c2 > 0 such that for all x ∈ℜn . The bigger the C. we have c1 x α ≤ x β ( ) ≤ c2 x α Condition Number of A Matrix: C ≡ A A−1 . 86 Math6911. The condition number gives a measure of how close a matrix is close to singular. if • α and • β are norms on ℜn . That is.

S08. HM ZHU .matrix A k → 0 ⇔ A k − 0 → 0 87 Math6911.Convergence .vectors x k converges to x ⇔ x k − x converges to 0 .

Basic Row Operations Math6911 S08. HM Zhu .Appendix B.

Basic row operations = * Three kinds of basic row operations: 1) Interchange the order of two rows or (equations) ⎡0 1 0⎤⎡a11 ⎢ ⎥⎢ ⎢1 0 0⎥⎢a21 ⎢ ⎣0 0 1⎥ ⎦⎢ ⎣a31 a12 a22 a32 a13 ⎤ ⎡a21 a22 ⎥ ⎢ a23 ⎥ = ⎢a11 a12 a33 ⎥ ⎦ ⎢ ⎣a31 a32 a23 ⎤ ⎥ a13 ⎥ a33 ⎥ ⎦ 89 Math6911. HM ZHU . S08.

S08. HM ZHU a13 ⎤ ⎥ a23 − a13 ⎥ a33 ⎥ ⎦ 90 .Basic row operations = * 2) Multiply a row by a nonzero constant ⎡c 0 0⎤⎡a11 a12 ⎢ ⎥⎢ ⎢0 1 0⎥⎢a21 a22 ⎢ ⎣0 0 1⎥ ⎦⎢ ⎣a31 a32 a13 ⎤ ⎡ca11 ca12 ⎥ ⎢ a23 ⎥ = ⎢ a21 a22 a33 ⎥ ⎦ ⎢ ⎣ a31 a32 ca13 ⎤ ⎥ a23 ⎥ a33 ⎥ ⎦ 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.