Master
Master
Master
Brynjulf Owren1
1
Translated and amended by E. Celledoni
Preface
The preparation of this note started in the winter of 2004. The note is a teaching aid for
the first half of the course TMA4210 "Numerical solution of partial differential equations
with difference methods". In the winter of 2006 the note was updated and several new
sections were added to adapt it to the course TMA4212. I want to thank all the students
who followed the courses during these semesters. They have been a source of inspiration
for the writing and they helped me in the correction of many typos and mistakes in the
earlier versions of this note.
i
ii
Contents
1 Introduction 1
2 Background material 3
2.1 Background on matrix theory . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 Jordan form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2 Symmetric matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.3 Positive definite matrices . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.4 Gershgorin’s theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.5 Vector and matrix norms . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.6 Consistent and subordinate matrix norms . . . . . . . . . . . . . . . 6
2.1.7 Matrix norms and spectral radius. . . . . . . . . . . . . . . . . . . . 7
2.2 Difference formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.1 Taylor expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.2 Big O-notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.3 Difference approximations to the derivatives . . . . . . . . . . . . . . 10
2.2.4 Difference operators and other operators . . . . . . . . . . . . . . . 11
2.2.5 Differential operator. . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
iii
iv CONTENTS
7 Hyperbolic equations 81
7.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
7.2 Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
7.3 Explicit difference formulae for ut + aux = 0 . . . . . . . . . . . . . . . . . . 84
7.4 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.5 Implicit methods for ut + aux = 0 . . . . . . . . . . . . . . . . . . . . . . . . 88
7.6 Hyperbolic systems of first order equations . . . . . . . . . . . . . . . . . . . 90
7.7 Dissipation and dispersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Chapter 1
Introduction
1
2 CHAPTER 1. INTRODUCTION
and consistency will be also introduced as important tools for showing convergence of a
numerical scheme.
In chapter 5 we discuss elliptic equations and typical examples in this case are the
Laplace’s equation and the Poisson’s equation. We work with 2-dimensional domains,
where both the independent variables are space variables. In this case it is interesting to
look at more complex geometries compared to the parabolic case, and the domain is not
necessarily rectangular like in chapter 3. As a consequence most of the discussion is about
how to approximate different boundary conditions for domains which are not rectangular.
The first chapter of this note reviews some background material on matrix theory and
Taylor expansion, in this chapter we will also set the notation on differential operators.
Chapter 2
Background material
Λ = diag(λ1 , . . . , λn ).
3
4 CHAPTER 2. BACKGROUND MATERIAL
X −1 = X T .
Example.
1+i 1 0
A = 0.5 3 1 .
1 1 5
2.1. BACKGROUND ON MATRIX THEORY 5
Im z
0
−1
−2
−3
0 1 2 3 4 5 6 7
Re z ,
Proof of Gershgorin’s theorem: Let λ be a eigenvalue with associate eigenvector x =
[ξ1 , . . . , ξn ]T 6= 0. Choose ` among the indexes 1, . . . , n such that |ξ` | ≥ |ξk |, k = 1, . . . , n,
and so |ξ` | > 0. The equation Ax = λx has component `:
n
X X
a`k ξk = λ ξ` ⇒ (λ − a`` )ξ` = a`k ξk
k=1 k6=`
X ξk X |ξk | X
|λ − a`` | = a`k ≤ |a`k | ≤ |a`k |
ξ` |ξ` |
k6=` k6=` k6=`
Then we get λ ∈ S` .
Example. Diagonally dominant matrices with positive diagonal elements are positive
definite. Why?
3. kx + yk ≤ kxk + kyk
Examples. x = (ξk ), X = Rn .
n n
!1/2
X X
2
kxk1 = |ξk |, kxk2 = |ξk | , kxk∞ = max |ξk |.
1≤k≤n
k=1 k=1
6 CHAPTER 2. BACKGROUND MATERIAL
The matrix spaces Rn×n and Cn×n are also vector spaces over R (C). We say that k · k
is a matrix norm if for all A, B ∈ Rn×n (Cn×n )
1. kAk > 0 for all A, kAk = 0 ⇔ A = 0,
3. kA + Bk ≤ kAk + kBk,
4. kA · Bk ≤ kAk · kBk.
Remark. The last point requires that a matrix-matrix product is defined (this operation is
not defined in a general vector space). In abstract terms the axioms 1–4 give an example
of Banach-algebra.
1. Let k · k1 be the matrix norm subordinate to the vector norm k · k1 . One can show
that A ∈ Rn×n (Cn×n ) is
Xn
kAk1 = max |aik |.
1≤k≤n
i=1
In other words we can say that kAk1 is the “maximal column-sum in A”.
2. To find the matrix norm subordinate to the vector norm k · k2 we must define the
spectral radius of a matrix M ∈ Rn×n (Cn×n ). If λ1 , . . . , λn are the eigenvalues of
M , we denote the spectral radius of M by ρ(M ), and it is defined as
If we plot the eigenvalues of M in the complex plane, the spectral radius is the
minimal radius of a circle centered in the origin and containing all eigenvalues of M .
We define now the 2-norm of a matrix A as
q
kAk2 = ρ(AT A).
2.1. BACKGROUND ON MATRIX THEORY 7
Note that AT A is positive (semi)definite, so all the eigenvalues are real and positive.
Taking the square root of the biggest eigenvalue, we obtain kAk2 . Note also that
the spectral radius of A can be very different from (the square root of ) the spectral
radius of AT A. On the other hand if A is symmetric then kAk2 = ρ(A).
That is kAk∞ is the “maximal row-sum in A”. Observe also that kAk1 = kAT k∞ .
Ax = λx.
such that
kA(xy T )k ≤ kAk kxy T k.
As a consequence
Therefore |λ| ≤ kAk, and since this is true for every eigenvalue of A, it must be ρ(A) ≤ kAk.
Question to the reader: What is wrong with the following line of reasoning
Ak → 0 when k → ∞.
Proof.
Necessary and sufficient criterion. A is convergent if and only if the spectral radius
ρ(A), defined by (2.2), satisfies ρ(A) < 1.
8 CHAPTER 2. BACKGROUND MATERIAL
Proof: We use Jordan form, and let A = M JM −1 where M ∈ Cn×n and J is like in
(2.1). Then we have A2 = M JM −1 M JM −1 = M J 2 M −1 , and by induction we get
Ak = M J k M −1 . Now Ak → 0 if and only if J k → 0. And J k → 0 if and only if
every Jordan block Jik → 0. Assume such a Jordan block has diagonal element λ and the
mi × mi -matrix F has its (j, j + 1) elements, for j = 1, . . . , mi − 1, equal to 1, and the other
elements equal to zero. Then Ji = λI + F where I is the identity matrix. The matrix F
is nihilpotent, i.e. F m = 0, m ≥ n. We assume that k ≥ n − 1 and compute
k n−1
X k n−1
X k X (m)
Jik k
= (λI + F ) = λ k−m m
F = λk−m F m = ϕk (λ)F m
m m
m=0 m=0 m=0
(m)
where ϕk (λ) = λk /k!. When k → ∞ then ϕk (λ) → 0 for 0 ≤ m ≤ n − 1 if and only if
|λ| < 1. This must be true for all Jordan blocks (i.e. eigenvalues of A) and this concludes
the proof.
where
hn+1
rn = u(n+1) (x + θh), 0 < θ < 1.
(n + 1)!
2 free variables. Assume now that u ∈ C n+1 (Ω) where Ω ⊂ R2 . It is convenient to use
a operatornotation for the partial derivatives. We write h = [h, k], and let
∂ ∂ ∂u ∂u
h · ∇ := h +k i.e. h · ∇u = h +k
∂x ∂y ∂x ∂y
The operator produces the derivative of a function in the direction h = [h, k], and we find
the directional derivative.
We can also define powers of the operator by for example
∂ 2 ∂2 ∂2 ∂2
∂
(h · ∇)2 = h +k = h2 2 + 2hk + k2 2
∂x ∂y ∂x ∂x∂y ∂y
where
∂ n+1
1 ∂
rn = h +k u(x + θh, y + θk), 0 < θ < 1.
(n + 1)! ∂x ∂y
We have here assumed that the line segment between (x, y) and (x + h, y + k) is included
in Ω.
The typical use of the big O-notation is in connection with the local truncation error
in numerical methods. For example in the Taylor expansion in one variable
hn+1 M
|rn | = u(n+1) (x + θh) ≤ |h|n+1 , M = max |u(n+1) (y)|
(n + 1)! (n + 1)! y∈I
where we know that the maximum exists if I is a closed, and bounded interval. So in this
case we have rn = O(hn+1 ).
Note that with the definition above for positive integers p we have
φ(h) = O(hp+1 ) ⇒ φ(h) = O(hp ).
Therefore sometimes when we write φ(h) = O(hp ) we mean that p is the biggest possible
integer such that this is true. Often it is convenient to write O(hp ) in formulae with sums,
like for example in the Taylor expansion of u above we replace rn with O(hn+1 ) such that
n
X hk
u(x + h) = u(m) (x) + O(hn+1 ).
k!
k=0
xn−1 xn xn+1
Assume that u(x) is a given function, u ∈ C q (I), for a q which we will specify later. Let
un := u(xn ), u(m)
n := u(m) (xn ).
Assume the grid points xn are equidistant, i.e. xn+1 = xn + h for all n, where h ∈ R is
(m)
called step-size. We want to approximate un with expressions of the type
q
X
a` un+`
`=p
Note that we have q−p+1 = j +1 free parameters ap , . . . , aq we can use, and the conditions
in (2.5) must be satisfied for 0 ≤ k ≤ j, this means a total of j + 1 conditions. The system
of equations has a unique solution for h 6= 0. If we choose a` from (2.5), and assume ν ≥ j,
we obtain the following truncation error
ν q
X hk (k) X
τn = un a` `k + O(hν+1 ).
k!
k=j+1 `=p
un+1 − un
m=1 = u0n + 1 00
2! h un + ···
h
un − un−1
m=1 = u0n − 1 00
2! h un + ···
h
un+1 − 2un + un−1 1 2 (4)
m=2 = u00n + 12 h un + ···
h2
Which order have these formulae?
Exercises
1. Assume m = 1, p = −2, q = 0 use the method of undetermined coefficients to obtain
(1)
an approximation of un of the second order in h.
2. Assume m = 1, p = −2, q = 1 use the method of undetermined coefficients to obtain
(1)
an approximation of un of the third order in h.
3. Consider m = 2, p = 0, q = 1, so that j = q − p = 1 < m. Try to construct an
(2)
approximation formula for un using the method of undetermined coefficients. What
happens?
Powers of the operators. Let F be one of the above defined operators. We can define
powers of F as follows
F 0 = 1, F k u(x) = F (F k−1 u(x)).
Example.
δu(x) = u(x + h2 ) − u(x − h2 ),
Another interesting example is the shift operator. We observe that E k u(x) = u(x+kh).
In this case it is easy to extend the definition to include all possible real powers, simply by
defining E s u(x) = u(x + sh) for all s ∈ R. For example we have E −1 u(x) = u(x − h) and
this is the inverse of E since Eu(x − h) = E −1 u(x + h) = u(x).
1
∆ = hD + (hD)2 + · · ·
2!
We will see that under the extra assumption that u is analytic we can make manipulations
with analytic functions in the way we are used to. The meaning is always that the final
result is expanded with a Taylor expansion and is interpreted as a sum of powers of oper-
ators which are applied to a smooth function. The analyticity requirement can always be
relaxed by considering a Taylor expansion with reminder, and requiring the function to be
differentiable only a finite number of times.
We consider powers of ∆, and we obtain
∞
!k
X (hD) m k
∆k = = hk Dk + hk+1 Dk+1 + · · ·
m! 2!
m=1
or
k k+1 k+1
∆k u(x) = hk Dk u(x) + h D u(x) + · · ·
2!
showing that ∆k /hk is a first order approximation (truncation error O(h)) of the operator
Dk .
Note that for s ∈ R we have
∞
X (sh)k
E s u(x) = u(x + sh) = Dk u(x) = eshD u(x)
k!
k=0
which reflects known computational rules. For central differences we can therefore write
1 1 hD
δ = E 1/2 − E −1/2 = e 2 hD − e− 2 hD = 2 sinh .
2
1
By analytic function on an interval we simply mean that its Taylor expansion converges in a neigh-
borhood of any point of the interval.
14 CHAPTER 2. BACKGROUND MATERIAL
that is
k k+2 k+2
δ k u(x) = hk Dk u(x) + h D u(x) + · · ·
24
this shows that δ k /hk is a second order approximation of Dk .
In particular we find as before that
1 4 (4)
δ 2 u(x) = u(x + h) − 2u(x) + u(x − h) = h2 u00 (x) + h u (x) + · · · (2.6)
12
It is tempting to manipulate further with analytic functions. We have seen that
δ hD
= sinh .
2 2
We write therefore formally
2 δ
D= sinh−1 .
h 2
It is possible to expand sinh−1 z in a Taylor expansion
1 3 5 7
sinh−1 z = z − z 3 + z 5 − z + ···
6 40 112
so z = δ/2 and by multiplying by 2/h we obtain
1 1 3 3 5 5 7
D= δ− δ + δ − δ + ··· .
h 24 640 7168
Since we know that δ k = O(hk ) we see that we can find approximations to the differential
operator D of arbitrary high order by including enough terms in the expansion. The
manipulation we have carried out is not rigorously justified here, but it turns out to be
correct. For a detailed discussion on algebraic manipulations with differential operators,
see the textbook by Arieh Iserles, A first course in the numerical analysis of differential
equations, published by Cambridge University Press.
Chapter 3
the exact solution can be obtained by integrating twice on both sides between 0 and 1,
and then imposing the boundary conditions. We want to use this simple test problem to
illustrate some of the basic features of finite difference discretization methods.
To obtain a finite difference discretization for this problem we consider the grid
1
xm = m h, m = 0, . . . , M + 1, h= ,
M +1
and the notation um := u(xm ) such that u0 = α and uM +1 = β. We denote with capital
letters Um ≈ um the numerical approximation to u(x) at the grid point x = xm .
By replacing derivatives with central difference approximations to the left hand side of
(3.1) we obtain the so called discrete problem whose solution is the numerical approxima-
tion that we are seeking, this is
1
(Um−1 − 2Um + Um+1 ) = fm , m = 1, . . . , M. (3.2)
h2
This is a linear system of equations
Ah U = F, (3.3)
f1 − hα2
−2 1
1 −2 1 U1 f2
1
.. .. ..
.
..
Ah := 2 , U := .. , F := .
. . . .
h
1 −2 1 UM fM −1
1 −2 fM − hβ2
15
16 CHAPTER 3. BOUNDARY VALUE PROBLEMS
uM
We will in the sequel associate such vector to a piecewise constant function eh (x) defined
on the interval [0, 1] as follows
R 1 P 1
• keh k2 =
1 2 2
= h M 2 2 = h 12 ke k ;
0 |eh (x)| dx m=1 |e m | h 2
and we see that in these three popular cases the vector norm is related to the function
norm of the corresponding piecewise constant function (with respect to the assumed grid)
simply by a scaling factor. A similar result is true for the case of k · kq .
Truncation error. The truncation error is the vector that by definition has components
τ1
1
τm := 2 (um−1 − 2um + um+1 ) − fm , m = 1, . . . , M, τh := ... .
h
τM
1 2 (4)
By using that u00 (xm ) = 1
δ 2 u(xm ) − + O h4 and u00m = fm , we obtain
h2 12 h um
1 2 (4) 1
τm = u00m + h um + O h4 − fm = h2 u(4) 4
m +O h .
12 12
Equation for the error. The relationship between the error eh and the truncation error
is easily obtained: recall that by definition
τh = Ah u − F,
1
(em−1 − 2em + em+1 ) = −τm , m = 1, . . . , M.
h2
3.1. A SIMPLE CASE EXAMPLE 17
Definition. A method for the boundary value problem (3.1) is said to be consistent with
the boundary value problem with respect to the norm k · k if and only if
kτh k → 0, when h → 0.
Consistence in the vector norm k · k implies that the corresponding piecewise constant
function tends to zero as h tends to zero in the corresponding function norm, this is because
of the relationship between vector and function norms as we have seen for k · k1 , k · k∞ and
k · k2 .
Definition. A method for the boundary value problem (3.1) is said to be convergent in
the (function) norm k · k if and only if
keh k → 0, when h → 0.
Definition. Stability. Assume a difference method for the boundary value problem (3.1)
is given by the discrete equation
Ah U = F,
where h is the step-size of discretization. The method is stable in the norm k · k if there
exist constants C > 0 and H > 0 such that
1. A−1
h exists for all h < H;
The matrix norm in which we should prove stability is the one subordinate to the
chosen function/vector norm in which we want to prove convergence.
Proposition. For the boundary value problem (3.1), stability and consistence with
respect to the norm k · k imply convergence in the same norm.
Proof. We use (3.4) to obtain a bound for the norm of the error. Since we have stability
Ah is invertible for all h < H and therfore
eh = −A−1
h τh .
Then
1
keh kq ≤ h q kA−1 −1
h kq kτh kq = kAh kq kτh kq ≤ Ckτh kq ,
2
λm = (cos(m π h) − 1) , m = 1, . . . , M,
h2
1
kA−1 −1 −1
h k2 = ρ(Ah ) = max |λ | = .
λ∈σ(Ah ) minλ∈σ(Ah ) |λ|
2 4
Using the series expansion cos(x) = 1 − x2 + x4! + O(x6 ), with x = m π h in the expression
for the m-th eigenvalue we get
(m π h)2 (m π h)4
2
λm = 2 − + + O(h ) = −m2 π 2 + O(h2 ),
6
h 2 4!
and
min |λ| = |λ1 | = −π 2 + O(h2 ),
λ∈σ(Ah )
such that
1 1
kA−1
h k2 = → 2, when h → 0,
|λ1 | π
1 h2.5 00
keh k ≤ kf k2 + O(h3.5 ),
π 2 12
and we propose three different discretizations of the left boundary condition which com-
bined with the earlier consider discretization of the second derivative will lead to three
different linear systems. In this case the matrices we obtain are no longer symmetric.
3.1. A SIMPLE CASE EXAMPLE 19
Case 1
We approximate u0 (0) = σ by
U1 − U0
= σ,
h
and combine this discrete equation with (3.2), this leads to the (M + 1) × (M + 1) linear
system
Ah U = F,
where
−h h σ
1 −2 1 U0 f1
1 .. .. ..
..
..
Ah := 2 , U := . , F := .
. . . .
h
1 −2 1 UM fM −1
1 −2 fM − hβ2
Case 2
To obtain order two we introduce a fictitious node external to the domain to the left of x0
which we call x−1 . We approximate u0 (0) = σ by
U1 − U−1
= σ.
2h
1
(U−1 − 2U0 + U1 ) = f0 ,
h2
U1 − U0 f0 h
= +σ
h 2
Ah U = F,
Case 3
In this discretization we want to obtain order 2 without the use of fictitious nodes. We
then consider the approximation of u0 (0) = σ by
3
U0 − 2U1 + 12 U2
−2 = σ,
h
where the left hand side gives a discretization of order two of the first derivative of u at
zero. Proceeding as in case 1, we obtain the (M + 1) × (M + 1) linear system
Ah U = F,
where
− 23 h 2h − h2
σ
U0
1 −2 1
U1
f1
1 .. .. ..
..
Ah := 2 , U := . , F := .
. . . .
h ..
1 −2 1 fM −1
UM
1 −2 fM − hβ2
and we propose a second order discretization of the boundary conditions using two fictitious
nodes external to [0, 1], x−1 and xM +2 . The approximated boundary conditions become
U1 − U−1 UM +2 − UM
= σ0 , = σ1 ,
2h 2h
which we combine respectively with (3.2) for m = 0 and m = M + 1 and obtain the linear
system of equations (M + 2) × (M + 2) linear system
Ah U = F,
where
−h h
σ0 + h2 f0
1 −2 1
.. .. ..
U0 f1
1 . . .
..
..
Ah := 2 , U := , F := .
h . .
1 −2 1
UM +1 fM
1 −2 1
fM +1 h2 − σ1
h −h
But now the matrix Ah is singular, in fact it is easy to verify that v := [1, . . . , 1]T ∈ RM +2
is an eigenvector of Ah with eigenvalue 0. We want to determine the condition of existence
of solutions for this linear system.
3.1. A SIMPLE CASE EXAMPLE 21
Before we do that we consider the solution of (3.6). Integrating on both sides between
0 and 1 we obtain Z 1
u0 (1) − u0 (0) = f (x) dx,
0
that is Z 1
σ1 − σ0 = f (x) dx, (3.7)
0
this is a necessary condition for the existence of solutions of the boundary value problem
(3.6).
We now turn to the analysis of the solutions of the discrete boundary value problem
Ah U = F. Recall that
Range(Ah ) := span{Ah e1 , . . . Ah eM +2 },
∀z ∈ RM +2 , s.t. ATh z = 0, FT z = 0,
and we find that the solution is z = [z0 , hz0 , . . . , hz0 , z0 ]T ∈ RM +2 for any value of z0 ∈ R.
Then
M
T h X h
F z = 0 ⇔ z0 (f0 + σ0 ) + hz0 fm + z0 (fM +1 + σ1 ) = 0,
2 2
m=1
22 CHAPTER 3. BOUNDARY VALUE PROBLEMS
for all z0 and for z0 6= 0 we can divide out by z0 to obtain the condition
M
h X h
σ1 − σ0 = f0 +h fm + fM +1 .
2 2
m=1
We easily recognize that this condition is the discrete analogous of (3.7) and in fact the
right hand side is the composite trapezoidal rule applied to the integral of f (x) on the
discretization grid.
we could differentiate out the left hand side to obtain a problem of the class described
above, i.e
κ(x)u00 (x) + κ0 (x)u0 (x) = f (x)
this is however not the best strategy because, as we have seen, this leads in general to non
symmetric linear systems. Consider now the differential operator L defined as follows
this operator is self-adjoint with respect to the L2 ([a, b]) inner product,
Z b
hf, gi := f (x)g(x) dx, f, g ∈ L2 ([a, b]).
a
h
To achieve this we consider the mid-points of the grid xm− 1 = xm − 2 and xm+ 1 =
2 2
xm + h2 , we then consider the following approximations
um − um−1
κm− 1 u0m− 1 = κm− 1 + O(h2 )
2 2 2 h
and
um+1 − um
κm+ 1 u0m+ 1 = κm+ 1 + O(h2 ).
2 2 2 h
We use these two to produce
1 h i
(κ u0 )0 xm = 2 κm− 1 um−1 − (κm− 1 + κm+ 1 )um + κm+ 1 um+1 + O(h2 ).
h 2 2 2 2
The methods is of second order and the linear system we have to solve is
κ1
−(κ 1 + κ 3 ) κ3
2 2 2
U1
f1 − α h22
κ3 −(κ 3 + κ 5 ) κ 5
..
f2
2 2 2 2
1 .. .. .. .
= ..
.
. . .
.. .
h2
.
κM − 1 fM −1
2
UM κM + 1
κM − 1 −(κM − 1 + κM + 1 ) fM − β h2
2
2 2 2
ΘM
where Gh (Θ) = Ah Θ + sin(Θ), sin(Θ) := [sin(Θ1 ), . . . , sin(ΘM )]T and Ah is the same as
in (3.3).
The numerical solution of this system must be addressed iteratively, for example with
a Newton method:
Θ[k+1] = Θ[k] − Jh (Θ[k] )−1 Gh (Θ[k] ),
where Jh (Θ) is the Jacobian of Gh (Θ), and it is easily seen that Jh (Θ) is a tridiagonal
symmetric matrix such that
1
h2
for j = i − 1 or j = i + 1,
−2
(Jh )i,j (Θ) = h2
+ cos(Θi ) for j = i,
0 otherwise,
24 CHAPTER 3. BOUNDARY VALUE PROBLEMS
so
Jh (Θ) = Ah + C(Θ), C(Θ) := diag(cos(Θ1 ), . . . , cos(ΘM )).
The truncation error is
θ1
→
− →
−
τh := Gh ( θ ), θ := ... , θj := θ(tj ).
θM
It is easily shown by Taylor expansion that the components of τh satisfy
1 2 (4)
τj = h θ (tj ) + O(h4 ), j = 1, . . . , M,
12
this ensures that the method is consistent of order 2. As usual we want to use the connection
→
−
between error Eh := Θ − θ and truncation error τh in order to prove convergence. In
general this connection is a bit less manageable in the case of nonlinear problems, but in
this particular example it is not too complicated.
We combine the discrete equation Gh (Θ) = 0 and the equation for the truncation error
→
−
Gh ( θ ) = τh to obtain
→
−
Gh (Θ) − Gh ( θ ) = −τh . (3.9)
From (3.9), using Gh (Θ) = Ah Θ + sin(Θ) we get
→
−
Ah Eh + sin(Θ) − sin( θ ) = −τh ,
so
(1 − kA−1 −1
h k2 ) kEh k2 ≤ kAh k2 kτh k2 .
We know from earlier analysis that kA−1 1
h k2 = |λ1 | where λ1 is the eigenvalue of Ah with
minimum absolute value. We also obtained the estimate |λ1 | = π 2 + O(h2 ) and so we can
also deduce that kA−1 1 2 −1
h k2 = π 2 + O(h ) and for h small enough kAh k2 < 1 and we get
kA−1
h k2
kEh k2 ≤ kτh k2 .
1 − kA−1
h k2
kA−1
h k2 1
−1 = 2 + O(h2 ).
1 − kAh k2 π −1
3.3. A NONLINEAR EXAMPLE 25
1
kEh k2 ≤ kτh k2 + O(h2 )
π2 − 1
1 2 (4)
and recalling that kτh k2 = + O(h4 ) we get finally
12 h kθ k2
1 1 2 (4)
kEh k2 ≤ 2 h kθ k2 + O(h4 )
π − 1 12
which guarantees convergence when h goes to zero, as it is easy to see that θ(4) is bounded
by differentiating the equation twice.
26 CHAPTER 3. BOUNDARY VALUE PROBLEMS
Chapter 4
The rod in the picture has length L = 1, and let the coordinate x describes a point
along the rod. At time t ≥ 0 the rod has temperature u(x, t) at the point x. We can derive
the differential equation by using Fourier’s law. The flux of heat φ through a cross section
of the rod at x is proportional to the temperature gradient, such that
φ = −λux , λ > 0,
27
28 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
Together with the differential equation we need to provide appropriate boundary conditions
and initial conditions. The kind of boundary and initial conditions necessary and sufficient
to get a unique solution vary from differential equation to differential equation. We will
consider few options for the heat equations.
Pure initial value problem. In this case we assume the rod is infinitely long.
ut = uxx , x ∈ R, t > 0,
u(x, 0) = f (x), x ∈ R.
Initial/Boundary value problem (I/BVP). This case includes the situation of heat
transport in a homogeneous rod of length 1. We must consider an initial function and
boundary conditions at the two ends of the rod.
u(x, 0) = f (x), 0 ≤ x ≤ 1,
u = g0 u = g1
u(0, t) = g0 (t), t > 0,
u=f x
We adopt a step-size h in the x-direction, and one in the t-direction which we denote k.
We assume at first that h = 1/(M + 1) for a given integer M .
We then define gridpoints or nodes (xm , tn ) by
xm = mh, 0 ≤ m ≤ M + 1, tn = nk, n = 0, 1, 2, . . . .
Observe that this means that x0 = 0 and xM +1 = 1 are the boundary points. The solution
in the point (xm , tn ) is denoted unm := u(xm , tn ). And from now on we denote with Um
n
: u known
: u unknown
The Euler’ s method. We adopt a simpler notation for the derivatives and set
∂u ∂ku ∂u
∂x u = ux = , ∂xk u = , ∂t u = ut = .
∂x ∂xk ∂t
We expand un+1
m = u(xm , tn + k) for constant x = xm , around t = tn , and get
1
un+1
m = unm + k∂t unm + ϕnm , ϕnm = k 2 ∂t2 unm + · · · .
2
But we can now use the heat equation ensuring ∂t unm = ∂x2 unm , we then approximate this
second derivative with central differences as in (2.6)
k 2 n
un+1
m = unm + n
δ u − ψm + ϕnm
h2 x m
where the index on δ means that we apply this operator in the x-direction i.e.
n 1
ψm = k h2 ∂x4 unm + · · · .
12
Summarizing we have
k 2 n k
un+1
m = unm + 2
n
δx um + kτm = unm + 2 (unm+1 − 2unm + unm−1 ) + kτm
n
h h
where
n 1 2 2 1
kτm = ϕnm − ψm
n
= k ∂t − k h2 ∂x4 unm + · · ·
2 12
the Euler’s formula is obtained by replacing all the exact u-values (small letters) with
n.
approximate values U (capital letters) in the above formula and discard the term kτm
30 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
Euler’s method
m, n + 1
n+1 n
(4.2) Um = Um + r δx2 Um
n
k
r = h2
m − 1, n m, n m + 1, n
The picture above to the right is called computational molecule, it is a sort of local
chart over the grid, indicating which grid-points are used in the formula. The idea is now
to start at n = 0, corresponding to t0 = 0 where u(x, t0 ) = u(x, 0) = f (x) which is known.
0 = f (x ), m = 0, . . . , M + 1. Then we set n = 1
It is then possible to order the values Um m
and use first the boundary values to get U01 = g0 (k) and UM1
+1 = g1 (k). For the remaining
values we use the formula (4.2) above. It is possible to see that the grid-point at level
tn+1 = t1 in the computational molecule can be computed using known values.
Um0 := f (x ), m = 0, . . . , M + 1
m
for n = 0, 1, 2, . . .
U0n+1 := g0 (tn+1 )
n+1
UM +1 := g1 (tn+1 )
Umn+1 := U n + r δ 2 U n , m = 1, . . . , M
m x m
end
Example.
0.8
ut = uxx 0 < x < 1, t > 0,
0.6
0 ≤ x ≤ 21 ,
u
2 x, 0.4
f (x) =
2 (1 − x), 12 < x ≤ 1,
0.2
g0 (t) = g1 (t) = 0, t > 0.
0
0 0.2 0.4 0.6 0.8 1
x
In the picture above we display the initial function. By running a simulation in Matlab
based on this example, where we let h = 0.1 (M = 9), and k = 0.0045. The reason why we
take k so small compared to h will be explained later on. Figure 4.1 shows the numerical
solution in the grid-points as small rings, at time t = 0, 5, 10 and 20.
4.2. NUMERICAL SOLUTION OF THE INITIAL/BOUNDARY VALUE PROBLEM31
n=0 n=5
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
n=10 n=20
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Figure 4.1: Matlab simulation of the heat equation using the Euler method
Backward Euler. We expand now instead unm around x = xm , t = tn+1 , and obtain
1 2 2 n+1
= un+1 2 n+1
m − k ∂x um + 2 k ∂t um + · · ·
1 2 n+1 1 2 4 n+1
= un+1
m − k ( h2 δx um − 12 h ∂x um + · · · ) + 21 k 2 ∂t2 un+1
m + ···
= un+1 2 n+1 n
m − rδx um + kτm ,
where
n 1 1
kτm = k h2 ∂x4 + k 2 ∂t2 un+1
m + ··· .
12 2
n we obtain
By replacing the u’s med U ’s and discard the term kτm
The Backward Euler method is an implicit method. This means that at each time
n+1 , m = 1, . . . , M . We
step we must solve a system of linear equations to compute Um
32 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
will discuss later on the solution of linear systems. We now will present another implicit
method.
Crank–Nicolsons method. This method is based on the trapezoidal rule, consider the
following expansion of the error for the trapezoidal rule for quadrature
Z k
1 1 3 00 k
f (t) dt = k (f (0) + f (k)) − k f + ··· .
0 2 12 2
To derive the method we use the obvious formula
Z tn+1
u(xm , tn+1 ) − u(xm , tn ) = ut (xm , t) dt,
tn
n+1/2
and approximate the integral with the trapezoidal rule where we use the notation um =
u(xm , tn + 21 k).
1 1 3 3 n+1/2
un+1
m = unm + k (∂t unm + ∂t un+1
m )− k ∂t um + ···
2 12
1 1 3 3 n+1/2
= unm + k (∂x2 unm + ∂x2 un+1
m )− k ∂t um + ···
2 12
n 1 1 2 n 1 2 n+1 1 1 2 4 n 1 2 4 n+1
= um + k δ u + δ u − k h ∂x um + h ∂x um + · · ·
2 h2 x m h2 x m 2 12 12
1 3 3 n+1/2
−k ∂t um + ··· .
12
We simplify and summarize
r
un+1
m = unm + (δx2 unm + δx2 un+1 n
m ) + kτm ,
2
n 1 3 3 n+1/2 1
kτm = − k ∂t um − k h2 ∂x4 un+1/2
m + ··· ,
12 12
where we have used that
1 4 n
(∂ u + ∂x4 un+1 4 n+1/2
m ) = ∂x um + O(k 2 ).
2 x m
Crank–Nicolsons method
m − 1, n + 1 m, n + 1 m + 1, n + 1
(1 − 2r δx2 ) Um
n+1 = (1 + r δ 2 ) U n ,
2 x m
(4.4)
k
r= h2
.
m − 1, n m, n m + 1, n
n+1 1 1 2 n
(E) Um = (1 + r δx2 ) Um
n or n
k ∆t Um = δ U ,
h2 x m
1 1 2 n+1
(BE) (1 − r δx2 ) Um
n+1 n
= Um or n+1
k ∇t Um = δ U
h2 x m
,
n+1/2 n+1/2
(CN) (1 − 2r δx2 ) Um
n+1 = (1 + r δ 2 ) U n
2 x m or 1
k δ t Um = 1
h2
δx2 µt Um .
Note that (E) is explicit while both (BE) and (CN) are implicit.
4.2. NUMERICAL SOLUTION OF THE INITIAL/BOUNDARY VALUE PROBLEM33
The local the truncation error. In the methods presented we have used the symbol
τmn , this is the local truncation error in the point (x , t ). Given a finite difference formula,
m n
to find the corresponding local truncation error one inserts the exact solution evaluated in
the grid points in the finite difference formula. Since the exact solution does not satisfy
the finite difference formula, then an error term appears, this is the local truncation error.
So for example for the forward Euler method applied to the heat equation we have the
finite difference formula
Umn+1 − U n U n − 2Um n + Un
m
= m−1 m+1
,
k h2
replacing Um n with the exact solution in (x , t ), un we get
m n m
un+1 n
m − um un − 2unm + unm+1
= m−1 n
+ τm ,
k h2
so
un+1
m − um
n un − 2unm + unm
n
τm := − m−1 .
k h2
The local truncation error can expressed in powers of the step-sizes h and k and the
derivatives of the exact solution by using the Taylor expansion.
consider Crank–Nicolson first. The right hand side (r.h.s.) of the equations is known, we
set r 2 n r n r n
dn+1
m = 1 + δx Um = Um−1 + (1 − r) Um n
+ Um+1 , 1 ≤ m ≤ M.
2 2 2
For the left hand side (l.h.s.) we get component-wise
r n+1 r n+1 r n+1
1 − δx2 Um = − Um−1 + (1 + r) Umn+1
− Um+1 , 1 ≤ m ≤ M,
2 2 2
where we substitute U0n+1 = g0n+1 = g0 (tn+1 ) and UM n+1 n+1
+1 = g1 = g1 (tn+1 ). We can now
express the equation in matrix-vector form
1 + r − 2r U1n+1 dn+1 + r n+1
g
1 2 0
r r n+1 n+1
−2 1 + r −2 U2 d2
. .
.. .. .. .. ..
. . . = .
r r
n+1 n+1
− 2 1 + r − 2 U M −1
dM −1
n+1
− 2r 1 + r UM dn+1
M + r n+1
g
2 1
1 + 2r −r U1n+1 U1n + r g0n+1
n+1
−r 1 + 2r −r U2 U2n
.. ..
.. .. ..
. . . = .
. .
n+1 n
−r 1 + 2r −r UM −1
UM −1
n+1 n + r g n+1
−r 1 + 2r UM UM 1
34 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
The two matrices in Crank-Nicolson and Backward Euler are examples of tridiagonal
matrices. These special tridiagonal matrices are also called Toeplitz matrices, i.e. the
elements along each of the three diagonals are equal. In Toeplitz matrices we need only to
specify the first row and the first column to determine the whole matrix. If in addition we
know that the matrix is symmetric, it is enough to specify the first row (or column).
In general when we solve differential equations with difference methods we obtain sparse
matrices. PDEs in one space dimension and at most second order derivatives give rise typ-
ically to (at least) tridiagonal matrices. Higher order derivatives imply a larger bandwidth
in the matrix. There is a clear correspondence between the bandwidth of the matrix and
the number of neighboring values Um−p , . . . , Um , Um+1 , . . . , Um+q used to approximate the
highest order derivative of u with respect to x, at the grid point xm (see also the method of
undetermined coefficients form chapter 1). In the case of several space dimensions we obtain
a block structure in the matrices, for example the heat equation in two space dimensions
will typically give a block-tridiagonal matrix. Toeplitz structure is lost when considering
a heat equation where the rod’s material is inhomogeneous (see the chapter 4.1), then the
differential equation becomes
ut = a(x)uxx
where a(x) is a given function.
There are special algorithms which can be used to solve linear systems with tridiagonal
matrices. Among the direct methods a variant of Gaussian elimination called Thomas
algorithm. We are not going to discuss this algorithm in detail here.
Instead we consider some simple examples on how it is possible to use Matlab to
assemble and solve the above equations.
diagonal, the sub-diagonal gets index −1, the super-diagonal gets index 1 and so on. The
second input argument of spdiags is a vector d of integer numbers such that the coulmn j
from the matrix given as the first input argument becomes the diagonal d(j) in the result.
The two last input arguments in the call to the function specify that the result must be a
M × M matrix.
Let us see how a time-step with Crank–Nicolson can be implemented in Matlab. As-
sume that the variable U0 has M + 1 elements and stores the numerical approximation at
time t = tn . If for example n = 0, U0 is generated from the given starting values. It can
be a good idea to let U0 have dimension M + 2 and store the boundary points respectively
in U0(1) and U0(M+2)
Let us now set n = 0, and use the hat function as a starting value, i.e. f (x) = 1−|2x−1|.
We define U0 by
Assume the above commands are executed, such that r,A,U0,X are all defined.
We assume also that the boundary values are g0 (t) = g1 (t) = 0. Then we can make a
step with Crank–Nicolson as follows
> d=r/2*U0(1:end-2)+(1-r)*U0(2:end-1)+r/2*U0(3:end);
> U1=[0;A\d;0]; % Numerisk losning ved tidsskritt n+1
> plot(X,U1,’o’) % Plott resultatet
Observe that the definition of A is done once and for all, and it is used in all the following
time-steps. It would have been even better to LU-factorize A at the beginning, so that in
the subsequent steps one uses just the backward substitution algorithm.
Try to plot or make a movie of the results in time, look at > help movie, for ex-
ample.You can also try with a bigger value of M to improve accuracy and decrease the
numerical error.
n
k τm = (1 − θ r δx2 ) un+1 2 n 2 n+1 n 2 n
m − (1 + (1 − θ) r δx ) um = (1 − θ r δx )(um − um ) − r δx um .
36 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
1 1 1 1
= ( − θ) k 2 ∂t2 unm − k h2 ∂x4 unm + ( − θ) k 3 ∂t3 unm + · · · .
2 12 6 2
We conclude that
n 1
k τm = O(k 2 + k h2 ) when θ 6= ,
2
n 1
k τm = O(k 3 + k h2 ) when θ = .
2
And we then expect that (CN) is more accurate than (E) and (BE).
4.3 Semi-discretization
4.3.1 Semi-discretization of the heat equation
We look again at the (I/BV) problem for the heat equation (4.1). Let us now draw vertical
grid-lines as shown in the picture.
u = g0 u = g1
h
x1 x2 x3 xM xM +1
The lines are parallel to the t-axis and cross the x-axes in x = xm , m = 0, . . . , M + 1.
We consider the differential equation along such lines, this means
v0 (t) = g0 (t),
vM +1 (t) = g1 (t),
1 2
v̇m (t) = δ vm (t), vm (0) = f (xm ), m = 1, . . . , M,
h2 x
dvm (t)
where v̇m (t) = . For a more compact notation, let v(t) := [v1 (t), . . . , vM (t)]T . We
dt
get
v̇1 −2 1 v1 g0 (t)
v̇2 1 −2 1 v2 0
.
1
.. .. .. ..
1 .
v̇ = .. = 2 . . . · . + 2 .. .
h h
v̇M −1
1 −2 1
v M −1
0
v̇M 1 −2 vM g1 (t)
| {z } | {z }
A b(t)
This system is a special case of the general format for ODEs which is used in standard
numerical codes for ODEs. The general format is
where v and F (t, v) are vectors in RM . Three of the simplest methods for the numerical
solution of (4.6) with time-step k are
By setting F (t, v) = Av + b(t) from (4.5), it is possible to reproduce the three methods
presented earlier. In particular (T) becomes (CN).
In particular the method can be of interest in case of nonlinear PDEs, because in that case
also the semi-discrertized ODE problem will be nonlinear, and standard ODE software is
designed to solve numerically also such problems in an efficient way.
A problem often encountered is that the resulting ODE system is stiff. For the linear
semi-discrete system (4.5) this means typically that the eigenvalues λ1 , . . . , λM of A have
negative real part and the quotient
maxi |Re λi |
α= ,
mini |Re λi |
is relatively large. If A is the tridiagonal matrix reported above then
4 sπ
λs = − 2
sin2 , m = 1, . . . , M,
h 2(M + 1)
that is all the eigenvalues are real. For small values of x, sin x ≈ x, such that, for big M ,
the eigenvalue with the smallest absolute value is
4 π 2 h2
|λ1 | ≈ = π2,
h2 22
and the eigenvalue with the biggest absolute value is
4 Mπ 4 π 4
|λM | = − 2
sin2 ≈ 2 sin2 = 2 .
h 2(M + 1) h 2 h
∂t u = Lu,
where L is a differential operator with space derivatives. For example the heat equation is
obtained by considering L = ∂x2 . Generally, in one space dimension, we have
L −→ Lh ,
that is, Lh , is a discrete operator now acting on the components of a vector of functions
in one variable instead of functions of two variables. For each component we write
where ϕ(xm , t) is the truncation error in the space direction. We let now vm (t) ≈ u(xm , t)
and define
v̇m (t) = Lh vm (t), (including the boundary conditions).
We will next look at the truncation error due to the time-discretization, that is after having
chosen an integration method for ODEs. Assume we use the trapezoidal rule for example.
4.3. SEMI-DISCRETIZATION 39
ẏ = F (t, y), y ∈ RM .
n+1 n k
Fm (tn , y n ) + Fm (tn+1 , y n+1 ) + ψm
n
ym := ym (tn+1 ) = ym + ,
2
where
n 1 3 (3)
ψm =− k ym (tn ) + · · · .
12
But u(xm , t) is such that ∂t u(xm , t) = Lh u(xm , t)+ϕ(xm , t). Let us insert ym (t) = u(xm , t)
in the general ODE-formulation above, such that
i.e., a system of ODEs whose solution is the solution of the PDE problem along the vertical
lines (x = xm , t). We get then
k k
un+1 = unm + Lh unm + ϕnm + Lh un+1 n+1 n+1
= unm + Lh unm + Lh un+1 n
m m + ϕm +ψm m +k τm ,
2 2
where
n k n
k τm = (ϕ + ϕn+1 n
m ) + ψm .
2 m
Note that this is true in general for the semi-discretization principle. In particular the result
is consistent with what we know for the three methods (E), (BE) and (CN) applied to
the heat equation.
Space-discretization
We set therefore
1
h ∆x u
1 2
1
Lh u = a δ u+b h ∇x u
+ c u.
h2 x
1
δ
h x µ u
We get Lu = Lh u + ϕ where
− 12 h ∂x2 u
1
ϕ = − a h2 ∂x4 u − b 1 2
2 h ∂x u
.
12
− 1 h2 ∂ 3 u
6 x
ut = (a(x) ux )x , L = ∂x (a∂x ).
| {z }
Lu
L is self-adjoint. In particular this means that if you use the inner product between
differentiable functions which are 0 in the endpoints 0 and 1, defined by
Z 1
hu, vi = u(x)v(x) dx,
0
so we get hLu, vi = hu, Lvi for all u, v. If we look at an analogous situation with the inner
product on Rn
hx, yi = y T x
and replace L with a matrix, then the analogous condition becomes
ut = auxx + a0 ux .
So that we get an equation of the same type as in the case A with b = a0 and c = 0.
Another (and usually better) possibility is to discretize directly the original form, we let
1 1 1
∂x (a ∂x )u(xm , t) −→ δx (a δx U )m = 2 δx (am (Um+1/2 − Um−1/2 ))
h h h
1
= 2
am+1/2 (Um+1 − Um ) − am−1/2 (Um − Um−1 ) .
h
The truncation error is O(h2 ).
1) ut + wx = 0, 2) w = −aux .
4.4. BOUNDARY CONDITIONS INVOLVING DERIVATIVES 41
We discretize 1) by
1 1
∂t um = −∂x wm ≈ − δx wm = − (wm+1/2 − wm−1/2 ).
h h
For the other equation we get ux = −w/a and
Z xm+1 Z xm+1 Z xm+1
w dx
ux dx = − dx ≈ −wm+1/2 .
xm xm a xm a
Set now
1
Am = R xm+1 dx
.
h xm a
And therefore
1 1
w ≈ −Am (um+1 − um ), w ≈ −Am−1 (um − um−1 ),
h m+1/2 h m−1/2
such that in the discretization of 1) we get
∂u
−λ = φ given.
∂n
42 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
2. Convection
∂u
−λ
= α(u − u0 ).
∂n
where we do not consider the boundary layer.
3. Radiation (Plancks radiation law from statistical mechanics)
∂u
−λ = σ(u4 − u40 ).
∂n
~n ~n
∂u ∂u
∂n
= −∂xu ∂n
= ∂x u
−∂xu + η0u = g0 ∂x u + η1 u = g 1
∂u
In one space dimension ∂n = ±ux , the sign depends on where the normal vector is
pointing (to the right or to the left). We call the relative Initial/Boundary value problem
(I/BVP).
ut = uxx ,
u(x, 0) = f (x),
−ux (0, t) + η0 u(0, t) = g0 (t),
ux (1, t) + η1 u(1, t) = g1 (t),
η0 , η1 > 0.
NB! u(0, t) and u(1, t) are unknown.
Left boundary. We want to use a difference approximation with truncation error O(h2 )
and try the use of central differences, which will involve the solution at the fictitious grid
line outside the domain of definition of the solution of the equation.
1 2 1
v̇M = 2
δx vM = 2 (vM −1 − 2 vM + vM +1 )
h h
1 2
= 2
2 vM −1 − 2 (h η1 + 1) vM + g1 .
h h
44 CHAPTER 4. DISCRETIZATION OF THE HEAT EQUATION
We can write this in matrix-vector notation. With v(t) = [v0 (t), . . . , vM (t)]T we get
1 2
v̇ = 2
Q v + d, (4.8)
h h
where
−2(hη0 + 1) 2 g0
1 −2 1 0
..
Q= .. .. ..
. . . , d= . (4.9)
.
1 −2 1
0
2 −2(hη1 + 1) g1
We note that this matrix is not symmetric, but it can be obtained from√a symmetric√ matrix
via a similarity transformation. With the diagonal matrix D = diag( 2, 1, . . . , 1, 2) we
find in fact that Q̃ = D−1 QD is symmetric and it has therefore real eigenvalues. Q̃ is also
negative definite 1 .
To get an example of a fully discrete method, we can use the trapezoidal rule, and
obtain Crank–Nicolson. Let U n = (U0n , . . . , UMn )T , then
n+1 n k 1 n 2 n 1 n+1 2 n+1
U =U + QU + d + 2 QU + d ,
2 h2 h h h
or in matrix-vector notation
r r k
(I − Q) U n+1 = (I + Q) U n + (dn + dn+1 ).
2 2 h
Burgers’ equation.
ut = ε uxx − uux
It is possible to semi-discretize by taking
ε 1
Fm = (vm+1 − 2vm + vm−1 ) − vm (vm+1 − vm−1 ).
h2 2h
Here it is possible for example to use a Runge-Kutta method applied to v̇ = F (v), see
for example > help ode45 in Matlab. Note that Burgers’ equations can be written in the
form
1
∂t u = ε ∂x2 u − ∂x u2 ,
2
which can be discretized directly with central differences, to obtain
ε 1 2 2
Fm = (vm+1 − 2vm + vm−1 ) − (v − vm−1 ).
h 2 4h m+1
n+1 n k
Fm (U n ) + Fm (U n+1 ) ,
Um = Um +
2
where
1
Fm (U n ) = (α n
∆x Um n
− αm−1/2 ∇x Um ).
b(U n ) m+1/2
This means that we must solve a nonlinear equation to compute Um n+1 . If we require the
same accuracy as for Crank–Nicolson, but we would like to avoid solving nonlinear systems
of equations at each time step, we could try and apply a 3-level formula. We use central
differences in time and get
Umn+1 − U n−1
m
= Fm (U n ),
2k
or
n+1 n−1
Um = Um + 2k Fm (U n ).
Replace
n 1 n−1 n n+1
∆x Um −→ (∆x Um + ∆x Um + ∆ x Um ),
3
n 1 n−1 n n+1
∇x Um −→ (∇x Um + ∇x Um + ∇ x Um ).
3
We get the method
We are now going to analyze the numerical solution of a partial differential equation. Part
of this theory is valid for general PDEs, but the examples are based on the heat equation
and the methods introduced so far for such equation.
Example. We consider again the I/BVP for the heat equation as an example
u(x, 0) = f (x), 0 ≤ x ≤ 1,
u(0, t) = g0 (t), t > 0,
u(1, t) = g1 (t), t > 0.
Assume f , g0 and g1 are continuous and that f (0) = g0 (0), f (1) = g1 (0). Then the I/BVP
for the heat equation has a unique solution u(x, t) which is continuous for 0 ≤ x ≤ 1, t ≥ 0
and fulfilling the maximum principle
max |u(x, t)| ≤ max max |f (x)|, max |g0 (s)|, max |g1 (s)| . (5.1)
0≤x≤1 0≤x≤1 s≤t s≤t
More general and advanced results of this type can be found in the literature. We
are not going to report the proof of this result, but rather observe how the maximum
47
48 CHAPTER 5. STABILITY, CONSISTENCY AND CONVERGENCE
principle (5.1) implies the properties (2) and (3) listed above. Let u1 and u2 be solutions
with data
(i) (i)
f (i) , g0 , g1 , i = 1, 2.
Consider
(1) (2) (1) (2)
w = u(1) − u(2) , φ = f (1) − f (2) , γ0 = g0 − g0 , γ1 = g1 − g1 .
So uniqueness (2) follows now, because two solutions with the same initial and boundary
data will have φ, γ0 , γ1 identically equal to zero, and therefore also w(x, t) will be zero. But
also the property (3) follows from (5.2). The property (3) is often referred to as stability
of the differential equation. Can we transfer this concept to the numerical solution?
We introduce a grid
G = {(xm , tn ), 0 ≤ m ≤ M, 0 ≤ n ≤ N } ,
where
1 T
xm = mh, h = , tn = nk, k = .
M N
enm = unm − Um
n
, unm = u(xm , tn ).
U n = [U0n , . . . , UM
n T
] , un = [un0 , . . . , unM ]T , en = [en0 , . . . , enM ]T , vectors in RM +1 .
5.3. DOMAIN OF DEPENDENCE OF A NUMERICAL METHOD 49
M
!1/2
X 1
ken k2,h = h |enm |2 = √ ken k2 .
m=0
M
Remarks.
1. The concept of norm is a bit tricky in this context. We know that all norms on a
finite-dimensional space are equivalent , a fact that implies in turn that convergence
in one norm is equivalent to convergence in another norm. But now we must take
into account that the dimension of this space goes towards infinity when h → 0. We
have for example the relationship
√
kxk2,h ≤ kxk∞ ≤ M kxk2,h .
And the vector with 1 in the first component and 0 on the others will converge to 0
in the norm k · k2,h but not in the norm k · k∞ as h → 0 (and M → ∞).
M
!1/2 1/2
X Z 1
kf k2,h = h |enm |2 ≈ 2
|f (x)| dx = kf kL2 ,
m=0 0
n
Um
m, n + 1
m − 1, n m, n m + 1, n
In the (I/BV) problem the domain of dependence will look like in the picture below.
The angle
k
φ = arctan ,
h
t (m, n)
characterizes the domain of dependence for φ
the Euler method. The solution of the
PDE u(xm , tn ) has a domain of dependence
including the whole rectangle with corners
(0, 0), (0, tn ), (1, tn ), (1, 0). If we let r = hk2 be
constant when h → 0 then
k
φ = arctan = arctan rh → 0,
h
such that in the limit we will get the whole do- x
main of dependence for the exact solution.
U0n = g0n , n
UM n
+1 = g1 , n > 0,
U0m = fm , 0 ≤ m ≤ M + 1.
un+1
m = unm + r δx2 unm + kτm
n
, (5.4)
and τmn is the local truncation error. We define now en = un − U n , and subtract (5.3)
m m m
from (5.4). We get
en+1
m = enm + r δx2 enm + kτm
n
, n > 0, 1 ≤ m ≤ M. (5.5)
Moreover we have e0m = 0 and en0 = enM +1 = 0. We know that for the Euler’s method it
holds that
n 1 1
kτm = k 2 ∂t2 unm − k h2 ∂x4 unm + · · · ,
2 12
5.5. STABILITY ON UNBOUNDED TIME INTERVAL (F -STABILITY) 51
and it seems reasonable assuming enough regularity of the exact solution, to assume that
there exists a constant A such that
n
|τm | ≤ A(k + h2 ), for all m, n.
en+1
m = r enm−1 + (1 − 2r)enm + r enm+1 + kτm
n
.
1
When we later on take the absolute value, we will make use of the hypothesis that 0 ≤ r ≤ 2
because this implies that both r and 1 − 2r are non-negative. We obtain therefore
|en+1 n n n 2 2
m | ≤ r |em−1 | + (1 − 2r) |em | + r |em+1 | + A (k + kh )
≤ max |en` |(r + (1 − 2r) + r) + A (k 2 + kh2 )
`
= max |en` | + A (k 2 + kh2 ).
`
E n+1 ≤ E n + A (k 2 + kh2 ),
and since E 0 = 0 is
E n ≤ n k A (k + h2 ) = tn A (k + h2 ) ≤ T A (k + h2 ),
that is
max |en` | ≤ T A (k + h2 ) for all n ≤ T /k.
`
(1 − θ r δx2 )Um
n+1
= (1 + (1 − θ) r δx2 )Um
n
.
vector-form as
(I − θ r S)U n+1 = (I + (1 − θ) r S)U n + dn ,
where
dn = [θ r g0n+1 + (1 − θ) r g0n , 0, . . . , 0, θ r g1n+1 + (1 − θ) r g1n ]T .
52 CHAPTER 5. STABILITY, CONSISTENCY AND CONVERGENCE
A U n+1 = B U n + cn . (5.7)
A and B will depend on h and k since the elements are functions of h and k, but also
because the matrix dimension typically is M × M where M = 1/h (or M = 1/h − 1).
A and B can depend on n, but we assume here this does not happen.
A method is called a one-step method (ODE-terminology) or alternatively two-level-
method (PDE-terminology) if it can be written in the form
U n+1 = C U n + q n . (5.8)
Note that the stability concept here considered has nothing to do with the solution of
a differential equation, but is merely a property of the difference scheme.
Without Proof.
You can find more on F -stability in the Norwegian version of the note.
Definition of stability. We say that (5.8) is stable if and only if it exists a constant
L independent on h and k such that wn+1 = Cwn satisfies
T
kwn k ≤ L kw0 k for all n ≤ and starting vectors w0 , (5.9)
k
where k · k is a vector-norm.
Equivalent definition. The scheme defined by (5.8) is stable if and only if there exists
a constant L independent of h and k such that
T
kC n k ≤ L for all n ≤ , (5.10)
k
where the matrix norm is subordinate to the vector-norm in the previous definition.
Proof of the equivalence of (5.9) and (5.10). Assume that (5.9) holds true. Let h, k and
n be arbitrary. Since the matrix norm in (5.10) is subordinate, we can find w0 such that
kC n w0 k = kC n k kw0 k. And so we get
Assume on the other hand that (5.10) holds true, and let w0 , h, k and n be arbitrary, then
If not specified otherwise, we will assume from now on that the matrix-norm which is
used is subordinate to the vector norm in the definition (5.9).
Proof
µ T
kC n k ≤ kCkn ≤ (1 + µ k)n ≤ (1 + µ k)T /k = (1 + µ k)1/(µ k) ≤ eµ T .
54 CHAPTER 5. STABILITY, CONSISTENCY AND CONVERGENCE
Proof. Since we assume that (5.8) is stable, it exists a constant L such that kC n k ≤ L for
n ≤ T /k. Moreover we have from (2.3) that
ρ(C)n = ρ(C n ) ≤ kC n k.
We apply Taylor’s formula with reminder to the right hand side of this inequality and we
get
k
ρ(C) ≤ 1 + ln L ek/T θ ln L , where 0 < θ < 1.
T
We use now that ex is a monotone increasing function and that θ < 1 and k ≤ T , so we
get
k k
ρ(C) ≤ 1 + ln Leln L = 1 + L ln L,
T T
L ln L
such that (5.11) is fulfilled with ν = .
T
A common mistake. The following argument is wrong. Assume that the considered
subordinate matrix norm is such that for diagonal matrices we have ρ(D) = kDk (this is
true for the usual norms). Assume also that C is diagonalizable, C = P ΛP −1 .
kC n k = kP Λn P −1 k ≤ kP k kΛn k kP −1 k = kP k kP −1 k ρ(C)n
≤ kP k kP −1 k (1 + νk)n ≤ kP k kP −1 k eνT ,
so we have at the same time found a bound for kC n k. The problem is however that P can
depend on h, k in such a way that kP k (kP −1 k) → ∞ when h, k → 0.
5.6. STABILITY ON [0, T ] WHEN H → 0, K → 0 55
Stability of the θ-method for (I/BVP). We recall that the θ-method has the form
such that
C = (I − θ r S)−1 (I + (1 − θ) r S).
Here we have r = k/h2 , and S is the symmetric matrix defined in (5.6). And we have
therefore the diagonalization S = P ΛP T where P T P = I. We get also
I − θ r S = P (I − θ r Λ)P T ,
(I + (1 − θ) r S) = P (I + (1 − θ) r Λ)P T .
C = P (I − θ r Λ)−1 (I + (1 − θ) r Λ) P T = P ∆P T .
| {z }
∆
1 + (1 − θ) rλm
∆m =
1 − θ rλm
From the diagonalization it is clear that C is also symmetric so it is enough to require that
ρ(C) ≤ 1 + ν k for a ν ≥ 0. From before we know that
mπ
λm = −4 sin2 φm , φm = , m = 1, . . . , M,
2(M + 1)
and therefore
1 − 4(1 − θ) r sin2 φm
∆m = .
1 + 4 θ r sin2 φm
We assume that 0 ≤ θ ≤ 1, such that the expression in the numerator is ≤ 1, while the
denominator is such that ≥ 1. So we have ∆m ≤ 1 for all m. We try and require that
∆m ≥ −1, substitute the expression for ∆m in the above inequality, and multiply each side
with the denominator (which is positive)
If 21 ≤ θ ≤ 1 the left hand side is ≤ 0, so the inequality is satisfied for all values of r ≥ 0.
But if 0 ≤ θ < 12 we must require
1
r≤ , m = 1, . . . , M.
2 (1 − 2θ) sin2 φm
56 CHAPTER 5. STABILITY, CONSISTENCY AND CONVERGENCE
Mπ π hπ
The right hand side is minimal when m = M , i.e. φm = 2(M +1) = 2 − 2 . We get
2 π hπ hπ
sin − = cos2 ,
2 2 2
1
r≤ .
2(1 − 2θ) cos2 (hπ/2)
For small values of h we have cos2 (hπ/2) ≈ 1 and we get a sufficient condition by substi-
tuting it with 1. In summary we get
1 1
0≤θ< 2 ⇒ Stable if 0 ≤ r ≤ ,
2(1 − 2θ)
1
2 ≤θ≤1 ⇒ Stable for all r ≥ 0.
C = (I − θ r Q)−1 (I + (1 − θ) r Q),
where Q is given by (4.9). Since Q is not symmetric also C will not be symmetric, and it
is not possible to use the condition ρ(C) ≤ 1 + ν k for non symmetric matrices (because
this is only necessary for stability). However in this particular case this condition is also
sufficient.
√ Here is√the explanation. We have seen earlier that by using the matrix D =
diag( 2, 1, . . . , 1, 2) we get that Q̃ = D−1 Q D is symmetric. This implies that also
C̃ = D−1 CD is symmetric. We obtain that
1 + (1 − θ) r λm
∆m = , (5.12)
1 − θ r λm
where λm are the eigenvalues of Q. We can not find an explicit expression for the eigenval-
ues of Q, but we know they are real because Q̃ is symmetric. We can use the Gershgorin’s
theorem to get a sufficient criterion for stability.
5.7. STABILITY AND ROUNDOFF ERROR 57
r λm (2θ − 1) ≤ 2,
,which is satisfied for θ ≥ 12 , for any r > 0.
Let θ < 21 .
If we had had λm = 0 the inequality would have hold unconditionally. For λm < 0 we divide
on both sides by a the positive value −λm (1 − 2θ). The critical value occurs for the eigen-
value placed furthest to the left so we substitute the limit value instead λm ≥ −4 − 2η h.
In the end we get
1 1
0≤θ< 2 ⇒ Stable if 0 ≤ r ≤ ηh
,
2(1 − 2θ)(1 + 2 )
1
2 ≤θ≤1 ⇒ Stable for all r ≥ 0.
where η = max{η0 , η1 }.
Ũ n+1 = C Ũ n + q n + sn .
The vector sn contains the round-off error produced at step n. If we define the error due
to round-off by Rn = Ũ n − U n we get
Rn+1 = C Rn + sn .
Further we assume to have a bound σ such that ks` k ≤ σ for all `. If (5.8) is stable we get
then
n−2
X
kRn k ≤ σ + L σ = (1 + (n − 2)L)σ,
j=1
so stability guarantees that the round-off error increases at most linearly with n.
Consistency. The difference method (5.13) is consistent (with the differential equa-
tion) if
n
τm → 0, for all m, n når h → 0, k → 0.
Remark. The literature is not consistent about the definition of local truncation error,
and this fact influences also the definition of consistency. Alternatively it is common to
n = k τ n such that the condition for consistency is 1 τ n
define truncation error as τbm m k bm → 0.
The proof of Lax’ equivalence theorem is outside the scope of this course. We will instead
juts show a simpler result, namely that consistency and stability imply convergence.
Proposition Assume the two level difference scheme (5.13) is consistent (i.e. for τmn
n
defined by (5.14), τm → 0 when k → 0 and h → 0) and there exsist constants K > 0,
K̃ > 0 and H > 0 such that the inverse A−1 exitst for all h < H and k < K and
kA−1 k ≤ K̃ for all h < H and k < K in a given norm subordinate to the vector norm
k · k.
Assume the difference scheme can be written in the form (5.8) with C = A−1 B and it is
stable.
Then the difference scheme converges.
5.9. VON NEUMANN’S STABILITY CRITERION 59
Proof. Subtracting (5.14) from (5.13) we obtain the following equation for the error
AE n+1 = BE n − kτ n .
we set q n−1 := −kA−1 τ n−1 and simplify the above equation to obtain
E n = CE n−1 + q n−1
Taking the norm on both sides and using the assumed stability of (5.8) we get
n−1
X
kE n k ≤ L kq s k,
s=0
kE n k ≤ L K̃ n k max kτ s k ≤ L K̃ T max kτ s k,
0≤s≤n−1 0≤s≤n−1
which we substitute in the bound for the norm of the error and we get
kE n k ≤ L T K̃ max kτ s k → 0,
0≤s≤n−1
1
0
u
−1
−5 0 5 10
x ,
60 CHAPTER 5. STABILITY, CONSISTENCY AND CONVERGENCE
Let us consider an analogous analysis for the numerical solution, we use first the Euler
method.
n+1 2π
Um = (1 + r δx2 )Um
n
, h= ,
M
n n
Um+M = Um for all m ∈ Z,
0
Um = f (xm ) for all m ∈ Z.
We can assume ξ 6= 0 and use that xm = mh, we can divide each side by ξ n eiβxm and we
get
βh
ξ = 1 + r (e−iβh − 2 + eiβh ) = 1 + 2r (cos βh − 1) = 1 − 4r sin2 .
2
We can take ξ = ξβ from this expression in the sum (5.15) and obtain
∞
X
n
Um = Aβ ξβn eiβxm , ξβ = 1 + 2r (cos βh − 1),
β=−∞
2
which is the exact solution of the differential equation. ξβ corresponds the factor e−β h in
the expression for the exact solution We should therefore require that |ξβ | ≤ 1 for all β to
ensure that the numerical solution is stable. In this particular case ξβ is real, and we note
immediately that ξβ ≤ 1 for all β. When we require ξβ ≥ −1 we get as a condition
1
r≤ βh
, for all β,
2 sin2 2
and so
s
X
bp eiβph
p=−s
ξ = r .
X
iβph
ap e
p=−r
|ξ| ≤ 1 + µ k.
ut = uxx − λux .
n+1 n k 2 n k
Um = Um + δ U −λ (U n − Um−1
n
).
h2 x m 2h m+1
βh
1 − 4 r sin2 ≤ 1 + µ̃ k,
2
and from the Euler’s method applied to ut = uxx we know already that this implies r ≤ 12 .
But if r ≤ 12 we get
1
|ξ|2 ≤ 1 + λ2 k,
2
and obtain by using the mean-value theorem that von Neumann’s stability criterion is
satisfied with µ = 14 λ2 when r ≤ 21 .
then von Neumann’s stability is necessary and sufficient for stability (as previously de-
fined).
One might note that von Neumann’s stability analysis is used as an indication of
stability or instability in much more general cases.
Example.
ut = a(x, u) uxx , (+randkrav & startkrav).
Using Euler’s method we get
n+1 n n
Um = Um + r a(x, Um ) δx2 Um
n
.
With a constant the von Neumann’s stability criterion has the form
βh
|ξ| = 1 − 4 a r sin2 = 1 + O(k).
2
Let us for example assume it is possible to bound a such that 1 ≤ a(x, u) ≤ 2 for all x, u
we are interested in. Then we could require
1 1
r≤ = ,
2 max a 4
without having performed any rigorous analysis.
Chapter 6
Ω ∂Ω
x
,
ac − b2 > 0
uxx + uyy = 0.
63
64 CHAPTER 6. ELLIPTIC DIFFERENTIAL EQUATIONS
∂u
3. Robin boundary conditions: αu + β ∂n = γ on ∂Ω.
The boundary conditions can often be a mixture of 1–3, such that the boundary ∂Ω
can be divided in subparts, and with different boundary conditions on the different parts.
Grid-lines: x = x` , y = ym
Grid-points: P = (x` , ym )
Gitterpunkt
The intersection points (between the boundary and the grid-lines) can cause problems,
because often they reduce the accuracy of the numerical approximation and can also destroy
the matrix structure (e.g. symmetry) and produce linear systems of equations which are
difficult to solve numerically via iterative techniques.
6.2. DIFFERENCE METHODS DERIVED USING TAYLOR SERIES 65
Grid-like net. A net is grid-like if all the points in the set D are grid-points. In the
sequel we consider grid-like nets with constant step-size, i.e. x` = x0 + `h, ` = 0, 1, . . . and
ym = y0 + mh, m = 0, 1, . . ..
Poisson’s equation. y
∆u = uxx + uyy = f i Ω, u = g(x, y) på ∂Ω.
1 2
∂x2 up = δ up + O(h2 )
h2 x
1 2
∂y2 up = δ up + O(k 2 )
k2 y
k
where up is the solution of the differential equa-
tion evaluated in the point p = (x, y). x
h
If we discretize the differential equation in the point p = (x, y) we get
1 2 1
∆up = fp −→ 2
δx up + 2 δy2 up = fp + τp
h k
where fp is the function f evaluated in the point p, and the local truncation error τp is
1 2 4 1 2 4
τp = h ∂x up + k ∂y up + · · · (6.1)
12 12
We let Up be the approximation of up and we get the linear system
1 2 1 2
δ U
h2 x p
+ δ U
k2 y p
= fp , p ∈ N o,
Up = gp p ∈ D.
Uw + Us + Ue + Un − 4Up = h2 fp
s
y u = 4x(x2 − 1)
g(0, y) = 0, 0≤y≤1
3 4
g(x, 0) = 0, 0≤x≤1
u=0 u = 4y(1 − y 2)
g(1, y) = 4y(1 − y 2 ), 0≤y≤1
1 2
g(x, 1) = 4x(x2 − 1), 0 ≤ x ≤ 1
u=0 x
p = 1 : −4 U1 +U2 +U3 = 0
32
p=2: U1 −4 U2 +U4 = − 27
32
p=3: U1 −4 U3 +U4 = 27
p=4: U2 +U3 −4 U4 = 0.
By solving these equations we get
8 8
U1 = U4 = 0, U2 = , U3 = − .
27 27
You can verify that the solution of the partial equation is
From (6.1) we see that the local truncation error is identically equal to zero because
≡ 0 and ∂y4 u ≡ 0 and therefore all the higher order derivatives. So in this case the
∂x4 u
formula gives the exact solution of the problem. This is a very special case, with different
boundary conditions we would get τp 6= 0.
n
1
∂x (a∂x u) = (aø 0 (uø − up ) − av0 (up − uv )) + O(h2 )
h2 n’
1
(cn0 (un − up ) − cs0 (up − us )) + O(k 2 )
∂y (c∂y u) = p
k2
So Lu = f can be discretized to v v’ ø’ ø
αø Uø + αn Un + αv Uv + αs Us − αp Up = fp ,
s’
where αp = αø + αn + αv + αs s
and
1 1 1 1
αø = 2
aø 0 , αn = 2 cn0 , αv = 2 av0 , αs = 2 cs0 .
h k h k
6.3. BOUNDARY CONDITIONS OF NEUMANN AND ROBIN TYPE 67
y
∆u = 0 iΩ
∂Ω2
u = g(x, y) on ∂Ω1 ∪ ∂Ω2
∂Ω3 ∂Ω1
Ω ∂x u − q (0) u = f (0) on ∂Ω3
n
∂y u − q (1) u = f (1) on ∂Ω4
∂Ω4 n x
n
We require that q (0) ≥ 0 and q (1) ≥ 0. Now we need
an equation for Up for all p ∈ N o , and for all p on ∂Ω3
∂Ω3
and ∂Ω4 . Let us for the sake of simplicity use the same v p ø
step in both space directions, i. e. k = h. Let us use
the left boundary ∂Ω3 as an example,
∂x u − qu = f.
s
Alternative 1.
uø − up Uø − Up
∂x up = + O(h) −→ − qp(0) Up = fp(0)
h h
(0) (0)
where qp and fp are the given functions q (0) and f (0) evaluated in the point p.
Alternative 2. Use the fictitious point v lying outside the domain see picture.
uø − uv Uø − Uv
∂x up = + O(h2 ) −→ − qp(0) Up = fp(0) (6.2)
2h 2h
The extra unknown Uv requires an extra equation, and we use the scheme for the approx-
imation of the differential equation in the point p
Uø + Un + Uv + Us − 4Up = 0, (6.3)
Uv = Uø − 2h (qp(0) Up + fp(0) ),
The same approach is used on the boundary ∂Ω4 . For this boundary we see only at
alternative 2 with fictitious boundary point s, and pon ∂Ω4 :
un − us Un − Us
∂y up = + O(h2 ) −→ − qp(1) Up = fp(1) .
2h 2h
Here we can also use (6.3) and eliminate the fictitious value Us , the result is
h
∂n u + qu = ~n · ∇u + qu = f
~n
h ~n = [nx , ny ]T
v p
nx = ny = √1 because k = h
2
⇓
s
∂n u = nx ∂x u + ny ∂y u = √1 (∂x u + ∂y u)
2
up − uv up − us
1
∂n up = √ + + O(h)
2 h h
It is usual to consider such low order approximations for this kind of boundary. In principle
it is possible to use fictitious grid-points as in alternative 2, but the formulae become quite
complicated.
A problem with pure Neumann boundary conditions for the Laplace’s equation.
The problem
∆u = 0, in Ω
∂n u = g, on ∂Ω
R
hasR a solution only if ∂Ω g = 0. This can be shown by using the divergence theorem
on Ω ∆u. If u is a solution, we see immediately that also u + c is a solution for an arbitrary
constant c. Therefore we have not a well posed PDE-problem. This fact has a counterpart
in the discrete problem where we solve a linear system of equations of the type AU = b
where A is a square singular matrix. If b belongs to the range of A (the span of the columns
of A) there is at least a solution (not necessarily unique as we can add any arbitrary non
zero vector belonging to the null space of A), otherwise there is no solution of the linear
system.
6.4. GRID-LIKE NET AND VARIABLE STEP-SIZE 69
n0
hn
h
v
p ø0 ø
v v0
hø
hs s0
x
s
We consider the approximation of
We let
Uø − Up Up − Uv
(x) 2
∂x (a∂x u) −→ Lh Up = aø 0 − av 0
hv + hø hø hv
and
Un − Up Up − Us
(y) 2
∂y (c∂y u) −→ Lh Up = cn0 − cs0
hs + hn hn hs
We refer to the picture above to the right for the definition of the points p, v, v 0 , s, s0 , ø, ø 0 , n, n0
and the relative step-sizes. We approximate L by
(x) (y)
Lh = Lh + Lh
and find
h2 h3
(x) 2 hø 1
Lh up = (1 + ∂x + ø ∂x2 + ø ∂x3 + · · · )(ap (∂x + h2ø ∂x3 + · · · )up )
hv + hø 2 8 48 24
2 3
hv hv 2 hv 3 1 2 3
−(1 − ∂x + ∂x − ∂x + · · · )(ap (∂x + hv ∂x + · · · )up )
2 8 48 24
3 3
1 1 hø + hv
= ∂x (a∂x )up + (hø − hv )∂x2 (a∂x )up + (∂x a∂x3 + ∂x3 a∂x )up + . . .
3 24 hø + hv
(y)
By a similar calculation for Lh up eventually we get
O((hø − hv ) + (hn − hs ) + h2 + h2 ) generelt
ø n
Lu − Lh u =
O(h2 + h2 )
hø = hv , hn = hs .
ø n
70 CHAPTER 6. ELLIPTIC DIFFERENTIAL EQUATIONS
Indre gitterpunkt
Dirichlet problem. We can use the general 5-points-formula with hø , hv , hn , hs for all
the grid-points internal to the domain.
Robin problem. The difficulty here is ∂n u = ~n · ∇u. We let the grid be rectangular
with step-sizes h and k respectively in the x- and y-direction.
d(P, Q) = d
~n
d(Q, S) = h0
P
d(P, S) = k 0
R Q S
We have
uP − uQ p
∂n uP = + O(d), d = h02 + k 02 .
d
The problem is that Q is not a grid-point, but we can approximate the solution in the
point Q using linear interpolation. We find
h0 h − h0
uQ = uR + uS + O(h2 ).
h h
Therefore we get
h0 h − h0
1
∂n uP = uP − (uR + uS ) + O(h2 /d) + O(d).
d h h
But we note that this type of discrete problem is generally difficult to derive and handle.
6.6. DISCRETIZATION USING TAYLOR EXPANSION ON A COMPLETELY GENERAL NET71
P Qi = (ξi h, ηi h).
As usual we insert the exact solution u in this formula and using Taylor expansion in
2 dimensions as in (2.4), we get
1 1
uQi = uP + ξi h∂x uP + ηi h∂y uP + ξi2 h2 ∂x2 uP + ξi ηi h2 ∂x ∂y uP + ηi2 h2 ∂y2 uP + · · · ,
2 2
s s s s
! ! ! !
X X X 1 2X 2
Lh up = αi − α0 uP + h ξi α i ∂x uP + h ηi αi ∂y uP + h ξi αi ∂x2 uP
2
i=1 i=1 i=1 i=1
s s
! !
2
X 1 2X 2
+ h ξi ηi αi ∂x ∂y uP + h ηi αi ∂y2 uP
2
i=1 i=1
72 CHAPTER 6. ELLIPTIC DIFFERENTIAL EQUATIONS
Moreover the following equation should be satisfied for as many values of ` as possible
s
X
ξi` ηi`−m αi = 0, m = 0, . . . , `, ` = 3, 4, . . . .
i=1
This can be justified by considering the rest of the Taylor expansion of Lh uP , the terms
h3 , of order 3 in h, and higher
··· ` s
X h` X ` X
(αi ξim ηi`−m ) ∂xm ∂y`−m uP .
`! m
`=3 m=0 i=1
u kjent
u ukjent
y
Γ2
Γ3 R Γ1
Γ4 x
∆u = f, i R.
∂n u + au = d, on Γ1 ,
u = g, on Γ2 ∪ Γ3 ∪ Γ4 .
Here we have introduced a rectangular grid on R, note that it is possible that the step-sizes
are variable in both directions.
Let now P be an internal grid-point in R. We h3
first look at the rectangle bounded by the grid- Q2
lines neighbouring the gridlines on which P lies
(see the picture). Next we look at a new rectan- γ2
gle placed exactly in the center of the previous h1
one as in the picture, we call this Ω. The edge γ3 Ω ~n
Q3 P
boundaries of Ω are centered between the grid-
lines and are called γi , i = 1, 2, 3, 4. The lenght γ1 Q1
of γi is called `i . We let the step-size out of P be
h1 (to the right), h2 (upwards), h3 (to the left), h4 γ4
h4 (downwards). So as in the picture we get
h2 + h4 h1 + h3 Q4
`1 = `3 = , ` 2 = `4 = .
2 2 h1
1
The area Ω becomes A = 4 (h1 + h3 )(h2 + h4 ). Now we use Gauss’ divergence theorem on
the small rectangle Ω and get
Z I Z
∆u = f ⇒ ∆u dA = ∂n u ds = f dA .
Ω
| ∂Ω {z } | Ω {z }
I II
74 CHAPTER 6. ELLIPTIC DIFFERENTIAL EQUATIONS
4 Z 4
uQi − uP
I X X
I: ∂n u ds = ∂n u ds ≈ `i
∂Ω γi hi
i=1 i=1
Z
1
II: f dA ≈ fP A = fP (h1 + h3 )(h2 + h4 ).
Ω 4
So our difference formula becomes
4
X `i
(UQi − UP ) = fP .
Ahi
i=1
where
2 2 2 2 2 2
α1 = , α2 = , α3 = , α4 = , α0 = + .
h1 (h1 + h3 ) h2 (h2 + h4 ) h3 (h1 + h3 ) h4 (h2 + h4 ) h1 h3 h2 h4
This formula can be used for all internal points in R. But we must have equations also
for the unknowns on the boundary Γ1 .
Now γ1 coincides with the exterior boundary Γ1
where we have
∂n u + au = d Q2
Gauss’ divergence theorem on Ω gives
4 Z
X Z γ2
∂n u ds = f dA. h2
i=1 γi Ω γ3 Ω
Q3 P
Looking in particular at the boundary γ1 where
∂n u is given as d − au we obtain
γ1
Z Z
∂n u ds = (d − au) ds ≈ `1 (dP − aP uP ) h4 γ4
γ1 γ1
γ6
γ3
Q3 Q6
i=1 γi Ω
UQ − UP
Z
∂n u ds ≈ `i i
γi hi Q4 Q5
such that the final formula becomes
s
X `i
(UQi − UP ) = fP .
hA
i=1 i
We have not given specific formulae for the computation of A or any relation between `i
and hi (this is not possible in the general case we have considered). There is an important
alternative to box-integration, namely the so called finite element method. Which rely
on completely different mathematical fundaments compared to the one presented in this
and the previous chapter. The course TMA4220 Numerical solution of partial differential
equations with the finite element method treats all the details abut these methods.
We let P range over all the points where we want to approximate u. Here Qi is the
neighbouring point of P for i = 1, . . . , s. The coefficients α1 , . . . , αs can depend on P ,
and similarly does s. Using these formulae one determines the linear system of algebraic
equations approximating the elliptic PDE. The entries of the matrix defining such linear
system (coefficient matrix) are the coefficients αi , i = 0, . . . s for all P where the numerical
solution is sought.
ii.
s
X
α0 ≥ αi for all P,
i=1
if this property hols the coefficient matrix is called diagonally dominant. We also
require strict inequality for at least one P .
P Qi
If we assume that the coefficient used in node P in front of Q
is αP,Q , the symmetry of the matrix means that αP,Q = αQ,P .
We recall the maximum principle discussed in chapter 6.1. An analogous principle
holds true for difference equations of the type described above.
Discrete maximum principle. Assume that the difference equation satisfies (i) and
(ii) given above. Assume the quantity VP is defined for all P ∈ Ω ∪ ∂Ω and that
X
α0 VP − αi VQi ≤ 0
i
Proof. Assume the converse is true, namely that there is a P ∗ ∈ Ω such that
m (i)
X αi (ii) 1 X X
VP ∗ ≤ VQi ≤ P αi VQi = γi VQi
α0 j αj
i i i
where
αi X
γi = X such that γi = 1.
αj i
j
and then VP ∗ ≤ maxi VQi . By (6.5), we get VP ∗ = maxi VQi = VQi1 , so (α0 − αi1 )VP ∗ ≤
P
i6=i1 αi VQi . So either there is only one neighbouring point Qi1 , or α0 − αi1 > 0 so by
a similar argument we get VP ∗ = maxi6=i1 VQi and we can proceed til we cover all the
neighbouring points so that VQi = VP ∗ for all i. We can next move in turn to each one
of the neighbouiring points Qi and repeat the same argument till one of the neighbouring
points is a boundary point S. Therefore we get that VS = VP ∗ for S ∈ ∂Ω which is a
contradiction (see (6.5)) and we conclude that the theorem holds.
1
Lh Up = (4Up − Uø − Uv − Un − Us ), p∈R
h2
Up = gp , p ∈ ∂R.
this definition requires that these fourth derivatives are bounded on R. The discretization
error (global error) is defined as
ep = up − Up ,
78 CHAPTER 6. ELLIPTIC DIFFERENTIAL EQUATIONS
Lh ep = Lh up − Lh Up = fp + τp − fp = τp , p ∈ R
Lh ep = 0, p ∈ ∂R.
So we have
|Lh ep | ≤ τ̄ for alle p ∈ R.
We find now that the function ϕ(x, y) = 21 x2 and we apply the operator Lh on this function
1 1 2 1 2 1 2 1 2 1 2
Lh ϕp = 2 4 xp − xø − xv − xs − xn .
h 2 2 2 2 2
Where we have
xo = xp + h
1 2 2 2 2 2
xn = xs = xp ⇒ Lh ϕp = 2 4xp − (xp + h) − (xp − h ) − xp − xp = −1.
2h
xv = xp − h
Lh Vp = Lh ep + τ̄ Lh ϕp = Lh ep − τ̄ ≤ 0.
1
ep + τ̄ ϕp ≤ max (eS + τ̄ ϕS ) ≤ τ̄ for alle p ∈ R,
S∈∂R 2
1
−ep + τ̄ ϕp ≤ τ̄ for all p ∈ R.
2
Since ϕp τ̄ ≥ 0 can we conclude that
1 1
|ep | ≤ τ̄ ≤ Kh2 for alle p ∈ R.
2 12
If we arrange all the values of the error and the local truncation error in the grid-points
ep , τp , p ∈ R in vectors e and τ , we can write the system in the form
Ae = τ
If A is invertible we get
e = A−1 τ
implying
kek∞ ≤ kA−1 k∞ · kτ k∞ .
Stability: the difference methods is called stable if there is a constant C such that
It is typically possible to prove (by Taylor expansion) that he truncation error τ satisfies
kek∞ = O(hσ ).
It can happen that for example τp = O(h2 ) for some p, while for others (typically those
close to the boundary or on the boundary) we have τp = O(h). So in general the global
error kek∞ can not be expected to be of higher order than 1 in h, O(h). It can happen
however that in such situations one can get kek∞ = O(h2 ) anyway.
1. the linear systems are very large and sparse; a system is sparse if the non zero entries
of the matrix are relatively small portion of the total number of entries;
80 CHAPTER 6. ELLIPTIC DIFFERENTIAL EQUATIONS
2. the matrices are not banded, i.e. there are indexes, corresponding to non zero ele-
ments, relatively far away form the diagonal position (ij-element with large value of
|i − j|); the bandwidth of a matrix can be for example defined as follows
3. the system can be preconditioned effectively; this means that it is possible to find
matrices T, S, such that the system
T −1 AS S −1 x = T −1 b
A
b x̂ = b̂
In practice direct methods and iterative methods are both effective when working with
partial differential equations in 2 space dimensions, while in 3 space dimensions we might
expect an advantage in using iterative methods. Typically iterative solvers use matrix-
vector multiplications (by A or respectively A) b as building blocks. If property 1. above is
satisfied the multiplications Ax can be executed efficiently provided the matrix is easy to
access in the computer memory. The property 2. disfavours the use of Gaussian elimina-
tion, which can be executed efficiently for banded matrices. The factors L and U in the
LU -factorization have in this case the same bandwidth as A (if no pivoting is performed).
On the other hand if the bandwidth is large the number of non zero elements in L and U
can be much larger than in A. This effect is called “fill-in”.
A real difference in performance between iterative methods and direct methods can be
seen when we use appropriate preconditioning techniques, property 3. above. Note that
the transformation A b = T −1 AS is not carried out in practice but only in theory. For the
sake of simplicity, let us assume S = I. As mentioned above the iterative methods are built
on operations of the type y = Ax for arbitrary vectors x. For the preconditioned system
we get y = Ax b = T −1 Ax. The preconditioning is therefore an internal procedure in the
method: each time we compute Ax b we do it by first computing ỹ = Ax and theny = T −1 ỹ.
The last operation is not performed as an explicit matrix-vector multiplication, but as
a process, a function applied to ỹ. An example of such a process is the computation of
parts of the Gaussian elimination algorithm on the system Ay = ỹ. Such approach is called
incomplete LU-factorization and is done by limiting or neglecting the fill-in. This approach
can also be efficiently parallelized, meaning that the computational work can be divided
over many processors on a supercomputer and can be executed very efficiently. Another
preconditioning technique can be obtained by splitting the domain of definition of the
partial differential equation in many small sub-domains. In turn, the differential equation
is split in many different differential equations, while discarding or approximating the
coupling between the various sub-domains. Each of the linear systems arising form one of
the differential equations is then solved on a different processor by, for example, Gaussian
elimination.
The course TMA4205 Numerical Linear Algebra presents these issues and methods in
detail.
Chapter 7
Hyperbolic equations
7.1 Examples
1. The most famous example of a hyperbolic differential equation is the linear second
order wave equation
utt = c2 uxx
or in several space dimensions
utt = c2 ∆u.
2. Consider the following general second order linear PDEs in two space dimensions
a uxx + 2b uxy + cuyy + dux + euy + f u = 0,
where a, b, c, d, e, f are functions of x, y, such equation is said to be hyperbolic when
b2 − ac > 0.
Note that y plays here the role of t in the equations above.
3. Another equation appearing in many applications is the so called conservation law
ut + c(x, t, u) ux = 0.
This is a scalar quasi-linear PDE, of first order which is also said to be hyperbolic.
Such an equation can be used to describe the road traffic flow .
4. Systems of first order linear equations with constant coefficients can be written in
the following form
ut + A ux = 0 (7.1)
where u ∈ Rn and A is a real n × n-matrix. Such a system is hyperbolic if A is
diagonalisable with real eigenvalues.
5. Let us consider a nonlinear hyperbolic system of equations describing an important
application namely the shallow water equations. We consider this set of equations
in one space dimension, and let v(x, t) be the velocity of the fluid in the point x at
time t, while z(x, t) measures the (vertical) wave height relative to an equilibrium
position.
Mass conservation zt + (vz)x = 0.
Momentum conservation vt + ( 21 v 2 + z)x = 0.
81
82 CHAPTER 7. HYPERBOLIC EQUATIONS
7.2 Characteristics
We consider a model problem which we will use a lot in the sequel
ut + aux = 0, −∞ < x < ∞, t ≥ 0, a>0 (7.3)
where a is a constant. The initial function must be given on all of R
u(x, 0) = f (x), −∞ < x < ∞.
For this simple model problem it is possi-
ble to find the exact solution, that is t
x−at=x0
u(x, t) = f (x − at).
u(x,t)=f(x 0 )
You can verify that by differentiating ap-
propriately and substituting into the equa-
tion u(x, t) = f (x−at) satisfies (7.3). This
means that in the (x, t)-plane there is a
line where u(x, t) is constant, i.e. the line
x = x0 + at where u(x, t) = u(x0 + at, t) =
x0 x
f (x0 + at − at) = f (x0 ). This line is called
characteristic.
Constant values of u are transported from the initial value u(x0 , 0) = f (x0 ) and forward
in time. The velocity of propagation is the reciprocal of the slope of the curve. When the
line is vertical the slope is infinite, and the velocity is 0. If the characteristic is oriented
towards right and upwards the value u(x0 , 0) is transported in the same direction. In a
xu-plot we can draw the solution at different values of time
u
t=t 0 t=t 1
dx
= a(x, t). (7.5)
dt
7.2. CHARACTERISTICS 83
If we know u(x0 , t0 ) we can find u(x, t) for (x, t) ∈ γ from the formula
Z t
u(x, t) = u(x0 , t0 ) + b(g(x0 , t0 , s), s) ds. (7.6)
t0
Initial value problem for (7.4). Assume that u(x, t) satisfies the PDE (7.4) and that
u(x, t) = f (x, t) along the curve Σ : x = σ(t)
NB! Σ should not be a characteristic.
t
Solution strategy: Compute the charac- karakteristikk
teristic x = g(x0 , t0 , t) through the point
(x0 , t0 ) belonging to Σ. Use than (7.6)
(x 0 ,t0 )
with u(x0 , t0 ) = f (x0 , t0 ). Σ
x
x
f (x − at), x − at ≥ 0
u(x, t) = u=f
h(t − x/a), x − at < 0.
Remark. We could have used, for example, boundaries x = 0 and x = 1, but than it would
be wrong to specify the solution along the line x = 1.
t
n+1
xm = mh, tn = nk n−1
unm = u(xm , tn )
m−1 m m+1
x
Different discretizations
1 n+1
∂t unm = (u − unm ) + O(k) (7.7)
k m
1
∂x unm = (unm+1 − unm ) + O(h) (7.8)
h
1
∂x unm = (unm − unm−1 ) + O(h) (7.9)
h
1 n
∂x unm = (u − unm−1 ) + O(h2 ) (7.10)
2h m+1
If we choose (7.7) and (7.9) we get
1 n+1 a
(u − unm ) + (unm − unm−1 ) + O(k) + O(h) = 0
k m h
and therefore for the numerical method
n+1 n n k
Um = (1 − ap)Um + apUm−1 , p= (7.11)
h
The truncation error bacomes τm n = O(k 2 ) + O(kh). If we choose (7.10) for u we obtain
x
instead
n+1 n ap n n
Um = Um − (Um+1 − Um−1 ) (7.12)
2
Here we obtain τmn = O(k 2 ) + O(kh2 ), looking as an improvement compared to (7.11) but
we will later show that (7.12) is always unstable for this problem!
7.4. STABILITY 85
We construct a difference discretization by Taylor expanding un+1 m to the second order, use
the differential equation, and then discretize the spatial derivatives with central differences.
We obtain
n+1 1 2 2 n
um = unm + k ∂t unm + k ∂t um + O(k 3 )
2
1
= unm − ak ∂x unm + (ak)2 ∂x2 unm + O(k 3 )
2
n 1 1 1
= um − ak (um+1 − unm−1 ) + + (ak)2 2 δx2 unm + O(kh2 ) + O(k 3 )
n
2h 2 h
From here we obtain
n+1 n ap n n 1
Um = Um − (Um+1 − Um−1 ) + (ap)2 δx2 Um
n
(7.13)
2 2
Truncation error
n
kτm = O(k 3 ) + O(kh2 )
n+1
1 n+1
∂t unm = (u n−1
− um ) + O(k 2 )
2k m
1 n
∂x unm = (u − unm−1 ) + O(h2 )
2h m+1
n
We get therefore the leap-frog formula
(hoppe-bukk formel) for ut + aux = 0
n+1 n−1 n n
Um = Um − ap(Um+1 − Um−1 )
n−1 n = O(k 3 ) + O(kh2 )
Truncation error: kτm
m−1 m m+1
Note that this is a two-step (three levels) method in time. For this reason it is neceaasry
to provide a starting method, analogously to what happens for multistep methods for
ordinary differential equations.
7.4 Stability
Courant-Friedrichs-Levy condition. We consider again the equation ut + aux = 0.
Assume we have a difference formula of the type
n+1 n n n
Um = α−1 Um−1 + α0 Um + α1 Um+1 d (7.14)
86 CHAPTER 7. HYPERBOLIC EQUATIONS
n . U n depends on U 0
We study the domain of dependence for Um m m+` der −n ≤ ` ≤ n. The
n n
dependence intervall for Um on the x-axis is Im = [xm−n , xm+n ].
n
Um
xm−n xm xm+n
h t∗
xm±n = x∗ ± nh = x∗ ± t∗ = x∗ ±
k p
∗ ∗
So Im n = [x∗ − t , x∗ + t ]. Note that this interval is fixed when h and k go to zero as
p p
described above. Let γ be a characteristic for ut + aux = 0 passing though the point
(x∗ , t∗ ). The inclination with respect to the x-axis is a and the line intersects the x-axis
in x∗ − at∗ so u(x∗ , t∗ ) = f (x∗ − at∗ ). If x∗ − at∗ 6∈ Im
n this means that the computed
approximation Um is built upon initial data that do not include f (x∗ − at∗ ) regardless of
n
how small h and k are. In the situation depicted in the figure we can not have convergence
towards the exact solution, when h, k → 0, for all initial values.
( x*,t* )
The same principle holds also for curved characteristic curves, as those one gets when
a = a(x, t).
The characteristic though (xm , tn+1 ) inter-
sects the line t = tn between the two ex- n+1
ternal points corresponding to m − 1 and
m + 1 (whose corresponding numerical ap-
proximations are featuring in the differ-
γ
ence formula), as described in the figure.
The characteristics must never leave the n
domain of dependence. m−1 m m+1
7.4. STABILITY 87
Let us see which is the necessary criterion for convergence for the case of constant a and
a difference formula of the type considered above. We have the condition
x∗ − t∗ /p ≤ x∗ − at∗ ≤ x∗ + t∗ /p
giving |a|p ≤ 1. This is the necessary condition for convergence for all the numerical
formulae of the type (7.14).
in the difference equation, and then solve it writh respect to th amplification factor ξ. The
stability condition is then
|ξ| ≤ 1 for any β ∈ R.
Stability of the Lax-Wendroff ’s scheme. We remind the formula valid for problems
of the type ut + aux = 0
n+1 n 1 n n 1
Um = Um − ap(Um+1 − Um−1 ) + (ap)2 (Um+1
n n
− 2Um n
+ Um−1 ).
2 2
If we substitute (7.15), simplified with ξ n eiβxm on both sides and we use eiβh = cos βh +
i sin βh we get
βh
ξ = 1 − i ap sin βh + (ap)2 (cos βh − 1) = 1 − 2(ap)2 sin2 − i ap sin βh.
2
βh
We now use the trigonometric identity cos βh = 1 − 2 sin2 2 here and below. Let us define
r = ap og q = sin βh
2 .
We require then
1 − 4r2 (1 − r2 ) q 4 ≤ 1, 0≤q≤1
m
4r2 (1 − r2 ) ≥ 0
m
|r| ≤ 1
m
|a| p ≤ 1
then we obtain exactly the same condition obtained from the CFL-condition.
A simpler fomula to check is the “naive” formula (7.12) which we DO NOT recommend
n+1 n ap n n
Um = Um − (U − Um−1 ).
2 m+1
We obtain here
ξ = 1 − i ap sin βh (7.16)
88 CHAPTER 7. HYPERBOLIC EQUATIONS
so that
|ξ|2 = 1 + (ap)2 sin2 βh > 1
for almost all the β, that is the formula is unstable for all step-sizes. An interesting
modification of this bad method can be obtained by replacing
n 1 n n
Um with Um−1 + Um+1 .
2
In von Neumann analysis the expression for ξ in (7.16) is replaced by
ξ = cos βh − i ap sin βh,
and we find that |ξ|2 = 1 + (1 − (ap)2 ) sin2 βh so that we get stability if |ap| ≤ 1. This
method is called Lax-Friedrichs method.
ut + aux = 0, x ≥ 0, t ≥ 0,
u=g
u(x, 0) = f (x), x ≥ 0,
u(0, t) = g(t), t ≥ 0.
x
u=f
The easiest implicit formula. We try the easiest possible discretization of the deriva-
tive in (xm , tn+1 )
1
m
k m
1
∂x un+1
m = (un+1 − un+1
m−1 + O(h)
h m
which gives the formula
ut + aux = 0
m+1 n+1
⇓ R
Z tn+1 Z xm+1
(ut + aux ) dx dt = 0.
tn xm m n
If we exchange the order of integration for the first term and we use the fundamental
theorem of calculus, we find
Z xm+1 Z tn+1
n+1 n
(u − u ) dx + a (um+1 − um ) dt = 0 (7.17)
xm tn
where
un = u(x, tn ), and um = u(xm , t).
Now we recall the trapezoidal rule for quadrature. Given a function f (x) we have
Z r+d
d 1 d
f (s) ds = (f (r) + f (r + d)) − d3 f 00 (r + ) + · · ·
r 2 12 2
So if we apply the trapezoidal rule to both the integrals in (7.17) we obtain
h n+1 n n+1 n ak n+1
(um − um ) + (um+1 − um+1 ) + (um+1 − um ) + (um+1 − um ) + O(k 3 + h3 ) = 0
n n n+1
2 2
Wendroff’s method.
n+1 n+1 n n
(1 + ap) Um+1 + (1 − ap) Um − (1 − ap) Um+1 − (1 + ap) Um =0
The truncation error can be expanded around the midpoint (xm + h/2, tn + k/2) of the
rectangle R, and we get then
n 1 3 3 n+1/2
kτm = a k − a kh ∂x3 um+1/2 + · · · = O(k 3 + kh2 ).
2
6
To study the stability of the method we use the Von Neumann-condition again, with
γ = (1 − ap)/(1 + ap) we can write
n+1 n+1 n n
Um+1 + γ Um − γ Um+1 − Um = 0.
n = eiβmh we get
By setting Um
ξ(eiβh + γ) = γeiβh + 1,
γ + e−iβh
ξ = eiβh .
γ + eiβh
The first factor eiβh has absolute value 1, and the fraction is an expression of the type
z ∗ /z so this has also absolut value 1. Therefore we have |ξ| = 1 for all β and we say that
Wendroeff’s method is unconditionally stable, that is stable for all h and k.
90 CHAPTER 7. HYPERBOLIC EQUATIONS
u = T v ⇔ v = T −1 u
ut = T vt
ux = T vx
T vt + (T ΛT −1 )T vx = T (vt + Λvx ) = 0.
vt + Λvx = 0
m (7.19)
(vi )t + λi (vi )x = 0, i = 1, . . . , `.
x = λi t + konstant, i = 1, . . . , `. (7.21)
φtt = c2 φxx
u1 = φt , u 2 = φx ,
(u1 )t = φtt = c2 φxx = c2 (u2 )x
(u2 )t = φxt = φtx = (u1 )x ,
0 −c2
u1 u1
+ · = 0. (7.22)
u2 t
−1 0 u2 x
7.6. HYPERBOLIC SYSTEMS OF FIRST ORDER EQUATIONS 91
0 c2
A=− ,
1 0
and so it is diagonalizable:
A = T ΛT −1 ,
c 0 −c c −1/(2c) 1/2
Λ= , T = , T −1 = .
0 −c 1 1 1/(2c) 1/2
The characteristic equation is dx/dt = ±c, and (7.22) has two families of characteristics
x = ±ct + konst. The tranfromation to the form (7.19) is
u=Tv
ut = T vt + Tt v, ux = T vx + Tx v
(7.23) ⇒
T vt + Tt v + T ΛT −1 (T vx + Tx v) + BT v = f
giving
vt + Λvx + Γv = g,
Γ = T −1 Tt + ΛT −1 Tx + T −1 BT, (7.24)
g = T −1 f.
The equations (7.24) are not any longer a decoupled system as in the case (7.21), but lead
to charachteristic equations for (7.23)
dx
= λi (x, t), i = 1, . . . , `.
dt
92 CHAPTER 7. HYPERBOLIC EQUATIONS
t
R = {(x, t) : x ≥ 0, t ≥ 0
ut + Aux = 0 i R
u=? u(x, 0) = f (x), x ≥ 0
wt + awx = 0.
w(x,t)=w(b,0)
w(x,t)=w(b,0)
q
x=at+b
x
x b
b a > 0. To be able to determine w(x, t) in
a ≤ 0. w(x, t) is uniquely determined in R we need to know w(x, 0), x ≥ 0 and
R if w(x, 0) is known for x ≥ 0. w(0, t), t ≥ 0.
Consider a system
) (
ut + Aux = 0, i R, vt + Λvx = 0 i R,
⇐⇒
u(x, 0) = f (x), x ≥ 0 A = T ΛT −1 , v(x, 0) = h(x), x ≥ 0.
u = T v,
h = T −1 f.
Let Λ = diag(λi )i=1:` and assume the eigenvalues are ordered such that λi > 0, i = 1, . . . , k
and λi ≤ 0, i = k + 1, . . . , ` (for a certain k). We get scalar equations
In this case vi (x, t) will be determined by vi (x, 0) = hi (x) for all i ≥ k + 1 (characteristics
pointing upwards towards left). To compute vi (x, t) in R with i ≤ k we need values of vi
along the t-axis. We can get such values by imposing k boundary conditions.
l
X
γij vj (0, t) = gi (t), i = 1 : k.
j=1
The equations must be solvable for {vi , i = 1, . . . , k} this means C = [γij ]i,j=1:k must be
non singular. This leads to the following initial/boundary value problem:
ut + Aux = 0 i R, Ati = λi ti , i = 1, . . . , `,
u(x, 0) = f (x), x ≥ 0, λi > 0, i = 1, . . . , k,
Bu(0, t) = g(t). B er k × `,
C = B · [t1 , · · · , tk ] is non singular.
Example.
(u1 )t − c2 (u2 )x = 0
u1 (x, 0) = f1 (x)
i R, , x ≥ 0.
(u2 )t − (u1 )x = 0 u2 (x, 0) = f2 (x)
β1 u1 (0, t) + β2 u2 (0, t) = g(t), t ≥ 0, −β1 c + β2 6= 0.
B u=g B u=g
0 0 1 1 ut + Aux = 0 i R,
u(x, 0) = f (x), 0 ≤ x ≤ 1,
B0 u(0, t) = g0 (t), t ≥ 0,
B1 u(1, t) = g1 (t), t ≥ 0.
Here B0 k × ` and B1 is m × `.
u=f
0 1 x
Lax-Wendroff and Wendroff for systems. We recall the Lax-Wendroff for the scalar
equation ut + aux = 0
n+1 n n 1
Um = Um − apµx δx Um + (ap)2 δx2 Um
n
2
where µx u(x, t) = 12 (u(x + h/2, t) + u(x − h/2, t)) is a averaging operator and δx u(x, t) =
u(x + h/2, t) − u(x − h/2, t) as always. Particularly we note that
n n n 1 n n 1 n n 1 n n
µx δx Um = µx (Um+1/2 − Um−1/2 ) = (Um+1 + Um ) − (Um + Um−1 ) = (Um+1 − Um−1 ).
2 2 2
94 CHAPTER 7. HYPERBOLIC EQUATIONS
We formulate now the Lax-Wendroff method for a system of equations ut + Aux = 0 where
the matrix A ∈ R`×` is constant and Um
n ∈ R` for all m and n
n+1 n n p2 2 2 n
Um = Um − pAµx δx Um + A δx Um , (7.25)
2
this is a straigtforward generalization. But we let now A = A(x, t) depend on x and t, and
get
We consider now stability for constant A, and generalize the Von Neumann-condition
to systems. We present only the procedure which is based on taking
n
Um = eiβxm Gn U 0
and substitute it in the difference method. Now G ∈ R`×` is a matrix, often called
amplification matrix, β ∈ R is an arbitrary frequency, and U 0 ∈ R` an arbitrary vector.
We substitute this expression into (7.25), and we get
A = T ΛT −1 , Λ = diag(λ1 , . . . , λ` ).
then the matrix T diagonalizes both A and G. So the eigenvalues of G are on the mid
diagonal factor, they are
The expression for µj is then exactly the same as for ξ in the scalar stability analysis for
the Lax-Wendroff method, only a is replaced by λj on the right hand side. The same
analysis goes through when we require |µj | ≤ 1, and we obtain the condition p|λj | ≤ 1 for
all j, i.e.
ρ(A) p ≤ 1,
which is the stability condition for Lax-Wendroff applied to systems with A constant.
A necessary condition for stability for variable A is that ρ(A(x, t)) p ≤ 1 for all (x, t)
where the method is used.
7.6. HYPERBOLIC SYSTEMS OF FIRST ORDER EQUATIONS 95
Initial/boundary value problem for systems of two equations. The wave equation
φtt = φxx can be rewritten in the form of a system as in (7.22), with c = 1 the equation
becomes
u1 0 −1 u1
+ · = 0.
u2 t −1 0 u2 x
Here A has eigenvalues λ1 = 1 and λ2 = −1, so a family of characteristics points towards
left and the other points towards right as in the picture at page 92. So it is necessary to
specify only one boundary condition. The boundary/initial conditions can for example be
u(x, 0) = f (x), x ≥ 0
v(x, 0) = g(x), x ≥ 0
u(0, t) = φ(t), t ≥ 0.
Let us for example chose the Lax-Wendroff method as difference method. We let
U n 0 −1
n m
Wm = , A= .
Vmn −1 0
The method becomes then
p2
n+1
Wm = I − pAµx δx + A2 δx2 n
Wm . (7.27)
2
Assume now that Wmn is known for all m ≥ 0 and a n ≥ 0. We can use (7.27) to find W n+1
m
for m ≥ 1. What about W0n+1 ?
U0n+1 = φ(tn+1 ) OK, the problem is V0n+1 .
To obtain V0n+1 we propose two alternatives
96 CHAPTER 7. HYPERBOLIC EQUATIONS
Note that V1n+1 is obtained from (7.27). Higher order approximations of the deriva-
tive can also be used,
u(x, t) = eiβ(x−at) .
7.7. DISSIPATION AND DISPERSION 97
The solution u is a wave with amplitude 1 and wave length λ = 2π/β, moving with speed
a along the x-axis. Let us now apply a difference method to this equation with the same
initial function. This gives a numerical approximation
n
Um = ξ n eiβxm ,
as we have already seen in the case of Von Neumann stability. Here ξ is a complex number
depending on β, as one can find by substituting the expression above in the differential
equation. In the sequel it is useful to write ξ in polar form
ξ = |ξ| e−iϕ .
Let us define the number α by requiring ϕ = β α k where k is the time-step, so α = ϕ/(βk).
We find
ξ n = |ξ|n e−i n ϕ = |ξ|n e−i n k α β = |ξ|n e−i β α tn
and so we obtain the following expression for the numerical and the exact solution
n
Um = |ξ|n ei β(xm −αtn ) ,
Earlier we have used |ξ| ≤ 1 as stability condition. The strict inequality is considered in
the following definition.
Dissipation. If there is an upper bound for the time-step k0 > 0 and a constant σ > 0
such that
|ξ| ≤ 1 − σ(βh)2s for |βh| ≤ π
and all k ≤ k0 , the difference formula is dissipative of order 2s.
Example. Let us use the definitions on the Lax-Wendroff method. From earlier analysis
we have (with θ = βh)
2 2 2 θ
ξ = 1 − i ap sin θ − (ap) (1 − cos θ) = 1 − 2r sin − i r sin θ, r = ap.
2
From the stability analysis for the Lax-Wendroff method we found the expression
θ
|ξ|2 = 1 − q sin4 , q = 4r2 (1 − r2 ). (7.28)
2
As earlier shown, we see that |ξ| ≤ 1 if and only if |r| ≤ 1, but the question is how |ξ|
behaves for 0 < |r| < 1, case when 0 < q ≤ 1. Let us assume that if x is a number such
that x ≤ 1 then
1 x √ x
1 − x ≤ 1 − x + x2 = (1 − )2 ⇒ 1−x≤1−
4 2 2
98 CHAPTER 7. HYPERBOLIC EQUATIONS
θ
Taking the square root of (7.28) and letting x = q sin4
2 we get
q sin(θ/2) 4 4
q θ
|ξ| ≤ 1 − sin4 =1− θ .
2 2 2 θ
2(ap)2 (1 − (ap)2 )
We conclude that Lax-Wendreoff is dissipative of order 4 with σ = .
π4
If we analyze now the dispersion, we find that
r sin θ
ϕ = α β k = arctan .
1 − 2r2 sin2 (θ/2)