Sei sulla pagina 1di 22

The implicit finite-difference method in matrix terms

André Ran
Vrije Universiteit Amsterdam

1
The implicit finite difference method

The implicit finite


difference method
Last week we did the explicit finite difference method, based on forward
Solution difference in time.
Errors
Stability This week we consider so-called implicit finite difference methods, based
Conclusion on a backward difference in time.
Solution methods
LU-method
Examples

2
The implicit finite
difference method
The discretization of the heat equation becomes
Solution
m+1 m+1 + um+1
Errors
um+1
n − u m
n un+1 − 2u n n−1
Stability =
Conclusion δτ (δx)2
Solution methods
LU-method
Examples for m = 0, 1, · · · , with the initial conditions u0n = u(nδx, 0), and with
boundary conditions as before at (−N − δx, mδτ ) and at (N + δx, mδτ ).
δτ
Put α = (δx) 2.
Rewrite the equation above as

−αum+1
n+1 + (1 + 2α)u m+1
n − αum+1
n−1 = u m
n.

Note that we now need to compute the um n in an implicit manner, we


cannot work our way forward in time as we did before. Thus it is now
necessary to use matrix-vector methods.

3
The implicit finite
difference method
Let us put the equation
Solution
Errors
Stability
−αum+1
n+1 + (1 + 2α)u m+1
n − αum+1
n−1 = u m
n.
Conclusion
Solution methods with its initial and boundary conditions in matrix-vector form.
LU-method
Examples Put
um+1
 
−N − +1
..
um+1 =
 
. 
um+1
N + −1
This vector contains the u-values on the grid that are at time level
(m + 1) · δτ , but not on the boundary.
Put k = N + + N − − 1. Then um+1 ∈ Rk .

4
The implicit finite
difference method
To compute we need to use the boundary points, that is, we need the
Solution vector
um
Errors
 
Stability −N −
Conclusion
 0 
 
Solution methods  .. 
LU-method bm =  . .
Examples  
 0 
um
N+
This should be understood correctly: we want bm and um to be vectors of
the same size k !

5
The implicit finite
difference method
With these notations the equation
Solution
Errors
Stability
−αum+1
n+1 + (1 + 2α)u m+1
n − αum+1
n−1 = u m
n.
Conclusion
Solution methods can be rewritten as
LU-method
Examples
(I + αT )um+1 = um + αbm

where α > 0 and T is the symmetric tridiagonal Toeplitz matrix

2 −1 0 ··· ··· 0
 
.. ..
−1 2 −1 .
 
.

 .. .. .. .. ..
0 . . . . .
 
T = . .

 .. .. .. .. ..
 . . . . 0

 . .. 
 .. . −1 2 −1
0 ··· ··· 0 −1 2 6
Solution

The implicit finite


difference method
(I + αT )um+1 = um + αbm
Solution
Errors
Stability
We can now solve the equation:
Conclusion
Solution methods
LU-method
um+1 = (I + αT )−1 (um + αbm ) .
Examples

Since we know u0 , which is the given initial condition, we can compute

1 −1 0 0

u = (I + αT ) u + αb ,
2 −1 1 1

u = (I + αT ) u + αb =
(I + αT )−2 u0 + α(I + αT )−2 b0 + α(I + αT )−1 b1 ,
..
.
m
X
um+1 = (I + αT )−m−1 u0 + α (I + αT )−j−1 bm−j .
j=0

7
Error propagation

The implicit finite


difference method
Assuming we make no errors in bm , errors we make at time step m, which
Solution are denoted by em propagate as
Errors
Stability
Conclusion em+1 = (I + αT )−1 em .
Solution methods
LU-method
Examples Iterating this: errors we make at time 0 have at time m + 1 the effect

em+1 = (I + αT )−m−1 e0 .

These will decay as m increases when the eigenvalues of (I + αT )−1


are in the interval (−1, 1).

8
Eigenvalues

The implicit finite


difference method
To see this, argue as follows.
Solution
Errors
Stability
Since T = T > , we have that T = V DV −1 , where V is an orthogonal
Conclusion matrix, D is diagonal with real numbers on the diagonal. Then
Solution methods
LU-method
Examples (I + αT )−m−1 = V (I + αD)−m−1 V −1

Now since D is a diagonal matrix, so is I + αD . So, the right hand side


will go to zero as m → ∞ if and only if all eigenvalues of (I + αT )−1 are
in the interval (−1, 1).

We show something stronger.

9
Stability

The implicit finite δτ


difference method Recall α = δx 2 > 0.
Solution
Errors
Stability Theorem For all α > 0 the eigenvalues of (I + αT )−1 are in (0, 1).
Conclusion
Solution methods
LU-method
Examples

10
Stability

The implicit finite δτ


difference method Recall α = δx 2 > 0.
Solution
Errors
Stability Theorem For all α > 0 the eigenvalues of (I + αT )−1 are in (0, 1).
Conclusion
Solution methods
LU-method Proof. Since T is positive definite (i.e., hT x, xi > 0 for all non-zero x)
Examples
and α > 0 all eigenvalues of M = I + αT are in (1, ∞). Indeed,

λ−1
M x = λx ⇔ (M −I)x = (λ−1)x ⇔ αT x = (λ−1)x ⇔ T x = x.
α
Thus λ > 1.

10
Stability

The implicit finite δτ


difference method Recall α = δx 2 > 0.
Solution
Errors
Stability Theorem For all α > 0 the eigenvalues of (I + αT )−1 are in (0, 1).
Conclusion
Solution methods
LU-method Proof. Since T is positive definite (i.e., hT x, xi > 0 for all non-zero x)
Examples
and α > 0 all eigenvalues of M = I + αT are in (1, ∞). Indeed,

λ−1
M x = λx ⇔ (M −I)x = (λ−1)x ⇔ αT x = (λ−1)x ⇔ T x = x.
α
Thus λ > 1.
Furthermore,
1
M x = λx ⇔ M −1 x = x.
λ
So all eigenvalues of (I + αT )−1 are in (0, 1). 2

10
Conclusion

The implicit finite


difference method
This is good news. Remember, for the explicit method we had to keep α
Solution below 21 . Now we have stability of the method for all α > 0.
Errors
Stability So, if we want to improve on the calculations by choosing ten times as
Conclusion many data points in the x-direction (which in financial terms is the variable
Solution methods
LU-method S ), we can do so without having to change δτ as well!
Examples
However, we pay a price: we have to compute an inverse:

(I + αT )−1

or we have to solve the equations

(I + αT )um+1 = um + αbm .

11
Solution Methods

The implicit finite


difference method
Ideas:
Solution
Errors • Direct inversion of I + αT is possible in a fast way (based on the
Stability
Conclusion fact that it is a tri-diagonal positive definite Toeplitz matrix; via the
Solution methods
Gohberg-Semencul formulas or the Levinson algorithm).
LU-method
Examples This will not be discussed.

12
Solution Methods

The implicit finite


difference method
Ideas:
Solution
Errors • Direct inversion of I + αT is possible in a fast way (based on the
Stability
Conclusion fact that it is a tri-diagonal positive definite Toeplitz matrix; via the
Solution methods
Gohberg-Semencul formulas or the Levinson algorithm).
LU-method
Examples This will not be discussed.

• We can use the LU-decomposition of I + αT to solve the


matrix-vector equations.
This will be discussed today.

12
Solution Methods

The implicit finite


difference method
Ideas:
Solution
Errors • Direct inversion of I + αT is possible in a fast way (based on the
Stability
Conclusion fact that it is a tri-diagonal positive definite Toeplitz matrix; via the
Solution methods
Gohberg-Semencul formulas or the Levinson algorithm).
LU-method
Examples This will not be discussed.

• We can use the LU-decomposition of I + αT to solve the


matrix-vector equations.
This will be discussed today.

• We can use iteration methods to solve the equations.


This will be discussed next time.

12
LU-method

The implicit finite


difference method
Idea is to write
Solution I + αT = L · U
Errors
Stability
where L is lower triangular and U is upper triangular.
Conclusion
Solution methods Because of the fact that T is tri-diagonal, L will be bi-diagonal and U as
LU-method
Examples
well.
Write
   
1 0 ··· ··· 0 y1 u1 0 ··· 0
 .. ..   .. .. 
l1 1 . .   0 y2 u2 . . 
  
..  ..
L = 0 ... .. .. , U =  0 ... .. ..
.
  
. . . . . .
  
 ..   .. .. 
. lk−2 1 0  . . yk−1 uk−1 
0 ··· 0 lk−1 1 0 ··· ··· 0 yk

13
The implicit finite
difference method
I + αT = L · U
Solution
Errors
Stability
gives
Conclusion
Solution methods
LU-method
y1 = 1 + 2α, l1 = −α/y1 , u1 = −α,
Examples
l1 u1 + y2 = 1 + 2α ⇒
α2
y2 = 1 + 2α − , l2 = −α/y2 , u2 = −α.
y1
Continue this way: y1 = 1 + 2α and for all j = 1, 2, · · ·

α2 α
yj+1 = 1 + 2α − , lj = − , uj = −α.
yj yj

14
Now (I + αT )um+1 = um + αbm translates to
The implicit finite
difference method
Solution

L · U um+1 = um + αbm .
Errors
Stability
Conclusion
Solution methods
LU-method
First solve Lq m = um + αbm , then solve U um+1 = q m . Denote
Examples    
c1 q1
cm = um + αbm =  ...  , qm =  ...  .
   

ck qk

with k = N − + N + − 1.

15
The implicit finite
difference method
Then Lq m = cm can be solved top-to-bottom:
Solution
α
q1m = cm qjm = cm m m m
Errors
Stability 1 , j − lj qj−1 = c j + qj−1 .
Conclusion
yj−1
Solution methods
LU-method
And from that U um+1 = q m can be solved from the bottom up:
Examples

qkm qjm + αum+1


j−N − +1
um+1
N + −1
= , um+1
j−N −
= .
yk yj

This is easy to implement.

16
Examples

The implicit finite


difference method
In the examples we compute the European put, as before with
Solution T = 0.5, σ = 0.4, r = 0.02, E = 20. Again, the light blue line is the
Errors
Stability exact value. The dark blue line is the approximation using the implicit
Conclusion difference LU-method. In all figures the left hand graph is the graph of the
Solution methods
LU-method put, the right hand graph is the graph of its derivative, the ∆. In all cases
Examples
we compute using an algorithm that solves the heat equation between
x = −2 and x = 1.5.
In the graphs we take δτ = 10−4 , and vary δx. The values for δx are, in
this order δx = 0.05, and δx = 0.01. The corresponding values for α
are, respectively, α = 0.04, and α = 1. We see that the value of the put is
nicely approximated (actually indistinguishable from the exact value), but
the approximation of ∆ is poor for large δx. It improves greatly with
decreasing δx, and we do not now need to worry about keeping δx below
1
2 . In fact, with δx = 0.01 the computed value is indistinguishable from the
theoretical value.

17
The implicit finite 10
prijs Europese put
0
Approximation of Delta

difference method 9 −0.1

Solution 8 −0.2

Errors 7 −0.3

Stability 6 −0.4

5 −0.5
Conclusion
4 −0.6
Solution methods
3 −0.7

LU-method
2 −0.8

Examples 1 −0.9

0 −1
10 15 20 25 30 10 15 20 25 30

prijs Europese put Approximation of Delta


10 0

9 −0.1

8 −0.2

7 −0.3

6 −0.4

5 −0.5

4 −0.6

3 −0.7

2 −0.8

1 −0.9

0 −1
10 15 20 25 30 10 15 20 25 30

Figure 1: δx = 0.05 (above), δx = 0.01 (below), δτ = 10−4


18

Potrebbero piacerti anche