A Concise Introduction To Numerical Analysis
A Concise Introduction To Numerical Analysis
A Concise Introduction To Numerical Analysis
Analysis
Douglas N. Arnold
Author address:
Institute for Mathematics and its Applications, 400 Lind Hall, 207 Church
Street S.E., University of Minnesota, Minneapolis, MN 55455
E-mail address: [email protected]
URL: http://www.ima.umn.edu/~ arnold/
1991 Mathematics Subject Classification. Primary 65-01.
1999,
c 2000, 2001 by Douglas N. Arnold. All rights reserved. Not to be disseminated
without explicit permission of the author.
Preface
These notes were prepared for use in teaching a one-year graduate level introductory
course on numerical analysis at Penn State University. The author taught the course during
the 1998–1999 academic year (the first offering of the course), and then again during the
2000–2001 academic year. They are still being put into final form, and cannot be used
without express permission of the author.
Douglas N. Arnold
iii
iv PREFACE
Contents
Preface iii
Chapter 1. Approximation and Interpolation 1
1. Introduction and Preliminaries 1
2. Minimax Polynomial Approximation 4
3. Lagrange Interpolation 15
4. Least Squares Polynomial Approximation 23
5. Piecewise polynomial approximation and interpolation 27
6. Piecewise polynomials in more than one dimension 34
7. The Fast Fourier Transform 44
Exercises 49
Bibliography 53
Chapter 2. Numerical Quadrature 55
1. Basic quadrature 55
2. The Peano Kernel Theorem 57
3. Richardson Extrapolation 60
4. Asymptotic error expansions 61
5. Romberg Integration 65
6. Gaussian Quadrature 67
7. Adaptive quadrature 71
Exercises 74
Chapter 3. Direct Methods of Numerical Linear Algebra 77
1. Introduction 77
2. Triangular systems 78
3. Gaussian elimination and LU decomposition 79
4. Pivoting 82
5. Backward error analysis 83
6. Conditioning 87
Exercises 88
Chapter 4. Numerical solution of nonlinear systems and optimization 91
1. Introduction and Preliminaries 91
2. One-point iteration 92
3. Newton’s method 94
4. Quasi-Newton methods 96
5. Broyden’s method 97
v
vi CONTENTS
n
X 1/p
p
kxklp = |xi | , kxkl∞ = sup |xi |.
1≤i≤n
i=1
1
2 1. APPROXIMATION AND INTERPOLATION
Figure 1.1. The best approximation depends on the norm in which we mea-
sure the error.
(The triangle inequality for the lp norm is called Minkowski’s inequality.) If wi > 0, i =
1, . . . , n, we can define the weighted lp norms
X n 1/p
kxkw,p = wi |xi |p , kxkw,∞ = sup wi |xi |.
1≤i≤n
i=1
The various lp norms are equivalent in the sense that there is a positive constant C such that
kxklp ≤ Ckxklq , kxklq ≤ Ckxklp , x ∈ Rn .
Indeed all norms on a finite dimensional space are equivalent. Note also that if we extend the
weighted lp norms to allow non-negative weighting functions which are not strictly positive,
we get a seminorm rather than a norm.
(2) Let I = [0, 1] be the closed unit interval. We define C(I) to be the space of continuous
functions on I with the L∞ norm,
kf kL∞ (I) = sup |f (x)|.
x∈I
Obviously we can generalize I to any compact interval, or in fact any compact subset of Rn
(or even more generally). Given a positive bounded weighting function w : I → (0, ∞) we
may define the weighted norm
kf kw,∞ = sup[w(x)|f (x)|].
x∈I
(5) If n ∈ N, 1 ≤ p < ∞, we define the Sobolev seminorm |f |Wpn := kf (n) kLp , and the
Sobolev norm by
n
X
kf k Wpn := ( |f |pW k )1/p .
p
k=0
We are interested in the approximaton of a given function f , defined, say on the unit
interval, by a “simpler” function, namely by a function belonging to some particular subspace
S of C n which we choose. (In particular, we will be interested in the case S = Pn (I), the
vector space of polynomials of degree at most n restricted to I.) We shall be interested in
two sorts of questions:
• How good is the best approximation?
• How good are various computable approximation procedures?
In order for either of these questions to make sense, we need to know what we mean by
good. We shall always use a norm (or at least a seminorm) to specify the goodness of the
approximation. We shall take up the first question, the theory of best approximation, first.
Thus we want to know about inf p∈P |f − p| for some specified norm.
Various questions come immediately to mind:
• Does there exist p ∈ P minimizing kf − pk?
• Could there exist more than one minimizer?
• Can the (or a) minimizer be computed?
• What can we say about the error?
The answer to the first question is affirmative under quite weak hypotheses. To see this,
we first prove a simple lemma.
Lemma 1.1. Let there be given a normed vector space X P
and n + 1 elements f0 , . . . , fn
of X. Then the function φ : R → R given by φ(a) = kf0 − ni=1 ai fi k is continuous.
n
Proof. We easily deduce from the triangle inequality that |kf k − kgk| ≤ kf − gk.
Therefore
X
X X
|φ(a) − φ(b)| ≤
(ai − bi )fi
≤ |ai − bi |kfi k ≤ M |ai − bi |,
where M = maxkfi k.
Theorem 1.2. Let there be given a normed vector space X and a finite dimensional
vector subspace P . Then for any f ∈ X there exists p ∈ P minimizing kf − pk.
Proof. Let f1 , . . . , fn be a basis for P . The map a 7→ k ni=1 ai fi k is then a norm on
P
Rn . Hence it is equivalent to any other norm, and so the set
X
n
i
S = {a ∈ R |
ai f
≤ 2kf k },
4 1. APPROXIMATION AND INTERPOLATION
which is impossible.
R
Exercise: a) Using the integral (kf k2 g − kgk2 f )2 , prove the Cauchy-Schwarz inequality:
R1
if f, g ∈ C(I) then 0 f (x)g(x) dx ≤ kf k2 kgk2 with equality if and only if f ≡ 0, g ≡ 0, or
f = cg for some constant c > 0. b) Use this to show that the triangle inequality is satisfied
by the 2-norm, and c) that the 2-norm is strictly convex.
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
The weighting functions nk xk (1 − x)n−k entering the definition of Bn f are shown in Fig-
ure 1.2. Note that for x near k/n, the weighted average weighs f (k/n) more heavily than
other values. Notice also that B1 f (x) = f (0)(1 − x) + f (1)x is just the linear polynomial
interpolating f at x = 0 and x = 1.
Now Bn is a linear map of C(I) into Pn . Moreover, it follows immediately from the
positivity of the Bernstein weights that Bn is a positive operator in the sense that Bn f ≥ 0
on I if f ≥ 0 on I. Now we wish to show that Bn f converges to f in C(I) for all f ∈ C(I).
Remarkably, just using the fact Bn is a positive linear operator, this follows from the much
more elementary fact that Bn f converges to f in C(I) for all f ∈ P2 (I). This latter fact
we can verify by direct computation. Let fi (x) = xi , so we need to show that Bn fi → fi ,
i = 0, 1, 2. (By linearity the result then extends to all f ∈ P2 (I). We know that
n
X n k n−k
a b = (a + b)n ,
k=0
k
and by differentiating twice with respect to a we get also that
n n
X k n k n−k n−1
X k(k − 1) n k n−k
a b = a(a + b) , a b = a2 (a + b)n−2 .
k=0
n k k=0
n(n − 1) k
Setting a = x, b = 1 − x, expanding
k(k − 1) n k2 1 k
= −
n(n − 1) n − 1 n2 n − 1 n
in the last equation, and doing a little algebra we get that
n−1 1
Bn f0 = f0 , Bn f1 = f1 , Bn f2 = f2 + f1 ,
n n
for n = 1, 2, . . . .
Now we derive from this convergence for all continuous functions.
Theorem 1.5. Let B1 , B2 , . . . be any sequence of linear positive operators from C(I) into
itself such that Bn f converges uniformly to f for f ∈ P2 . Then Bn f converges uniformly to
f for all f ∈ C(I).
Proof. The idea is that for any f ∈ C(I) and x0 ∈ I we can find a quadratic function
q that is everywhere greater than f , but for which q(x0 ) is close to f (x0 ). Then, for n
sufficiently large Bn q(x0 ) will be close to q(x0 ) and so close to f (x0 ). But Bn f must be less
6 1. APPROXIMATION AND INTERPOLATION
than Bn q. Together these imply that Bn f (x0 ) can be at most a little bit larger than f (x0 ).
Similarly we can show it can be at most a little bit smaller than f (x0 ).
Since f is continuous on a compact set it is uniformly continuous. Given > 0, choose
δ > 0 such that |f (x1 ) − f (x2 )| ≤ if |x1 − x2 | ≤ δ. For any x0 , set
q(x) = f (x0 ) + + 2kf k∞ (x − x0 )2 /δ 2 .
Then, by checking the cases |x − x0 | ≤ δ and |x − x0 | ≥ δ separately, we see that q(x) ≥ f (x)
for all x ∈ I.
Writing q(x) = a + bx + cx2 we see that we can write |a|, |b|, |c| ≤ M with M depending
on kf k, , and δ, but not on x0 . Now we can choose N sufficiently large that
kfi − Bn fi k ≤ , i = 0, 1, 2,
M
for n ≥ N , where fi = xi . Using the triangle inequality and the bounds on the coefficients
of q, we get kq − Bn qk ≤ 3. Therefore
Bn f (x0 ) ≤ Bn q(x0 ) ≤ q(x0 ) + 3 = f (x0 ) + 4.
Thus we have shown: given f ∈ C(I) and > 0 there exists N > 0 such that Bn f (x0 ) ≤
f (x0 ) + 4 for all n ≥ N and all x0 ∈ I.
The same reasoning, but using q(x) = f (x0 ) − − 2kf k∞ (x − x0 )2 /δ 2 implies that
Bn f (x0 ) ≥ f (x0 ) − 4, and together these complete the theorem.
From a practical point of view the Bernstein polynomials yield an approximation proce-
dure which is very robust but very slow. By robust we refer to the fact that the procedure
convergence for any continuous function, no matter how bad (even, say, nowhere differ-
entiable). Moreover if the function is C 1 then not only does Bn f converge uniformly to
f , but (Bn f )0 converges uniformly to f 0 (i.e., we have convergence of Bn f in C 1 (I), and
similarly if f admits more continuous derivatives. However, even for very nice functions
the convergence is rather slow. Even for as simple a function as f (x) = x2 , we saw that
kf − Bn f k = O(1/n). In fact, refining the argument of the proof, one can show that this
same linear rate of convergence holds for all C 2 functions f :
1 00
kf − Bn f k ≤ kf k, f ∈ C 2 (I).
8n
this bound holds with equality for f (x) = x2 , and so cannot be improved. This slow rate
of convergence makes the Bernstein polynomials impractical for most applications. See
Figure 1.3 where the linear rate of convergence is quite evident.
2.2. Jackson’s theorems for trigonometric polynomials. In the next sections we
address the question of how quickly a given continuous function can be approximated by a
sequence of polynomials of increasing degree. The results were mostly obtained by Dunham
Jackson in the first third of the twentieth century and are known collectively as Jackson’s
theorems. Essentially they say that if a function is in C k then it can be approximated by a
sequence of polynomials of degree n in such a way that the error is at most C/nk as n → ∞.
Thus the smoother a function is, the better the rate of convergence.
Jackson proved this sort of result both for approximation by polynomials and for ap-
proximation by trigonometric polynomials (finite Fourier series). The two sets of results
2. MINIMAX POLYNOMIAL APPROXIMATION 7
0.8 32
0.6 16
0.4 1
8
0.2
4
0
−0.2
2
−0.4
−0.6
−0.8
−1
0 1 2 3 4 5 6 7 8
are intimately related, as we shall see, but it is easier to get started with the results for
trigonometric polynomials, as we do now.
k
Let C2π be the set of 2π-periodic continuous functions on the real line, and C2π the set of
k
2π-periodic functions which belong to C (R). We shall investigate the rate of approximation
of such functions by trigonometric polynomials of degree n. By these we mean linear combi-
nations of the n + 1 functions 1, cos kx, sin kx, k = 1, . . . , n, and we denote by Tn the space
of all trigonometric polynomials of degree n, i.e., the span of these of the 2n + 1 functions.
Using the relations sin x = (eix − e−ix )/(2i), cos x = (eix + e−ix )/2, we can equivalently write
n
X
Tn = { ck eikx | ck ∈ C, c−k = c̄k }.
k=−n
1
Our immediate goal is the Jackson Theorem for the approximation of functions in C2π
by trigonometric polynomials.
1
Theorem 1.6. If f ∈ C2π , then
π
inf kf − pk ≤ kf 0 k.
p∈Tn 2(n + 1)
(We are suppressing the subscript on the L∞ norm, since that is the only norm that
we’ll be using in this section.) The proof will be quite explicit. We start
R π by writing f (x) as
an integral of f 0 times an appropriate kernel. Consider the integral −π yf 0 (x + π + y) dy.
Integrating by parts and using the fact that f is 2π-periodic we get
Z π Z π
0
yf (x + π + y) dy = − f (x + π + y) dx + 2πf (x).
−π −π
8 1. APPROXIMATION AND INTERPOLATION
The integral on the right-hand side is just the integral of f over one period (and so indepen-
dent of x), and we can rearrange to get
Z π
¯ 1
f (x) = f + yf 0 (x + π + y) dy,
2π −π
where f¯ is the average value of f over any period. Now suppose P we replace the function y
in the last integral with a trigonometric polynomial qn (y) = nk=−n ck eiky . This gives
Z π Z π n
X Z π
0 0
qn (y)f (x + π + y) dy = qn (y − π − x)f (y) dy = ck eik(y−π) f 0 (y) dy e−ikx ,
−π −π k=−n −π
Thus to obtain a bound on the error, we need only give a bound on the L1 error in trigono-
metric polynomial approximation to the function g(y) = y on [−π, π]. (Note that, since we
are working in the realm of 2π periodic functions, g is the sawtooth function.)
Lemma 1.7. There exists qn ∈ Tn such that
Z π
π2
|x − qn (x)| dx ≤ .
−π n+1
This we shall prove quite explicitly, by exhibiting qn . Note that the Jackson theorem,
Theorem 1.6 follows directly from (1.1) and the lemma.
Proof. To prove the Lemma, we shall determine qn ∈ Tn by the 2n + 1 equations
πk πk
qn = , k = −n, . . . , n.
n+1 n+1
That, is, qn interpolates the saw tooth function at the n + 1 points with abscissas equal to
πk/(n + 1). See Figure 1.4.
This defines qn uniquely. To see this it is enough to note that if a trigonometric polynomial
of degree n vanishes at 2n + 1 distinct points in [−π, π) it vanishes P identically. This is
so because if nk=−n ck eikx vanishes at xj , j = −n, . . . , n, then z n nk=−n ck z k , which is a
P
polynomial of degree 2n, vanishes at the 2n+1 distinct complex numbers eixj , so is identically
zero, which implies that all the ck vanish.
Now qn is odd, since replacing qn (x) with Pn −qn (−x) would give another solution, which
then must coincide with qn . Thus qn (x) = k=1 bk sin kx.
To get a handle on the error x − qn (x) we first note that by construction this function
has 2n + 1 zeros in (−π, π), namely at the points πk/(n + 1). It can’t have any other zeros or
any double zeros in this interval, for if it did Rolle’s Theorem would imply that its derivative
1 − qn0 ∈ Tn , would have 2n + 1 zeros in the interval, and, by the argument above, would
2. MINIMAX POLYNOMIAL APPROXIMATION 9
3 3
0 0
−3 −3
−pi 0 pi −pi 0 pi
vanish identically, which is not possible (it has mean value 1). Thus qn changes sign exactly
at the points πk/(n + 1).
Define the piecewise constant function
kπ (k + 1)π
s(x) = (−1)k , ≤x< , k ∈ Z.
n+1 n+1
Then
Z π Z
|x − qn (x)| dx = [x − qn (x)]s(x) dx.
−π
k
Theorem 1.8. If f ∈ C2π , some k > 0, then
k
π
inf kf − pk ≤ kf (k) k.
p∈Tn 2(n + 1)
Proof. We shall use induction on k, the case k = 1 having been established. Assuming
the result, we must show it holds when k is replaced by k + 1. Now let q ∈ Tn be arbitrary.
Then
k
π
inf kf − pk = inf kf − q − pk ≤ k(f − q)(k) k,
p∈Tn p∈Tn 2(n + 1)
by the inductive hypothesis. Since q is arbitrary and { p(k) | p ∈ Tn } = T̂n ,
k k
π (k) π π
inf kf − pk ≤ inf kf − rk ≤ kf (k+1) k.
p∈Tn 2(n + 1) r∈T̂n 2(n + 1) 2(n + 1)
2.3. Jackson theorems for algebraic polynomials. To obtain the Jackson theorems
for algebraic polynomials we use the following transformation. Given f : [−1, 1] → R define
g : R → R by g(θ) = f (cos θ). Then g is 2π-periodic and even. This transformation is a linear
isometry (kgk = kf k). Note that if f ∈ C 1 ([−1, 1]) then g ∈ C2π
1
and g 0 (θ) = −f 0 (cos θ) sin θ,
0 0 −ix
so kg k ≤ kf k. Also if f (x) = x , then g(θ) = [(e + e )/2]n which is a trigonometric
n ix
polynomial of degree at most n. Thus this transformation maps Pn ([−1, 1]) to the Tneven , the
subspace of even functions in Tn , or, equivalently, the span of cos kx, k = 0, . . . , n. Since
dim Tneven = dim Pn ([−1, 1]) = n + 1, the transformation is in fact an isomorphism.
The Jackson theorem in C 1 ([−1, 1]) follows immediately from that in C2π 1
:
Theorem 1.9. If f ∈ C 1 ([−1, 1]), then
π
inf kf − pk ≤ kf 0 k.
p∈Pn 2(n + 1)
1
Proof. Define g(θ) = f (cos θ) so g ∈ C2π . Since g is even, inf q∈Tneven kg−qk = inf q∈Tn kg−
qk. (If the second infimum is achieved by q(θ), then it is also achieved by q(−θ), then use
the triangle inequality to show it is also achieved by the even function [q(θ) + q(−θ)]/2.)
Thus
π π
inf kf − pk = inf kg − qk ≤ kg 0 k ≤ kf 0 k.
p∈Pn q∈Tn 2(n + 1) 2(n + 1)
You can’t derive the Jackson theorem in C k ([−1, 1]) from that in C2π k
(since we can’t
bound kg (k) k by kf (k) k for k ≥ 2), but we can use a bootstrap argument directly. We know
that
π
inf kf − pk = inf inf kf − q − pk ≤ inf kf 0 − q 0 k.
p∈Pn q∈Pn p∈Pn q∈Pn 2(n + 1)
so, in all, nk ≤ ek M where ek = max(2k , dk ). Thus we have arrived at the Jackson theorem
in C k :
Theorem 1.10. Let k be a positive integer, n ≥ k − 1 an integer. Then there exists a
constant c depending only on k such that
c
inf kf − pk ≤ k kf (k) k.
p∈Pn n
for all f ∈ C k ([−1, 1]).
2.4. Polynomial approximation of analytic functions. If a function is C ∞ the
Jackson theorems show that the best polynomial approximation converges faster than any
power of n. If we go one step farther and assume that the function is analytic (i.e., its
power series converges at every point of the interval including the end points), we can prove
exponential convergence.
We will first do the periodic case and show that the Fourier series for an analytic periodic
function converges exponentially, and then use the Chebyshev transform to carry the result
over to the algebraic case.
A real function on an open interval is called real analytic if the function is C ∞ and for
every point in the interval the Taylor series for the function about that point converges to
the function in some neighborhood of the point. A real function on a closed interval J is
real analytic if it is real analytic on some open interval containing J.
It is easy to see that a real function is real analytic on an interval if and only if it extends
to an analytic function on a neighborhood of the interval in the complex plane.
Suppose that g(z) is real analytic and 2π-periodic on R. Since g is smooth and periodic
its Fourier series,
∞ Z π
X 1
g(x) = inx
an e , an = g(x)e−inx dx,
n=−∞
2π −π
we see that we can shift the segment [−π, π] on which we integrate to define the Fourier
coefficients upward or downward a distance δ in the complex plane:
Z π
e±nδ π
Z
1 −in(x±iδ)
an = g(x ± iδ)e dx = g(x ± iδ)e−inx dx.
2π −π 2π −π
Thus |an | ≤ kgkL∞ (Sδ ) e−δ|n| and we have shown that the Fourier coefficients of a real analytic
periodic function decay exponentially.
Now consider the truncated Fourier series q(z) = nk=−n ak eikz ∈ Tn . Then g(z) − q(z) =
P
ikz
P
|k|>n ak e , so for any real z
∞
X X 2e−δ
|g(z) − q(z)| ≤ |ak | ≤ 2kgkL∞ (Sδ ) e−δk = kgkL∞ (Sδ ) e−δn .
1 − e−δ
|k|>n k=n+1
The algebraic case follows immediately from the periodic one. If f is real analytic on
[−1, 1], then g(θ) = f (cos θ) is 2π-periodic and real analytic. Since inf q∈Tn kg − qk∞ =
inf q∈Tneven kg − qk∞ = inf p∈Pn kf − pk∞ , we can apply the previous result to bound the latter
quantity by Ce−δn .
Theorem 1.12. Let f be real analytic on a closed interval. Then there exist positive
constants C and δ so that
inf kf − pk∞ ≤ Ce−δn .
p∈Pn
While the above result applies to approximation by any finite dimensional subspace P ,
we now add the extra ingredient that P = Pn ([a, b]) the space of polynomial functions of
degree at most n on a compact interval J = [a, b].
Theorem 1.14 (Chebyshev Alternation Theorem). Let f ∈ C([a, b]), p ∈ Pn . Then p
is a best approximation to f in Pn if and only if f − p achieves its maximum magnitude at
n + 2 distinct points with alternating sign.
Proof. If f −p achieves its maximum magnitude at n+2 distinct points with alternating
sign, then certainly no function q ∈ Pn has the same sign as f − p on its extreme set (since
a nonzero element of Pn cannot have n + 1 zeros). So p is a best approximation to f in Pn .
Conversely, suppose that f − p changes sign at most n + 1 times on its extreme set. For
definiteness suppose that f − p is positive at its first extreme point. Then we can choose
n points x1 < x2 < · · · xn in [a, b] such that f − p is positive on extreme points less than
x1 , negative on extreme points in on [x1 , x2 ], positive on extreme points in [x2 , x3 ], etc. The
function q(x) = (x1 − x) · · · (xn − x) ∈ Pn then has the same sign as f − p on its extreme
set, and so p is not a best approximation to f in Pn .
1 .33
0 0
−1 −.33
degree 4 error
1 .1
0 0
−1 −.1
Remarks. 1. The only properties we used of the space Pn are (1) that no non-zero
element has more than n zeros, and (2) given any n points there is an element with exactly
those points as the zeros. These two conditions together (which are equivalent to the exis-
tence and uniqueness of an interpolant at n + 1 points, as discussed in the next section) are
referred to as the Haar property. Many other subspaces satisfy the Haar property, and so
we can obtain a Chebyshev Alternation Theorem for them as well.
2. The Chebyshev alternation characterization of the best approximation can be used
as the basis for a computational algorithm to approximate the best approximation, known
as the exchange algorithm or Remes algorithm. However in practice something like the
interpolant at the Chebyshev points, which, as we shall see, is easy to compute and usually
gives something quite near best approximation, is much more used.
3. LAGRANGE INTERPOLATION 15
Figure 1.6. The Lagrange basis functions for 6 equally space points and 4
unequally spaced points.
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−1 −1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
3. Lagrange Interpolation
3.1. General results. Now we consider the problem of not just approximating, but
interpolating a function at given points by a polynomial. That is, we suppose given n + 1
distinct points x0 < x1 < · · · < xn and n + 1 values y0 , y1 , . . . , yn . We usually think of the
yi as the value f (xi ) of some underlying function f , but this is not necessary. In any case,
there exists a P unique polynomial p ∈ Pn such that p(xi ) = yi . To prove this, we notice that if
we write p = ni=0 ci xi , then the interpolation problem is a system of n + 1 linear equations
in the n + 1 unknowns ci . We wish to show that this system is non-singular. Were it not,
there would exists a non-zero polynomial in Pn vanishing at the xi , which is impossible, and
the uniqueness and existence is established. (A more algebraic proof consists of writing out
the matrix of the linear systemQexplicitly. It is a Vandermonde system, whose determinant
can be computed explicitly as i<j (xi − xj ).)
The polynomial p is called the Lagrange interpolant of the values yi at the points xi . If
the yi = f (xi ) for some function f , we call p the Lagrange interpolant of f at the xi .
While the proof of existence of a Lagrange interpolating polynomial just given was indi-
rect, it is also straightforward to derive a formula for the solution. Lagrange’s formula states
that
Xn Y x − xm
p(x) = yk ,
k=0
x − xm
0≤m≤n k
m6=k
and is easily verified. Note that we have expressed the solution not as a linear combination
of the monomials xi , but rather as a linear combination of the Lagrange basis functions
Y x − xm
lkn (x) = ,
x − xm
0≤m≤n k
m6=k
plotted in Figure 1.6. We don’t have to solve a linear system to find the coefficients in this
basis: they are simply the yi . It is instructive to compare the Lagrange basis functions with
the Bernstein weighting functions plotted in Figure 1.2. In each case the sum of all the basis
functions is identically 1 (prove this for the Lagrange basis functions).
Our first result is a straightforward application of calculus to obtain an error formula for
Lagrange interpolation to a smooth function.
16 1. APPROXIMATION AND INTERPOLATION
One possibility is to make a very strong assumption on f , namely that f is real analytic
on [a, b]. Now if f is analytic on the closed disk B̄(ξ, R) of radius R about ξ, then, by
Cauchy’s estimate, |f (n+1) (ξ)| ≤ (n + 1)!kf k∞,B̄(ξ,R) /Rn+1 . Let O(a, b, R) denote the oval
S
ξ∈[a,b] B̄(ξ, R). We then have
Theorem 1.17. Let a < b and suppose that f extends analytically to the oval O(a, b, R)
for some R > 0. Let x0 < · · · < xn be any set of n + 1 distinct points in [a, b] and let p be
the Lagrange interpolating polynomial to f at the xi . Then
n+1
|b − a|
kf − pk∞,[a,b] ≤ kf k∞,O(a,b,R) .
R
This shows that if the domain of analyticity of f contains O(a, b, R) for some R > |b − a|,
then for any choice of interpolating tableau, the pn converge to f exponentially fast in
C([a, b]). See Figure 1.7 In particular if the function f is entire, this will occur.
However, even if f is real analytic on [a, b], the pn need not converge to f if a pole lies
nearby in the complex plane. A famous example using equally spaced interpolation points
was given by Runge: a = −5, b = 5, xni = −5 + 10i/n, f (x) = 1/(1 + x2 ). In this case he
proved the existence of a number κ ≈ 3.63338 such that limn→∞ pn (x) = f (x) if and only if
|x| < κ. Figure 1.8 contrasts the striking non-convergence of Lagrange interpolation using
equally spaced points in this case, with the convergence that partakes for the entire Gaussian
function f (x) = exp(2x2 /5).
If the function is not smooth, the results may be even worse: in 1918 S. Bernstein proved
that equidistant interpolation to f (x) = |x| on [−1, 1] does not converge at any point except
x = −1, 0, and 1.
Fortunately, as we shall see in the next subsection, there exist much better choices of
interpolation points than equally spaced ones. But in 1914 Faber showed that no choice of
points works for all continuous functions.
18 1. APPROXIMATION AND INTERPOLATION
1 1
0.5 0.5
0 0
−0.5 −0.5
−5 0 5 −5 0 5
x00
x10 x11
x20 x21 x22
..
.
in [a, b] and a continuous function f (x) on [a, b], let pn (x) be the polynomial of degree ≤ n
which interpolates f at the n + 1 points xn0 , xn1 , . . . , xnn . Then no matter how the points are
chosen, there exists a continuous function f for which the pn do not converge uniformly to
f.
In 1931 Bernstein strengthened this negative theorem to show that there exists a con-
tinuous function f and a point c in [a, b] for which pn (c) does not converge to f (c). In 1980
Erdös and Vértesi showed that in fact there exists a continuous function f such that pn (c)
does not converge to f (c) for almost all c in [a, b].
However, as we shall now show, if the function f is required to have a little smoothness,
and if the interpolation points are chosen well, then convergence will be obtained.
3.2. The Lebesgue constant. Given n + 1 distinct interpolation points in [a, b] and
f ∈ C([a, b]), let Pn f ∈ Pn be the Lagrange interpolating polynomial. Then Pn is an operator
from C([a, b]) to itself, and we may consider its norm:
Figure 1.9. Lebesgue function for degree 8 interpolation at equally spaced points.
12
10
−2
−4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Using this norm, it is easy to relate the error in interpolation to the error in best approxi-
mation:
kf − Pn f k = inf kf − q − Pn (f − q)k ≤ (1 + kPn k) inf kf − qk.
q∈Pn q∈Pn
Note that the only properties of Pn we have used to get this estimate are linearity and the
fact that it preserves Pn .
Thus, if we can bound kPn k we can obtain error estimates for interpolation from those
for best approximation (i.e., the Jackson theorems). Now let
Y x − xm
lkn (x) =
x − xm
0≤m≤n k
m6=k
Pn n
denote the Lagrange basis functions. Recall that k=0 lk (x) = 1. Set
n
X
Ln (x) = |lkn (x)|,
k=0
Figure 1.9 shows the Lebesgue function for interpolation by a polynomial of degree 8 us-
ing equally spaced interpolation points plotted together with the Lagrange basis functions
entering into its definition.
The constant kPn k = kLn k∞ is called the Lebesgue constant of the interpolation opera-
tor. Of course it depends on the point placement. However it only depends on the relative
configuration: if we linearly scale the points from the interval [a, b] to another interval, then
the constant doesn’t change. Table 1.1 shows the Lebesgue constants for equally spaced
interpolation points ranging from a to b. Note that the constant grows quickly with n re-
flecting the fact that the approximation afforded by the interpolant may be much worse than
20 1. APPROXIMATION AND INTERPOLATION
n Equal Chebyshev
2 1.25 1.67
4 2.21 1.99
6 4.55 2.20
8 11.0 2.36
10 29.9 2.49
12 89.3 2.60
14 283 2.69
16 935 2.77
18 3,170 2.84
20 11,000 2.90
the best approximation. The column labelled “Chebyshev” shows the Lebesgue constant if a
better choice of points, the Chebyshev points, is used. We study this in the next subsection.
It is not clear from the table whether the Lebesgue constant remains bounded for inter-
polation at the Chebyshev points, but we know it does not: otherwise the Chebyshev points
would give a counterexample to Faber’s theorem. In fact Erdös proved a rather precise lower
bound on growth rate.
Theorem 1.19. [Erdös 1961] For any triangular array of points, there is a constant c
such that corresponding Lebesgue constant satisfies
2
kPn k ≥ log n − c.
π
This result was known well earlier, but with a less precise constant. See, e.g., Rivlin’s
Introduction to the Approximation of Functions [5] for an elementary argument.
3.3. The Chebyshev points. Returning to the error formula for Lagrange interpola-
tion we see that a way to reduce the error is to choose the interpolation points xi so as to
decrease ω(x) = (x − x0 ) . . . (x − xn ). Assuming that we are interested in reducing the error
on all of [a, b], we are led to the problem of finding x0 < · · · < xn which minimize
(1.4) sup |(x − x0 ) . . . (x − xn )|.
a≤x≤b
In fact, we can solve this problem in closed form. First consider the case [a, b] = [−1, 1].
Define Tn (x) = cos(n arccos x) ∈ Pn ([−1, 1]), the polynomial which corresponds to cos nθ
under the Chebyshev transform. Tn is called the nth Chebyshev polynomial:
T0 (x) = 1, T1 (x) = x, T2 (x) = 2x2 − 1, T3 (x) = 4x3 − 3x, T4 (x) = 8x4 − 8x2 + 1, . . .
Using trigonometric identities for cos(n ± 1)x, we get the recursion relation
Tn+1 (x) = 2xTn (x) − Tn−1 (x),
from which it easily follows that Tn (x) is a polynomial of exact degree n with leading coef-
ficient 2n−1 .
3. LAGRANGE INTERPOLATION 21
Now let xni = cos[(2i + 1)π/(2n + 2)]. Then it is easy to see that 1 > xn0 > xn1 > · · · >
xnn> −1 and that these are precisely the n + 1 zeros of Tn+1 . These are called the n + 1
Chebyshev points on [−1, 1]. The definition is illustrated for n = 8 in Figure 1.10. The next
theorem shows that the Chebyshev points minimize (1.4).
Theorem 1.20. For n ≥ 0, let x0 , x1 , . . . xn ∈ R and set ω(x) = (x − x0 ) . . . (x − xn ).
Then
sup |ω(x)| ≥ 2−n ,
a≤x≤b
Proof. First assume that the xi are the n+1 Chebyshev points. Then ω and Tn+1 are two
polynomials of degree n + 1 with the same roots. Comparing their leading coefficients we see
that ω(x) = 2−n Tn+1 (x) = 2−n cos(n arccos x). The second statement follows immediately.
Note also that for this choice of points, |ω(x)| achieves its maximum value of 2−n at n + 2
distinct points in [−1, 1], namely at cos[jπ/(n + 1)], j = 0, . . . , n + 1, and that the sign of
ω(x) alternates at these points.
Now suppose that some other points x̃i are given and set ω̃(x) = (x − x̃0 ) · · · (x − x̃n ). If
|ω̃(x)| < 2−n on [−1, 1], then ω(x) − ω̃(x) alternates sign at the n + 2 points cos[jπ/(n + 1)]
and so has at least n + 1 zeros. But it is a polynomial of degree at most n (since the leading
terms cancel), and so must vanish identically, a contradiction.
Table 1.1 indicates the Lebesgue constant for Chebyshev interpolation grows rather slowly
with the degree (although it does not remain bounded). In fact the rate of growth is only
logarithmic and can be bounded very explicitly. See [6] for a proof.
Theorem 1.21. If Pn : C([a, b]) → Pn ([a, b]) denotes interpolation at the Chebyshev
points, then
2
kPn k ≤ log(n + 1) + 1, n = 0, 1, . . . .
π
22 1. APPROXIMATION AND INTERPOLATION
1 .33
0 0
−1 −.33
degree 4 error
1 .1
0 0
−1 −.1
Comparing with Theorem 1.19, we see that Chebyshev interpolation gives asymptotically
the best results possible. Combining this result with the Jackson theorems we see that Cheby-
shev interpolation converges for any function C 1 , and if f ∈ C k , then kf −Pn k ≤ Cn−k log n,
so the rate of convergence as n → ∞ is barely worse than for the best approximation. Using
the Jackson theorem for Hölder continuous functions (given in the exercises), we see that in-
deed Chebyshev interpolation converges for any Hölder continuous f . Of course, by Faber’s
theorem, there does exist a continuous function for which it doesn’t converge, but that func-
tion must be quite unsmooth. We can summarize this by saying that Chebyshev interpolation
is a robust approximation procedure (it converges for any “reasonable” continuous function)
and an accurate one (it converges quickly if the function is reasonably smooth). Compare
this with Bernstein polynomial approximation which is completely robust (it converges for
any continuous function), but not very accurate.
Figure 1.11 repeats the example of best approximation from Figure 1.5, but adds the
Chebyshev interpolant. We see that, indeed, on this example the Chebyshev interpolant is
not far from the best approximation and the error not much larger than the error in best
approximation.
4. LEAST SQUARES POLYNOMIAL APPROXIMATION 23
Definition. A normed vector space X is an inner product space if there exists a sym-
metric bilinear form h · , · i on X such that kxk2 = hx, xi.
Proof. We know that there exists a best approximation p. To obtain the character-
ization note that kf − p + qk2 = kf − pk2 + 2hf − p, qi + 2 kqk2 achieves its minimum
(as a quadratic polynomial in ) at 0. If p and p∗ are both best approximation the normal
equations give hp − p∗ , qi = 0 for q ∈ P . Taking q = p − p∗ shows p = p∗ . (Alternative proof
of uniqueness: show that an inner product space is always strictly convex.)
In the course of the proof we showed that the normal equations admit P a unique solution.
To obtain the solution, we select a basis φ1 , . . . , φn of P , write p = j aj φj , and solve the
equations
n
X
hφj , φi iaj = hf, φi i, i = 1, . . . , n.
j=1
4.2. The Legendre polynomials. Consider now the case of X = L2 ([a, b]), P =
Pn ([a, b]). Applying the Gram-Schmidt process to the monomial basis we get a sequence
of polynomials pn = xn + lower with pn ⊥ Pn−1 . This is easily seen to characterize the pn
uniquely.
The Gram-Schmidt process simplifies for polynomials. For the interval [−1, 1] define
p0 (x) = 1,
p1 (x) = x,
hxpn−1 , pn−2 i
pn (x) = xpn−1 (x) − pn−2 (x), n ≥ 2.
kpn−2 k2
It is easy to check that these polynomials are monic and orthogonal. The numerator in the
last equation is equal to kpn−1 k2 . These polynomials, or rather constant multiples of them,
are called the Legendre polynomials.
p0 (x) = 1,
p1 (x) = x,
p2 (x) = x2 − 1/3,
p3 (x) = x3 − 3x/5.
We can obtain the Legendre polynomials on an arbitrary interval by linear scaling.
We normalized the Legendre polynomials by taking their leading coefficient as 1. More
commonly the Legendre polynomials are normalized to have value 1 at 1. Then it turns out
that the recursion can be written
(n + 1)Pn+1 (x) = (2n + 1)xPn (x) − nPn−1 (x),
starting with P0 = 1, P1 (x) = x (see [5], Ch. 2.2 for details). Henceforth we shall use Pn
to denote the Legendre polynomials so normalized. Now we shall gather some properties of
them (see [5] Ch. 2, including the exercises, for details).
0) Pn (1) = 1, Pn (−1) = (−1)n , Pn is even or odd according to whether n is even or odd.
1) kPn k2 = 2/(2n + 1).
2) The leading coefficient of Pn = (2n − 1)(2n − 3) · · · 1/n! = (2n)!/[2n (n!)2 ].
dn 2 n
3) It is easy to check, by integration by parts, that the functions dx n [(x − 1) ] are
polynomials of degree n and are mutually orthogonal. Comparing leading coefficients we get
Rodrigues’s formula for Pn :
1 dn
Pn = n n
[(x2 − 1)n ].
2 n! dx
4) Using Rodrigues’s formula one can show, with some tedious manipulations, that
d 2 dPn
(x − 1) = n(n + 1)Pn ,
dx dx
i.e., the Pn are the eigenfunctions of the given differential operator.
5) Using this equation one can prove that |Pn | ≤ 1 on [−1, 1] (see Isaacson & Keller,
Ch. 5, Sec. 3, problem 8).
4. LEAST SQUARES POLYNOMIAL APPROXIMATION 25
6) Pn has n simple roots, all in (−1, 1). Indeed to prove this, it suffices to show that
Pn changes sign at n points in (−1, 1). If the points where Pn changes sign in (−1, 1) are
x1 , . . . , xk , then Pn isn’t orthogonal to (x − x1 ) · · · (x − xk ), so k ≥ n.
Using the Legendre polynomials to compute the least squares approximation has the
additional advantage that if we increase the degree the polynomial approximation changes
only by adding additional terms: Pthe coefficients of the terms already present don’t change.
Now consider the error f − cj Pj . We have
n
X n
X n
X
kf − cj Pj k2 = kf k2 + c2j kPj k2 − 2 cj hf, Pj i.
j=0 j=0 j=0
The last equation is Parseval’s equality. It depended only on the orthogonality of the
Pn and on the completeness of the polynomials (any continuous function can be represented
arbitrarily closely in L2 by a polynomial).
4.3. Error analysis. We now consider the rate of convergence of pn , the √ best L2 approx-
imation of f , to f . An easy estimate follows from the fact that kf kL2 ([−1,1] ≤ 2kf kL∞ ([−1,1]) :
√
inf kf − pk2 ≤ 2 inf kf − pk∞ .
p∈Pn p∈Pn
The right-hand side can be bounded Jackson’s theorems, e.g., by ck n−k kf (k) k∞ .
26 1. APPROXIMATION AND INTERPOLATION
4.4. Weighted least squares. The theory of best approximation in L2 extends to best
approximation in the weighted norm
Z b 1/2
2
kf kw,2 := |f (x)| w(x) dx ,
a
where w : (a, b) → R+ is an integrable function. The point is, this norm arises from an
inner product, and hence most of theory developed above goes through (one thing that does
not go through, is that unless the interval is symmetric with respect to the origin and w is
even, it will not be the case
R b that the orthogonal polynomials will alternate odd and even
parity). Writing hf, gi = a f (x)g(x)w(x) dx for the inner product, we define orthogonal
polynomials by a modified Gram-Schmidt procedure as follows. Let Q0 (x) ≡ 1. Define
Q1 = xQ0 − a0 Q0 where a0 is chosen so that hQ1 , Q0 i = 0, i.e., a0 = hxQ0 , Q0 i/kQ0 k2 . Then
Q2 = xQ1 − a1 Q1 − b1 Q0 where a1 is chosen so that hQ2 , Q1 i = 0 (a1 = hxQ1 , Q1 i/kQ1 k2 )
and b1 is chosen so that hQ2 , Q0 i = 0 (b1 = h(x − a1 )Q1 , Q0 i/kQ0 k2 . We then define
Q3 = xQ2 − a2 Q2 − b2 Q1 , choosing a2 and b2 to get orthogonality to Q2 and Q1 respectively.
Each of the terms on the right-hand side is individually orthogonal to Q0 , so this procedure
works, and can be continued. In summary:
hxQn , Qn i h(x − an )Qn , Qn−1 i
Qn+1 = (x − an )Qn − bn Qn−1 , an = , bn = .
kQn k2 kQn−1 k2
5. PIECEWISE POLYNOMIAL APPROXIMATION AND INTERPOLATION 27
√Other famous families of orthogonal polynomials are: Chebyshev of second kind (weight
of 1 − x on [−1, 1]), Jacobi (weight of (1 − x) (1 + x)β on [−1, 1]) which contains the three
2 α
preceding cases as special cases, Laguerre (weight of e−x on [0, ∞), and Hermite (weight of
2
e−x on R).
Pk (T ) (as long as the partition contains more than one subinterval), and its dimension
grows with the number of subintervals. To determine the dimension explicitly we note that
an element of p ∈ Msk (T ) can be specified as follows: first choose p1 = p|I1 as an arbitrary
element of Pk (I1 ); then choose p2 = p|I2 as an arbitrary element of Pk (I2 ) subject to the
(m) (m)
constraint that p2 (x1 ) = p1 (x1 ), m = 0, 1, · · · , s; then choose p3 = u|I3 as an arbitrary
28 1. APPROXIMATION AND INTERPOLATION
Figure 1.12. Piecewise polynomials. In the first row are plotted typical
elements of M 0 (T ), M 1 (T ), and M 2 (T ). In the second are shown typical
elements of M01 (T ), M02 (T ), and M12 (T ). The mesh T consists of the same six
subintervals in all cases.
(m) (m)
element of Pk (I2 ) subject to the constraint that p3 (x2 ) = p3 (x2 ), m = 0, 1, · · · , s; and so
forth. In this we we see that
dim Msk (T ) = (k − s)n + s + 1
k
for 0 ≤ s ≤ k (and even for s = −1 if we interpret M−1 as M k ). We get the same result if
k
we start with the dimension of M (T ), which is n(k + 1), and subtract (s + 1)(n − 1) for
the value and first s derivatives which need to be constrained at each of the n − 1 interior
breakpoints.
Since they are continuous, the functions p ∈ M0k (T ) have a well-defined value p(x) at
each x ∈ [a, b], (including the possibility that x is a breakpoint). Consider the set S of
points in [a, b] consisting of the n + 1 breakpoints and an additional k − 1 distinct points in
the interior of each subinterval. For definiteness, when k = 2 we use the midpoint of each
subinterval, when k = 3, we use the points 1/3 and 2/3 of the way across the interval, etc.
Thus S contains nk + 1 points, exactly as many as the dimension of M0k (T ). An element
p ∈ M0k (T ) is uniquely determined by its value at these nk + 1 points, since—according to
the uniqueness of Lagrange interpolation—it is uniquely determined on each subinterval by
its value at the k+1 points of S in the subinterval (the two end points of the subinterval and
k − 1 points in the interior). Thus the interpolation problem of finding p ∈ M0k (T ) taking on
given values at each of the points in S has a unique solution. This observation leads us to a
useful set of basis of function for M0k (T ), analogous to the Lagrange basis functions for Pn
discussed in § 3.1, which we shall call a Lagrange basis for M0k (T ). Namely, for each s ∈ S
we define a basis function φs (x) as the element of M0k (T ) which is equal to 1 at s and is zero
at all the other points of S. Figure 1.13 shows the first few basis functions for M01 (T ) and
M02 (T ). Notice that this is a local basis in the sense that all the basis functions have small
5. PIECEWISE POLYNOMIAL APPROXIMATION AND INTERPOLATION 29
Figure 1.13. Some Lagrange basis functions for M01 (T ) (first row) and
M02 (T ) (second row).
supports: they are zero outside one or two subintervals. This is in contrast to the Lagrange
basis functions for Pn , and is an advantage of piecewise polynomial spaces.
To approximate a given function f on [a, b] by a function in p ∈ M k (T ) we may in-
dependently specify p in each subinterval, e.g., by giving k + 1 interpolation points in the
subinterval. In order to obtain a continuous approximation (p ∈ M0k ) it suffices to include
the endpoints among the interpolation points. For example, we may determine a continuous
piecewise linear approximation by interpolating f at the breakpoints. We may determine a
continuous piecewise quadratic approximation by interpolating at the breakpoints and the
midpoint of each subinterval. In terms of the basis functions described in the last paragraph,
the formula for the interpolant in M0k (T ) is simple:
X
p(x) = f (s)φs (x).
s∈S
Because the basis functions have small support this sum is cheap to evaluate even when
there are many subintervals (because for any given x, only a few of the φs (x) are non-zero).
Figure 1.14 shows the interpolants of a smooth function using various piecewise polynomial
spaces.
It is easy to obtains error bounds for these interpolation procedures because on each
subinterval Ii we are simply performing Lagrange interpolation, and so we may apply the
estimate (1.3) to bound the L∞ (Ii ) error of the interpolant in terms of kf (k+1) kL∞ (Ii ) and
hi = xi − xi−1 . Taking the maximum over all the subintervals gives us an L∞ error bound
on the entire interval in terms of kf (k+1) kL∞ ([a,b]) and the mesh size h := maxi hi . These
considerations are summarized in the following theorem.
Theorem 1.24. Let T be a mesh of [a, b], k a non-negative integer, and f a function
on [a, b]. Given k + 1 interpolation points in each subinterval of the mesh, there exists a
unique function p ∈ M k (T ) interpolating f at all the interpolation points. Moreover, if
30 1. APPROXIMATION AND INTERPOLATION
Figure 1.15. As the interior mesh points tend to the endpoints, the Lagrange
cubic interpolant tends to the Hermite cubic interpolant.
Now if we are given the mesh T , then we may define the piecewise Hermite cubic inter-
polant p to a C 1 function f by insisting that on each subinterval p be the Hermite cubic
interpolant to f . Then p is determined by the interpolation conditions
(1.6) p(xi ) = f (xi ), p0 (xi ) = f 0 (xi ), i = 0, 1, . . . , n.
By construction p ∈ M13 (T ). When f ∈ C 4 ([a, b]) we obtain an O(h4 ) error estimate just as
for the piecewise Lagrange cubic interpolant. We can specify C 1 interpolants of higher degree
and order, by supplementing the conditions (1.6) with additional interpolation conditions.
Thus to interpolate in M1k (T ), k > 3, we insist that p satisfy (1.6) and as well interpolate f at
k − 3 points interior to each subinterval. It is possible to obtain even smoother interpolants
(C 2 , C 3 , . . . ) using the same idea. But to obtain an interpolant in C s in this way it is
necessary that the degree k be at least 2s + 1.
5.1. Cubic splines. The space M23 (T ) of cubic splines has dimension n + 3. It is
therefore reasonable to try to determine an element p of this space by interpolation at the
nodes, p(xi ) = f (xi ), and two additional conditions. There are a number of possible choices
for the additional conditions. If the values of f 0 are known at the end points a natural choice
is p0 (a) = f 0 (a) and p0 (b) = f 0 (b). We shall mostly consider such derivative end conditions
here. If the values of f 0 are not known, one possibility is approximate f 0 (a) by r0 (a) where
r ∈ P3 agrees with f at xi , i = 0, 1, 2, 3. Another popular possibility is to insist that p000
be continuous at x1 and xn−1 . This means that p belongs to P3 ([x0 , x2 ]) and P3 ([xn−2 , xn ]).
That is, x1 and xn−1 are not true breakpoints or knots. Thus these are called the not-a-knot
conditions.
We shall now proceed to proving that there exists a unique cubic spline interpolating f
at the breakpoints and f 0 at the end points. With derivative end conditions it is convenient
32 1. APPROXIMATION AND INTERPOLATION
to define x−1 = x0 = a, xn+1 = xn = b and h0 = hn+1 = 0. This often saves us the trouble
of writing special formulas at the end points.
Lemma 1.25. Suppose that e is any function in C 2 ([a, b]) for which e(xi ) = e0 (a) =
e0 (b) = 0. Then e00 ⊥ M01 (T ) in L2 ([a, b]).
Proof. Let q ∈ M01 (T ). Integrating by parts and using the vanishing of the derivatives
at the end points we have
Z b Z b
00
e q dx = − e0 q 0 dx.
a a
0
But, on each subinterval [xi−1 , xi ], q is constant and e vanishes at the end points. Thus
Z xi
e0 q 0 dx = 0.
xi−1
Theorem 1.26. Given breakpoints x0 < x1 < · · · < xn and values y0 , . . . , yn , ya0 , yb0 there
exists a unique cubic spline p satisfying p(xi ) = yi , p0 (a) = ya0 , p0 (b) = yb0 .
Proof. Since the space of cubic splines has dimension n + 3 and we are given n + 3
conditions, it suffices to show that if all the values vanish, then p must vanish. In that case,
we can take e = p in the lemma, and, since p00 ∈ M01 (T ) we find that p00 is orthogonal to itself,
hence vanishes. Thus p ∈ P1 ([a, b]). Since it vanishes at a and b, it vanishes identically.
The lemma also is the key to the error analysis of the cubic spline interpolant.
Theorem 1.27. Let f ∈ C 2 ([a, b]) and let p be its cubic spline interpolant with derivative
end conditions. Then p00 is the best least squares approximation to f 00 in M01 (T ).
If we write IM23 f for the cubic spline interpolant of f and ΠM01 g for the L2 projection
(best least squares approximation) of g in M01 , we may summarize the result as
(IM23 f )00 = ΠM01 f 00 ,
or by the commutative diagram
d2
dx2
C ([a, b]) −−−→ C 0 ([a, b])
2
IM 3 Π 1
y M0
2 y
M23 (T ) −−−→ M01 (T )
d2
dx2
1
kf 00 − p00 k∞ ≤ h2 kf (4) k.
2
34 1. APPROXIMATION AND INTERPOLATION
Figure 1.16. A Lagrange basis function for cubic spline interpolation. This
cubic spline is equal to 1 at the third breakpoint and to 0 at the others,
and satisfies zero derivative endpoint conditions. Notice that, although its
magnitude decreases quickly away from the third breakpoint, it is non-zero on
every subinterval.
Here we will consider the case of a plane domain, that is, n = 2, although the extension
to n > 2 is quite similar. Let Ω be a polygon. By a triangulation of Ω we mean a set T of
closed triangles T with the properties that
S
1. T ∈T T = Ω̄
2. any two distinct elements T1 , T2 ∈ T are either disjoint or meet in a common edge or
vertex
The second point means we exclude configurations such as shown in Figure 1.17 from trian-
gulations.
determine a linear polynomial taking the given values at the vertices. In this way we define a
piecewise linear function. The function is continuous. To show this we need only show that if
two triangles share a common edge, then the linear polynomials determined by interpolation
of the vertex values on the two triangles agree on the common edge. But the restriction
of these polynomials to the edge is a linear polynomial in one variable (say in the distance
along the edge from one of the vertices), and they agree at the two endpoints of the edge,
so they must agree on the entire edge. In this way we obtain a formula for the dimension of
the space of piecewise linears with respect to the given triangulation:
dim M01 (T ) = VT ,
where VT is the number of vertices in the triangulation. We also obtain a Lagrange basis for
M01 (T ), a typical element of which is shown in Figure 1.19. For obvious reasons, these are
called hat functions. Notice that the basis is local: each basis function is zero outside the
Figure 1.19. A typical Lagrange basis function for the space M01 (T ).
Similar considerations allow us to determine the dimension and a local basis for M0k (T )
for k > 1. This time we assign values at the vertices and the midpoints of edges. Our first
claim is that for T a triangle we can determine p ∈ P2 (T ) by giving the values at the vertices
of T and at the edge midpoints. There is something to prove here, since a priori there might
exist a non-zero quadratic polynomial vanishing at all six of these points. To see that this
doesn’t happen we notice that the restriction of the polynomial to each edge is a quadratic
function on the edge which vanishes at three points on the edge. This certainly implies that
the restriction to each edge vanishes identically. But if a polynomial vanishes on a line, then
it must be divisible by the linear polynomial defining the line. If the three lines through the
edges of the triangle are given by li (x) = 0, i = 1, 2, 3, which li ∈ P2 (R2 ), we conclude that
the polynomial is divisible by the product l1 l2 l3 . Since this product has degree 3 and the
polynomial in question has degree at most 2, the only possibility is that the polynomial is
identically 0.
Thus we can indeed determine an element of M 2 (T ) by giving arbitrary values at vertices
and edge midpoints. To see that the resulting function is in M02 (T ) we again observe that
on a common edge to two triangles, the restriction to the edge is fully determined by the
values at the endpoints and midpoint of the edge. We conclude that
dim M02 (T ) = VT + ET ,
with ET the number of edges of triangles. Figure 1.20 shows a typical basis element associated
with a vertex and another one associates with and edge midpoint.
Figure 1.20. Two Lagrange basis functions for the space M02 (T ).
Proof. Let F (s) = u(y + s(x − y)). By Taylor’s theorem in one dimension,
n
1 t
Z
X 1 (m) m
F (t) = F (0)t + (t − s)n F (n+1) (s) ds.
m=0
m! n! 0
Taking t = 1 and substituting s 7→ 1 − s in the last integral gives the result.
Now we suppose that Ω is a bounded open convex set in R2 and proceed to the proof of
the Bramble–Hilbert lemma. Translating and dilating we can assume that Ω contains the
unit ball B.
Integrating (1.7) over y ∈ B and dividing by π (the area of B), we find that
u(x) = P n u(x) + E(x),
where
Z
n 1
P u(x) = Tyn u(x) dy
π B
6. PIECEWISE POLYNOMIALS IN MORE THAN ONE DIMENSION 39
We have used the characteristic function χB of the unit ball to enable us to write the outer
integral over R2 . Next we change variable in the double integral from (s, y) to (t, z) with
t = s and z = x + s(y − x). This gives
X n+1Z Z 1
t−3 Dα u(z)χB x + t−1 (z − x) (z − x)α dt dz
E(x) =
πα! R2 0
|α|=n+1
for all x, z ∈ Ω (with a possibly different constant C, but still just depending on Ω and n).
It follows1 that
X
kEkLp (Ω) ≤ C kDα ukLp (Ω) .
|α|=n+1
Thus (modulo the proof of Lemma 1.31) we have proven the following theorem, which is a
part of the Bramble–Hilbert theorem.
Theorem 1.32. Let Ω ⊂ RN be a bounded open convex set and let n be a non-negative
integer. Then there exists a constant C depending only on Ω and n, such that for 1 ≤ p ≤ ∞,
ku − P n ukLp (Ω) ≤ C|u|Wpn+1 (Ω) ,
for all u ∈ C n+1 (Ω).
1
This usesR the generalized Young inequality: if K isR a function on Ω × Ω for which
p
g(x) := Ω K(x, z)f (z) dz belongs to Lp (Ω) and
R
Ω
|K(x, z)| dx, Ω
|K(x, z)| dz ≤ C and f ∈ L (Ω), then
kgkLp (Ω) ≤ Ckf kLp (Ω) .
40 1. APPROXIMATION AND INTERPOLATION
The proof consists of two main steps. First we prove an estimate of the same form, except
without any indication of how the error depends on the triangle T . Namely:
6. PIECEWISE POLYNOMIALS IN MORE THAN ONE DIMENSION 41
Theorem 1.34. For each triangle T there exists a constant CT such that
2
kf − IT f kL∞ (T ) ≤ CT |f |W∞
2 (T ) for all f ∈ C (T ).
In the second step we shall apply Theorem 1.34 for one particular triangle T̂ and use an
affine map from an arbitrary T to T̂ deduce Theorem 1.33.
Proof of Theorem 1.34. If q ∈ P1 (T ), then IT q = q, so f −IT f = (f −q)−IT (f −q).
Now clearly kIT gkL∞ ≤ kgkL∞ for all continuous functions g. Applying this with g = f − q
gives
kf − IT f kL∞ = k(f − q) − IT (f − q)kL∞ ≤ 2kf − qkL∞ .
Since this is true for all q ∈ P1 (T ), by the Bramble–Hilbert lemma (actually only the part
of it given in Theorem 1.32), we get
kf − IT f kL∞ (T ) ≤ CT |f |W∞
2 (T ) ,
Since T̂ is a fixed triangle, CT̂ is an absolute constant: it doesn’t depend on T . To finish the
argument we need to show that
|fˆ| 2 ≤ Ch2 |f |W 2 (T ) .
W∞ (T̂ ) T ∞
42 1. APPROXIMATION AND INTERPOLATION
Figure 1.22. Mapping between the reference triangle and an arbitrary triangle.
v1
v2
A
v̂2 F
1 A J
@@ v0 J
@ J f
@ XX J
XXX J
@ XXX
XXX J
fˆ
@
@ XXX J ^
@
z
X R
v̂0 v̂1
This just comes from the chain rule for differentiation. We have
2 2
∂ fˆ X ∂f ∂xj X ∂f
(x̂) = (x) = bji j (x).
∂ x̂i j=1
∂xj ∂ x̂i j=1
∂x
Differentiating again,
2 2
∂ 2 fˆ XX ∂2f
(x̂) = b ji (x)blk .
∂ x̂i ∂ x̂k j=1 k=1
∂x j ∂xl
Thus
∂ 2 fˆ 2 ∂2f
| (x̂)| ≤ 4hT max | (x)|
∂ x̂i ∂ x̂k j,l ∂xj ∂xl
and
(1.9) |fˆ|W∞ 2
2 (T̂ ) ≤ 4hT |f |W∞
2 (T ) .
Figure 1.23. A function with a small Lp norm (solid line), but large inter-
polant (dashed line).
where Dβ ranges over the second partial derivatives. Using the chain rule we have
X
|Dβ fˆ(x̂)| ≤ Ch2T |Dγ f (x)|
|γ|=2
In other words
kf − IT f kLp ≤ Ch2T |f |Wp2 (T ) .
Note that the factor of |T |/2, which came from the change of variables x 7→ x̂ disappeared
when we changed back to the original variable.
44 1. APPROXIMATION AND INTERPOLATION
Finally we consider estimates of the error in the first derivatives of the interpolants;
that is, we bound |f − IT f |Wp1 . As we remarked above, in the boundedness result kIT gk ≤
CT kgkWp2 (which holds for any p > 1), it does not matter what norm we take on the left-hand
side. Consequently it is straightforward use the Bramble–Hilbert lemma and show that
(1.10) |fˆ − I fˆ| 1 ≤ C|fˆ| 2 .
T̂ Wp (T̂ ) Wp (T̂ )
The next step is to use affine scaling to relate |f − IT f |Wp1 (T ) to |fˆ − IT̂ fˆ|Wp1 (T̂ ) and |f |Wp2 (T )
to |fˆ|Wp2 (T̂ ) . We have already made the second relation:
(note that we index the vectors starting from 0). We can use the above formula to define
(FN y)k for any k, not just 0 ≤ k < N , but it is an N -periodic sequence. RIf you recall that
1
the kth Fourier coefficient of a function f on [0, 1] is defined by fˆ(k) = 0 f (x)e−2πikx dx,
we see that N −1 (FN y)k is just the approximation to fˆ(k) obtained by using the trapezoidal
rule with N equal subintervals to compute the integral, expressed in terms of the values
yj = f (j/N ).
Note that application of the DFT is simply multiplication of an N -vector by a particular
N × N matrix. This would suggest that N 2 multiplications and additions are needed to
compute it. The fast Fourier transform (FFT) is a clever algorithm to compute the DFT
much more quickly (for large N ). Because large DFTs arise in many contexts, the FFT
proved to be one of the most important algorithms of the twentieth century. In particular,
it has played a tremendous role in signal processing.
The FFT can also be used as a fast means of computing the coefficients of the a trigono-
metric interpolating polynomial with equally spaced interpolation points (or for the closely
related problem of computing the algebraic polynomial interpolating polynomial at the
Chebyshev points). In this last section of the chapter we introduce the FFT in that context.
We defined the space Tn of real-valued trigonometric polynomials of degree at most n as
the span of the 2n + 1 functions 1, cos x, sin x, . . . , cos nx, sin nx. Recall that
n
X
Tn = { ck eikx | ck ∈ C, c−k = c̄k }.
k=−n
This space has dimension 2n + 1. However, for reasons that will soon be clear, it is more
convenient to work with a space of even dimension at this point. Hence we define Tn0 as the
span of the 2n functions 1, cos x, sin x, . . . , cos nx, or, equivalently,
n
X
Tn0 ={ ck eikx ∈ Tn | c−n = cn } = span[1, cos x, sin x, . . . , cos nx].
k=−n
(If the yj are real, we may conjugate this equation to find that if (ck ) is a solution, then so
is (c̄−k ). Since—as we shall see—the solution is unique, we see that the condition ck = c̄−k
is automatic.)
It is possible to write this system of equations in a somewhat more convenient fashion.
If −n ≤ k ≤ −1, we use the identity e2πijk/N = e2πij(k+N )/N . Then n ≤ k + N ≤ N − 1. In
46 1. APPROXIMATION AND INTERPOLATION
where
ck ,
0 ≤ k < n,
dk = cn + c−n , k = n,
c
k−N , n < k < N.
Note that, since cn = c−n , we can recover the ck from the dk .
Thus our problem is to find the coefficients dk such that
N
X −1
(1.14) dk e2πijk/N = yj .
k=0
In 1965 Cooley and Tukey published a clever way to multiply by FN that exploits its
special structure. The resulting algorithm, which exists in many variants, is the FFT. With
it, it is quite practical to compute DFTs of size in the tens of thousands, or even millions.
Let x ∈ RN be given with N = 2n. Let x̄, x̃ ∈ Rn be the odd and even index elements of
x: x̄j = x2j , x̃j = x2j+1 . Then
N −1 n−1 n−1
−(2j+1)k
X −jk
X −2jk
X
(FN x)k = ωN xj = ωN x2j + ωN x2j+1
j=0 j=0 j=0
n−1
X n−1
X
−k
= ωn−jk x̄j + ωN ωn−jk x̃j
j=0 j=0
−k
= (Fn x̄)k + ωN (Fn x̃)k .
This equation shows how to reduce the evaluation of the size N discrete Fourier transform
FN x to the two size n discrete Fourier transforms Fn x̄ and Fn x̃. In matrix terms it shows
1
Fn x̄ ω −1 Fn x̃
N
FN x = ...... + ...... .
. .
F x̄ . F x̃
n 1−N n
ωN
Now if n is itself an even number, then we can reduce each of the discrete Fourier
transforms of size n to two transforms of size n/2, etc. If N is a power of 2, we can continue
in this way until we have reduced the work to N transforms of size 1, which of course are
trivial (F1 = 1). Algorithm 1.1 shows, in metacode, an algorithm for computing the FFT in
this case. Notice that the use of recursion makes the algorithm statement quite brief.
y = FFT(x)
input: x = (x0 , . . . , xn−1 ) ∈ Cn where n is a power of 2
output: y = Fn x ∈ Cn
if n = 1 then
y←x
else
x̄ ← (x0 , x2 , . . . , xn−2 )
x̃ ← (x1 , x3 , . . . , xn−1 )
ȳ ← FFT(x̄)
ỹ ← FFT(x̃)
ω ← e−2πi/n
yk ← ȳk + ω −k ỹk , k = 0, 1, . . . , n/2 − 1
yk ← ȳk−n/2 + ω −k ỹk−n/2 , k = n/2, n/2 + 1, . . . , n − 1
end if
In fact the code is even briefer when implemented in Matlab,2 as shown in the listing
below.
function y = simplefft(x)
N = length(x);
if N == 1
y = x;
else
omega = exp(-2*pi*i/N);
ybar = simplefft(x(1:2:N-1));
ytilde = simplefft(x(2:2:N));
y = [ ybar ; ybar ] + omega.^-(0:N-1)’ .* [ ytilde; ytilde ];
end
Let us count the amount of work for this algorithm. For simplicity we count only the
multiplications and ignore the additions. We also ignore the computation of the powers of ωN
needed in the algorithm. In an efficient implementation, all N powers would be computed
once (via N multiplications). If we let mN be the number of multiplications needed to
compute the action of FN , we have mN = 2mn + N where n = N/2. Also m1 = 0. This
gives m2k = k2k , i.e., mN = N log2 N .
We close with some applications. Figure 1.24 shows a plot of a smooth periodic function
and its derivative on the left. The function
P8 was sampled at 16 equally spaced points and its
ikx
trigonometric polynomial interpolant k=−8 ck e was computed and plotted on the right.
The derivative, computed as 8k=−8 ikck eikx , is also shown. This approach to reconstructing
P
the derivative of a function from its values at a discrete set of points is the basis of spectral
methods for solving differential equations.
0.5 0.5
0 0
−0.5 −0.5
−1 −1
0 1 2 3 4 5 6 0 1 2 3 4 5 6
Of course when N = 16 the efficiency afforded by the FFT is not important. Figure 1.25
shows an application involving 1,024 interpolation points, for which the efficiency is signif-
icant. On the left are 1024 points (taken from a sound sample of people laughing). In the
2
Matlab offers an FFT function, fft, which is more sophisticated and also works when N is not a power
of 2.
EXERCISES 49
middle is the trigonometric polynomial interpolant of the sample values (computed via the
FFT), and on the right is a blow-up of the region 2 ≤ x ≤ 2.1 showing that the polynomial
does indeed interpolate the given values.
0 0 0
Exercises
1. Show that for any 1 ≤ p < q ≤ ∞ the Lp and Lq norms on C(I) are not equivalent.
2. Let f (x) = ex . a) For p = 1, 2, and ∞ find the best Lp approximation to f in P0 (I). b) Same
thing but in P1 (I).
3. Prove or disprove: if f ∈ C([−1, 1]) is odd then a best approximation to f by odd polynomials
of degree at most n is a best approximation to f among all polynomials of degree n.
4. Prove or disprove: if f ∈ C([−1, 1]) has mean value zero, then a best approximation to f by
polynomials of degree at most n with mean value zero is a best approximation to f among
all polynomials of degree n.
5. State and prove the Jackson theorem in C k ([a, b]) paying attention to the dependence of the
constant on the interval [a, b].
6. If f ∈ C(R) and δ > 0 define Rδ f ∈ C(R) by
1 x+δ/2
Z
Rδ f (x) = f (t) dt.
δ x−δ/2
Note that Rδ f ∈ C 1 (R). Prove that kf − Rδ f k ≤ ω(δ), where ω denotes the modulus of
continuity of f (i.e., ω(δ) is the supremum of |f (x) − f (y)| over x, y for which |x − y| ≤ δ).
1
7. Let f ∈ C2π and let ω denote its modulus of continuity. Using the Jackson theorem in C2π
and the regularization operator of the previous problem, prove that
1
inf kf − pk∞ ≤ c ω .
p∈Tn n+1
Give an explicit expression for c.
50 1. APPROXIMATION AND INTERPOLATION
8. Let f ∈ C([−1, 1]) and let ω denote its modulus of continuity. Prove that
1
inf kf − pk∞ ≤ c ω .
p∈Pn n+1
Give an explicit expression for c.
9. Suppose that f ∈ C([−1, 1]) satisfies the Holder condition |f (x) − f (y)| ≤ M |x − y|α where
M, α > 0. What can you say about the rate of convergence of the best uniform approximation
to f by polynomials of increasing degree?
In the exercises 10–17, which treat divided differences and Newton’s formula for the
interpolating polynomial, we denote by f a real-valued function on an interval, by
x0 , . . . , xn n + 1 distinct points in J and by pk ∈ Pk the Lagrange interpolating
polynomial for f at the first k + 1 points x0 , . . . , xk .
10. Prove that pn (x) − pn−1 (x) = c(x − x0 ) · · · (x − xn−1 ) for some constant c. We use the
notation f [x0 , . . . , xn ] to denote this constant and call it the nth divided difference of f at
the xi . Use Lagrange’s formula for the interpolating polynomial to derive an expression for
f [x0 , . . . , xn ] in terms of xi and f (xi ).
11. Prove that f [x0 , . . . , xn ] is a symmetric function of its n + 1 arguments.
12. Prove the recursion relation
f [x1 , . . . , xn ] − f [x0 , . . . , xn−1 ]
f [x0 , . . . , xn ] = ,
xn − x0
where, by convention, f [x] := f (x). (This explains the terminology “divided difference”.)
13. Give explicit formulas for f [a], f [a, b], f [a, b, c], and f [x, x + h, x + 2h, . . . , x + nh].
14. Prove Newton’s formula for the interpolating polynomial
15. Prove that if f ∈ C n (J), then there exists a point ξ in the interior of J such that
1 (n)
f [x0 , . . . , xn ] = f (ξ).
n!
16. Assuming that f ∈ C n (J), use the recursion defining the divided differences to establish the
Hermite-Gennochi formula
Z
f [x0 , . . . , xn ] = f (n) (t0 x0 + t1 x1 + · · · + tn xn ) dt,
Sn
where
n
( )
X
SN = t = (t1 , . . . , tn ) ∈ Rn | ti ≥ 0, ti ≤ 1 ,
1
Pn
and t0 = 1 − 1 ti .
EXERCISES 51
17. The Hermite-Gennochi formula shows that as a function of n + 1 variables the nth divided
difference extends to a function on all of J n+1 (the arguments need not be distinct). Find
simple closed form expressions for f [a, a], f [a, a, b], and f [a, a, b, b].
For the next 3 problems define Πn : C([−1, 1]) → Pn ([−1, 1]) by kf − Πn f kw =
R1
inf p∈Pn kf − pkw , where kf k2w = −1 |f (x)|2 (1 − x2 )−1/2 dx.
18. Give a formula for Πn f .
19. Prove that
√
kf − Πn f k∞ ≤ c n + 1 inf kf − pk∞
p∈Pn
√
for some constant c. N.B.: This estimate is not sharp. It can be show to hold with n+1
replaced by 1 + log(2n + 1), but that is harder to prove.
20. Prove that if f ∈ Pn+1 , then
kf − Πn f k∞ = inf kf − pk∞ ,
p∈Pn
that is, Πn coincides with best minimax approximation when applied to polynomials of
degree n + 1.
21. In proving the convergence of the conjugate gradient method for solving linear systems, a
key step is showing that
2
(1.16) min max |p(x)| = √ n √ n
p∈Pn x∈[a,b] 1+ a/b 1− a/b
p(0)=1 √ + √
1− a/b 1+ a/b
for 0 < a < b. In fact, the polynomial for which the minimum is achieved is a scaled
Chebyshev polynomial:
b+a b+a b−a
p(x) = Tn (x̂)/Tn , where x = − x̂,
b−a 2 2
and the right-hand side of (1.16) is just 1/Tn (b + a)/(b − a) . Prove all this.
22. Let f ∈ C 1 ([a, b]). Prove that the cubic spline interpolant with derivative end conditions
minimizes the quantity kg 00 kL2 ([a,b]) among all C 2 functions on [a, b] which interpolate f at
the xi and f 0 at a and b. Since the second derivative is a measure of curvature, this says
that in a certain sense the cubic spline interpolant is the straightest, or smoothest, function
satisfying the interpolation conditions.
23. Let x0 < x1 < · · · < xp and suppose that s is a cubic spline defined on all of R with
breakpoints at the xi (only), and for such that s(x) ≡ 0 if x ≤ x0 or x ≥ xp . Prove that if
p ≤ 3, then s(x) ≡ 0. In other words, there does not exist a nonzero cubic spline supported
in just 3 intervals.
24. With the same notation as the previous problem show that that such a nonzero cubic spline
s(x) does exist if p = 4. Show that s(x) is determined uniquely up to a constant multiple.
With appropriate normalization s(x) is called the cubic B-spline for the knots x0 , . . . x4 .
25. Give the explicit formula
P for the cubic B-spline B(x) with knots xi = i, i = 0, . . . , 4,
normalized so that B(i) = 1. Draw a plot of this function.
52 1. APPROXIMATION AND INTERPOLATION
Prove that the discrete Fourier transform converts convolution into multiplication: (FN c)k =
(FN a)k (FN b)k .
27. Let p and q be polynomials of degree less than n, where n is a power of 2. Explain how the
coefficients of the product pq can be computed from the coefficients of p and q in O(n log2 n)
operations.
Bibliography
1. J. H. Bramble and S. R. Hilbert, Estimation of linear functionals on Sobolev spaces with application to
Fourier transforms and spline interpolation, SIAM J. Numer. Anal. 7 (1970), 112–124.
2. Philippe G. Ciarlet, The finite element method for elliptic problems, North-Holland, Amsterdam, 1978.
3. J. Deny and J. L. Lions, Les espaces du type de Beppo Levi, Ann. Inst. Fourier, Grenoble 5 (1953–54),
305–370 (1955).
4. Todd Dupont and Ridgway Scott, Polynomial approximation of functions in Sobolev spaces, Math. Comp.
34 (1980), no. 150, 441–463.
5. Theodore J. Rivlin, An introduction to the approximation of functions, Dover Publications Inc., New
York, 1981.
6. , Chebyshev polynomials, John Wiley & Sons, New York, 1990.
53
54 BIBLIOGRAPHY
CHAPTER 2
Numerical Quadrature
1. Basic quadrature
Rb
The problem is to compute a f (x) dx given a, b, and an integrable function f on [a, b].
We shall mainly use quadrature rules of the form
Z b Xn
f (x) dx ≈ wi f (xi ),
a i=0
with points xi ∈ [a, b] and weights wi ∈ R. More abstractly put, we want to approximate
Rb
the functional f 7→ a f by a linear combination of point-evaluation functionals.
Typical examples are: R
b
left endpoint rule: a f ≈ (b − a)f (a)
Rb
midpoint rule: a f ≈ (b − a)f (a + b)/2
Rb
trapezoidal rule: a f ≈ b−a 2
[f (a) + f (b)]
Rb b−a
Simpson’s rule: a f ≈ 6 [f (a) + 4f (a + b)/2 + f (b)]
2 point
R b Gauss rule: √ √
b−a
a
f ≈ 2
[f (a + b)/2 − (b − a)/(2 3) + f (a + b)/2 + (b − a)/(2 3) ]
composite midpoint rule (equal subintervals):
Rb
f = ni=1 hf (a − h/2 + ih), h = (b − a)/n
P
a
composite midpoint rule (a = x0 < x1 < · · · < xn = b):
Rb
f = ni=1 hi f (xi−1 + xi )/2 , hi = xi − xi−1
P
a
For any choice of distinct points xi ∈ [a, b], i = 0, 1, . . . , n there is a natural way to assign
Rb Rb
weights wi : let p ∈ Pn interpolate
P f at the points x i and approximate a
f by a
p. Using
Lagrange’s formula p(x) = i f (xi )li (x), with li (x) = Πj6=i (x − xj )/(xi − xj ), we can write
Rb P Rb
the resulting quadrature rule a f ≈ i wi f (xi ) where wi = a li (x) dx. Such rules are called
interpolatory quadrature rules. All the rule listed above except the composite midpoint rule
are of this form (the composite rules are based on piecewise polynomial interpolation). By
construction an interpolatory quadrature with n + 1 points has degree of precision at least n,
that is, the rule is exact on all polynomials of degree at most n. For some choices of points
a higher degree of precision is achieved. For example, Simpson’s rule has degree of precision
3 as does the 2 point Gauss rule.
A well-known class of interpolatory quadrature rules are based on using n + 1 equally
spaced points including the end points. These are called the closed Newton-Cotes rules (the
word “closed” refers to the fact that the endpoints are included). For n = 1 this is the
trapezoidal rule, for n = 2 it is Simpson’s rule. For n = 3 we get Simpson’s 3/8 rule with
weights 1/8, 3/8, 3/8, 1/8 (on an interval of unit length). For n = 4 we get Boole’s rule with
55
56 2. NUMERICAL QUADRATURE
weights 7/90, 32/90, 12/90, 32/90, 7/90. By construction the Newton-Cotes rule with n + 1
points has degree of precision n. But it is also provides the exact value when applied to any
odd power of x − (a + b)/2 (namely 0) by symmetry. Thus when n is even the Newton-Cotes
rule with n + 1 points has degree of precision n + 1.
In view of the large Lebesgue constant of high degree interpolation with equally spaced
points, it is not suprising that the Newton-Cotes rules are not very good for n large. Starting
with n = 8 some of the weights are negative, and for larger n the coefficients become very
large and oscillatory (they sum to one). As a result the formulas are very sensitive to errors
in f and difficult to evaluate in finite precision (cancellation).
For interpolatory quadrature rule we can deduce the error from the error formula for
Lagrange interpolation. As an example consider the trapezoidal rule on the unit interval
[0, 1], which is based on Lagrange interpolation at the points 0 and 1. Denoting by p the
interpolant, we have f (x) − p(x) = f [x, 0, 1]x(x − 1), so the error in the trapezoidal rule is
Z 1 Z 1 Z 1
(2.1) err = f− p= f [x, 0, 1]x(x − 1) dx.
0 0 0
We now recall the integral mean value theorem: if u ∈ C([a, b]) and w is an integrable (but
not necessarily continuous) function on [a, b] which doesn’t change sign, then
Z b Z b
u(x)w(x) dx = u(η) w(x) dx
a a
for some η ∈ (a, b). Applying this to the integral on the right-hand side of (2.1) with
u(x) = f [x, 0, 1] and w(x) = x(x − 1) we find that
Z 1 Z 1
1
f− p = − f [η, 0, 1]
0 0 6
for some η ∈ (0, 1), and hence, if f ∈ C 2 ([0, 1]),
Z 1
1
err = f [η, 0, 1] x(x − 1) dx = − f 00 (ξ)
0 12
for some ξ ∈ (0, 1).
Next we scale this result to an arbitrary interval [α, β]. If f ∈ C 2 ([α, β]), we define
fˆ(x̂) = f (x) where x = α + (β − α)x̂. Then
Z β Z 1
β−α 1
f− [f (α) + f (β)] = (β − α) fˆ − [fˆ(0) + fˆ(1)]
α 2 0 2
1 ˆ = − 1 (β − α)3 f 00 (ξ),
= − (β − α)fˆ00 (ξ)
12 12
for some ξ ∈ (α, β).
Now consider the composite trapezoidal rule using n equal subintervals of size h = (b −
a)/n. Applying the above result on each subinterval and summing we get
Z b n−1 n
1 X 1 1 3 X 00 1
f − h[ f (a) + f (a + ih) + f (b)] = − h f (ξi ) = − (b − a)h2 f 00 (ξ).
a 2 i=1
2 12 i=1 12
2. THE PEANO KERNEL THEOREM 57
Here ξi ∈ (a + (i − 1)h, a + ih) and we have used the fact that i f 00 (ξi ) = nf 00 (ξ) for some
P
ξ ∈ (a, b) (again a consequence of the intermediate value theorem). This is an exact formula,
not just a bound, for the error. It implies the bound |err| ≤ (b − a)h2 /12kf 00 kL∞ .
Now consider the composite trapezoidal rule with unequal subintervals determined by a
partition a = x0 < . . . xn = b. With hi = xi − xi−1 , h = maxi hi , we have
Z
b n n
X h i
1 X
3 00
f − [f (x ) + f (x )] = − h f (ξ )
i−1 i i i
2 12
a
i=0 i=1
1 X 1
≤ h2 hi kf 00 kL∞ = (b − a)h2 kf 00 kL∞ ,
12 12
00
and we see that this bound is sharp since equality must hold if f is constant.
Note that we get the same bound |err| ≤ (b − a)h2 /12kf 00 kL∞ for an unequal spacing of
points as for uniform spacing. Of course this bound doesn’t show any particular advantage
to choosing a nonuniform spacing. For that we would have to consider more carefully the
sum i h3i f 00 (ξi ). If we adjust the spacing so that hi is smaller where |f 00 | is larger we can
P
decrease the error.
If we try to apply the same arguments to the midpoint rule we come across one difference.
For the midpoint rule on [0, 1] the interpolant is simply the constant value f (1/2), and so
we get, instead of (2.1),
Z 1 Z 1
err = f − f (1/2) = f [x, 1/2](x − 1/2) dx.
0 0
However now the kernel x − 1/2 changes sign on [0, 1] and so we cannot continue using the
integral mean value theorem as before.
A simple approach for the midpoint rule is to use Taylor’s theorem. Assuming that
f ∈ C 2 ([0, 1]) we have
1
f (x) = f (1/2) + f 0 (1/2)(x − 1/2) + f 00 (ξx )(x − 1/2)2 , x ∈ (0, 1)
2
where ξx ∈ (0, 1) depends continuously on x. Integrating over x ∈ (0, 1) we get
Z 1
1 1 00
Z
1
(2.2) f − f (1/2) = f (ξx )(x − 1/2)2 dx = f 00 (ξ),
0 2 0 24
for some ξ ∈ (0, 1). Note that term involving x − 1/2 integrated to zero and we were able
to use the integral mean value theorem in the last term because (x − 1/2)2 is everywhere
non-negative. Once we have the expression (2.2) for the error in the simple midpoint rule
on the unit interval, we can scale to an arbitary interval and add up over subintervals just
as for the trapezoidal rule. We find that the error is bounded by (1/24)(b − a)h2 kf 00 kL∞ ,
exactly 1/2 times the bound we got for the trapezoidal rule.
Define two linear functionals on C([a, b]) by the integral and by the quadrature rule:
Rb
If = a f , Jf = ni=0 wi f (xi ). If the degree of the precision of the quadrature rule is d,
P
then the error functional Ef := If −Jf vanishes on Pd . From this fact alone we can derive a
very useful expression for the error. The approach is very much like the one we used to derive
interpolation error estimates on triangles in Chapter 1.6.2. In deriving the Bramble–Hilbert
lemma we represented an arbitrary function in C k as the sum of a polynomial of degree at
most k (the averaged Taylor polynomial), and an integral of the k + 1st derivatives of the
function times suitable kernel functions. In one dimension the story is simpler, because we
can use the ordinary Taylor theorem with remainder, without the averaging.
Let 0 ≤ k ≤ d be an integer and suppose that f ∈ C k+1 ([a, b]). Then, by Taylor’s
theorem,
1 x (k+1)
Z
f (x) = p(x) + f (t)(x − t)k dt,
k! a
with p ∈ Pk the Taylor polynomial for f about x = a. Now let us write xn+ = xn for
x > 0, 0 otherwise. We can then express the remainder in Taylor’s theorem as r(x) =
1
R b (k+1)
k! a
f (t)(x − t)k+ dt. Since f = p + r and Ep = 0, we have Ef = Er. This gives the
Peano Kernel representation of the error:
Z b
Ef = f (k+1) (t)K(t) dt
a
where K(t) = Ex [(x − t)k+ ]/k!. The key point is that when the linear functional E vanishes
on Pk , we can express Ef as the integral of f (k+1) (t) times an explicit function K(t). The
function K(t) is called the Peano kernel of the error. To establish this result we required
only that E be a linear functional which vanishes on polynomials of degree k and be of a
form that commutes with integration. So it can be used for bounding errors in other contexts
than numerical integration. Note also that if E vanishes on Pk , it also vanishes on Pk−1 ,
Pk−2 , etc. So we have k different Peano kernel representations of the error, which express it
as integral involving f 0 , f 00 , . . . , f (k+1) . We refer to the corresponding Peano kernels as the
first derivative Peano kernel, the second derivative Peano kernel, etc.
As an example of the application of the Peano kernel error representation, we reanalyze
the midpoint rule from using it. Again, we consider first the unit interval and so define
Z 1
Ef = f − f (1/2).
0
2
R 1 00 of precision is 1, so we have two error representations. If f ∈ C , we have
The degree
Ef = 0 f (t)K(t) dt with
Z 1 (
t2 /2, 0 ≤ t ≤ 1/2,
K(t) = (x − t)+ dx − (1/2 − t)+ = 2
0 (1 − t) /2, 1/2 ≤ t ≤ 1
This is the second derivative Peano kernel for the midpoint rule on [0, 1], and is plotted on
the left of Figure 2.1, which also shows the second derivative Peano kernel for the trapezoidal
rule and Simpson’s rule. Note that the midpoint rule Peano kernel satisfies K ≥ 0 on [0, 1],
kKkL∞ = 1/8, kKkL1 = 1/24.
2. THE PEANO KERNEL THEOREM 59
Figure 2.1. The second derivative Peano kernels for the midpoint rule, the
trapezoidal rule, and Simpson’s rule. on [0, 1].
0.2 0.2 0.2
0 0 0
Next scale to an arbitrary interval [α, β] to find the Peano kernel in that case. To
distinguish between the Peano kernel for the midpoint rule on [0, 1] and the Peano kernel for
the midpoint rule on [α, β], at this point we will write K[0,1] and K[α,β] for the latter. With
t̂ = (t − α)/(β − α) we have
Z β Z 1 Z 1
α + β
f (x) dx−(β−α)f = (β−α) fˆ(x̂) dx̂ − fˆ(1/2) = (β−α) fˆ00 (t̂)K[0,1] (t̂) dt̂
α 2 0 0
Z 1 Z β Z β
= (β − α)3 f 00 (t)K[0,1] (t̂) dt̂ = (β − α)2 f 00 (t)K[0,1] (t̂) dt = f 00 (t)K[α,β] (t) dt,
0 α α
where
(
(t − α)2 /2, α ≤ t ≤ α+β ,
K[α,β] (t) = (β − α)2 K[0,1] (t̂) = 2 α+β
2
(β − t) /2, 2
≤ t ≤ β.
For the Peano kernel on [α, β] we have K[α,β] ≥ 0 and kK[α,β] kL1 = (β − α)3 /24.
As an immediate consequences we obtain:
(β − α)3 00 (β − α)3 00
Ef = f (ξ) for some ξ ∈ (α, β), |Ef | ≤ kf kL∞ ,
24 24
Note that the first result is an exact expression for the error and used the fact that K[α,β] is
of one sign, while the only property of K[α,β] entering the error bound are its L1 norm.
Now consider the composite midpoint rule arising from a partition a = x0 < · · · < xn = b.
Once again we have a Peano kernel error representation,
Z b n Z b
X xi−1 + xi
(2.3) f− hi f = f 00 (t)K(t) dt,
a i=1
2 a
where now
(
(t − xi−1 )2 /2, xi−1 ≤ t ≤ (xi−1 + xi )/2,
(2.4) K(t) =
(xi − t)2 /2, (xi−1 + xi )/2 ≤ t ≤ xi ,
i = 1, . . . , n. Note that again K ≥ 0 and now kKkL∞ = supi h2i /8 = h2 /8. We thus obtain
1 X 3 00 (b − a)h2 00
(2.5) Ef = hi f (ξ) for some ξ ∈ (a, b), |Ef | ≤ kf kL∞ .
24 i 24
Thus if f ∈ C 2 ([a, b]), the composite midpoint rule converges as the second power of the
maximal subinterval size.
60 2. NUMERICAL QUADRATURE
We can also use the Peano kernel theorem to represent the error as the integral of the
first derivative of the integrand times the kernel K0 (t) = E[( · − t)+0 ]. In fact, rather than
compute this, let us derive the final (composite rule) representation by integrating by parts
in (2.3). Writing K1 for the kernel given by (2.4) we have
Z b n Z b Z b
X xi−1 + xi 00
f− hi f = f (t)K1 (t) dt = − f 0 (t)K10 (t) dt,
a i=1
2 a a
so
(
xi−1 − t, xi−1 ≤ t ≤ (xi−1 + xi )/2,
K0 (t) = −K10 (t) =
xi − t, (xi−1 + xi )/2 ≤ t ≤ xi .
Note that in
Pthis case the kernel does not have constant sign. The L1 norm is easily bounded:
2
kK0 kL1 = hi /4 ≤ (b − a)h/4. We thus get another estimate for the composite midpoint
rule, valuable especially for f which is not in C 2 ([a, b]):
(b − a)h 0
|Ef | ≤ kf kL∞ .
4
Remark. We have bounded the Peano kernels in L1 in order to obtain an error bound
involving the L∞ norm of a derivative of the solution. It is also possible to use an Lp bound
for the Peano kernel (p > 1) in order to obtain a bound in terms of the Lq (q = p/(p−1) < ∞)
norm of a derivative of the solution. This is preferable in cases were the derivative is singular
or nearly so.
3. Richardson Extrapolation
Let J1 be a quadrature rule on the unit interval with degree of precision p. That is
E1 f := If − J1 f = 0 for f ∈ Pp , but not, in general for f ∈ Pp+1 . We can then write
R1 R1
E1 f = 0 f p+1 (t)K1 (t) dt. Let c1 = 0 K1 . Note that c1 6= 0, since that would imply degree
of precision at least p + 1.
Now let J2 be another quadrature of the same degree of precision, and let c2 denote the
corresponding constant. Assume that c2 6= c1 . Then it is possible to find a linear combination
J = α1 J1 +α2 J2 of the rules, which is itself a quadrature rule with degree of precision greater
than p. Indeed, define the αi by the equations α1 + α2 = 1 and α1 c1 + α2 c2 = 0. With these
values, suppose f ∈ Pp+1 so f (p+1) is constant. Then
For this purpose it is not even necessary to know the error constant c1 for J1 , but only
the fact that the degree of precision of the rule is 1. When we apply the composite form
this means we bring in a factor of the second power of the subinterval size, i.e., a factor
of 1/4, so c2 = c1 /4. Thus α1 = −1/3 and α2 = 4/3, and the new rule turns out to be
Simpson’s rule again. The general pattern is that if J1 is a rule with degree of precision p,
and J2 is the same rule applied with two subintervals, then the constants ci are in the ratio
2p+1 : 1 so α1 = −1/(2p+1 − 1), α2 = 2p+1 /(2p+1 − 1). As a second example, suppose that
J1 f = [f (0) + 3f (1/3) + 3f (2/3) + f (1)]/8 is Simpson’s 3/8 rule, so p = 3. Then
Since this rule is fourth order accurate, we have identified the leading term of an asymptotic
expansion of the error is the (ordinary) composite trapezoidal rule as a function of h. We
Rb
knew before that Eh = a f − Jh f = O(h2 ). We know now that
Eh f = c2 h2 + O(h4 ),
where c2 is precisely [f 0 (b) − f 0 (a)]/12.
With careful analysis we can determine the entire asymptotic expansion of Eh f . To do
this, we need to introduce the Bernoulli polynomials Bn (x). There are many ways to define
the Bernoulli polynomials. We use:
• B0 (x) = 1
• B1 (x) = x − 1/2
• Bn0 (x) = nBn−1 (x), n = 2, 3, . . .
• Bn (0) = Bn (1) = 0 for n = 3, 5, 7, . . .
This clearly uniquely determines all the odd-indexed polynomials as the solution of the
boundary value problem
Bn00 (x) = n(n − 1)Bn−2 (x), Bn (0) = Bn (1) = 0, n = 3, 5, . . . ,
and then the equation nBn−1 (x) = Bn0 (x) determines the even-indexed Bernoulli polynomi-
als. Note that Bn (x) is a monic polynomial of degree n and is an odd or even function of
x − 1/2 according to whether n is odd or even.
(2.6) B0 (x) = 1,
1
(2.7) B1 (x) = x − ,
2
1 1 1
(2.8) B2 (x) = (x − )2 − = x2 − x + ,
2 12 6
1 3 1 1 3 1
(2.9) B3 (x) = (x − ) − (x − ) = x3 − x + x,
2 4 2 2 2
1 1 1 2 7 1 1
(2.10) B4 (x) = (x − )4 − (x − ) + (x − ) = x4 − 2x3 + x2 − .
2 2 2 48 2 30
The Bernoulli numbers are defined by Bk = Bk (0). Thus B1 = −1/2 and Bk = 0 for
k = 3, 5, 7 . . . . B0 = 1, B2 = 1/6, B4 = −1/30, B6 = 1/42.
Remark. Euler gave a generating function for the Bernoulli polynomials:
∞
tetx X tn
= Bn (x) ,
et − 1 n=0 n!
and this is often used to define them. Setting x = 0 we get a generating function for the
Bernoulli numbers:
∞
t X tn
= B n .
et − 1 n=0 n!
4. ASYMPTOTIC ERROR EXPANSIONS 63
R1
Now we apply the Bernoulli polynomials to expand 0 f in terms of the values of f and
its derivatives at 0 and 1. This will give the trapezoidal rule, the endpoint corrections, and
then higher endpoint corrections. The derivation is simply repeated integration by parts:
Z 1 Z 1 Z 1
f (x) dx = f (x)B0 (x) dx = f (x)B10 (x) dx
0 0 0
Z 1
1
= [f (0) + f (1)] − f 0 (x)B1 (x) dx
2 0
1 1 0
Z
1
= [f (0) + f (1)] − f (x)B20 (x) dx
2 2 0
1 1 00
Z
1 B2 0 0
= [f (0) + f (1)] + [f (0) − f (1)] + f (x)B2 (x) dx.
2 2 2 0
Now
Z 1 Z 1
1 00 1
f (x)B2 (x) dx = f 00 (x)B400 (x) dx,
2 0 4! 0
This theorem gives the formula for the trapezoidal rule with m endpoint corrections and
shows
R1 that it has degree of precision at least 2m − 1, and exhibits the Peano kernel. However
0
B2m (x) dx = 2m[B2m−1 (1) − B2m−1 (0)] = 0, so the degree of precision is at least 2m, and
by parity, actually 2m + 1. To derive the Peano kernel error representation in terms of the
2m + 2 derivative, replace m by m + 1 in the expansion and combine the final term of the
sum with the integral to get
Z 1 m
1 X B2k (2k−1)
f (x) dx = [f (0) + f (1)] + [f (0) − f (2k−1) (1)] + Rm ,
0 2 k=1
(2k)!
64 2. NUMERICAL QUADRATURE
where
Z 1
B2m+2 (2m+1) (2m+1) 1
Rm = [f (0) − f (1)] + f (2m+2) (x)B2m+2 (x) dx
(2m + 2)! (2m + 2)! 0
Z 1
1
= f (2m+2) (x)[B2m+2 (x) − B2m+2 ] dx.
(2m + 2)! 0
Thus we see that the trapezoidal rule with m end corrections has degree of precision 2m + 1
and the Peano kernel for the 2m + 2nd derivative is [B2m+2 (x) − B2m+2 (0)]/(2m + 2)!. Note
that this kernel does not change sign (since the even indexed Bernoulli polynomials are
monotonic on [0, 1/2] and even), and that its integral is −B2m+2 /(2m + 2)! (since the even
indexed Bernoulli polynomials have mean value zero). Thus we have the following theorem.
Theorem 2.2. Let m be a positive integer, f ∈ C 2m+2 ([0, 1]). Then
Z 1 m
1 X B2k (2k−1)
f (x) dx = [f (0) + f (1)] + [f (0) − f (2k−1) (1)] + Rm
0 2 k=1
(2k)!
where
Z 1
1 B2m+2 (2m+2)
Rm = f (2m+2) (x)[B2m+2 (x) − B2m+2 ] dx = − f (ξ)
(2m + 2)! 0 (2m + 2)!
for some ξ ∈ (0, 1).
From this we easily get a result for the composite trapezoidal rule.
Corollary 2.3. Let m and n be positive integers and f ∈ C 2m+2 ([a, b]) for some a < b.
Set h = (b − a)/n, xi = a + ih. Then
Z b n−1 m
h X X B2k 2k (2k−1)
f (x) dx = [f (a) + 2 f (xi ) + f (b)] + h [f (a) − f (2k−1) (b)] + Rm
a 2 i=1 k=1
(2k)!
where
B2m+2
Rm = − (b − a)h2m+2 f (2m+2) (ξ),
(2m + 2)!
for some ξ ∈ (a, b).
For smooth periodic functions integrated over a period, the endpoint corrections disap-
pear and the ordinary trapezoidal rule (with constant subintervals) is O(hp ) for any p:
Corollary 2.4. Let m and n be positive integers and f ∈ C 2m+2 (R) is periodic with
period T . Let a ∈ R, b = a + T , h = T /n, xi = a + ih. Then
Z b n−1
X
f (x) dx = h f (xi ) + Rm
a i=0
where
B2m+2
Rm = − (b − a)h2m+2 f (2m+2) (ξ),
(2m + 2)!
for some ξ ∈ (a, b).
5. ROMBERG INTEGRATION 65
In fact, if f is real-analytic and periodic, then the convergence of the trapezoidal rule is
exponential. We can deduce this from our previous analysis of the approximation of periodic
analytic functions by trigonometric polynomials (and so we don’t need the Euler-Maclaurin
expansion for this). Assume for simplicity that the period is 2π and recall that we proved
that for such f there exist positive constants C and δ for which inf q∈Tn kf − qkL∞ ≤ Ce−δn .
R 2π
Now if q(x) = eimx , m 6= 0, then 0 q = 0 and n−1
P
k=0 q(k/n) = 0 for all n which are not
divisors on m. In particular, if we write En for the error operator for the trapezoidal rule
with n equal subintervals, En q = 0 for all q ∈ Tn−1 . Note also that |En g| ≤ 2kgkL∞ for any
continuous g. Thus
Theorem 2.5. Let f be real-analytic and T -periodic, b = a+T . Then there exist positive
constants δ and C such that
Z
b n−1
T X
f− f (a + kT /n) ≤ Ce−δn .
n
a
k=0
5. Romberg Integration
Rb
Suppose we compute the trapezoidal rule approximation to I = a f using equal subin-
tervals of size h, and compute it again using twice as many subintervals of size h/2. Call the
resulting approximations Th f and Th/2 f , respectively. Then, assuming f is smooth, we have
I = Th f + c1 h2 + c2 h4 + · · · ,
1 1
I = Th/2 f + c1 h2 + c2 h4 + · · · .
4 16
Here the ci are independent of h (c1 = [f 0 (a) − f 0 (b)]/12, . . . ). We may then use Richardson
extrapolation to obtain an O(h4 ) approximation to I: with Th/2 1
= (4Th/2 f − Th )/3 we have
1
I = Th/2 + c12 h4 + c13 h6 + · · ·
for some numbers c21 independent of h. Of course we know that the fourth order rule T 1 is
just Simpson’s rule.
If we also compute Th/4 f as well, that we can combine similarly it with Th/2 f to obtain
1
Th/4 f , and for which the leading term of the error will be (c12 /16)h4 . We can then combine
1 1 2 1
Th/2 f and Th/4 by Richardson extrapolation to obtain a sixth order rule: Th/4 = (16Th/4 −
1
Th/2 )/15. In fact, using the same set of functional evaluations we need to compute the 2nd
m
order rule Th/2m f we can obtain a 2mth order rule Th/2 m f . The following diagram shows the
66 2. NUMERICAL QUADRATURE
order of computation.
Th f
&
1
Th/2 f → Th/2 f
& &
1 2
Th/4 f → Th/4 →
Th/4 f
.. .. .. ..
. . . .
1 2 m
Th/2m f → Th/2 m f → Th/2m f · · · Th/2 mf
This systematic use of Richardson extrapolation to obtain the highest possible order from
the given point evaluations is called Romberg Integration. The computation of the final
m
approximation Th/2 m f is very cheap once the first column has been generated (namely once
f has been evaluated at all the necessary points), but it often gives a drastic improvement
in accuracy.
This diagram is reminiscent of a divided difference table for computing an interpolating
polynomial. In fact, there is a direct connection. Let us denote by T (h) the trapezoidal rule
approximation to I using equal subintervals of size h. (Of course T (h) is only defined when
h = (b − a)/n for some positive integer n.) The limh→0 T (h) = I. If we have computed T (h)
for m + 1 distinct positive values of h, h0 , . . . , hm , then a natural way to estimate I = T (0)
is to compute the Lagrange interpolating polynomial determined by these m + 1 values of h
and T (h) and estimate I by the value of the interpolating polynomial at 0. Actually, since
we know from the Euler-Maclaurin expansion that T (h) has P an asymptotic expansion in
powers of h2 , we shall use a polynomial in h2 : P (h) = Q(h2 ) = m 2k
k=0 ak h . The polynomial
2
Q ∈ Pm is determined by the conditions Q(hi ) = Thi f . For example, if we have computed
Th0 f and Th1 f , then
Th f − Th0 f
Q(x) = Th0 f + 1 2 (x − h20 ),
h1 − h20
so
h2 Th f − h21 Th0 f
I ≈ Q(0) = 0 1 2 ,
h1 − h20
In particular, if h1 = h0 /2, then
4Th1 f − Th0 f
I ≈ Q(0) = ,
3
and we see that this procedure reduces to Richardson extrapolation (this in fact explains
the use of the word “extrapolation”). In general, if we compute Thi f for i = 0, . . . , m with
hi = h0 /2i , and then compute the polynomial Q ∈ Pm determined by Q(h2i ) = Thi f , it can
be checked that Q(0) is exactly Thm0 /2m f , the result of Romberg integration. For this reason,
Romberg integration is sometimes called extrapolation to the limit. This analysis also shows
that it is not necessary that the hi = h0 /2i . We could use another sequence of values of hi
as well. Of course the sequence h0 /2i is convenient, because it means that all the function
evaluation needed to compute Thm f are sufficient to compute all the Thi f .
Remark. Note that the idea of extrapolation to the limit applies not only to error in
quadrature, but whenever we know that the error has an asymptotic expansion in powers of
6. GAUSSIAN QUADRATURE 67
a parameter h. We have assumed the expansion is a sum of even powers, but this can be
generalized to allow an expansion in an arbitrary sequence of (known) powers.
6. Gaussian Quadrature
Consider an ordinary quadrature rule with n points x1 < x2 < · · · < xn and weights
w1 , w2 , . . . , wn :
Z b n
X
f (x) dx ≈ wi f (xi ).
a i=1
What is the maximal possible degree of precision? For example, it’s obvious that if n = 1,
the maximal possible degree of precision is 1, which is achieved by the midpoint rule. For
any number of points, an upper bound is immediate:
Theorem 2.6. The degree of precision of an n-point rule is < 2n.
Qn 2
R
Proof.
P The function f (x) = i=1 (x − x i ) is a polynomial of degree 2n. Clearly f>
0 = wi f (xi ).
We shall show that the maximum possible degree of precision 2n − 1 is achieved by a
unique n-point rule. Without loss of generality, we may restrict to the interval [a, b] = [−1, 1].
Our chief tool will be the Legendre polynomials Pn (x). Recall that deg Pn = n and Pn is
L2 ([−1, 1])-orthogonal to Pn−1 . Let x1 < · · · < xn denote the roots of Pn , which we know to
be distinct and to belong to [−1, 1]. These
R1 are Rcalled the n Gauss points on [−1, 1].
1
We define a quadrature rule by −1 f ≈ −1 In f where In f ∈ Pn−1 is the Lagrange
interpolant to f at the n Gauss points. This is a standard interpolatory quadrature rule:
Z 1 n Z bY n
X x − xj
In f = wi f (xi ), wi = dx.
−1 i=1 a j=1
x i − x j
j6=i
The weights of the n-point Gauss rule are positive for all n. To see this, let lj ∈ Pn−1 be
the function that is 1 at xj and 0 at the other xi . Then lj2 ∈ P2n−2 , so
X Z 1
2
wj = wi lj (xi ) = lj2 (x) dx > 0.
i −1
68 2. NUMERICAL QUADRATURE
Note that the n-pointPnGauss rule isR 1the only n-point quadrature rule with degree of
precision 2n − 1. For if i=1 wi f (xi ) = −1 f , then we find that
Z 1
q(x)Πni=1 (x − xi ) dx = 0, q ∈ Pn−1 .
−1
This implies that Πni=1 (x
− xi ) is a multiple of Pn , and hence the xi are the n Gauss points.
Example: Since P2 (x) = (3x2 − 1)/2, the only 2-point rule with degree of precision 3 is
the 2-point Gauss rule
Z 1
f (x) dx ≈ f (a) + f (−a),
−1
√
where a = 3/3 ≈ 0.57735.
6.1. Weighted Gaussian quadrature. The error in numerical integration depends on
the smoothness of the integrand. Frequently an integrand can be written as the product of
a relatively simple, but unsmooth function, times a smoother function. This leads to the
subject of product integration, the determination of quadrature rules for integrands of the
form f (x)ω(x) where f (x) is smooth and ω(x) is in some sense simple or standard.
If ω(x) is any non-negative integrable weight function on [a, b], we can generalize the
Rb
notion of Gaussian quadrature to computing the product a f (x)ω(x) dx. We summarize
the result as:
Theorem 2.8. Let p0 , p1 , . . . be the orthogonal polynomials on [a, b] with respect to the
Rb
innerproduct (f, g) = a f (x)g(x)ω(x) dx. Then pn has n distinct roots in (a, b), x1 , . . . , xn .
If weight wi are defined by
Z bYn
x − xj
wi = ω(x) dx.
a j=1 xi − xj
j6=i
then
Z b X
f (x)ω(x) dx = wi f (xi ) for all f ∈ P2n−1 ,
a
and no other choice of n points and weights realizes this. The weights wi are all positive.
The reader should supply the proof.
For weight ≡ 1 on [−1, 1], we get ordinary Gaussian integration, with the points at the
roots of the Legendre polynomials.
The zeros of the Chebyshev polynomials are the best points to use for approximating
product integrals of the form
Z 1
f (x)
√ dx.
−1 1 − x2
2
The Hermite polynomials, which are orthogonal polynomials on R with the weight e−x , give
the best points for estimating
Z ∞
2
f (x)e−x dx.
−∞
6. GAUSSIAN QUADRATURE 69
6.2. The error in Gaussian quadrature. R1 Let xi and wi be the Gaussian quadra-
ture weights and points for approximating −1 f (x)ω(x) dx (we allow a general non-negative
weight, because it adds no additional difficulty). Then the error functional
Z 1 Xn
Ef := f (x)ω(x) dx − wi f (xi )
−1 i=1
so
|Ef | ≤ Cn kf (2n) k∞ .
We can use Hermite interpolation to get an explicit expression for the constant Cn .
Let h ∈ P2n−1 be the Hermite interpolant of f :
h(xi ) = f (xi ), h0 (xi ) = f 0 (xi ), i = 1, . . . , n.
Then
Z 1 n
X n
X
h(x)ω(x) dx = wi h(xi ) = wi f (xi ),
−1 i=1 i=1
so
Z 1
Ef = [f (x) − h(x)]ω(x) dx.
−1
Theorem 2.9. If f ∈ C (2n) ([−1, 1]), then the error in the Gaussian quadrature rule
satisfies
Z 1 n
X f (2n) (ξ)
f (x)ω(x) dx − wi f (xi ) = kpn k2ω
−1 i=1
(2n)!
for some ξ ∈ (−1, 1).
If we restrict to the case ω = 1, we can scale this result from the unit interval to an
interval of length h, and add up on subintervals to obtain the usual sort of error estimate
when the Gauss rule is used as a composite quadrature rule. (If f ∈ C 2n ([a, b]), then the error
in the composite n-point Gauss rule tends to zero like h2n where h is the largest subinterval
size.
Now we want to analyze the behavior of the error En f in the simple n-point Gauss rule
as n → ∞. For the Newton-Cotes rules, we don’t have convergence as the number of points
tends to infinity, even for f analytic on [−1, 1] (this is quite believable, in view of the Runge
example). However the situation for the Gauss rules is altogether different. First we consider
the Lebesgue constant of the n-point Gauss rule:
X X
Ln = sup | wi f (xi )| = |wi |.
kf kL∞ ≤1
Rb
Since the wi are all positive and sum to kωkL1 = a ω(x) dx, we have Ln = kωkL1 . Note that
Rb
we also have | a f ω| ≤ kωkL1 kf kL∞ , so |En f | ≤ 2kωkL1 kf kL∞ . We then use the standard
argument:
|En f | = inf |En (f − q)| ≤ 2kωkL1 inf kf − qkL∞ .
q∈P2n−1 q∈P2n−1
We can thus bound the error using what we know about polynomial approximation. For
example using the Weierstrass theorem we get:
Theorem 2.10. For any f ∈ C([a, b]) error En f in the n-point (weighted) Gauss rule
tends to zero as n tends to infinity.
Similarly, using the Jackson theorems, we get:
Theorem 2.11. For each positive integer m, there exists a constant C such that |En f | ≤
−m
Cn kf (m) kL∞ for all f ∈ C m ([a, b]).
Finally we get exponential convergence for f analytic.
Theorem 2.12. If f is analytic on [a, b], then there exist positive constant C and δ such
that |En f | ≤ Ce−δn .
Thus to improve the error in a Gaussian quadrature calculation we have two choices:
we may increase n, or we may use the rule as a composite rule and increase the number of
subinterval size.
A disadvantage of the Gaussian rules, is that, whichever of these two choices we make,
we won’t be able to use the functional evaluations from the previous computation for the
new one.
7. ADAPTIVE QUADRATURE 71
7. Adaptive quadrature
The idea of adaptive quadrature is to use a composite rule with (unequal) subintervals
chosen automatically so as to make the error small with as few function evaluations as
possible. To explain the ideas we will first discuss the composite Simpson’s rule.
Let a = x0 < . . . < xn = b, hi = xi − xi−1 . Let S[xi−1 ,xi ] f = hi [f (xi−1 ) + 4f ((xi−1 +
x
R ix)/2) + f (xi )]/6 denote the Simpson’s rule on the ith subinterval and Ei = E[xi−1 ,xi ] f =
xi−1
i
f − S[xi−1 ,xi ] f the error. We know that Ei = ch5i f (4) (ξi ) for some ξi ∈ (xi−1 , xi ) and
some absolute constant c. (For Simpson’s rule, c = −1/2880, but we don’t need to know the
particular value in what follows.) We will assume that hi is small enough that f (4) is roughly
(4) (4)
constant on (xi−1 , xi ), so Ei f = ch5i fi where fi is this constant value (e.g., the value of
f (4) at the midpoint). The error in the composite Simpson’s rule is given by |E1 + · · · + En |.
Since we don’t want to count on the errors from some subintervals cancelling those from
other subintervals, we shall try to minimize |E1 | + · · · + |En |. If we vary the subinterval
sizes hi , we vary this quantity. We claim that when an optimal choice of the hi is made,
(4)
then the error per unit subinterval size, |Ei /hi | = ch4i |fi |, will be roughly the same on each
subinterval (i.e., independent of i). To see this, consider how the error on the ith subinterval
changes when we increase the interval size by a small amount δ. The change is
d|Ei | (4)
δ = 5cδh4i |fi |.
dhi
So if we decrease hi by δ and increase hj by δ, the total change to the error will be about
(4) (4)
5cδ(h4j |fj | − h4i |fi |). If we are at an optimum, this quantity must be 0 (since if it were
negative it would be advantageous to make this change, and if it were positive it would
be advantageous to change in the opposite way). Thus for the optimal mesh distribution,
(4)
h4i |fi | is indeed roughly constant.
This suggest the basic structure of an adaptive quadrature algorithm. Start with a coarse
partition (e.g., one or a few equal subintervals), and a tolerance for |Ei |/hi , i.e., the solution
will be considered acceptable when |Ei |/hi ≤ for all subintervals. This will ensure that
|E1 | + · · · + |En | ≤ (h1 + · · · + hn ) = (b − a) and the user should supply the tolerance
accordingly. Now check each of the subintervals for the condition |Ei |/hi ≤ , and bisect (or
otherwise refine) any one which does not pass.
In order to be able to implement a scheme along these lines we need R β a way to estimate
E[α,β] f for h = β − α small. Since we don’t know the exact value α f we can’t use the
definition of the error as the difference between the exact and computed values. Since we
don’t know f (4) we can’t use our asymptotic formula for the error either. Instead we shall
use Richardson extrapolation. Set γ = (α + β)/2 and let S̃[α,β] = S[α,γ] f + S[γ,β] f , the double
Simpson’s rule (composite rule with two equal subintervals). Then
Z β
f = S[α,β] f + Ch5 + O(h7 ),
α
Z β
1
f = S̃[α,β] f + Ch5 + O(h7 ),
α 16
72 2. NUMERICAL QUADRATURE
I = adapt(f, a, b, )
input: a, b, endpoints of interval of integration
f ∈ C([a, b]), integrand
errorR per unit subinterval tolerance
b
output: I ≈ a f (x) dx
The following Matlab function, adaptsimp.m implements this flow. It includes some
basic practicalities. First, it takes care not to evaluate f at the same point twice. Second, in
7. ADAPTIVE QUADRATURE 73
order to avoid very long or possibly non-terminating computations for very bad integrands
it puts a limit of 10 on the number of times a subinterval can be bisected. It accomplishes
both of these by using two different calling syntaxes. When called by the user, the syntax
is adaptsmp(f,a,b,tol) as above. But when the routine calls itself recursively it uses the
call adaptsmp(f,a,b,tol,lev,fa,fm,fb). The extra parameter lev simply keeps track
of the recursion level so that an exit can be effected if it exceeds 10. The parameters fa,
fm, fb are the values of f at a, (a + b)/2, and b, since these have already been computed
and will be needed again. Finally, from among the various ways to pass a function (f )
as the argument to another function (adaptsimp) in Matlab, we have chosen to make the
argument f a string containing the name of another Matlab function, which should be of the
form function y=f(x), and then we use, e.g., feval(f,a) to evaluate this function at a.
% Divide the interval in half and apply Simpson’s rule on each half.
% As an error estimate for this double Simpson’s rule we use 1/15 times
% the difference between it and the simple Simpson’s rule (which is
% an asymptotically exact error estimate).
h = b - a;
flm = feval(f,a+h/4);
frm = feval(f,b-h/4);
simpl = h*(fa + 4*flm + fm)/12;
simpr = h*(fm + 4*frm + fb)/12;
int = simpl + simpr;
simp = h*(fa+4*fm+fb)/6;
err = (int-simp)/15;
Exercises
1. Consider the function fα (x) = xα on (0, 1). For α > −1 this function is integrable. Us-
ing the computer investigate the rateR 1 of convergence of the composite midpoint rule with
equal subintervals for computing 0 fα for various values of α. Let rα denote the rate of
convergence, i.e., the largest real number so that the error can be bounded by Chrα for some
EXERCISES 75
Figure 2.2. Evaluation points for the adaptive quadrature routine adaptsmp.
100
80
60
40
20
−20
0 0.5 1 1.5 2 2.5 3
6. Find the 1- and 2-point Gaussian quadrature rules for the weight function log(1/x) on [0, 1].
Find expression for the errors.
R1
7. The n-point Gauss-Lobatto quadrature rule (n > 1) is the rule −1 f ≈ ni=1 wi f (xi ) where
P
the x1 = −1, xn = 1, and the other nodes and the weights are chosen so that the degree
of precision is as high as possible. Determine the rule for n = 2, 3, and 4. Explain how,
for general n, the points relate to the orthogonal polynomials with weight 1 − x2 . Give a
formula for the weights.
8. One way to define a non-uniform partition of an interval is through a grading function. A
grading function for the interval [a, b] is a monotone increasing function f mapping [0, 1] one-
to-one and onto [a, b]. We can then define a partition of [a, b] into n subintervals via the points
R1
xi = φ(i/n), i = 0, . . . , n. Consider using this partition to compute the integral 0 f (x) dx
with the trapezoidal rule. Justify heuristically
0 but convincingly that the optimal choice
00
of grading function should satisfy f φ(t) [φ (t)] = const. For the function f (x) = xα ,
2
0 < α < 1, find a grading function satisfying this equation (hint: try φ(t) = tβ ). For
R1
α = 0.2, and n = 1, 2, . . . , 1024, compute the trapezoidal rule approximation to 0 xα dx
using the optimal grading function, and verify numerically that the error behaves as O(1/n2 ).
Thus, using the appropriate grading function, we obtain the same rate of convergence for
this singular integrand as for a smooth integrand.
9. Prove that
R 1 the rate of convergence for the appropriately graded trapezoidal rule approxima-
tion to 0 x dx is indeed O(1/n2 ) by making a change of variable in the integral so that
α
the trapezoidal rule with the graded partition for the original integral corresponds to the
trapezoidal rule with a uniform partition for the new integral.
CHAPTER 3
1. Introduction
To fix ideas and notations we start with a very simple algorithm: multiplication of an
n-vector by an m × n matrix: b = Ax, A ∈ Rm×n , x ∈ Rn , so b ∈ Rm . An obvious algorithm
is
for i =P
1:m
bi = nj=1 aij xj
end
for i = 1 : m
bi ← 0
for j = 1 : n
bi ← bi + aij xj
end
end
Thus the algorithm involves nm additions and nm multiplications. The number of oper-
ations is proportional to the number Pnof input data, which is optimal.
Note that the operation bi = j=1 aij xj may be viewed as the computation of a dot
product of the vector x with the ith row of A. Since many linear algebra algorithms involve
dot products, there are optimized routines to compute dot products on almost all computers,
and an efficient implementation can be built on these. This is one example of a BLAS (basic
linear algebra subroutine).
Note that our algorithm accesses the matrix A by row order. If the matrix is stored by
columns in the computer memory, it is more efficient to use a column oriented algorithm
(especially if the matrix is so large that it does not fit in main memory and must be paged
to disk; similar considerations apply to cache memory). The computer languages Fortran
and Matlab store matrices by column. The computer language C stores by rows.
In fact the matrix-vector multiplication algorithm can be reordered to become P column-
oriented. Namely, we think of b as a linear combination of the columns of a: b = j xj aj ,
where aj denotes the jth column of A. Written out fully in terms of scalar operations the
algorithm is now
77
78 3. DIRECT METHODS OF NUMERICAL LINEAR ALGEBRA
for i = 1 : m
bi ← 0
end
for j = 1 : n
for i = 1 : m
bi ← bi + aij xj
end
end
The inner loop computes a SAXPY operation. A SAXPY is a BLAS which takes a scalar
s and two vectors x and y and computes sx + y. Thus we may implement matrix-vector
multiplication as a row-oriented algorithm consisting chiefly of m dot products of size n or
a column-oriented algorithm consisting chiefly of n SAXPYs of size m.
2. Triangular systems
We recall the forward
Pi−1 elimination algorithm to solve Lx = b where L is lower triangular.
We have xi = (bi − j=1 lij xj )/lii . We may overwrite the bi with the xi to get the algorithm:
b1 ← b1 /l11
for i = 2 : n
for j = 1 : (i − 1)
bi ← bi − lij bj
end
bi ← bi /lii
end
With the usual convention for empty loops, we can write this more briefly as
for i = 1 : n
for j = 1 : (i − 1)
bi ← bi − lij bj
end
bi ← bi /lii
end
or just
for i = 1 : n P
bi ← (bi − i−1
j=1 lij bj )/lii
end
3. GAUSSIAN ELIMINATION AND LU DECOMPOSITION 79
Note that this algorithm accesses L by rows and can be implemented in terms of dot
products. To get a column-oriented algorithm, we can partition L as
l11 0 x1 b1
˜l L̃ = .
x̃ b̃
This shows that, after computing x1 = b1 /l11 we can reduce to the (n − 1) × (n − 1) lower
triangular system L̃x̃ = b̃ − x1 ˜l. This idea leads to the algorithm
for j = 1 : n
bj ← bj /ljj
for i = (j + 1) : n
bi ← bi − lij bj
end
end
for k = 1 : (n − 1)
for i = (k + 1) : n
(k) (k)
mik = aik /akk
for j = (k + 1) : n
(k+1) (k) (k)
aij = aij − mik akj
end
end
end
The multipliers mik determine a unit lower triangular matrix L with the property that,
setting U = A(n−1) , we have A = LU . That is, Gaussian elimination computes the Doolittle
decomposition of a matrix as a product of a unit lower triangular matrix times an upper
triangular matrix.
(k)
We may store the aij over the initial aij and the multiplier mik over aik (since after mik
is computed, aik is set equal to zero). This leads to:
80 3. DIRECT METHODS OF NUMERICAL LINEAR ALGEBRA
Figure 3.1. The bold numbers indicate the order in which the equations are considered.
a11 a12 a13 · · · 1
a21 a22 a23 · · · 3
a31 a32
.. ..
. .
2 4
for k = 1 : (n − 1)
for i = (k + 1) : n
aik ← aik /akk
for j = (k + 1) : n
aij ← aij − aik akj
end
end
end
Note that Gaussian elimination may break-down, namely one of the diagonal elements
(k)
akk may be zero. The most obvious situation in which this happens is when a11 happens
to be zero. To investigate when this happens, let us consider a more direct algorithm for
computing the Doolittle LU decomposition. Suppose A = LU with L unit lower triangular,
U upper triangular. Then
n
(P
j
X lik ukj , j < i,
aij = lik ukj = Pk=1
i
k=1 k=1 lik ukj , j ≥ i
only if A2 is nonsingular and, since we know that u11 6= 0, this holds if and only if u22 is
nonsingular. Continuing in this way, we conclude
Theorem 3.1. An n × n nonsingular matrix A admits a decomposition LU with L unit
lower triangular and U upper triangular if and only if all its principal minors are nonsingular.
We have seen two algorithms for computing the Doolittle LU factorization. They involve
basically the same operations in different order. In particular the number of additions and
multiplications required are n3 /3 in each case. The classical Gaussian elimination is easily
implemented with the inner loop consisting of row-oriented SAXPY operations. It is also
straightforward to devise a column-oriented version.
If the nonsingular matrix admits a Doolittle decomposition, we may write the upper
triangular part as DU with D diagonal and U unit upper triangular. Thus A has a unique
decomposition as LDU with D diagonal and L and U unit lower and upper triangular,
respectively. In addition to the Doolittle decomposition L(DU ), there is the Crout decom-
position (LD)U into a lower triangular matrix times a unit upper triangular. Algorithms
for this may be constructed as for the Doolittle decomposition.
If A is symmetric, then in the LDU decomposition U = LT . If, in addition, the elements
of D are positive, then we can use the symmetric decomposition LD1/2 D1/2 LT . Writing L
for LD1/2 , so now L is a lower triangular matrix with positive diagonal elements, we have
A = LLT . This is the Cholesky decomposition of A. If A admits a Cholesky decomposition, it
is SPD (symmetric positive-definite). Conversely, reasoning much as we did for the Doolittle
decomposition, we can show that every SPD matrix admits a unique Cholesky decomposition
(left as an exercise to the reader). Here is an algorithm. In view of the symmetry of A, it
never refers to the elements of A lying above the diagonal:
for k = 1 : n
for i = 1 : (k − 1)
lki = (aki − i−1
P
m=1 lim lkm )/lii
end q
lkk = akk − k−1 2
P
m=1 lkm
end
for k = 1 : n
for i = 1 : (k − 1)
aki ← (aki − i−1
P
m=1 aim akm )/aii
end q
akk ← akk − k−1 2
P
m=1 akm
end
4. Pivoting
Gaussian elimination breaks down at the first step if a11 = 0. In this case we may switch
the first row with any row that has a nonzero element in the first column. Such a row
must exist, if the matrix is nonsingular. Similarly, at some later stage of the procedure one
of the updated diagonal elements akk (the so-called pivots) may vanish and the algorithm
will break-down. Even if the pivot is not zero, it may be very small, and this increases the
possibility there will be large round-off errors introduced. Indeed if a very small pivot is
used, the corresponding multiplier will be very large, and if the solution is not large, there
must be some cancellation occuring when we compute it. To understand this in more detail,
let’s consider the 2 × 2 case.
For the system
a11 a12 x1 b
= 1
a21 a22 x2 b2
Gaussian elimination reads:
1: m ← a21 /a11
2: a22 ← a22 − m · a12
3: b2 ← b2 − m · b1
4: x2 ← b2 /a22
5: x1 ← (b1 − a12 · x2 )/a11
Precision can be lost, possibly, in steps 2, 3, and 5, since only these involve addition or
subtraction.
Now consider the specific system
1 x1 1
=
1 1 x2 2
where is very small (near unit round-off). If = 0, the solution is x1 = x2 = 1, and if
is small, the solution is x1 = 1/(1 − ) = 1 + O(), x2 = (1 − 2)/(1 − ) = 1 + O(). The
multiplier m is −1 , so the subtractions in steps 2 and 3 are 1 − −1 and 2 − −1 which will
not entail much loss of precision. However, the subtraction in step 5 is 1 − x2 with x2 very
near 1, and so will result in catastrophic cancellation. Hence we would expect that for
very small x2 will be computed accurately, but not x1 . In fact, a Fortran single precision
program with = 10−6 gives x1 = 1.013279, x2 = 0.999999. The correct answers to 7 places
are 1.000001 and 0.999999, and the relative errors are 1.3 × 10−2 for x1 , 1.3 × 10−8 for x2 .
If we consider this system with = 0, the solution is obvious: interchange the rows. The
same is advisable for small. In this case the multiplier is , and the subtractions are 1 − ,
1 − 2, and 2 − x2 where x2 is close to 1. Thus there are no serious cancellations.
In general, if facing a matrix in which the (1, 1) element is very small, a reasonable idea is
to switch the first row with the row containing an element which is not small. A reasonable
choice, which is usually made, is to switch with the row which has the largest element (in
absolute value) in the first column. This results in multipliers which are no greater than 1,
which prevents the creation of large magnitude element during this step of the elimination,
which tends to decrease cancellation in later stages.
5. BACKWARD ERROR ANALYSIS 83
Similarly, before performing the second step of the elimination we switch the second row
with whatever row below the first has the largest magnitude element in the second column.
Etc. This procedure is known as partial pivoting. Actually, in practice one does not switch
the rows, but rather changes the order of the rows used in elimination. That is, rather than
using the order 1, 2, . . . , n, one uses some permutation p1 , p2 , . . . , pn , which is determined
in the course of the algorithm (as described above). Thus the basic Gaussian elimination
routine which reads
for k = 1, 2, . . . , n − 1
for i = k + 1, k + 2, . . . , n
aik ← aik /akk
aij ← aij − aik akj , j = k + 1, k + 2, . . . , n
end for
end for
becomes
for pi = i, i = 1, 2, . . . , n
for k = 1, 2, . . . , n − 1
choose i ≥ k and interchange pk and pi
for k = 1, 2, . . . , n − 1
for i = k + 1, k + 2, . . . , n
m ← api k /apk k
api j ← api j − mapk j , j = k + 1, k + 2, . . . , n
end for
end for
The values of the pi are determined in the course of the algorithm (before they are used
of course!). It can be seen that Gaussian elimination with partial pivoting is equivalent to
factoring the matrix P A as LU where P A is the matrix obtained from A by switching the
order of the rows from the outset. This is actually the matrix product P A where P is a
permutation matrix, i.e., a matrix with the same columns as the identity matrix (but in
a different order). For any nonsingular matrix, partial pivoting determines a permutation
such that P A admits an LU decomposition. In other words, in exact arithmetic Gaussian
elimination with partial pivoting always works. (In the next section we shall discuss the effect
of partial pivoting on the propagation of round-off error when floating point arithmetic is
used.)
There are also several situations in which it can be shown that pivoting is not neces-
sary. The two most important cases P are positive definite matrices and diagonally dominant
matrices (matrices with |aii | > j6=i |aij |.
uT |u|T
a11 0 0 |a11 |
L̂Û = =: A + , |L̂||Û | = .
a11 ˆl L̂1 Û1 + ˆluT f F |a11 ||ˆl| |L̂1 ||Û1 | + |ˆl||u|T
Thus we need to show that
(3.1) |f | ≤ 2(n − 1)(|v| + |a11 ||ˆl|)u + O(u2 ),
(3.2) |F | ≤ 2(n − 1)(|B| + |L̂1 ||Û1 | + |ˆl||u|T )u + O(u2 ).
Now
|f | = |a11 ˆl − a11 l| = |a11 ||ˆl − l| ≤ |a11 ||l|u = |v|u,
so (3.1) is trivially satisfied and the proof will be complete if we can establish (3.2).
5. BACKWARD ERROR ANALYSIS 85
Now
(3.3) F = L̂1 Û1 + ˆluT − B = (L̂1 Û1 − Â(1) ) + (Â(1) + ˆluT − B).
First consider the second term on the right-hand side. From the definition of Â(1) , we have
Â(1) = [B − (ˆluT + G)] + H with |G| ≤ |ˆl||u|T u, |H| ≤ (|B| + |ˆl||u|T )u + O(u2 ), so
(3.4) |Â(1) + ˆluT − B| = | − G + H| ≤ 2(|B| + |ˆl||u|T )u + O(u2 ).
We also deduce from this estimate that
(3.5) |Â(1) | ≤ (1 + 2u)(|B| + |ˆl||u|T ) + O(u2 ).
Turning to the first term on the right-hand side of (3.3), we invoke the inductive hypoth-
esis and then use (3.5) to get
|L̂1 Û1 − Â(1) | ≤ 2(n − 2)(|Â(1) | + |L̂1 ||Û1 |)u + O(u2 )
(3.6)
≤ 2(n − 2)(|B| + |ˆl||u|T + |L̂1 ||Û1 |)u + O(u2 ).
Combining (3.3), (3.4), and (3.6), we easily obtain (3.2), and so conclude the proof.
It is important to interpret the result of this theorem. First of all, it is a backward error
analysis. That is, we are not bounding the errors L − L̂ and U − Û (which is harder to do),
but rather the residual E = L̂Û − A. Second, in the bound derived for |E|, the term 2(n − 1)
should be considered of little importance. Since in practice u is many orders of magnitude
smaller than 1/n, we can think of this factor as contributing little. (In fact, at the expense
of a fussier proof and less transparent final statement, we could sharpen this factor, but
there is little point to doing so, just as there is little point in giving an explicit bound for
the O(u2 ) term although it would be possible to do.) So psychologically the bound on |E|
should be read as O (|A| + |L̂||Û |)u). Now if the bound were simply O(|A|u), this would be
a very satisfactory result: it would say that L̂Û is the LU decomposition of a matrix whose
elements approximate those of A with the same order of accuracy as the closest floating
point approximation. Put in another way, it would say that the errors due to floating point
arithmetic are of the same order as the errors that occur when the matrix (not assumed to
have exact floating point entries) is rounded to machine numbers. Now if the matrices L̂
and Û are not much larger than A, then we still have a very satisfactory result. However,
if we use Gaussian elimination without pivoting, we have seen that even in the 2 × 2 case,
that small pivots may arise, and then it will usually happen that L̂ and Û (or just L and
U ) have much larger entries than A. In this case the bound suggests (correctly) that the
error matrix E may be much larger than one would get by just approximating the original
matrix. One nice aspect, is that one can monitor this potential problem. After computing
the LU decomposition one can simply check whether L̂ and Û are very large. If this is not
the case, the relative residual L̂Û − A will not be large.
A similar backward error analysis can be given for the solution to triangular systems. If
we combine these results with the theorem above, we get a backward error bound for the
solution of linear systems. A proof is given in Golub and Van Loan, Matrix Computations.
Theorem 3.3. Let A be an n × n matrix of floating point numbers and b an n-vector
of floating point numbers. Let L̂ and Û be computed by Gaussian elimination with floating
86 3. DIRECT METHODS OF NUMERICAL LINEAR ALGEBRA
point arithmetic assuming no zero pivots are encountered and let x̂ be computed by solving
L̂Û x̂ = b using forward elimination and back substitution with floating point arithmetic.
Then there exists a matrix E satisfying
|E| ≤ 5n(|A| + |L̂||Û |)u + O(u2 ),
such that (A + E)x̂ = b.
Thus, if L̂ and Û are not very large, the computed solution is the exact solution to the
problem where the matrix has been replaced by a nearby matrix. Again, if we don’t pivot it
may happen that L̂ and/or Û is very large.
Let us now consider what happens if we perform Gaussian elimination with pivoting. We
may think of this as applying Gaussian elimination to a matrix which has been reordered
so that at every step the pivot element exceeds in magnitude all elements below it in the
column. In other words, the elements of the matrix L are all bounded by 1 in magnitude.
The question then becomes, how much larger the eliminated matrix U can be than the
original matrix A. In fact, it can be much larger. If we let
1 0 0 ... 1
−1 1 0 . . . 1
−1 −1 1 . . . 1 ,
A= . .
.. .. .. . . ..
. . .
−1 −1 −1 . . . 1
then it is easy to carry out the elimination by hand. All the multipliers are −1 (so partial
pivoting won’t occur) and the final matrix U is
1 0 0 ... 1
0 1 0 . . . 2
0 0 1 . . . 4 .
U =
... ... ... . . . ..
.
0 0 0 . . . 2n−1
Thus, although the largest magnitude of an element of A is 1, the eliminated matrix U has
an element equal to 2n−1 .
Fortunately cases like the above are rare, and the received wisdom is that in practice
Gaussian elimination with partial pivoting rarely fails.
For complete pivoting the worst possible growth of matrix size due to elimination is much
smaller. Let us define the growth factor as maxij |uij |/ maxij |aij |. (Actually the growth
(k) (k)
factor is generally defined as g = maxi,j,k |aij |/ maxi,j |aij | where the aij are the elements
of the intermediate matrices which come up during the elimination process, however for
complete pivoting the maximum in the numerator is achieved by one of the pivots, and
hence are present (on the diagonal) in the final matrix, so the two ratios are equal.) No one
has proved a sharp bound on the growth factor for complete pivoting. The chief theoretical
bound seems to be Wilkinson’s from 1961: the Q ratio of the largest element of U to that of
A with complete pivoting does not exceed n1/2 nj=2 j 1/[2(j−1)] . This gives a value of about
19 for n = 10; 570 for n = 50; 3, 500 for n = 100; 9, 000, 000 for n = 1000; and 1017 for
n = 100, 000. However based on numerical experience Wilkinson conjectured that the ratio
6. CONDITIONING 87
is actually bounded by n. This turned out to be false: a counterexample was given (by Nick
Gould, corrected by Alan Edelman) in 1991, with a matrix of size n = 13 with factor a bit
above 13.02. Similarly a matrix of size 25 was computed with a growth factor of 32.99. In
any case, as mentioned above, the received wisdom is that the growth due to partial pivoting
is almost always acceptable in practice, and so the slower growth due to complete pivoting
rarely justifies the extra expense. (Partial pivoting requires n2 /2 comparisons, and thus
invokes a small cost compared to the O(n3 ) operations necessary to perform the elimination,
but complete pivoting requires n3 /3 comparisons, which is not negligeable.)
6. Conditioning
Backward error analysis essentially assures us that if we use Gaussian elimination with
pivoting to solve a linear system with floating point arithmetic, then the residual of the
resulting solution will be small. It is important to realize that this does not imply that the
error will be small.
Thus, suppose Ax = b with A nonsingular. If we perturb b to b̃, this leads to a change
in x to x̃ defined by Ax̃ = b̃. If the relative error
kb̃ − bk
kbk
is small (measured in some vector norm), what about the relative error in x?
kx̃ − xk kA−1 (b̃ − b)k kAxk kb̃ − bk
= ≤ κ(A)
kxk kbk kxk kbk
where
κ(A) = kAkkA−1 k
is the condition number of A with respect to the associated matrix norm. (Given any norm
on Rn , there is an associated norm on Rn×n defined by kAk = sup06=x∈Rn kAxk/kxk. Such
a norm is sometimes called an operator norm, since it is the natural norm in the space of
linear operators from the normed vector space Rn to itself. The associated operator matrix
norm is compatible with the given vector norm in the sense that kAxk ≤ kAkkxk.)
Example (due to R. Wilson):
10 7 8 7 32 1
7 5 6 5 23 1
A= 8 6 10 9 ,
b= 33 ,
x= 1 .
7 5 9 10 31 1
32.1 9.2
22.9 −12.6
b̃ =
33.1 ,
x̃ =
4.5 .
30.9 −1.1
Exercises
1. Prove that if A is symmetric positive definite, then A = LLT for a unique lower triangular
matrix L. State an algorithm for computing L, and show that it does not break down (no
divisions by zero or square-roots of negative numbers).
2. Write a column oriented algorithm to compute the Doolittle LU decomposition. That is,
given a matrix A with nonsingular principal minors, your algorithm should overwrite the ele-
ments on or above the diagonal of A with the corresponding elements of an upper triangular
matrix U and overwrite the below-diagonal elements of A with the corresponding elements
of a unit lower triangular matrix L such that LU = A, and your algorithm should access
the elements of A by columns. In addition to writing the algorithm, submit a direct Matlab
EXERCISES 89
translation along with a verification that it works using a random 4 × 4 matrix. Discuss the
implementation of your algorithm using BLAS.
90 3. DIRECT METHODS OF NUMERICAL LINEAR ALGEBRA
CHAPTER 4
2. One-point iteration
For many iterative methods, xi+1 depends only on xi via some formula that doesn’t
depend on i: xi+1 = G(xi ). Such a method is called a (stationary) one-point iteration.
Before considering specific iterations to solve F (x) = 0, we consider one-point iterations in
general.
Assuming the iteration function G is continuous, we obviously have that if the iterates
xi+1 = G(xi ) converge to some limit x∗ , then x∗ = G(x∗ ), i.e., x∗ is a fixed point of G.
A basic result is the contraction mapping theorem. Recall that a map G : B → Rn
(B ⊂ Rn ) is called a contraction (with respect to some norm on Rn ) if G is Lipschitz with
Lipschitz constant strictly less than 1.
Theorem 4.1. Suppose G maps a closed subset B of Rn to itself, and suppose that G
is a contraction (with respect to some norm). Then G has a unique fixed point x∗ in B.
Moreover, if x0 ∈ B is any point, then the iteration xi+1 = G(xi ) converges to x∗ .
If G ∈ C 1 a practical way to check whether G is a contraction (with respect to some
norm on Rn ) is to consider kG0 (x)k (in the associated matrix norm). If kG0 (x)k ≤ λ < 1 on
some convex set Ω (e.g., some ball), then G is a contraction there. In one dimension this is
an immediate consequence of the mean value theorem. In n dimensions we don’t have the
mean value theorem, but we can use the fundamental theorem of calculus to the same end.
Given x, y ∈ Ω we let g(t) = G(x + t(y − x)), so g 0 (t) = 0
R 1G0 (x + t(y − x))(y − x). From the
fundamental theorem of calculus we get g(1) − g(0) = 0 g (t) dt, or
Z 1
0
G(y) − G(x) = G (x + t(y − x)) dt (y − x),
0
whence
kG(y) − G(x)k ≤ sup kG0 (x + t(y − x))kky − xk ≤ λky − xk,
0≤t≤1
and so G is a contraction.
If we assume that x∗ is a fixed point of G, G ∈ C 1 , and r = kG0 (x∗ )k < 1, then we can
conclude that the iteration xi+1 = G(xi ) converges for any starting iterate x0 sufficiently
close to x∗ . This is called a locally convergent iteration. The above argument also shows
that convergence is (at least) linear with rate r.
In this connection, the following theorem, which connects kAk to ρ(A) (the spectral
radius of A, i.e., the maximum modulus of its eigenvalues), is very useful.
Theorem 4.2. Let A ∈ Rn×n . Then
1. For any operator matrix norm, kAk ≥ ρ(A).
2. If A is symmetric, then kAk2 = ρ(A).
3. If A is diagonalizable, then there exists an operator norm so that kAk = ρ(A).
4. For any A and any > 0, there exists an operator norm so that ρ(A) ≤ kAk ≤ ρ(A)+.
Proof. 1. If Ax = λx where x 6= 0 and |λ| = ρ(A), then from kAxk = |λ|kxk we see
that kAk ≥ ρ(A).
p p
2. kAk2 = ρ(AT A) = ρ(A2 ) = ρ(A).
2. ONE-POINT ITERATION 93
3. First note that if S ∈ Rn×n is nonsingular and k · k0 any vector norm, then kxk :=
kSxk0 is another vector norm, and the associated matrix norms satisfy kAk = kSAS −1 k0 .
Now if A is diagonalizable, then there exists S nonsingular so that SAS −1 is a diagonal
matrix with the eigenvalues of A on the diagonal (the columns of S −1 are the eigenvectors
of A). Hence if we apply the above relation beginning with the ∞-norm for k · k0 , we get
kAk = ρ(A).
4. The proof is similar in this case, but we use the Jordan canonical form to write
SAS −1 = J where J has the eigenvalues of A on the diagonal, 0’s and ’s above the diagonal,
and 0’s everywhere else. (The usual Jordan canonical form is the case = 1, but if we
conjugate a Jordan block by the matrix diag(1, , 2 , . . . ) the 1’s above the diagonal are
changed to .) Thus for the matrix norm associated to kxk := kSxk∞ , we have kAk =
kJk∞ ≤ ρ(A) + .
Corollary 4.3. If G is C 1 in a neighborhood of a fixed point x∗ and r = ρ(G0 (x∗ )) < 1,
the one point iteration with iteration function G is locally convergent to x∗ with rate r.
Although we don’t need immediately it, we note another useful corollary of the proceeding
theorem.
Corollary 4.4. Let A ∈ Rn×n . Then limn→∞ An = 0 if and only if ρ(A) < 1, and in
this case the convergence is linear with rate ρ(A).
Proof. kAn k ≥ ρ(An ) = ρ(A)n , so if ρ(A) ≥ 1, then An does not converge to 0.
Conversely, if ρ(A) < 1, then for any ρ̄ ∈ (ρ(A), 1) we can find an operator norm so that
kAk ≤ ρ̄, and then kAn k ≤ kAkn = ρ̄n → 0.
Finally, let us consider the case G0 (x∗ ) = 0. Then clearly the iteration is superlinearly
convergent. If G is C 2 , or, less, if G0 is Lipschitz, then we can show that the convergence is
in fact quadratic. First note that for any C 1 function G,
Z 1
0
G(y) − G(x) − G (x)(y − x) = [G0 (x + t(y − x)) − G0 (x)] dt(y − x).
0
0
Hence, if G is Lipschitz,
C
kG(y) − G(x) − G0 (x)(y − x)k ≤ ky − xk2 ,
2
where C is the Lipschitz constant. Applying this with x = x∗ and y = xi and using the fact
that G(x∗ ) = x∗ , G0 (x∗ ) = 0, we get
C
kxi − x∗ k2 ,
kxi+1 − x∗ k ≤
2
which is quadratic convergence. In the same way we can treat the case of G with several
vanishing derivatives.
Theorem 4.5. Suppose that G maps a neighborhood of x∗ in Rn into Rn and that x∗
is a fixed point of G. Suppose also that all the derivatives of G of order up to p exist, are
Lipschitz continuous, and vanish at x∗ . Then the iteration xi+1 = G(xi ) is locally convergent
to x∗ with order p + 1.
94 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
3. Newton’s method
An important example of a one-point iteration is Newton’s method for root-finding. Let
F : Ω → Rn be C 1 with Ω ⊂ Rn . We wish to find a root x∗ of F in Ω. If x0 ∈ Ω is an initial
guess of the root, we approximate F by the linear part of its Taylor series near x0 :
F (x) ≈ F (x0 ) + F 0 (x0 )(x − x0 ).
The left-hand side vanishes when x is a root, so setting the right-hand side equal to zero gives
us an equation for a new approximate root, which we take to be x1 . Thus x1 is determined
by the equation
F (x0 ) + F 0 (x1 )(x1 − x0 ) = 0,
or, equivalently,
x1 = x0 − F 0 (x0 )−1 F (x0 ).
Continuing in this way we get Newton’s method:
xi+1 = xi − F 0 (xi )−1 F (xi ), i = 0, 1, . . . .
/ Ω or that some F 0 (xi ) is singular, in which case
(Of course it could happen that some xi ∈
Newton’s method breaks down. We shall see that under appropriate conditions this doesn’t
occur.)
Note that Newton’s method is simply iteration of the function
G(x) = x − F 0 (x)−1 F (x).
Now if x∗ is a root of F and F 0 (x∗ ) is nonsingular (i.e., if x∗ is a simple root), then G is
continuous in a neighborhood of x∗ , and clearly x∗ is a fixed point of G. We have that
G0 (x) = I − K(x)F (x) − F 0 (x)−1 F 0 (x) = −K(x)F (x)
where K is the derivative of the function x 7→ F 0 (x)−1 (this function maps a neighborhood
of x∗ in Rn into Rn×n ). It is an easy (and worthwhile) exercise to derive the formula for
K(x) in terms of F 0 (x) and F 00 (x), but we don’t need it here. It suffices to note that K
exists and is Lipschitz continuous if F 0 and F 00 are. In any case, we have that G0 (x∗ ) = 0.
Thus, assuming that F is C 2 with F 00 Lipschitz (e.g., if F is C 3 ), we have all the hypotheses
necessary for local quadratic convergence. Thus we have proved:
Theorem 4.6. Suppose that F : Ω → Rn , Ω ⊂ Rn is C 2 with F 00 Lipschitz continuous,
and that F (x∗ ) = 0 and F 0 (x∗ ) is nonsingular for some x∗ ∈ Ω. Then if x0 ∈ Ω is sufficiently
close to x∗ , the sequence of points defined by Newton’s method is well-defined and converges
quadratically to x∗ .
The hypothesis that the root be simple is necessary for the quadratic convergence of
Newton’s method, as can easily be seen by a 1-dimensional example. However, the smooth-
ness assumption can be weakened. The following theorem requires only that F 0 (rather than
F 00 ) be Lipschitz continuous (which holds if F is C 2 ). In the statement of the theorem any
vector norm and corresponding operator matrix norm can be used.
3. NEWTON’S METHOD 95
Theorem 4.7. Suppose that F (x∗ ) = 0 and that F 0 is Lipschitz continuous with Lipschitz
constant γ in a ball of radius r around x∗ . Also suppose that F 0 (x∗ ) is nonsingular with
kF 0 (x∗ )−1 k ≤ β. If kx0 − x∗ k ≤ min[r, 1/(2βγ)], then the sequence determined by Newton’s
method is well-defined, converges to x∗ , and satisfies
kxi+1 − x∗ k ≤ βγkxi − x∗ k2 .
Proof. First we show that F 0 (x0 ) is nonsingular. Indeed,
kF 0 (x∗ )−1 [F 0 (x0 ) − F 0 (x∗ )]k ≤ βγkx0 − x∗ k ≤ 1/2,
from which follows the nonsingularity and the estimate
1
kF 0 (x0 )−1 k ≤ kF 0 (x∗ )−1 k ≤ 2β.
1 − 1/2
Thus x1 is well-defined and
x1 − x∗ = x0 − x∗ − F 0 (x0 )−1 F (x0 )
= x0 − x∗ − F 0 (x0 )−1 [F (x0 ) − F (x∗ )]
= F 0 (x0 )−1 [F (x∗ ) − F (x0 ) − F 0 (x0 )(x∗ − x0 )].
We have previously bounded the norm of the bracketed quantity by γkx∗ − x0 k2 /2 and
kF 0 (x0 )−1 k ≤ 2β, so
kx1 − x∗ k ≤ βγkx0 − x∗ k2 .
This is the kind of quadratic bound we need, but first we need to show that the xi are indeed
converging to x∗ . Using again that kx0 − x∗ k ≤ 1/(2βγ), we have the linear estimate
kx1 − x∗ k ≤ kx∗ − x0 k/2.
Thus x1 also satisfies, kx1 − x∗ k≤ min[r, 1/(2βγ)], and the identical argument shows
kx2 − x∗ k ≤ βγkx1 − x∗ k2 , and kx2 − x∗ k ≤ kx1 − x∗ k/2.
Continuing in this way we get the theorem.
The theorem gives a precise sufficient condition on how close the initial iterate x0 must
be to x∗ to insure convergence. Of course it is not a condition that one can apply practically,
since one cannot check if x0 satisfies it without knowing x0 . There are several variant results
which weaken the hypotheses necessary to show quadratic convergence for Newton’s method.
A well-known, but rather complicated one is Kantorovich’s theorem (1948). Unlike the above
theorems, it does not assume the existence of a root x∗ of F , but rather states that if an
initial point x0 satisfies certain conditions, then there is a root, and Newton’s method will
converge to it. Basically it states: if F 0 is Lipschitz near x0 and nonsingular at x0 , and if
the value of F (x0 ) is sufficiently small (how small depending on the Lipschitz constant for
F 0 , and the norm of F 0 (x0 )−1 ), then Newton’s method beginning from x0 is well-defined and
converges quadratically to a root x∗ . The exact statement is rather complicated, so I’ll omit
it. In principle, one could pick a starting iterate x0 , and then compute the norms of F (x0 )
and F 0 (x0 ), and check to see if they fulfil the conditions of Kantorovich’s theorem (if one
knew a bound for the Lipschitz constant of F 0 in a neighborhood of x0 ), and thus tell in
advance whether Newton’s method would converge. In practice this is difficult to do and
would rule out many acceptable choices of initial guess, so it is rarely used.
96 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
4. Quasi-Newton methods
Each iteration of Newton’s method requires the following operations: evaluate the func-
tion F at the current approximation, evaluate the derivative F 0 at the current approximation,
solve a system of equations with the latter as matrix and the former as right-hand side, and
update the approximation. The evaluation of F 0 and the linear solve are often the most
expensive parts. In some applications, no formula for F 0 is available, and exact evaluation of
F 0 is not possible. There are many variations of Newton’s method that attempt to maintain
good local convergence properties while avoiding the evaluation of F 0 , and/or simplifying
the linear solve step. We shall refer to all of these as quasi-Newton methods, although some
authors restrict that term to specific types of modification to Newton’s method.
Consider the iteration
xi+1 = xi − Bi−1 F (xi ),
where for each i, Bi is a nonsingular matrix to specified. If Bi = F 0 (xi ), this is Newton’s
method. The following theorem states that if Bi is sufficiently close to F 0 (xi ) then this
method is still locally convergent. With a stronger hypothesis on the closeness of Bi to
F 0 (xi ) the convergence is quadratic. Under a somewhat weaker hypothesis, the method still
converges superlinearly.
Theorem 4.8. Suppose F 0 is Lipschitz continuous in a neighborhood of a root x∗ and
that F 0 (x∗ ) is nonsingular.
1. Then there exists δ > 0 such that if kBi − F 0 (xi )k ≤ δ and kx0 − x∗ k ≤ δ, then the
generalized Newton iterates are well-defined by the above formula, and converge to x∗ .
2. If further kBi − F 0 (xi )k → 0, then the convergence is superlinear.
3. If there is a constant c such that kBi − F 0 (xi )k ≤ ckF (xi )k, then the convergence is
quadratic.
Proof. Set β = kF 0 (x∗ )−1 k < ∞. Choosing δ small enough, we can easily achieve
kx − x∗ k ≤ δ, kB − F 0 (x)k ≤ δ =⇒ kB −1 k ≤ 2β.
Let γ be a Lipschitz constant for F 0 . Decreasing δ if necessary we can further achieve
2β(γ/2 + 1)δ ≤ 1/2.
Now let x0 and B0 be chosen in accordance with this δ. Then
x1 − x∗ = x0 − x∗ − B0−1 F (x0 ) = B0−1 [F (x∗ ) − F (x0 ) − B0 (x∗ − x0 )]
Z 1
−1
= B0 [F 0 ((1 − t)x0 + tx∗ ) − B0 ]dt (x∗ − x0 ).
0
0
Now kF ((1 − t)x0 + tx∗ ) − B0 k ≤ γtkx0 − x∗ k + δ, by the triangle inequality, the Lipschitz
condition, and the condition on B0 . Thus
which gives superlinearity under the additional hypothesis of (2). From the additional hy-
pothesis of (3), we get
kBi − F 0 (xi )k ≤ ckF (xi ) − F (x∗ )k ≤ c0 kxi − x∗ k,
which gives the quadratic convergence.
5. Broyden’s method
Broyden’s method (published by C. G. Broyden in 1965) is an important example of
a quasi-Newton method. It is one possible generalization to n-dimensions of the secant
method. For a single nonlinear equation, the secant method replaces f 0 (xi ) in Newton’s
method with the approximation [f (xi ) − f (xi−1 )]/(xi − xi−1 ), to obtain the iteration
xi − xi−1
xi+1 = xi − f (xi ).
f (xi ) − f (xi−1 )
Of course, we cannot directly generalize this idea to Rn , since we can’t divide by the vector
xi − xi−1 . Instead, we can consider the equation
Bi (xi − xi−1 ) = F (xi ) − F (xi−1 ).
However, this does not determine the matrix Bi , only its action on multiples of xi − xi−1 . To
complete the specification of Bi , Broyden’s method sets the action on vectors orthogonal to
xi − xi−1 to be the same as Bi−1 . Broyden’s method is an update method in the sense that
Bi is determined as a modification of Bi−1 .
In order to implement Broyden’s method, we note:
98 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
Choose x0 ∈ Rn , B0 ∈ Rn×n
for i = 0, 1, . . .
xi+1 = xi − Bi−1 F (xi )
si = xi+1 − xi
vi = F (xi+1 ) − F (xi )
1
Bi+1 = Bi + T (vi − Bi si )sTi
si si
end
Choose x0 ∈ Rn , H0 ∈ Rn×n
for i = 0, 1, . . .
xi+1 = xi − Hi F (xi )
si = xi+1 − xi
vi = F (xi+1 ) − F (xi )
1
Hi+1 = Hi + T (si − Hi vi )sTi Hi
si Hi v i
end
Note that if H0 is B0−1 this algorithm is mathematically equivalent to the basic Broyden
algorithm.
5.1. Convergence of Broyden’s method. Denote by x∗ the solution of F (x∗ ) = 0,
and let xi and Bi denote the sequences of vectors and matrices produced by Broyden’s
method. Set
ei = xi − x∗ , Mi = Bi − F 0 (x∗ ).
Roughly speaking, the key to the convergence of Broyden’s method are the facts that (1)
ei+1 will be small compared to ei if Mi is not large, and (2) Mi+1 will not be much larger
than Mi if the ei ’s are small. Precise results will be based on the following identities, which
follow directly from the definitions of xi and Bi ,
(4.2) ei+1 = −Bi−1 [F (xi ) − F (x∗ ) − F 0 (x∗ )(xi − x∗ )] + Bi−1 Mi ei ,
1 1
(4.3) Mi+1 = Mi I − T si si + T (vi − F 0 (x∗ )si )sTi .
T
si si si si
Our first result gives the local convergence of Broyden’s method, with a rate of conver-
gence that is at least linear. The norms are all the 2-norm.
Theorem 4.11. Let F be differentiable in a ball Ω about a root x∗ ∈ Rn whose derivative
has Lipschitz constant γ on the ball. Suppose that F 0 (x∗ ) is invertible, with kF 0 (x∗ )−1 k ≤ β.
Let x0 ∈ Ω and B0 ∈ Rn×n be given satisfying
1
kM0 k + 2γke0 k ≤ .
8β
100 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
Then the iterates xi , Bi given by Broyden’s method are well defined, and the errors satisfy
kei+1 k ≤ kei k/2, for i = 0, 1, · · · .
Proof. Claim 1: If xi and Bi are well-defined and kMi k ≤ 1/(2β), then Bi is invertible
(so xi+1 is well-defined), and
kBi−1 k ≤ 2β, kei+1 k ≤ (γβkei k + 2βkMi k)kei k.
Indeed, F 0 (x∗ )−1 Bi = I + F 0 (x∗ )−1 Mi , and since kMi k ≤ 1/(2β), kF 0 (x∗ )−1 Mi k ≤ 1/2, so
Bi is invertible with kBi−1 k ≤ 2β. Therefore, xi+1 is well-defined. The estimate on kei+1 k
follows easily from the bound on Bi−1 and (4.2).
Note that from claim 1 and the hypotheses of the theorem we know that x1 is well-defined
and ke1 k ≤ ke0 k/2.
Claim 2: If B0 , . . . , Bi are defined and invertible, then
kMi+1 k ≤ kMi k + γ max(kei k, kei+1 k).
To prove this, we use (4.3). The first term on the right-hand side is the product of Mi with
the orthogonal projection onto the orthogonal complement of si , so its 2-norm is bounded
by kMi k. For the second term, note that
Z 1
0
vi − F (x∗ )si = [F 0 ((1 − t)xi+1 + txi ) − F 0 (x∗ )] dt si .
0
0 0
Since kF (1 − t)xi+1 + txi ) − F (x∗ )k ≤ γ max(kei k, kei+1 k),
kvi − F 0 (x∗ )si k ≤ γ max(kei k, kei+1 k)ksi k,
and the second term on the right-hand side of (4.3) is bounded in norm by
γ max(kei k, kei+1 k),
which establishes the claim.
We are now ready to prove the theorem. We shall show, by induction on i, that
x0 , . . . , xi+1 are well-defined and
1 1
kei k ≤ , kMi k ≤ , kei+1 k ≤ kei k/2.
8γβ 8β
This is clearly true for i = 0. Assuming it true for i and all smaller indices, we immediately
get the first inequality with i replaced by i + 1. Using claim 2 repeatedly (and noting that
kei+1 k ≤ kei k ≤ · · · , we have
kMi+1 k ≤ kM0 k + γ(ke0 k + ke1 k + · · · + kei+1 k)
≤ kM0 k + γke0 k(1 + 1/2 + · · · ) = kM0 k + 2γke0 k ≤ 1/(8β),
which establishes the second inequality, and then applying claim 1 gives the third inequality.
Notice that the constant 1/2 in the linear convergence estimate arose from the proof
rather than anything inherent to Broyden’s method. Rearranging the proof, one could
change this constant to any positive number. Thus the convergence is actually superlinear.
It would be natural to try to prove this as an application of Theorem 4.8, but this is not
possible, because it can be shown by example, that Bi need not converge to F 0 (x∗ ). The
7. NEWTON’S METHOD 101
superlinear convergence of Broyden’s method was first proved in 1973 by Broyden, Dennis,
and Moré. They proved slightly more, namely that kxi+1 − x∗ k ≤ ri kxi − x∗ k where ri → 0.
6. Unconstrained minimization
We now turn to the problem of minimizing a real-valued function F defined on Rn . (The
problem of minimizing F over a subset of Rn , e.g., a subspace or submanifold, is known as
constrained minimization and is an important subject, which, however, we will not consider
in this course.) We shall sometimes refer to F as the cost function. Usually we will have
to content ourselves with finding a local minimum of the cost function since most methods
cannot distinguish local from global minima. Note that the word “local” comes up in two
distinct senses when describing the behavior of minimization methods: methods are often
only locally convergent (they converge only for initial iterate x0 sufficiently near x∗ ), and
often the limit x∗ is only a local minimum of the cost function.
If F : Rn → R is smooth, then at each x its gradient F 0 (x) is a row vector and its Hessian
F (x) is a symmetric matrix. If F achieves a local minimum at x∗ , then F 0 (x∗ ) = 0 and
00
F 00 (x∗ ) is positive semidefinite. Moreover, if F 0 (x∗ ) = 0 and F 00 (x∗ ) is positive definite, then
F definitely achieves a local minimum at x∗ .
There is a close connection with the problem of minimizing a smooth real-valued function
of n variables and that of finding a root of an n-vector-valued function of n variables. Namely
if x∗ is a minimizer of F : Rn → R, then x∗ is a root of F 0 : Rn → Rn . Another connection
is that a point is a root of the function K : Rn → Rn if and only if it is a minimizer of
F (x) = kK(x)k2 (we usually use the 2-norm or a weighted 2-norm for this purpose, since
then F (x) is smooth if K is).
7. Newton’s method
The idea of Newton’s method for minimization problems is to approximate F (x) by its
quadratic Taylor polynomial, and minimize that. Thus
1
F (x) ≈ F (xi ) + F 0 (xi )(x − xi ) + (x − xi )T F 00 (xi )(x − xi ).
2
The quadratic on the right-hand side achieves a unique minimum value if and only if the
matrix F 00 (xi ) is positive definite, and in that case the minimum is given by the solution to
the equation
F 00 (xi )(x − xi ) + F 0 (xi )T = 0.
Thus we are lead to the iteration
xi+1 = xi − F 00 (xi )−1 F 0 (xi )T .
Note that this is exactly the same as Newton’s method for solving the equation F 0 (x) = 0.
Thus we know that this method is locally quadratically convergent (to a root of F 0 , which
might be only a local minima of F ).
Newton’s method for minimization requires the construction and “inversion” of the entire
Hessian matrix. Thus, as for systems, there is motivation for using quasi-Newton methods in
which the Hessian is only approximated. In addition, there is the fact that Newton’s method
is only locally convergent. We shall return to both of these points below.
102 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
There is a great deal of freedom in choosing the direction and the step length. The major
criterion for the search direction is that a lower value of F than F (xi ) exist nearby on the
line xi + λsi . We may as well assume that the step λi is positive in which case this criteria
is that si is a descent direction, i.e., that F (xi + λsi ) decreases as λ increases from 0. In
terms of derivatives this condition is that F 0 (xi )T si < 0. Geometrically, this means that si
should make an acute angle with the negative gradient vector −F 0 (xi )T . An obvious choice
is si = −F 0 (xi )T (or −F 0 (xi )T /kF 0 (xi )k if we normalize), the direction of steepest descents.
For the choice of step length, one possibility is exact line search. This means that λi is
chosen to minimize F (xi + λsi ) as a function of λ. In combination with the steepest descent
direction we get the method of steepest descents:
choose λi > 0 minimizing F (xi − λF 0 (xi )T ) for λ > 0 set xi+1 = xi − λi F 0 (xi )T
This method can be shown to be globally convergent to a local minimizer under fairly
general circumstances. However, it may not be fast. To understand the situation better
consider the minimization of a quadratic functional F (x) = xT Ax/2 − xT b where A ∈ Rn×n
is symmetric postive definite and b ∈ Rn . The unique minimizer of F is then the solution x∗
to Ax = b. In this case, the descent direction at any point x is simply −F 0 (x)T = b − Ax,
the residual. Moreover, for any search direction s, the step length λ minimizing F (x + λs)
(exact line search) can be computed analytically in this case:
λ2 T 1
F (x + λs) = s As + λ(sT Ax − sT b) + xT Ax − xT b,
2 2
d
F (x + λs) = λsT As + sT (Ax − b),
dλ
so that at the minimum λ = sT (b − Ax)/sT As, and if s = b − Ax, the direction of steepest
descent, λ = sT s/sT As. Thus the steepest descent algorithm for minimizing xT Ax/2 − xT b,
i.e., for solving Ax = b is
It can be shown that this algorithm is globally convergent to the unique solution x∗ as
long as the matrix A is positive definite. However the convergence order is only linear and
the rate is (κ − 1)/(κ + 1) where κ(A) is the 2-norm condition number of A, i.e., the ratio
of the largest to the smallest eigenvalues of A. Thus the convergence will be very slow if A
is not well-conditioned.
2.5 2.5
2 2
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−1 −1
−1 −0.5 0 0.5 1 1.5 2 2.5 3 −1 −0.5 0 0.5 1 1.5 2 2.5 3
This highlights a weakness of the steepest descent direction. It will be even more pro-
nounced for a difficult non-quadratic cost function, such as Rosenbrock’s example in R2
F (x) = (y − x2 )2 + .01(1 − x)2 .
Figure 4.2. Some contours of the Rosenbrock function. Minimum is at (1, 1).
3
2.5
1.5
0.5
−0.5
−1
−1 −0.5 0 0.5 1 1.5 2 2.5 3
While exact line search is possible for a quadratic cost functions, in general it is a scalar
minimization problem which can be expensive or impossible to solve. Moreover, as illustrated
104 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
by the performance of steepest descents above, since the minimum may not be very near
the search line, it is often not worth the effort to search too carefully. Thus many methods
incorporate more or less sophisticated approximate line search algorithms. As we shall see,
it is possible to devise an approximate line search method which, when used in conjunction
with a reasonable choice of search direction, is globably convergent.
We begin our analysis with a simple calculus lemma.
Lemma 4.12. Let f : R → R be C 1 and bounded below and suppose that f 0 (0) < 0. For
any 0 < α < 1 there exists a non-empty open interval J ⊂ (0, ∞) such that
(4.4) f (x) < f (0) + αxf 0 (0), f 0 (x) > αf 0 (0),
for all x ∈ J.
Proof. Since f 0 (0) < 0 and 0 < α < 1, we have 0 > αf 0 (0) > f 0 (0). Thus the
line y = f (0) + αf 0 (0)x lies above the curve y = f (x) for sufficiently small positive x.
But, since f is bounded below, the line lies below the curve for x sufficiently large. Thus
x1 := inf{ x > 0 | f (x) ≥ f (0) + αf 0 (0)x } > 0. Choose any 0 < x0 < x1 . By the mean value
theorem there exists x between x0 and x1 such that
f (x1 ) − f (x0 )
f 0 (x) = .
x1 − x0
For this point x we clearly have (4.4), and by continuity they must hold on an open interval
around the point.
Add a figure.
Now suppose we use a line search method subject to the following restrictions on the
search directions si and the step lengths λi . We suppose that there exist positive constants
η, α, β, such that for all i:
(H1) there exists η ∈ (0, 1] such that −F 0 (xi )si ≥ ηkF 0 (xi )kksi k
(H2) there exists α ∈ (0, 1) such that F (xi + λi si ) ≤ F (xi ) + αλi F 0 (xi )si
(H3) there exists β ∈ (0, 1) such that F 0 (xi + λi si )si ≥ βF 0 (xi )si
We shall show below that any line-search method meeting these conditions is, essentially,
globally convergent. Before doing so, let us discuss the three conditions. The first condition
concerns the choice of search direction. If η = 0 were permitted it would say that the search
direction is a direction of non-ascent. By insisting on η positive we insure that the search
direction is a direction of descent (F (xi + λsi ) is a decreasing function of λ at λ = 0).
However the condition also enforces a uniformity with respect to i. Specifically, it says
that the angle between si and the steepest descent direction −F 0 (xi )T is bounded above by
arccos η < π/2. The steepest descent direction satisfies (H1) for all η ≤ 1 and so if η < 1
there is a open set of directions satisfying this condition. If the Hessian is positive definite,
then the Newton direction −F 00 (xi )−1 F 0 (xi )T satisfies (H1) for η ≤ 1/κ2 (F 00 (xi )), with κ2
the condition number with respect to the 2-norm, i.e., the ratio of the largest to smallest
eigenvalues (verify!). One possible strategy to obtain the fast local convergence of Newton’s
method without sacrificing global convergence is to use the Newton direction for si whenever
it satisfies (H1) (so whenever F 00 (xi ) is positive definite and not too badly conditioned),
otherwise to use steepest descents. A better approach when the Newton direction fails
(H1) may be to use a convex combination of the Newton direction and the steepest descent
8. LINE SEARCH METHODS 105
direction: si = −[θF 00 (xi )−1 F 0 (xi )T + (1 − θ)F 0 (xi )T ] which will satisfy (H1) if θ > 0 is
small enough. Or similarly, one can take si = [F 00 (xi )−1 + νI]−1 F 0 (xi )T with ν large enough
to insure that the bracketed matrix is positive definite. This is the Levenberg–Marquardt
search direction.
Conditions (H2) and (H3) concern the step length. Roughly, (H2) insures that it is not
too large, and in particular insures that F (xi+1 ) < F (xi ). It is certainly satisfied if λi is
sufficiently small. On the other hand (H3) ensures that the step is not too small, since it is
not satisfied for λi = 0. It is however satisfied at a minimizing λi if one exists. The lemma
insures us that if 0 < α < β < 1, then there is an open interval of values of λi satisfying
(H2) and (H3), and hence it is possible to design line-search algorithms which find a suitable
λi in a finite number of steps. See, e.g., R. Fletcher, Practical Methods of Optimization or
J. Dennis & R. Schnabel, Numerical methods for unconstrained optimization and nonlinear
equations. Fletcher also discusses typical choices for α and β. Typically β is fixed somewhere
between 0.9 and 0.1, the former resulting in a faster line search while the latter in a more
exact line search. Fletcher says that α is generally taken to be quite small, e.g., 0.01, but
that the value of of α is not important in most cases, since it is usually the value of β which
determines point acceptability.
We now state the global convergence theorem.
Theorem 4.13. Suppose that F : Rn → R is C 1 and bounded below, that x0 ∈ Rn is such
that { x ∈ Rn : F (x) ≤ F (x0 ) } is bounded, and that x1 , x2 , . . . is defined by a line search
method with descent search directions and positive step lengths satisfying the three conditions
above. Then limi→∞ F (xi ) exists and limi→∞ F 0 (xi ) = 0.
The next comment should be filled out. Perhaps the theorem should be stated in the
case of a single minimum and then the full state given as a corollary to the proof.
Hence for i ∈ S,
kF 0 (xi+1 ) − F 0 (xi )k ≥ η(1 − β) > 0,
which gives the contradiction.
The next theorem shows that if the point xi is sufficiently close to a minimum, then
choosing si to be the Newton direction and λi = 1 satisfies (H1)–(H3). This means that
it is possible to construct algorithms which are globally convergent, but which are also
quadratically convergent, since they eventually coincide with Newton’s method.
Theorem 4.14. Suppose that F is smooth, x∗ is a local minimum of F , and F 00 (x∗ )
is positive definite. Let 0 < α < 1/2, α < β < 1. Then there exists > 0 such that
if kxi − x∗ k ≤ , si = −F 00 (xi )−1 F 0 (xi )T , and λi = 1, then (H1)–(H3) are satisfied with
η = 1/{4κ2 [F 00 (x∗ )]}.
Proof. Let D denote the ball about x∗ of radius , where > 0 will be chosen below.
From our analysis of Newton’s method we know that by taking sufficiently small, xi ∈
D =⇒ xi + si ∈ D. By continuity of F 00 , we may also arrange that whenever x ∈ D, F 00 (x)
is positive definite, kF 00 (x)k ≤ 2kF 00 (x∗ )k, and kF 00 (x)−1 k ≤ 2kF 00 (x∗ )−1 k.
Then
Now
1 1
kF 0 (xi )k ≥ ksi k ≥ ksi k,
kF 00 (xi )−1 k 2kF 00 (x −1
∗) k
9. Conjugate gradients
Now we return to the case of minimization of a positive definite quadratic function
F (x) = xT Ax/2 − xT b with A ∈ Rn×n symmetric positive definite and b ∈ Rn . So the unique
minimizer x∗ is the solution to the linear system Ax = b. Consider now a line search method
with exact line search:
choose initial iterate x0
for i = 0, 1, . . .
choose search direction si
sT (b − Axi )
λi = i T
si Asi
xi+1 = xi + λi si
end
But
1 λ2
F (y + λsi ) = y T Ay + λsTi Ay + sTi Asi − y T b − λsTi b.
2 2
108 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
The second term on the right-hand side appears to couple the minimizations with respect
to y and λ, but in fact this is not so. Indeed, xi ∈ x0 + Wi , so for y ∈ x0 + Wi , y − xi ∈ Wi
and so is A-orthogonal to si . That is, sTi Ay = sTi Axi , whence
1 λ2
F (y + λsi ) = [ y T Ay − y T b] + [ sTi Asi + λsTi (Axi − b)],
2 2
and the minimization problem decouples. By induction the minimum of the first term in
brackets over x0 + Wi is achieved by y = xi , and clearly the second term is minimized by
λ = sTi (b − Axi )/sTi Asi , i.e., the exact line search. Thus xi+1 = xi + λi si minimizes F over
x0 + Wi+1 .
Any method which uses A-orthogonal (also called “conjugate”) search directions has the
nice property of the theorem. However it is not so easy to construct such directions. By
far the most useful method is the method of conjugate gradients, or the CG method, which
defines the search directions by A-orthogonalizing the residuals ri = b − Axi :
• s0 = r0
i−1 T
X sj Ari
• si = ri − sj .
sT Asj
j=0 j
The last formula (which is just the Gram-Schmidt procedure) appears to be quite expensive
to implement, but fortunately we shall see that it may be greatly simplified.
Proof. The first statement comes directly from the definitions. To verify the second
statement, note that, for 0 ≤ j < i, F (xi + trj ) is minimal when t = 0, which gives
rjT (Axi − b) = 0, which is the desired orthogonality. For the third statement, certainly there
is a least integer m ∈ [1, n] so that Wm = Wm+1 . Then rm = 0 since it both belongs to
Wm and is orthogonal to Wm . This implies that xm = x∗ and that sm = 0. Since sm = 0,
Wm+1 = Wm and xm+1 = xm = x∗ . Therefore rm+1 = 0, which implies that sm+1 = 0,
therefore Wm+2 = Wm+1 , xm+2 = x∗ , etc.
The fourth statement is an immediate consequence of the preceding ones. For the last
statement, we use the orthogonality of the residuals to see that sTi ri = riT ri . But, if 0 ≤ j ≤
i,then
since x0 − xj ∈ Wi .
9. CONJUGATE GRADIENTS 109
Since si ∈ Wi+1 and the rj , j ≤ i are an orthogonal basis for that space for i < m, we
have
i
X sT rji
si = rj .
j=0
rjT rj
i i−1
X rj X rj
si = riT ri T
T
= r i + ri ri T
,
r r
j=0 j j
r r
j=0 j j
whence
riT ri
si = ri + T
si−1 .
ri−1 ri−1
This is the formula which is used to compute the search direction. In implementing this
formula it is useful to compute the residual from the formula ri+1 = ri − λi Asi (since
xi+1 = xi + λi si ). Putting things together we obtain the following implementation of CG:
The conjugate gradient method gives the exact solution in n iterations, but it is most
commonly terminated with far fewer operations. A typical stopping criterion would be to
test if r2 is below a given tolerance. To justify this, we shall show that the method is linearly
convergence and we shall establish the rate of convergence. For analytical purposes, it is
most convenient to use the vector norm kxkA := (xT Ax)1/2 , and its associated matrix norm.
Lemma 4.17. Wi = span[r0 , Ar0 , . . . , Ai−1 r0 ] for i = 1, 2, . . . , m.
Proof. Since dim Wi = i, it is enough to show that Wi ⊂ span[r0 , Ar0 , . . . , Ai−1 r0 ],
which we do by induction. This is certainly true for i = 1. Assume it holds for some i.
Then, since xi ∈ x0 + Wi , ri = b − Axi ∈ r0 + AWi ∈ span[r0 , Ar0 , . . . , Ai r0 ], and therefore
Wi+1 , which is spanned by Wi and ri belongs to span[r0 , Ar0 , . . . , Ai r0 ], which completes the
induction.
The space span[r0 , Ar0 , . . . , Ai−1 r0 ] is called the Krylov space generated by the matrix A
and the vector r0 . Note that we have as well
Since xi − x0 ∈ Wi ,
inf kx∗ − xi + wkA = inf kx∗ − x0 + wkA .
w∈Wi w∈Wi
0.8 0.075
0.6 0.05
0.4 0.025
0.2 0
0 −0.025
−0.2 −0.05
0 2 4 6 8 10 12 2 4 6 8 10
Applying the obvious bound kp(A)(x∗ − x0 )kA ≤ kp(A)kA kx∗ − x0 kA we see that we can
obtain an error estimate for the conjugate gradient method by estimating
C = inf kp(A)kA .
p∈Pi
p(0)=1
Now if 0 < ρ1 < · · · < ρn are the eigenvalues of A, then the eigenvalues of p(A) are p(ρj ),
j = 1, . . . , n, and kp(A)kA = maxj |p(ρj )| (this is left as exercise 6). Thus1
C = inf max |p(ρj )| ≤ inf max |p(ρ)|.
p∈Pi j p∈Pi ρ1 ≤ρ≤ρn
p(0)=1 p(0)=1
The final infimum can be calculated explicitly using the Chebyshev polynomials, see Fig-
ure 4.3 and (1.16). The minimum value is precisely
√ i
2 κ−1
√ i √ i ≤ 2 √ ,
κ+1 κ−1 κ+1
√
κ−1
+ √
κ+1
where κ = ρn /ρ1 is the condition number of A. (To get the right-hand side, we suppressed
the second term in the denominator of the left-hand side, which is less than 1 and tends to
zero with i, and kept only the first term, which is greater than 1 and tends to infinity with
i.) We have thus proven that
√ i
κ−1
kxi − x∗ kA ≤ 2 √ kx0 − x∗ kA ,
κ+1
1
Here we bound maxj |p(ρj )| by maxρ1 ≤ρ≤ρn |p(ρ)| simply because we can minimize the latter quantity
explicitly. However this does not necessarily lead to the best possible estimate, and the conjugate gradient
method is often observed to converge faster than the result derived here. Better bounds can sometimes be
obtained by taking into account the distribution of the spectrum of A, rather than just its minimum and
maximum.
112 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
Of course, the same result holds if we replace x0 by xi and x1 by xi+1 . Thus steepest descents
converges linearly, with rate (κ − 1)/(κ + 1). Notice that the estimates indicate that a large
value of κ will slow the convergence
√ of both steepest descents and conjugate gradients, but,
since the dependence is on κ rather than κ, the convergence of conjugate gradients will
usually be much faster.
The figure shows a plot of the norm of the residual versus the number of iterations for
the conjugate gradient method and the method of steepest descents applied to a matrix
of size 233 arising from a finite element simulation. The matrix is irregular, but sparse
(averaging about 6 nonzero elements per row), and has a condition number of about 1, 400.
A logarithmic scale is used on the y-axis so the near linearity of the graph reflects linear
convergence behavior. For conjugate gradients, the observed rate of linear convergence is
about .8, and it takes 80 iterations to reduce the initial residual by a factor of about 106 .
The convergence of steepest descents is too slow to be useful: in 400 iterations the residual
is not even reduced by a factor of 2.
−10
10
0
10
−20
10
CG
−1
−30
CG 10
10
−40 −2
10 10
0 50 100 150 200 250 300 0 10 20 30 40 50
iterations iterations
9. CONJUGATE GRADIENTS 113
Remark. 1. The conjugate gradient algorithm can be generalized to apply to the min-
imization of general (non-quadratic) functionals. The Fletcher–Reeves method is such a
generalization. However in the non-quadratic case the method is significantly more compli-
cated, both to implement and to analyze.
2. There are a variety of conjugate-gradient-like iterative methods that apply to matrix
problems Ax = b where A is either indefinite, non-symmetric, or both. Many share the idea
of approximation of the solution in a Krylov space.
9.1. Preconditioning. The idea is we choose a matrix M ≈ A such that the system
M z = c is relatively easy to solve. We then consider the preconditioned system M −1 Ax =
M −1 b. The new matrix M −1 A is SPD with respect to the M innerproduct, and we solve the
preconditioned system using conjugate gradients but using the M -inner product in place of
the l2 -inner product. Thus to obtain the preconditioned conjugate gradient algorithm, or
PCG, we substitute M −1 A for A everywhere and change expressions of the form xT y into
xT M y. Note that the A-inner product xT Ay remains invariant under these two changes.
Thus we obtain the algorithm:
Note that term sTi Asi arises as the M -inner product of si with M −1 Asi . The quantity
r̄i is the residual in the preconditioned equation, which is related to the regular residual,
ri = b − Axi by ri = M r̄i . Writing PCG in terms of ri rather than r̄i we get
Thus we need to compute M −1 ri at each iteration. Otherwise the work is essentially the
same as for ordinary conjugate gradients. Since the algorithm is just conjugate gradients for
114 4. NUMERICAL SOLUTION OF NONLINEAR SYSTEMS AND OPTIMIZATION
Exercises
1. Let f : R → R be a C 2 function with a root x∗ such that neither f 0 nor f 00 has a root. Prove
that Newton’s method converges to x∗ for any initial guess x0 ∈ R.
2. Consider the 2 × 2 system of nonlinear equations
f (x, y) = 0, g(x, y) = 0, x, y ∈ R.
The Jacobi iteration for solving this system beginning from an initial guess x0 , y0 is Thus
for i = 0, 1, 2, . . .
solve f (xi+1 , yi ) = 0 for xi+1
solve g(xi , yi+1 ) = 0 for yi+1
end
EXERCISES 115
SD 0
SD
0
10 10
CG
norm of residual
norm of residual
−20 −2
10 10
CG
−40 −4
10 10
PCG
PCG
−60 −6
10 10
−80 −8
10 10
0 50 100 150 200 250 300 0 10 20 30 40 50
iterations iterations
each step of the iteration requires the solution of 2 scalar nonlinear equations. (N.B.: Of
course the method extends to systems of n equations in n unknowns.) If we combine the
Jacobi iteration with Newton’s method to solve the scalar equations, we get the Newton–
Jacobi iteration:
choose initial guess x0 , y0
for i = 1, 2, . . .
∂f
xi+1 = xi − (xi , yi )−1 f (xi , yi )
∂x
∂g
yi+1 = yi − (xi , yi )−1 g(xi , yi )
∂y
end
Let x0 , x1 , . . . be the sequence of iterates produced by Newton’s method. Show that all the
iterates after the initial guess satisfy the linear equations exactly. Show the same result is
true when the xi are determined by Broyden’s method with B0 chosen to be F 0 (x0 ).
6. Prove that if A is a symmetric positive-definite matrix with eigenvalues ρ1 , . . . , ρn , and p is
a polynomial, then kp(A)kA = max |p(ρj )|.
1≤j≤n
7. Prove that for the conjugate gradient method the search directions si and the errors ei :=
x∗ − xi satisfy sTi ei+1 ≤ 0 (in fact sTi ej ≤ 0 for all i, j). Use this to show that the l2 -norm
of the error kei k is a non-increasing function of i.
8. We analyzed preconditioned conjugate gradients, with a symmetric positive definite precon-
ditioner M , as ordinary conjugate gradients applied to the problem M −1 Ax = M −1 b but
with the M -inner product rather than the l2 -inner product in Rn . An alternative approach
which doesn’t require switching inner products in Rn is to consider the ordinary conjugate
gradient method applied to the symmetric positive definite problem (M −1/2 AM −1/2 )z =
M −1/2 b for which the solution is z = M 1/2 x. Show that this approach leads to exactly the
same preconditioned conjugate gradient algorithm.
9. The Matlab command A=delsq(numgrid(’L’,n)) is a quick way to generate a symmetric
positive definite sparse test matrix: it is the matrix arising from the 5-point finite difference
approximation to the Laplacian on an L-shaped domain using an n × n grid (e.g., if n = 40,
A will be 1, 083 × 1, 083 sparse matrix with 5, 263 nonzero elements and a condition number
of about 325. Implement the conjugate gradient algorithm for the system Ax = b for this
A (and an arbitrary vector b, e.g., all 1’s). Diagonal preconditioning does no good for this
problem. (Why?) Try two other possibilities: tridiagonal preconditioning and incomplete
Cholesky preconditioning (Matlab comes equipped with an incomplete Cholesky routine, so
you don’t have to write your own). Study and report on the convergence in each case.
CHAPTER 5
1. Introduction
In this chapter we are concerned with the numerical solution of the initial value problem
(IVP)
(5.1) y 0 = f (t, y), y(t0 ) = y0 .
More precisely, we suppose we are given a function f (t, y) defined in some domain D ⊂ R2
and a point (t0 , y0 ) ∈ D. We wish to find an interval I containing t0 and a function y : I → R
satisfying
y 0 (t) = f t, y(t) , t ∈ I,
as well as the initial condition. The function f specifies a slope field on the domain D, which
we can visualize graphically as a small line segment passing through each point of D, and
the IVP says that the graph of y passes through (t0 , y0 ) and at each point is tangent to the
line segment at that point.
2 2
−.15(y−1)
Figure 5.1. The slopefield for
0
f (t, y) = [(y + 1 − t/3) − sin t]e and
the solution to y (t) = f t, y(t) , y(0) = −3.
5
4
3
2
1
0
−1
−2
−3
−4
−5
0 1 2 3 4 5 6 7 8 9 10
Figure 5.2. The solution to y 0 = f (t, y), y(0) = .2. In this example the
domain D of f is the unit square, and the solution curve leaves D at t = .75, so
there is no solution to the initial value problem defined on the whole interval
I = [0, 1].
1.2
0.8
0.6
0.4
0.2
D
0
−0.2
−0.2 0 0.2 0.4 0.6 0.8 1
Even if D ⊃ I × R, it may happen that the solution tends to infinity as t tends to some
interior point of I, and so the solution can again not be continued to the end of the interval
I. For example, the solution to the IVP
y0 = y2, y(1) = 1,
is y(t) = 1/(2 − t), which blows up as t approaches 2. Thus there is no solution to this
simple-looking IVP on the interval [1, 3]. See Figure 5.3.
Another issue which must be faced before we can study numerical methods and their
convergence is uniqueness of solutions. If we only assume thatpf is continuous, then we
cannot assert uniqueness. For example, the function f (x, y) = |1 − y 2 | is continuous on
R2 , and the IVP
p
y 0 = |1 − y 2 |, y(−π/2) = −1,
has infinitely many solutions, among them y(t) = sin t and y(t) = −1.
Fortunately there is a simple condition which implies both global existence and unique-
ness.
Definition. Let f be a function defined on I ×R where I is an interval. Then f satisfies
a uniform Lipschitz condition with respect to its second variable if
|f (t, y) − f (t, z)| ≤ K|y − z|, t ∈ I, y, z ∈ R.
Note that if f ∈ C 1 (I × R) and ∂f /∂y is bounded, then f satisfies a uniform Lipschitz
condition with respect to y.
2. EULER’S METHOD 119
1
1 1.5 2 2.5 3
2. Euler’s Method
2.1. Derivation. If we recall the interpretation of a solution to the IVP as a function
whose graph passes through (t0 , y0 ) as is tangent to the slope field determined by f , this
suggests a graphical approach to the approximate solution of the IVP. We start to draw its
graph at the initial point, extending it in the direction of, say, increasing t, along the line
120 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
Figure 5.4. The left figure shows several solutions of an ODE for which
the solution is very sensitive to the initial data. The right figures shows the
opposite situation: even large differences in the initial data cause only small
differences in the solutions at the end of the interval.
through that point with slope f (t0 , y0 ). This determines an approximate solution on a short
time interval [t0 , t0 + h] as
y h (t) = y0 + tf (t0 , y0 ), t0 ≤ t ≤ t0 + h.
If h is sufficiently small this should not differ much from the true solution y(t) (since a curve
does not differ much from its tangent in a small interval). We may then repeat the process
starting from t1 := t0 + h and using the slope at (t1 , y1 ) where y1 = y h (t1 ) = y0 + hf (t0 , y0 ),
and so forth. Defining tn = t0 + nh, we thus get approximations yn = y h (tn ) ≈ y(tn )
satisfying
yn+1 = yn + hf (tn , yn ), n = 0, 1, . . .
This is Euler’s method for solving the IVP. For most purposes it is sufficient to think of
the approximate solution y h as defined only at the discrete points tn and thus given by the
values yn . For others it is useful to consider the approximate solution as the piecewise linear
function with break points at the tn and which interpolates yn at tn .
The graphical derivation just given does not easily generalize to give other numerical
methods, but here are three other derivations of Euler’s method which do.
2.1.1. Taylor series. The exact solution satisfies
y(tn+1 ) = y(tn ) + hy 0 (tn ) + O(h2 ).
Neglecting the O(h2 ) term we get
y(tn+1 ) ≈ y(tn ) + hy 0 (tn ) = y(tn ) + hf (tn , y(tn )).
This suggests the method
(5.2) y h (tn+1 ) = y h (tn ) + hf (tn , y h (tn ))
or
yn+1 = yn + hf (tn , yn ),
which is Euler’s method.
2. EULER’S METHOD 121
2.1.2. Numerical differentiation. Approximating the derivative y 0 (tn ) by the forward dif-
ference [y(tn+1 ) − y(tn )]/h gives
y(tn+1 ) − y(tn )
≈ f tn , y(tn ) ,
h
or
y(tn+1 ) ≈ y(tn ) + hy 0 (tn ) = y(tn ) + hf tn , y(tn ) .
and determine the behavior of this quantity as h ↓ 0. It would be a small matter, but not
now worth the effort, to use the max norm on the whole interval I.
Theorem 5.4 (Convergence of Euler’s method). limky h − yk∞,h = 0.
h↓0
Proof. Define the local truncation error on the (n + 1)st step by the equation
(5.3) y(tn+1 ) = y(tn ) + hf tn , y(tn ) + Tn .
Thus Tn is the amount by which the exact solution fails to satisfy Euler’s method. It is local
to the n + 1st step in that we compare the exact solution at the end of the step to what we
would have obtained using Euler’s method over the step starting with the exact solution at
the beginning of the step, and ignoring all the accumulated errors up to that point.
By the mean value theorem,
y(tn+1 ) = y(tn ) + hy 0 (ξn ) for some ξn ∈ (tn , tn+1 ),
while the differential equation gives f tn , y(tn ) = y 0 (tn ). Thus
and, since we start with the exact initial value, e0 = 0. We now apply a simple lemma (which
is easily established by induction):
Lemma 5.5. Let A, B, η0 , η1 , . . . , ηN be non-negative numbers satisfying
ηn+1 ≤ Aηn + B, n = 0, 1, . . . , N − 1.
Then
n−1
X
n
η n ≤ A η0 + Ai B, n = 0, 1, . . . , N.
i=0
Remark. The initial value problem (5.7) is linear so its solution can be written in closed
terms:
Z t 00 Z t
1 y (s) ∂f
δ(t) = − ρ(t) ds, ρ(s) = exp[ s, y(s) ds].
2 t0 ρ(s) t0 ∂y
This is not very useful in practice, since we don’t know y, much less y 00 . So the significance
of the theorem is mainly the assertion that the error behaves like δh, not the particular form
of δ. This is useful for many purpose, e.g., for Richardson extrapolation.
2.3. Variable step size. There is no reason why the same value of h has to be used
in each step of Euler’s method. We can instead vary h, determining it in advance or as we
go along in some adaptive way (adaptive step size selection will be treated in § 5 of this
chapter). Euler’s method with variable step size is thus
y h (t0 ) = y0
for n = 0, 1, . . .
choose hn > 0
tn+1 = tn + hn
if tn+1 ≤ t∗ then
y h (tn+1 ) = y h (tn ) + hn f tn , y h (tn )
else
stop
end if
end
Let e = y h − y denote the error. We again use the discrete maximum norm:
kek = max |e(tn )|,
where the maximum is taken over the particular mesh points used. We also set H = max hn ,
the largest step size. We then again have convergence (we continue to assume that f satisfies
a uniform Lipschitz condition with respect to y), and, if the solution is C 2 , the convergence
is first order in H:
Theorem 5.8 (Convergence of Euler’s method with variable step). For Euler’s method
with variable step size
lim kek = 0,
H→0
i.e., for all > 0 there exists H0 > 0 such that for any choice of steps hn with max hn ≤ H0
there holds max |e(tn )| ≤ .
Moreover, if the solution y ∈ C 2 (I), then kek ≤ CH, where C is again defined by (5.6).
3. LINEAR MULTISTEP METHODS 125
The proof of this theorem follows very much along the lines of the proofs of Theorems 5.4
and 5.6. The bounds on the local truncation error are the same. Lemma 5.5 which is used
to bound the accumulated contributions of the local truncation errors on all the steps, must
be generalized as follows.
Lemma 5.9. Let An > 1 and Bn ≥ 0 for n = 0, 1, . . . , N − 1 and let η0 , η1 , . . . , ηN ≥ 0.
Suppose that
ηn+1 ≤ An ηn + Bn , n = 0, 1, . . . , N − 1.
Then
n−1
Y n−1
Y Bi
ηn ≤ Ai η 0 + Ai − 1 sup , n = 1, 2, . . . , N.
0≤i≤n−1 Ai − 1
i=0 i=0
Notice that in each of these cases, the Φ is a linear function of yn , yn+1 , f (tn , yn ), and
f (tn+1 , yn+1 ). By contrast, for the improved Euler method,
h
yn+1 = yn + [f (tn , yn ) + f tn+1 , yn + hf (tn , yn ) ],
2
which is an explicit one-step method, and the implicit midpoint method,
tn + tn+1 yn + yn+1
yn+1 = yn + hf ( , ),
2 2
which is an implicit one-step method, the dependence of Φ on yn and yn+1 is more compli-
cated. In the next section, we shall consider such nonlinear one-step methods, while in this
section we study multistep methods, but assume linear dependence. That is, we consider
linear multistep methods with constant step size, which, by definition, are methods of the
form
(5.12) yn+1 = −a0 yn − a1 yn−1 + · · · − ak yn−k + h[b−1 fn+1 + b0 fn + · · · + bk fn−k ].
Here we have written fn for f (tn , yn ) (for brevity). The ai and bi are constants which must
be given and determine the specific method. For an explicit linear multistep method b−1 = 0.
It is also convenient to define a−1 = 1, so that the method can be written
k
X k
X
aj yn−j = h bj fn−j .
j=−1 j=−1
One obvious question concerning implicit methods is whether the formula for the method
determines yn+1 (whether the equation has a solution and whether it is unique). The answer
is yes, at least for h sufficiently small.
Theorem 5.10. Let h0 = (|b−1 |L)−1 where L is the Lipschitz constant for f . Then for
any h < h0 and any yn , yn−1 , . . . , yn−k there is a unique yn+1 such that
k
X k
X
(5.13) aj yn−j = h bj f (tn−j , yn−j ).
j=−1 j=−1
Proof. Define
k
X k
X
F (z) = − aj yn−j + hb−1 f (tn+1 , z) + h bj f (tn−j , yn−j ) = hb−1 f (tn+1 , z) + · · · ,
j=0 j=0
where the dots represent terms not depending on z. Then the equation is simply the fixed
point equation yn+1 = F (yn+1 ). Now F is a Lipschitz with Lipschitz constant ≤ h|b−1 |L.
By hypothesis the Lipschitz constant is stritly less than 1, i.e., F is a contraction. The
contraction mapping theorem then guarantees a unique fixed point.
Remark. The contraction mapping theorem also implies that the solution can be com-
puted by fixed point iteration, and this is often done in practice. Of course only finitely
many iterations are made (often quite few), introducing an additional source of error.
3. LINEAR MULTISTEP METHODS 127
Several examples of linear multistep methods are listed in Table 5.1. All the methods
R tn+1 table except
in the the last can be derived from the integral relation y(tn+1 ) = y(tn−k ) +
tn−i
f t, y(t) dt using an appropriate interpolatory quadrature rule. Note that for the two
Adams methods (the Adams–Bashford and Adams–Moulton families of methods will be dis-
cussed in detail in § 3.3 below) the quadrature rule is open, i.e., contains quadrature points
outside the interval of integration. The final method of the table is one of the backward differ-
entiation formula, or BDF, family of methods, which can be derived by replacing y 0 (tn+1 ) in
0
the equation y (tn+1 ) = f tn+1 , y(tn+1 ) with a backward difference approximation obtained
by differentiating an interpolating polynomial.
3.1. Consistency and order. Clearly the coefficients aj and bj in (5.12) must be chosen
carefully if the multistep method is to have a chance of being convergent. Specifically, we
should have
Xk k
X
aj y(tn−j ) ≈ h bj y 0 (tn−j )
j=−1 j=−1
for the exact solution y. Since this has to hold for any solution to any ODE, it should hold
for all reasonably smooth functions y. Thus we define
k
X k
X
(5.14) L[y, h, t] = aj y(t − jh) − h bj y 0 (t − jh)
j=−1 j=−1
1
for any y ∈ C , h > 0 and t ∈ R. Note that if y is the exact solution, then L[y, h, tn ] is
simply the local truncation error at the (n + 1)st step.
Definition. The linear multistep is consistent if
L[y, h, tn ]
lim max =0
h↓0 k≤n<N h
128 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
for all y ∈ C 1 (I). The method has order p (at least) if for all y ∈ C p+1 (I) there exists
constants C, h0 > 0 such that
L[y, h, tn ]
max ≤ Chp
k≤n<N h
whenever h < h0 .
Warning: it is not true that every method of order p converges with order p, or even
converges at all!
Using Taylor’s theorem, we can derive simple algebraic criteria for consistency and order.
The algebraic conditions (5.15) are called the consistency conditions and the conditions
(5.16) are called the order conditions. Before giving the proof we notice an immediate
corollary: a method is consistent if and only if it is of order at least 1.
Proof. The proof is just Taylor’s theorem. We have y(tn − jh) = y(tn ) − jhy 0 (ξj ), for
some ξj ∈ [tn − kh, tn + h], j = −1, 0, . . . , k. Note that each ξj → t as h → 0. Plugging into
(5.14)
k
X k
X
L[y, h, tn ] = aj [y(tn ) − jhy 0 (ξj )] − h bj y 0 (tn − jh)
j=−1 j=−1
0
= y(tn )C0 + hy (tn )C1 + hR,
where
k
X k
X k
X
C0 = aj , C1 = − jaj − bj ,
j=−1 j=−1 j=−1
and
k
X k
X
0 0
R = −h jaj [y (ξj ) − y (tn )] − h bj [y 0 (tn − jh) − y 0 (tn )].
j=0 j=−1
where
k k
1 hX X i
(5.17) Cm = (−j)m aj − m (−j)m−1 bj ,
m! j=−1 j=−1
and
k
X (−j)p+1 (p+1) (−j)p (p+1)
R = hp+1 [aj y (ξj ) − bj y (ζj )].
j=−1
(p + 1)! p!
For example, the consistency conditions are simply ρ(1) = 0 and ρ0 (1) = σ(1).
As an example of the use of the order conditions, we will use the method of undetermined
coefficients to find the 2-step method of highest order. For a 2-step method there are five
undetermined coefficients: a0 , a1 , b−1 , b0 , and b1 . The first five order conditions are
1 + a0 + a1 = 0, 1 − a1 − b−1 − b0 − b1 = 0, 1 + a1 − 2b−1 + 2b1 = 0,
1 − a1 − 3b−1 − 3b1 = 0, 1 + a1 − 4b−1 + 4b1 = 0.
This system of linear equations has a unique solution:
1 4 1
a0 = 0, a1 = −1, b−1 = , b0 = , b1 = ,
3 3 3
which are precisely the coefficients of the Milne-Simpson method. Thus the Milne-Simpson
method is the unique fourth order 2-step method.
If we consider instead explicit 2-step methods we no longer have the coefficient b−1 at
our disposal. Setting b−1 to zero in the first four linear equations above we get
1 + a0 + a1 = 0, 1 − a1 − b0 − b1 = 0, 1 + a1 + 2b1 = 0, 1 − a1 − 3b1 = 0,
130 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
which gives a0 = 4, a1 = −5, b0 = 4, b1 = 2. Thus the unique explict 2-step method of order
3 is
yn+1 + 4yn − 5yn−1 = h[4fn + 2fn−1 ].
Warning: we shall see below that this is not a good method. Order is not everything!
3.2. Stability and convergence. In this section we study the convergence of linear
multistep methods. Recalling that the initial k + 1 values of ynh must be determined by some
other method, we define convergence as follows.
Definition. A linear multistep method is convergent if whenever the initial values ynh
are chosen so that max0≤j≤k |ehj | → 0 as h → 0, then max0≤j≤N h |ehj | → 0.
There is a rather complete convergence theory available for linear multistep methods with
constant step size, due largely to G. Dahlquist. It is somewhat technical, and we will only
sketch it below. However, for many linear multistep methods a simple proof of convergence
can be given along the lines of the proof we used for Euler’s method. For example, consider
the midpoint method
yn+1 = yn−1 + 2hf (tn , yn ).
Checking the order conditions we find that this method is second order, i.e., if y is a smooth
function, then
y(tn+1 ) = y(tn−1 ) + 2hy 0 (tn ) + L[y, h, tn ]
where L[y, h, tn ] = O(h3 ). Now let en = yn − y(tn ). Then
en+1 = en−1 + 2h[f (tn , yn ) − f tn , y(tn ) ] − L[y, h, tn ],
so
|en+1 | ≤ |en−1 | + 2hL|en | + T, n = 1, 2, . . . , N − 1,
where T = max |L[y, h, tn ]| = O(h3 ). This immediately implies that
max(|en+1 |, |en |) ≤ (1 + 2hL) max(|en |, |en−1 |) + T, n = 0, 1, 2, . . . , N − 1,
whence, by Lemma 5.5,
∗ −t |
e2L|t
−1T 0
∗
max(|en+1 |, |en |) ≤ + e2L|t −t0 | max(|e1 |, |e0 |), n = 0, 1, 2, . . . , N − 1,
2L h
i.e., kek∞,h ≤ C1 T /h + C2 max(|e1 |, |e0 |) with C1 , C2 independent of h. If the initial values
are choosen so that max(|e1 |, |e0 |) → 0 as h → 0, then we have that kek∞,h → 0. This
is precisely the definition of convergence. For the midpoint method we see as well, that if
the initial error is O(h2 ) the error is globally O(h2 ). Note the one new idea of the proof:
instead of considering the propagation of the error (en−1 , en ) 7→ en+1 , we instead consider
the propagation of the pair of values, (en−1 , en ) 7→ (en , en+1 ).
Next we consider the two step method of highest order
yn+1 = −4yn + 5yn−1 + h(4fn + 2fn−1 ).
3. LINEAR MULTISTEP METHODS 131
We shall show that this method is not convergent even for the most trivial of initial value
problems:
y 0 (t) = 0, 0 ≤ t ≤ 1, y(0) = 0.
The multistep method is then yn+1 = −4yn + 5yn−1 . If we take as initial values y0 = 0,
y1 = h , then the multistep method is easily seen to give
yn = [1 − (−5)n ]h /6,
and so, if h = 1/N , y h (1) = yN = [1 − (−5)1/h ]h /6. It is clearly not sufficient that h → 0
in order to have convergence, we need 51/h h → 0, i.e., exponentially accurate initial values.
Note that if we take exact starting values y0 = y1 = 0, then yn = 0 for all n. Thus a
perturbation of size in the starting values leads to a difference of size roughly 51/h in the
discrete solution. Thus the method is not stable:
Definition. A linear k + 1-step method is stable if for any admissable initial value
problem (satisfying a Lipschitz condition) and for all > 0 there exists δ, h0 > 0 such that
if h ≤ h0 and two choices of starting values yj and ȳj are chosen satisfying
max |yj − ȳj | ≤ δ,
0≤j≤k
If, as above, we consider the trivial differential equation y 0 = 0, then the general linear
multistep method becomes
k
X
yn+1 + aj yn−j = 0, n = k, k + 1, . . . .
j=0
y(tn ) 0 1 yn−1 0
= + .
y(tn+1 ) −a1 −a0 yn h[b0 f tn , y(tn ) + b1 f tn−1 , y(tn−1 ) ] + L[y, h, tn ]
Subtracting gives an equation for the error. Let
n en−1 0 1
en = yn − y(tn ), E = , A= ,
en −a1 −a0
n 0
Q = .
h[b0 fn − f tn , y(tn ) + b1 fn−1 − f tn−1 , y(tn−1 ) ] − L[y, h, tn ]
Then
(5.18) E n+1 = AE n + Qn , n = 1, 2, . . .
Note that kQn k ≤ ChkE n k + T where T = maxn |L[y, h, tn ]| = O(hp+1 ) where p is the order
of the method (and we use the l∞ norm for the vectors). Iterating (5.18) gives
n−1
X
n n−1 1
E =A E + An−1−j Qj , n = 1, . . . , N.
j=1
Now we use the root condition. The characteristic polynomial of the matrix A is ρ(t) =
t2 + a0 t + a1 , i.e., the first characteristic polynomial of the linear multistep method. Thus
the eigenvalues of A all have modulus ≤ 1 with only simple eigenvalues of modulus 1. This
is precisely the condition for the powers of A to remain bounded: supn≥0 kAn k < ∞. Thus
we have
n−1 n−1
n 1
X
j 0
X T
kE k ≤ C(kE k + kQ k) ≤ C (h kE j k + kE 1 k + ), n = 1, . . . , N,
j=1 j=1
h
for some constants C and C 0 . Now from this relation it follows (by a sort of discrete Gronwall
lemma1 that
T
max kE n k ≤ K(kE 1 k + ),
1≤n≤N h
for a suitable constant K. For a consistent method T /h → 0 as h → 0, so convergence
follows.
m−1
X
1
Specifically, if ξm ≤ α ξj + β, m = 1, 2, . . . , where the ξm , α, and β are non-negative, then
j=1
ξm ≤ β(1 + α)m−1 .
134 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
We end this section with a statement of the attainable order of multistep methods.
Counting coefficients and order conditions one would guess (correctly) that the highest order
attainable by a k step method is 2k. However, such a method is not stable for any k > 1.
The next theorem states that only about half this order is attainable by a stable method.
Theorem 5.14 (First Dahlquist barrier). The highest order of a stable k step method is
k + 1 if k is odd and k + 2 if k is even.
3.3. Adams methods. The Adams methods are linear multistep methods with the
best possible stability properties. Namely the first characteristic polynomial has all its roots
at the origin except for the mandatory root at 1. That is, the first characteristic polynomial
of a k + 1 step Adams method is ρ(t) = tk+1 − tk . There are two Adams methods for each k,
an explicit method, called an Adams–Bashford method, and an implicit method, called an
Adams–Moulton method. They can be derived by quadrature as follows. We start with the
equation
Z tn+1
y(tn+1 ) = y(tn ) + f t, y(t) dt.
tn
Now, assuming that yj is known for j ≤ n, let P (t) ∈ Pk denote the Lagrange interpolating
polynomial satisfying P (tj ) = fj := f (tj , yj ), j = n, n − 1, . . . , n − k. We then define
Z tn+1
yn+1 = yn + P (t) dt,
tn
which is the k + 1 step Adams–Bashford method. For k = 0, 1, and 2, the formulas are
where
tn+1 1
t − tn−m
Z Z
1 Y Y m+t
bj = dt = dt.
h tn 0≤m≤k
tn−j − tn−m 0 0≤m≤k
m−j
m6=j m6=j
(Note that the first expression can be used also in the case of non-constant step size.)
3. LINEAR MULTISTEP METHODS 135
The Adams–Moulton methods are constructed similarly, except that P ∈ Pk+1 interpo-
lates fn−j at tn−j for j = −1, . . . , k. The first few formulas are
1 1
yn+1 = yn + h( fn+1 + fn ), (trapezoidal method)
2 2
5 2 1
yn+1 = yn + h( fn+1 + fn − fn−1 ),
12 3 12
3 19 5 1
yn+1 = yn + h( fn+1 + fn − fn−1 + fn−2 ).
8 24 24 24
We may also think of the backward Euler method as an Adams–Moulton method with
k = −1.
It is easy to check the order of the Adams methods. E.g., for the k + 1 step Adams–
Bashford method
Z tn+1
L[y, h, tn ] = [y 0 (t) − P (t)] dt,
tn
0
where P ∈ Pk interpolates y at tn , . . . , tn−k . By the Newton error formula for Lagrange
interpolation,
y 0 (t) − P (t) = y 0 [tn , . . . , tn−k , t](t − tn ) · · · (t − tn−k ),
so, using the integral mean value theorem,
Z tn+1
0
L[y, h, tn ] = y [tn , . . . , tn−k , ξ] (t − tn ) · · · (t − tn−k ) dt
tn
Z tn+1
1
= y (k+2) (η) (t − tn ) · · · (t − tn−k ) dt.
(k + 1)! tn
for some ξ. The integral is clearly order O(hk+2 ), so the method is of order k + 1. In fact it
equals γk+1 hk+2 where γ1 = 1/2, γ2 = 5/12, γ3 = 3/8, . . . . Thus for the Adams–Bashford
methods, the order is equal to the number of steps.
Similarly, for k step Adams–Moulton method also has order k+1 and the local truncation
error satisfies
1 ∗
L[y, h, tn ] = y (k+1) (η)γk+1 hk+2 .
(k + 1)!
The first few γk∗ are γ0∗ = −1/2 (for backward Euler), γ1∗ = −1/12 (for trapezoidal), γ2∗ =
−1/24, . . . . Thus to achieve the same order k + 1 we can use a k + 1 step Adams–Bashford
method or a k step Adams–Moulton method. The coefficient of hk+2 in the local truncation
error is significantly smaller for the Adams–Moulton method. When we study the notion of
absolute stability later, we shall find other advantages of the Adams–Moulton methods over
the Adams–Bashford methods.
using a small number of fixed point iterations starting from an initial approximation obtained
by an explicit method. Thus the scheme takes the form:
1. predict: pn+1 = E(yn , yn−1 , . . . , fn , fn−1 , . . . )
p
2. evaluate: fn+1 = f (tn+1 , pn+1 )
(1) p
3. correct: yn+1 = I(yn , yn−1 , . . . , fn+1 , fn , fn−1 , . . . )
(1) (1)
4. evaluate: fn+1 = f (tn+1 , yn+1 )
(2) (1)
5. correct: yn+1 = I(yn , yn−1 , . . . , fn+1 , fn , fn−1 , . . . )
(2) (2)
6. evaluate: fn+1 = f (tn+1 , yn+1 )
..
.
Here E(yn , yn−1 , . . . , fn , fn−1 , . . . ) refers to some explicit scheme, e.g., an Adams–Bashford
scheme, and I(yn , yn−1 , . . . , fn+1 , fn , . . . ) to some implicit, e.g., Adams–Moulton, scheme.
(m)
At some point we stop and declare yn+1 = yn+1 . We could stop in response to some stopping
criterion, but more commonly, a fixed, usually small, number of iterations are made. For
(1)
example, we may stop the iteration after step 4, and accept yn+1 . This would then be
referred to as a PECE scheme. Other possibilities are PECECE, P(EC)3 E, etc. As a simple
example, consider the PECE method with a 2 step Adams–Bashford predictor and a 2 step
Adams–Moulton corrector. This gives
pn+1 = yn + h[3f (tn , yn ) − f (tn−1 , yn−1 )]/2,
yn+1 = yn + h[5f (tn+1 , pn+1 ) + 8f (tn , yn ) − f (tn−1 , yn−1 )]/12.
Thus
yn+1 = yn +h 5f tn+1 , yn +h[3f (tn , yn )−f (tn−1 , yn−1 )]/2 +8f (tn , yn )−f (tn−1 , yn−1 ) /12.
Thus the resulting method is a nonlinear 2 step method.
The analysis of the error of such a scheme is relatively straightforward. We just briefly
sketch the main ideas for a PECE scheme. There are two contributions to the local trun-
cation error, one arising from predictor formula and one arising from the corrector formula.
If the predictor formula has order p and the corrector formula has order q, so their local
truncation errors are O(hp+1 ) and O(hq+1 ) respectively, then the local truncation error for
the PECE scheme will be O(hp+2 ) + O(hq+1 ) = O(hmin(p+2,q+1) ). The extra order in predic-
tor contribution comes from the fact that the term f (tn+1 , pn+1 ) involving the predictor is
multiplied by h in the formula for yn+1 . Thus if p ≥ q − 1, the local truncation error will be
O(hq+1 ) just as if the predictor equation were solved exactly. In fact, if we take p ≥ q, the
local truncation error for the PECE scheme will be asymptotically equal to that for the full
implicit scheme (i.e., they will agree up to terms of higher order). Thus the most common
choices are either p = q − 1 or p = q. For a PECE scheme based on Adams methods, we
might use the k step Adams–Bashford for predictor (order k) and the k step Adams–Moulton
for corrector (order k + 1), and thus achieve a method of order k + 1. Or we might take a
k + 1 step Adams–Bashford predictor, which would still achieve the same order, but which
we would expect to have an asymptotically smaller error. Yet another possibility is to use a
PECECE scheme with k step Adams methods for both predictor and corrector. This would
4. ONE STEP METHODS 137
again produce asymptotically the same error as the fully implicit k step Adams–Moulton
method.
which is a consistent stable linear 1 step method for any real θ (of course, all consistent 1
step methods are stable). Except for Euler’s method, all these methods are implicit.
We may also obtain an explicit, but nonlinear, single step method using Euler as a
predictor and one of the other methods as a corrector in a PECE (or PECECE, . . . )
scheme. E.g., with the trapezoidal method as corrector, we get
yn+1 = yn + h[f (tn , yn ) + f tn+1 , yn + hf (tn , yn ) ]/2,
where Φ is called the relative increment function. For an explicit method, Φ(f ; tn , yn , h) is
an explicit function of tn and yn involving f and h. For implicit methods, Φ(f ; tn , yn , h) is
given in terms of the solution to an algebraic equation. In fact we can even consider the
exact relative increment function
y(tn+1 ) − y(tn )
∆(f ; tn , yn , h) = ,
h
where u is the exact solution to the differential equation u0 (t) = f t, y(t) , y(tn ) = yn . This
one step method gives the exact solution, but is not implementable. A single step method
with increment function Φ is of order p (its local truncation error is O(hp+1 )) if and only if
4.1. Taylor series methods. In a sense, there is a canonical pth order one step method.
Taylor’s theorem tells us that
hp (p)
y(t + h) = y(t) + hy 0 (t) + · · · +y (t) + O(h(p+1) ).
p!
Now the differential equation tells us that y 0 (t) = f t, y(t) . But we can also differentiate
the differential equation to get
∂f ∂f
y 00 (t) =
t, y(t) + f t, y(t) t, y(t) ,
∂t ∂y
or, briefly, y 00 = ft + f fy =: Df , the total derivative of f . Differentiating again gives
y 000 = ftt + 2f fty + ft fy + f fy2 + f 2 fyy =: D2 f,
y (4) = D3 f , etc. (The expressions for the total derivatives get very complicated, very quickly.)
The p-term Taylor series method is the single step method
h2 hp
yn+1 = yn + hfn + Dfn + · · · + Dp−1 fn ,
2 p!
which clearly has order p. This method can be implemented in some cases, but it requires
evaluation of the partial derivatives of f , and is not commonly used.
4.2. Runge–Kutta methods. Now let us return to Heun’s method, which we derived
as a PECE scheme with Euler’s method as predictor and the trapezoidal method as corrector.
The relative increment function is
Φ = [f (tn , yn ) + f tn+1 , yn + hf (tn , yn ) ]/2.
Expanding the second term in brackets in a Taylor polynomial around (tn , yn ) we get
h
Φ = f + (ft + f fy ) + O(h2 ),
2
where the f and its derivatives are evaluated at (tn , yn ). Comparing with the Taylor expan-
sion of the exact relative increment we see that Φ = ∆ + O(h2 ), and hence Heun’s method
is second order. (If we expand Φ out to terms of order h2 , we get
h h2
Φ = f + (ft + f fy ) + (ftt + 2f fty + f 2 fyy ) + O(h3 ).
2 4
The coefficient of h2 does not agree with D2 f /3!, so Heun’s method is definitely not of higher
than second order.
Heun’s method is an explicit single step method which requires 2 evaluations of f per
step (but does not require knowledge of the derivatives of f ). This is an example of a
Runge–Kutta (RK) method. The general form of an explicit RK method is
yn+1 = yn + h(b1 φ1 + · · · + bq φq ),
4. ONE STEP METHODS 139
bT
The tableau for Heun’s method is
0
1 1
1 1
2 2
where we don’t bother to write the zeros in the upper triangle of A. Other well-known RK
methods are the modified Euler method, Heun’s 3 stage method, and the Runge–Kutta–
Simpson 4-stage method (often referred to as the Runge–Kutta method), whose tableaux
are
0
0 0 1 1
1 1 2 2
1 1 2 2 1 1
2 2 0
1 −1 2 2 2
1 0 0 1
0 1 1 2 1
6 3 6 1 1 1 1
6 3 3 6
respectively. For any of these methods, it is an elementary, but tedious computation (easily
carried out by a computer algebra program) to determine their order by an expansion in
Taylor series. One finds that the modified Euler method is of order 2, Heun’s 3-stage method
is of order 3, and the Runge–Kutta-Simpson method is of order 4. These are the highest
possible orders achievable with the given number of stages. That is, it can be verified, by
similarly tedious computation, that the highest order achievable by a Runge–Kutta method
with q stages is q for each q from 1 to 4. However for q from 5 to 7 order q − 1 is the
best achievable, and for q = 8, order 6 is the best achievable. Butcher has developed graph
theoretic techniques for constructing and analyzing RK methods which are necessary when
working with more than a modest number of stages.
It is also possible to use implicit Runge–Kutta methods. These are defined by the same
equations, except that the coefficient matrix A is no longer required to be lower triangular.
This requires the solution of a coupled system of q nonlinear equations to determine the ηi
140 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
at each step (and if, as is usually the case, we are solving a system of, say, d, ODEs, each ηi
is itself a vector with d components, and we have to solve a system of qd coupled nonlinear
algebraic equations). For this reason one rarely uses implicit RK methods with more than a
few stages.
4.3. Convergence of single step methods. We now consider the convergence of the
general single-step method
yn+1 = yn + hΦ(f ; tn , yn , h).
We assume as usual that f (t, y) belongs to C([t0 , t∗ ] × R) and satisfies a uniform Lipschitz
condition with respect to y. We assume that the relative increment function Φ(f ; t, y, h),
which is defined for t ∈ [t0 , t∗ ], y ∈ R, h ∈ [0, t∗ − t], is continuous there. Moreover we
assume the uniform Lipschitz condition
|Φ(f ; t, y, h) − Φ(f ; t, ȳ, h)| ≤ K|y − ȳ|,
whenever (t, y, h) and (t̄, y, h) belong to the domain of Φ. For Taylor series methods it is
easy to deduce the continuity and Lipschitz condition for Φ for smooth f . For Runge–Kutta
methods continuity is evident and the Lipschitz condition is not hard to obtain using the
same condition for f .
A single step method with relative increment function Φ is consistent if
lim[Φ(f ; t, y, h) − ∆(f ; t, y, h)] = 0.
h↓0
In view of continuity we can state this simply as Φ(f ; t, y, 0) = f (t, y). The method has
order p if |Φ(f ; t, y, h) − ∆(f ; t, y, h)| ≤ Chp (whenever f is smooth).
Theorem 5.15. A single step method is convergent if and only if it is consistent.
Proof. Define y h by the single step method:
y h (tn+1 ) = y h (tn ) + hΦ f ; tn , y h (tn ), h ,
starting from y h (t0 ) = y0 . We claim that, whether or not the method is consistent, as h → 0
y h converges to the solution of the boundary value problem
z 0 (t) = g t, z(t) , z(t0 ) = y0 ,
where g(t, y) = Φ(f ; t, y, 0). Since, by definition, the method is consistent if and only
if f = g, this will prove the theorem. (If f (t̄, ȳ) 6= g(t̄, ȳ) for some (t̄, ȳ), then we let
y(t) be the solution to y 0 = f (t, y) passing through ȳ at t̄. Then either y(t̄) 6= z(t̄) or
y 0 (t̄) = f (t̄, ȳ) 6= g(t̄, ȳ) = z 0 (t̄), so, in either case, z 6≡ y.)
To prove the claim, note that
z(tn+1 ) = z(tn ) + hz 0 (ξn ) = z(tn ) + hg ξn , z(ξn ) ,
for some ξn ∈ (tn , tn+1 ). Putting en = z(tn ) − y h (tn ) and subtracting we get
en+1 = en + h[g ξn , z(ξn ) − Φ f ; t, y h (tn ), h ].
5. ERROR ESTIMATION AND ADAPTIVITY 141
The first two terms tend to 0 with h by uniform continuity of g and Φ, and the last term
can be bounded by K|en | using the Lipschitz condition. Thus we have
|en+1 | ≤ (1 + Kh)|en | + ω(h),
where limh→0 ω(h) = 0. Since we also have e0 = 0, it follows, in the usual way, that the
sequence en tends to 0.
5. Error estimation and adaptivity
Just as for numerical quadrature, a code for the numerical solution of ordinary differential
equations can be much more efficient if the step size is adjusted adaptively to the solution.
Very roughly speaking, in parts of its domain where the solution is rapidly varying, and so
has large derivatives, a smaller step size will be needed than in places where the solution
is more slowly varying. In this section we will study the main ideas behind some modern
adaptive ODE solvers.
The first step in designing an adaptive solver is to establish the goal of the solver. In many
cases the user may wish to control some global error measure, like the discrete maximum
norm error
max |y h (tn ) − y(t)|.
0≤n≤N
Thus we could ask the user to input a tolerance and take as the goal of the code to select
step sizes which achieve max |y h (tn ) − y(t)| ≤ as inexpensively (i.e., with as few steps) as
possible. Unfortunately, the global error is difficult to estimate and to control. Indeed, as
we have seen, small error committed near the beginning of the interval of solution, may, or
may not, lead to large errors later in the interval. This cannot be known a code at least
until the solution process is complete, and thus there is no way to select the step size near
the beginning of the computation to control the final global error. This being the case, most
adaptive ODE solvers try to control a different error quantity known as the local error.
0
Definition. Let wn−1 (t) be the solution to the differential equation wn−1 = f (t, wn−1 )
h
satisfying wn−1 (tn−1 ) = y (tn−1 ). The local error at the nth step is defined to be
ln = y h (tn ) − wn−1 (tn ).
Thus, for a single step method with relative increment function Φ
ln = h[Φ(f ; tn−1 , y h (tn−1 ), h) − ∆(f ; tn−1 , y h (tn−1 ), h)].
Figure 5.5 shows the local error, the local truncation error, and the global error.
The role of the local error is clarified by the equation
y h (tn ) − y(tn ) = [y h (tn ) − wn−1 (tn )] + [wn−1 (tn ) − y(tn )].
The first bracketed quantity is the local error at the nth step. The second bracketed quantity
is the difference between two exact solutions of the ODE, one starting at y h (tn−1 ) at the
142 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
Figure 5.5. Local error, local truncation error, and global error.
local error
global error
wn−1 (t) local truncation error
y h (t)
y(t)
t0 t1 tn−1 tn
beginning of the step and the other starting at y(tn ). Thus this quantity represents the
error at the end of the nth step due to the accumulated global error at the start of the step
propagated forward by the differential equation, and the equation says that the error at the
end of the step is the sum of the local error on the step plus the accumulated errors made
previously and propagated forward.
In a similar way, we may write
n
X
y h (tn ) − y(tn ) = wn (tn ) − w0 (tn ) = [wi (tn ) − wi−1 (tn )].
i=1
Here wi and wi−1 are both exact solutions of the ODE. They differ by wi (ti ) − wi−1 (ti ) =
y h (ti )−wi−1 (ti ) = li at ti , and so the term wi (tn )−wi−1 (tn ) represents the error at tn obtained
by propagating the forward the local error on the ith step to the end of the interval. From
the stability theorem, Theorem 5.3, we have for 1 ≤ i ≤ n ≤ N ,
where C = exp(L|tN − t0 |)|li |. In this way we see that the global error is bounded by a
multiple of the sum of the local errors, with the multiplier depending on the stability of the
differential equation.
In light of these considerations, a useful goal for an adaptive solver is toPchoose the
N
number of steps and the step sizes to achieve as economically as possible that n=1 |li | ≤ ,
where is a user-supplied tolerance. The basic stucture of such solver is summarized, at a
very high level, in the following algorithm:
5. ERROR ESTIMATION AND ADAPTIVITY 143
5.1. Error estimation and step size selection. To fill out this algorithm, we need
to answer several questions:
1. How should the initial step size be chosen?
2. How can we estimate the local error?
3. When is the local error “small enough” to accept the step?
4. After an acceptable step, how should the step size for the next step be predicted?
5. After rejecting a step, how should the step size be adjusted for the next trial?
5.1.1. The local error per unit step criterion. Just as when we discussed adaptive quad-
rature we arrived at the error per unit step criterion, a good criterion for step acceptance
for adaptive ODE solvers is the local error per unit step criterion. This means that given a
desired bound for the sum of the local errors, we accept a step of size hn with a local error
of size ln if
hn
|ln | ≤ .
T − t0
If this criterion is met at each step, then we have
N N
X X
|ln | ≤ hn = ,
n=1
T − t0 n=1
as desired. If we set tol = /(T − t0 ), our step acceptance criterion is just |ln |/hn ≤ tol.
5.1.2. Step size design. Next we turn to answering questions 4 and 5. Our goal is to find
the largest step size hn so that the local error per unit step |ln |/hn does not exceed tol. Now
ln
= Φ(f ; tn−1 , y h (tn−1 ), hn ) − ∆(f ; tn−1 , y h (tn−1 ), hn ) = Chpn + O(hp+1
n ),
hn
where p is the order of the single step method and the constant C depends on the differential
equation and the step. Now suppose we have somehow computed est, a good approximation
for |ln |/hn , and found that it exceeds tol, and so we have rejected the step.
STOPPED HERE
5.1.3. Estimation of the local error.
6. Stiffness
Consider the very simple linear system with 2 components
(5.19) y 0 = Ay, y(0) = y 0 ,
where
−33.4 66.6 3
A= , y0 = .
33.3 −66.7 0
The matrix A has eigenvalues −100 and −1/10 and corresponding eigenvalues x1 = (1, −1)T ,
x2 = (2, 1)T . Thus the functions e−100t x1 and e−t/10 x2 are both exact solutions to the
given differential equation. To find the solution with the given initial value, we note that
y 0 = α1 x1 + α2 x2 where α1 = 1, α2 = 2, so
−100t
+ 2e−t/10
−100t −t/10 e
(5.20) y(t) = α1 e x1 + α2 e x2 = .
−e−100t + e−t/10
The exact solution on the interval [0, 3] is plotted in Figure 5.6. Note that the solution is
very smooth and slowly varying, after an initial transient period, related to the large negative
eigenvalue −100.
Figure 5.6. The exact solution of the moderately stiff 2 × 2 linear system
(5.19). The solid line shows the first component, the dashed line the second.
3
0
0 1 2 3
In the first five plots in Figure 5.7 we show the approximate solution to this system
obtained by using Euler’s method with step size h = 1/10, 1/20, 1/40, 1/80, and 1/160.
Notice the wild scale in the first three plots. Although both components of the exact solution
are bounded between 0 and 3, the approximate solution is on the order of 1028 when h = 1/10
and on the order of 1036 when h = 1/20. For h = 1/80 the solution appears qualitatively
correct except for a short time near 0, and for h = 1/160 the numerical solution is visually
indistinguishable from the exact solution.
Since our computation shows that we can integrate this system accurately with Euler’s
method if we take h = 1/160, and since the solution is very smooth for t ≥ 1/2, a natural
idea is to use a step size of 1/160 to solve on [0, 1/2], and then to increase the step size to,
say, 1/10. The result is shown in the final plot Figure 5.7. We have abject failure: again the
solution is off by orders of magnitude.
6. STIFFNESS 145
Figure 5.7. Euler’s method applied to a stiff 2 × 2 linear system. step sizes
are h = 1/10, 1/20, 1/40, 1/80, and 1/160. The final plot uses 80 steps of size
1/160 followed by steps of size 1/10.
28 36 21
x 10 x 10 x 10
5 2 2
0 0 0
−5 −2 −2
0 1 2 3 0 1 2 3 0 1 2 3
7
x 10
3 3 4
2 2
0
1 1
0 0 −4
0 1 2 3 0 1 2 3 0 1 2 3
2 2
1 1
0 0
0 1 2 3 0 1 2 3
As a final computational example, we compute the solution using two adaptive single
step solvers from Matlab, ode45, which uses an embedded Runge–Kutta pair, and ode15s,
which is designed for stiff problems. The results, pictured in Figure 5.8, show clearly that in
order to obtain an accurate solution ode45 requires small step size all through the domain,
even where the solution is smooth, while ode15s is able to use large step sizes after the initial
transient.
146 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
What we are seeing here is the problem of stiffness. A stiff problem is characterized
by rapidly varying transients which decay quickly, but for some reason require us to take
small step sizes even after they have disappeared from the solution. As we see from the
ode15s results, there are methods that are able to overcome the problem of stiffness. Stiff
problems are important, because they arise (though in more complicated form than this
simple example), in a number of applications including chemical reaction modeling, numerical
solution of parabolic and hyperbolic PDEs, control theory, and electric circuit modeling. In
the rest of this section, we seek to understand what is happening and how stiff problems can
be efficiently dealt with.
First let us return to Euler’s method with a constant step size. Because of the very simple
nature of the ODE, we can give a closed form for the Euler solution. Euler’s method for this
ODE gives y n+1 = (I + hA)y n . This gives y n = (I + hA)n y 0 for all n, howsoever the initial
value y 0 is chosen. In particular, if we take the initial value equal to the eigenvector x1 , then
at the nth step we have y n = (1 − 100h)n x1 (since x1 is also an eigenvector of I + hA, with
eigenvalue 1 − 100h). Similarly if the initial data is x2 , then y n = (1 − h/10)n x2 . Now any
2-vector can be written as linear combination of x1 and x2 . In particular, the given initial
data y 0 = (3, 0)T = α1 x1 + α2 x2 , with α1 = 1 and α2 = 2. Thus the Euler approximation
to (5.19) is given by
(5.21) y n = α1 (1 − 100h)n x1 + α2 (1 − h/10)n x2 .
Comparing with (5.20), we see that e−100t is being approximated by (1 − 100h)n when
t = hn. Now if 100h << 1 this is a reasonable approximation. Then e−100h ≈ 1 − 100h and
e−100hn ≈ (1−100h)n . But if 100h is not so small, then (1−100h)n does not behave at all like
e−100hn . In fact if 100h > 2, then 1 − 100h is a negative number of magnitude greater than
one, and so (1 − 100h)n is exponentially growing, and alternating sign. In that case the first
time on the right hand side on (5.21), instead of becoming negligeable as n increases, will
dominate the computation. In fact, in order that this term decay as n increases, a necessary
and sufficient condition is that |1 − 100h| < 1, or −2 < −100h < 0, or h ∈ (0, 1/50), which
matches will our numerical experience.
Notice, that we could have analyzed this situation by looking at the simpler problem
y 0 = −100y, y(0) = 1. In general, an advantageous property for methods to be used with
stiff problems is that when they are used to solve the very simple model problem
(5.22) y 0 = λy, y(0) = 1,
where λ < 0, the numerical solution yn should decay, not grow, as n increases. Generally,
this will imply some restriction on the step size. The more severe that restriction, the less
suitable the method is for stiff problems.
The model problem (5.22), while very simple, has relevance for a great many problems.
Many ODEs can be approximated, at least locally by a linear ODE. Starting with any linear
ODE y 0 = Ay, where A is a matrix, we may diagonalize to obtain a set of equations of the
form of (5.22) where the values of λ which arise are the eigenvalues of A. Of course this
requires that A be diagonalizable, but since any matrix is arbitrarily close to a diagonalizable
matrix, this is not a big restriction. However, a diagonalizable matrix may well have complex
eigenvalues (even when the matrix is real), and thus to results relevant to a reasonably
general situation we should consider (5.22) for λ ∈ C. Since the solution y = eλt decays with
6. STIFFNESS 147
increasing t, if and only if <λ < 0, we would like that the numerical solution yn decays with
increasing n for <λ < 0 and h > 0.
For Euler’s method, yn = (1 + λh)n , which is decaying if and only |1 + hλ| < 1. Consider
next the backward Euler method. Then yn+1 = yn + hλyn+1 , whence yn = [1/(1 − hλ)]n . For
<λ < 0, this holds for all h > 0. Thus we would expect (correctly), that stiffness is not a
problem for the backward Euler method.
Similarly, for any single step method and any λ ∈ C, we may consider the set of values of
h for which the numerical solution obtained when the method is applied to (5.22) is decaying
as n → ∞. (It doesn’t matter what nonzero initial value is used, since the problem is linear.)
Now for virtually any method (certainly any method we have studied, including all implicit
and explicit Runge–Kutta methods), the values of yn depend only on the product hλ (check
this!). Therefore we define the region of absolute stability of the single step method as
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
4 4
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
Theorem 5.16 (Second Dahlquist Barrier). An A-stable linear multistep method is im-
plicit and of order at most 2.
Because the Adams methods, and various other linear multistep methods, have rather
small regions of absolute stability, other linear multistep methods are preferred for stiff
problems. The most popular are the backward differentiation formula methods or BDF
methods. These are methods of the form
k
X
aj yn−j = hfn+1 .
j=−1
6. STIFFNESS 149
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
4
-2
-4
-6 -4 -2 0 2
The coefficients are aj are determined by interpolating yn−j and tn−j j = −1, . . . , k by a
polynomial p(t) of degree k and evaluating p0 (tn+1 ). The first few BDF methods are
The k-step BDF method is of order k. For k = 1 and 2, the method is A-stable. The second
Dahlquist barrier implies that this is not true for k > 2, but for k = 3 the region of absolute
stability just misses a tiny piece of the left half plane, so the method is good for most stiff
problems. See Figure 5.12. As k increases the region of absolute stability decreases, but it
still contains a great deal of the left half plane for k = 4 and k = 5. For k > 6, the BDF
formulas are not stable, in the usual sense, and so should not be used..
150 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
4 4
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
Exercises
1. Prove that Euler’s method is stable with respect to perturbations in the initial data y0 and
the function f . That is, prove that if yn is defined by Euler’s method and ȳn is defined by
the perturbed equations:
ȳn+1 = ȳn + hf¯(tn , ȳn ), ȳ0 given,
then |yn − ȳn | ≤ C1 |y0 − ȳ0 | + C2 kf − f¯kL∞ (I×R) . (State precisely the hypotheses needed
and give explicit formulas for C1 and C2 .)
2. State precisely and prove an asymptotic error estimate for the trapezoidal method.
3. Find the most general two stage Runge–Kutta method of order 2.
4. For solving the equation y 0 = f (t, y), consider the scheme
h 0 0 h2
yn+1 = yn + (yn + yn+1 ) + (yn00 − yn+1
00
),
2 12
EXERCISES 151
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
4 4
2 2
0 0
-2 -2
-4 -4
-6 -4 -2 0 2 -6 -4 -2 0 2
where yn0 = f (tn , yn ), and yn00 = (∂f /∂t + f ∂f /∂y)(tn , yn ). Determine the order of this
method. Show that its region of absolute stability contains the entire negative real axis.
5. Consider a consistent linear multistep methods yn+1 + kj=0 aj yn−j = h kj=−1 bj fn−j for
P P
which the coefficients aj ≤ 0, j = 0, . . . , k (there are many such methods). a) Prove that all
such consistent methods satisfy the root condition, and so are stable. b) Give an elementary
proof that all such methods are convergent (without invoking the Dahlquist theory).
152 5. NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS
CHAPTER 6
where c is the product of the specific heat of the material and the density of the material.
Since the temperature may vary with time, so can the heat content of D. The rate of change
of heat in D is given by
Z Z
∂ ∂(cu)
rate of change of heat in D = cu dx = (x, t) dx.
∂t D D ∂t
Now any change of heat in D must be accounted for by heat flowing in or out of D through
its boundary or by heat entering from external sources (e.g., if the body were in a microwave
oven). Fourier’s law of heat conduction says that heat flows in the direction opposite the
temperature gradient with a rate proportional to the magnitude of the gradient. That is,
the heat flow, at any point and any time, is given by
heat flow = −λ grad u,
where the positive quantity λ is called the conductivity of the material. (Usually λ is just
a scalar, but if the material is thermally anisotropic, i.e., it has preferred directions of heat
flow, as might be a fibrous or laminated material, λ can be a 3 × 3 positive-definite matrix.)
Therefore the heat that flows out of D is given by
Z
rate of heat flow out of D = − (λ grad u) · n ds.
∂D
R R
Now the divergence theorem says that for any vectorfield v, ∂D v · n ds = D div v dx. Thus
Z
rate of heat flow out of D = − div(λ grad u) dx.
D
153
154 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
where f is the rate at which heat per unit volume is being added from external sources (if
heat is being removed, f is negative). Thus the quantity
∂(cu)
− div(λ grad u) − f
∂t
has vanishing integral on any smoothly bounded subregion D. This happens if and only if
this quantity vanishes. Thus we have derived the equation
∂(cu)
= div(λ grad u) + f in Ω × J.
∂t
The source function f , the material coefficients c and λ and the solution u can all be functions
of x and t. If the material is homogeneous (the same everywhere) and not changing with
time, then c and λ are constants and the equation simplifies to the heat equation,
∂u
µ = ∆ u + f˜,
∂t
where µ = c/λ and we have f˜ = f /λ. If the material coefficients depend on the temperature
u, as may well happen, we get a nonlinear PDE generalizing the heat equation.
The heat equation not only governs heat flow, but all sorts of diffusion processes where
some quantity flows from regions of higher to lower concentration. The heat equation is the
prototypical parabolic differential equation.
Now suppose our body reaches a steady state: the temperature is unchanging. Then the
time derivative term drops and we get
(6.1) − div(λ grad u) = f in Ω,
where now u and f are functions of f alone. For a homogeneous material, this becomes the
Poisson equation
− ∆ u = f˜,
the prototypical elliptic differential equation. For an inhomogeneous material we can leave
the steady state heat equation in divergence form as in (6.1), or differentiate out to obtain
−λ ∆ u + grad λ · grad u = f.
To determine the steady state temperature distribution in a body we need to know not
only the sources and sinks within the body (given by f ), but also what is happening at the
boundary Γ := ∂Ω. For example a common situation is that the boundary is held at a given
temperature
(6.2) u = g on Γ.
The PDE (6.1) together with the Dirichlet boundary condition (6.2) form an elliptic bound-
ary value problem. Under a wide variety of circumstances this problem can be shown to
have a unique solution. The following theorem is one example (although the smoothness
requirements can be greatly relaxed).
Theorem 6.1. Let Ω be a smoothly bounded domain in Rn , and let λ : Ω̄ → R+ , f : Ω̄ →
R, g : Γ → R be C ∞ functions. Then there exists a unique function u ∈ C 2 (Ω̄) satisfying
the differential equation (6.1) and the boundary condition (6.2). Moreover u is C ∞ .
2. THE FIVE-POINT DISCRETIZATION OF THE LAPLACIAN 155
Instead of the Dirichlet boundary condition of imposed temperature, we often see the
Neumann boundary condition of imposed heat flux (flow across the boundary):
∂u
= g on Γ.
∂n
For example if g = 0, this says that the boundary is insulated. We may also have a Dirichlet
condition on part of the boundary and a Neumann condition on another.
Before defining ∆h , let us turn to the one-dimensional case. That is, given a function vh
defined at the mesh points nh, n ∈ Z, we want to define a function Dh2 vh on the mesh points,
so that Dh2 vh ≈ v 00 |Zh if vh = v|Zh . One natural procedure is to construct the quadratic
polynomial p interpolating vh at three consecutive mesh points (n − 1)h, nh, (n + 1)h, and
let Dh2 vh (nh) be the constant value of p00 . This gives the formula
v h (n + 1)h − 2v h (nh) + v h (n − 1)h
Dh2 vh (nh) = 2vh [(n − 1)h, nh, (n + 1)h] = .
h2
Dh2 is known as the 3-point difference approximation to d2 /dx2 . We know that if v is C 2 in
a neighborhood of nh, then limh→0 v[x − h, x, x + h] = v 00 (x)/2. In fact, it is easy to show
by Taylor expansion (do it!), that
h2 (4)
Dh2 v(x) = v 00 (x) +
v (ξ), for some ξ ∈ x − h, x + h ,
12
as long as v is C 4 near x. Thus Dh2 is a second order approximation to d2 /dx2 .
Remark. Alternatively, we could use the Peano kernel theorem to analyze the error
Dh2 v(0)− v 00 (0), say when h = 1, and then use scaling to get the result for arbitrary h. We
leave this as an exercise for the reader.
Now returning to the definition of the ∆h ≈ ∆ = ∂ 2 /∂x2 + ∂ 2 /∂y 2 , we simply use the
3-point approximation to ∂ 2 /∂x2 and ∂ 2 /∂y 2 . Writing vm,n for v(mh, nh) we then have
vm+1,n − 2vm,n + vm−1,n vm,n+1 − 2vm,n + vm,n−1
∆h v(mh, nh) = +
h2 h2
vm+1,n + vm−1,n + vm,n+1 + vm,n−1 − 4vm,n
= .
h2
From the error estimate in the one-dimensional case we easily get that for v ∈ C 4 (Ω̄),
h2 ∂ 4 v ∂4v
∆h v(mh, nh) − ∆ v(mh, nh) = (ξ, nh) + 4 (mh, η) ,
12 ∂x4 ∂y
for some ξ, η. Thus:
If v ∈ C 4 (Ω̄), then
h2
k∆h v − ∆ vk L∞ (Ω h)
≤ M4 ,
6
where M4 = max(k∂ 4 v/∂x4 kL∞ (Ω̄) , k∂ 4 v/∂y 4 kL∞ (Ω̄) ).
mesh points, we may regard (6.4) as a system of (N − 1)2 linear equations in (N − 1)2
unknowns. For example, in the case N = 4 the system is
2
−4 1 0 1 0 0 0 0 0 u1,1 h f1,1 − u1,0 − u0,1
1 −4 1 0 1 0 0 0 0 u2,1 h2 f2,1 − u2,0
0 1 −4 0 0 1 0 0 0 u3,1 h2 f3,1 − u3,0 − u4,1
1 0 0 −4 1 0 1 0 0 u1,2 h2 f1,2 − u0,2
0 1 0 1 −4 1 0 1 0 u2,2 = h2 f2,2
u h2 f − u
0 0 1 0 1 −4 0 0 1
3,2 3,2 4,2
0 −4 1 u1,3 h2 f1,3 − u0,3 − u1,4
0 0 0 1 0 0
2
0 0 0 0 1 0 1 −4 1 u2,3 h f2,3 − u2,4
0 0 0 0 0 1 0 1 −4 u3,3 h2 f3,3 − u4,3 − u3,4
The matrix may be rewritten as
A I O
I A I
O I A
where I is the 3 × 3 identity matrix, O is the 3 × 3 zero matrix, and
−4 1 0
A = 1 −4 1 .
0 1 4
For general N the matrix can be partitioned into (N − 1) × (N − 1) blocks, each in
R(N −1)×(N −1) :
A I O ··· O O
I A I · · · O O
O I A · · · O O ,
. .. .. . . . .
.. . . . .. ..
O O O ··· I A
where I and O are the identity and zero matrix in R(N −1)×(N −1) , respectively, and A ∈
R(N −1)×(N −1) is the tridiagonal matrix with −4 on the diagonal and 1 above and below the
diagonal. This assumes the unknowns are ordered
u1,1 , u2,1 , . . . , uN −1,1 , u1,2 , . . . , uN −1,N −1 ,
and the equations are ordered similarly.
Notice that the matrix has many special properties:
• it is sparse with at most 5 elements per row nonzero
• it is block tridiagonal, with tridiagonal and diagonal blocks
• it is symmetric
• it is diagonally dominant
• its diagonal elements are negative, all others nonnegative
• it is negative definite
158 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
2.1. Analysis via a maximum principle. We will now prove that the problem (6.4)
has a unique solution and prove an error estimate. The key will be a discrete maximum
principle.
Theorem 6.3 (Discrete Maximum Principle). Let v be a function on Ω̄h satisfying
∆h u ≥ 0 on Ωh .
Then maxΩh v ≤ maxΓh v. Equality holds if and only if v is constant.
Proof. Suppose maxΩh v ≥ maxΓh v. Take x0 ∈ Ωh where the maximum is achieved.
Let x1 , x2 , x3 , and x4 be the nearest neighbors. Then
4
X 4
X
2
4v(x0 ) = v(xi ) − h ∆h v(x0 ) ≤ v(xi ) ≤ 4v(x0 ),
i=1 i=1
since v(xi ) ≤ v(x0 ). Thus equality holds throughout and v achieves its maximum at all the
nearest neighbors of x0 as well. Applying the same argument to the neighbors in the interior,
and then to their neighbors, etc., we conclude that v is constant.
Remarks. 1. The analogous discrete minimum principle, obtained by reversing the in-
equalities and replacing max by min, holds. 2. This is a discrete analogue of the maximum
principle for the Laplace operator.
Theorem 6.4. There is a unique solution to the discrete boundary value problem (6.4).
Proof. Since we are dealing with a square linear system, it suffices to show nonsingu-
larity, i.e., that if ∆h uh = 0 on Ωh and uh = 0 on Γh , then uh ≡ 0. Using the discrete
maximum and the discrete minimum principles, we see that in this case uh is everywhere
0.
The next result is a statement of maximum norm stability.
Theorem 6.5. The solution uh to (6.4) satisfies
1
(6.5) kuh kL∞ (Ω̄h ) ≤ kf kL∞ (Ωh ) + kgkL∞ (Γh ) .
8
This is a stability result in the sense that it states that the mapping (f, g) 7→ uh is
bounded uniformly with respect to h.
Proof. We introduce the comparison function φ = [(x − 1/2)2 + (y − 1/2)2 ]/4, which
satisfies ∆h φ = 1 on Ωh , and 0 ≤ φ ≤ 1/8 on Ω̄h . Set M = kf kL∞ (Ωh ) . Then
∆h (uh + M φ) = ∆h uh + M ≥ 0,
so
1
max uh ≤ max(uh + M φ) ≤ max(uh + M φ) ≤ max g + M.
Ωh Ωh Γh Γh 8
Thus uh is bounded above by the right-hand side of (6.5). A similar argument applies to
−uh giving the theorem.
By applying the stability result to the error u − uh we can bound the error in terms of
the consistency error ∆h u − ∆ u.
2. THE FIVE-POINT DISCRETIZATION OF THE LAPLACIAN 159
Theorem 6.6. Let u be the solution of the Dirichlet problem (6.1) and uh the solution
of the discrete problem (6.4). Then
1
ku − uh kL∞ (Ω̄h ) ≤ k∆ u − ∆h ukL∞ (Ω̄h ) .
8
Proof. Since ∆h uh = f = ∆ u on Ωh , ∆h (u − uh ) = ∆h u − ∆ u. Also, u − uh = 0 on
Γh . Apply Theorem 6.5 (with uh replaced by u − uh ), we obtain the theorem.
If u ∈ C 4 (Ω̄), then
h2
ku − uh kL∞ (Ω̄h ) ≤ M4 ,
48
where M4 = max(k∂ 4 u/∂x4 kL∞ (Ω̄) , k∂ 4 u/∂y 4 kL∞ (Ω̄) ).
Remark. The quantity k∆ u − ∆h uk is the consistency error of the discretization, and
the statement that limh→0 k∆ u − ∆h uk = 0 means that the discretization is consistent. An
estimate of the form kvk ≤ Ch kf k whenever ∆h v = f on Ωh and v = 0 on Γh , is a stability
estimate, and if it holds with Ch independent of h, we say the discretization is stable. The
preceding proof shows that
consistency + stability =⇒ convergence.
(Of course all three concepts are defined with respect to specific norms.)
2.2. Fourier analysis. Define L(Ωh ) to be the set of functions Ωh → R, which is
isomorphic to RM , M = (N − 1)2 . Sometimes we think of these as functions on Ω̄h extended
by zero to Γh . The discrete Laplacian then defines an isomorphism of L(Ωh ) onto itself. The
stability result from the previous section says simply that k∆−1 h k ≤ 1/8 where the operator
∞
norm is with respect to the L norm on L(Ωh ). In this section we use Fourier analysis to
establish a similar stability result for a discrete analogue of the L2 norm.
First consider the one-dimensional case. With h = 1/N let Ih = {h, 2h, . . . , (N − 1)h},
and let L(Ih ) be the space of functions on Ih , which is an N − 1 dimensional vectorspace.
On L(Ih ) we define the inner product
N
X −1
hu, vih = h u(kh)v(kh),
k=1
Define φm ∈ L(Ih ) by φm (x) = sin πmx, x ∈ Ih . It turns out that these mesh functions
are precisely the eigenvectors of the operator Dh2 . Indeed
sin πm(x + h) − 2 sin πmx + sin πm(x − h) 2
Dh2 φm (x) = = (cos πmh − 1) sin πmx.
h2 h2
Thus
2 4 2 πmh
Dh2 φm = −λm φm , λm = (1 − cos πmh) = sin .
h2 h2 2
Note that
4
0 < λ1 < λ2 < · · · < λN −1 < .
h2
Note also that for small m << N , λm ≈ π 2 m2 . In particular λ1 ≈ π 2 . To get a strict lower
bound we note that λ1 = 8 for N = 2 and λ1 increases with N .
Since the operator Dh2 is symmetric with respect to the inner product on L(Ih ), and the
eigenvalues λm are distinct, it follows that the eigenvectors φm are mutually orthogonal. (This
can also be obtained using trigonometric identities, or by expressing the sin functions in terms
of complex exponentials and using the discrete Fourier transform studied in Chapter 1.7.)
Since there are N − 1 of them, they form a basis of L(Ih ).
Theorem 6.8. The functions φm , m = 1, 2, . . . , N − 1 form an orthogonal
PN −1 basis of
L(Ih ). Consequently, any function v ∈ L(Ih ) can be expanded as v = m=1 am φm with
2 2
PN −1 2 2
am = hv, φm ih /kφm kh , and kvkh = m=1 am kφm kh .
From this we obtain immediately a stability result for the one-dimensional Laplacian. If
v ∈ L(Ih ) and Dh2 v = f , we expand v in terms of the φm :
N
X −1 N
X −1
v= am φm , kvk2h = a2m kφm k2h .
m=1 m=1
Then
N
X −1 N
X −1
f =− λm am φm , kf k2h = λ2m a2m kφm k2h ≥ 82 kvk2h .
m=1 m=1
Theorem 6.9. The operator ∆h defines an isomorphism from L(Ωh ) to itself. Moreover
k∆−1
h k≤ 1/16 where the operator norm is with respect to the norm k · kh on L(Ωh ).
Since the kvkh ≤ kvkL∞ (Ωh ) we also have consistency with respect to the discrete 2-norm.
We leave it to the reader to complete the analysis with a convergence result.
2.3. Analysis via an energy estimate. Let v be a mesh function. Define the back-
ward difference operator
v(mh, nh) − v((m − 1)h, nh)
∂x v(mh, nh) = , 1 ≤ m ≤ N, 0 ≤ n ≤ N.
h
In this section we denote
N X
X N
2
hv, wih = h v(mh, nh)w(mh, nh),
m=1 n=1
with the corresponding norm k · kh (this agrees with the notation in the last section for mesh
functions which vanish on Γh ).
Lemma 6.10. If v ∈ L(Ωh ) (the set of mesh functions vanishing on Γh ), then
kvkh ≤ k∂x vkh .
Proof. For 1 ≤ m ≤ N , 0 ≤ n ≤ N ,
N
!2
X
|v(mh, nh)|2 ≤ |v(ih, nh) − v((i − 1)h, nh)|
i=1
N
!2
X
= h |∂x v(ih, nh)|
i=1
N
! N
!
X X
≤ h |∂x v(ih, nh)|2 h 12
i=1 i=1
N
X
=h |∂x v(ih, nh)|2 .
i=1
Therefore
N
X N
X
h |v(mh, nh)|2 ≤ h |∂x v(ih, nh)|2
m=1 i=1
and
N X
X N N X
X N
h2 |v(mh, nh)|2 ≤ h2 |∂x v(ih, nh)|2 .
m=1 n=1 i=1 n=1
162 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
Figure 6.2. The dots are points in Ωh with the elements of Ω̊h being circled.
The triangles are the points of Γh .
be the point (x + sh, y) where 0 < s ≤ 1 is the largest value for which (x + th, y) ∈ Ω for
all 0 ≤ t < s. The points of Γ so constructed (as neighbors to the right or left or above or
below points in Ωh ) constitute Γh . Thus every point in Ωh has four nearest neighbors all of
which belong to Ω̄h := Ωh ∪ Γh . We also define Ω̊h as those points in Ωh all four of whose
neighbor belong to Ωh . See Figure 6.2.
In order to discretize the Poisson equation we need to construct a discrete analogue of
the Laplacian ∆h v for mesh functions v on Ω̄h . Of course on Ω̊h , ∆h v is defined as the
usual 5-point Laplacian. For (x, y) ∈ Ωh \ Ω̊h , let (x + h1 , y), (x, y + h2 ), (x − h3 , y), and
(x, y − h4 ) be the nearest neighbors (with 0 < hi ≤ h), and let v1 , v2 , v3 , and v4 denote
the value of v at these four points. Setting v0 = v(x, y) as well, we will define ∆h v(x, y) as
a linear combination of the five values vi . In order to derive the formula, we first consider
approximating d2 v/dx2 (0) by a linear combination of v(−h− ), v(0), and v(h+ ), for a function
v of one variable. By Taylor’s theorem
α− v(−h− ) + α0 v(0) + α+ v(h+ ) = (α− + α0 + α+ )v(0) + (α+ h+ − α− h− )v 0 (0)
1 1
+ (α+ h2+ + α− h2− )v 00 (0) + (α+ h3+ − α− h3− )v 000 (0) + · · · .
2 6
Thus, to obtain a consistent approximation we must have
1
α− + α0 + α+ = 0, α+ h+ − α− h− = 0, (α+ h2+ + α− h2− ) = 1,
2
which give
2 2 −2
α− = , α+ = , α0 = .
h− (h− + h+ ) h+ (h− + h+ ) h− h+
Note that we have simply recovered the usual divided difference approximation to d2 v/dx2 :
Returning to the 2-dimensional case, and applying the above considerations to both
∂ 2 v/∂x2 and ∂ 2 v/∂y 2 we arrive at the Shortley–Weller formula for ∆h v:
∆h v(x, y)
2 2 2 2 2 2
= v1 + v2 + v3 + v4 − + v0 .
h1 (h1 + h3 ) h2 (h2 + h4 ) h3 (h1 + h3 ) h4 (h2 + h4 ) h1 h3 h2 h4
Using Taylor’s theorem with remainder we easily calculate that for v ∈ C 3 (Ω̄),
2M3
k∆ v − ∆h vkL∞ (Ωh ) ≤ h,
3
where M3 is the maximum of the L∞ norms of the third derivatives of v. Of course at the
mesh points in Ω̊h , the truncation error is actually O(h2 ), but for mesh points neighboring
the boundary, it is reduced to O(h).
The approximate solution to (6.3) is uh : Ω̄h → R determined again by 6.4. This is a
system of linear equations with one unknown for each point of Ωh . In general the matrix
won’t be symmetric, but it maintains other good properties from the case of the square:
• it is sparse, with at most five elements per row
• it has negative diagonal elements and non-negative off-diagonal elements
• it is diagonally dominant.
Using these properties we can obtain the discrete maximum principle with virtually the same
proof as for Theorem 6.3, and then a stability result as in Theorem 6.5 follows as before. In
this way we can easily obtain an O(h) convergence result.
In fact this result can be improved. Although the truncation error k∆ u − ∆h ukL∞ (Ωh )
is only O(h), it is O(h2 ) at all points except those neighboring the boundary, and these
account for only O(h−1 ) of the O(h−2 ) points in Ωh . Moreover these points are within h of
the boundary, where the solution is known exactly. For both of these reasons the contribution
to the error from these points is smaller than is seen from the simple argument outlined in
the previous paragraph. A sharp convergence result was proven by Bramble and Hubbard
in a paper in Numerische Mathematik 4 (1962), pp. 313–327.
Theorem 6.12. Let u be the solution to (6.3) and let uh be the mesh function satisfying
(6.4). Then
M4 d2 2 2M3 3
ku − uh kL∞ (Ω̄h ) ≤ h + h,
96 3
where d is the diameter of the smallest disk containing Ω and Mk = max k∂ k u/∂xi ∂y j k∞ .
i+j=k
Thus the rate of convergence is O(h2 ) as in the case of the square, and the points near
the boundary contribute only a higher order term (despite the fact that the truncation error
is of lower order there).
domain Ω:
(6.6) ∆ u = f in Ω, u = 0 on Γ.
Let’s assume that f is continuous on Ω̄. Now if we multiply the differential equation by a
test function v and integrate over Ω, we get that
Z Z
∆ u v dx = f v dx,
Ω Ω
and conversely, if this equation is satisfied for all integrable functions v, then u satisfies
Poisson’s equation. In fact, it is sufficient that the equation be satisfied for all C ∞ functions
with compact support inside Ω. In particular, if v is a C 1 function on Ω which vanishes on
Γ, we may integrate by parts to get
Z Z
(6.7) grad u · grad v dx = − f v dx.
Ω Ω
2
Thus it is evident that a C function which vanishes on Γ satisfies Poisson’s equation if and
only if it satisfies (6.7) for all C 2 functions v which vanish on Γ. The use of C 2 functions
is, however, not very natural for the formulation (6.7). A more natural space would be the
Sobolev space
H 1 (Ω) = { v ∈ L2 (Ω) | ∇v ∈ L2 (Ω) }.
This is a Hilbert space with inner product
Z
hu, viH 1 (Ω) = (uv + grad u · grad v) dx,
Ω
and corresponding norm
q
kvk1 = kvkH 1 (Ω) := kvk2L2 (Ω) + kgrad vk2L2 (Ω) .
(Note: we are using the same notation L2 (Ω) both for real-valued and vector-valued square
integrable functions.) We also define
H̊ 1 (Ω) = { v ∈ H 1 (Ω) | v|Γ ≡ 0 }.
We then define the weak formulation of the Dirichlet problem for Poisson’s equation to be:
Find u ∈ H̊ 1 (Ω) such that
Z Z
(6.8) grad u · grad v dx = − f v dx for all v ∈ H̊ 1 (Ω).
Ω Ω
The weak formulation fits an abstract framework we shall see frequently. We have a Hilbert
space V (namely H̊ 1 (Ω)), a bilinear form B : V × V → R (given by the left-hand side of
(6.8)), a linear functional F : V → R (given by the right-hand side of (6.8)), and the weak
formulation is
(6.9) Find u ∈ V such that B(u, v) = F (v) for all v ∈ V .
It is clear that if u is a C 2 function satisfying the classical formulation (6.6) of our bound-
ary value problem, then u ∈ H̊ 1 (Ω) and u satisfies the weak formulation (6.8). Conversely, if
u solves the weak formulation, and if u is C 2 , then u is a classical solution to the boundary
value problem. However the classical formulation and the weak formulation are not entirely
166 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
equivalent, because it may happen that there is a solution to the weak formulation which is
not C 2 . It can be shown that a solution to the weak formulation is automatically smooth if
both the forcing function f is smooth and the domain Ω has a smooth boundary, but such
elliptic regularity theorems are not trivial.
Remark. In defining the Sobolev spaces H 1 (Ω) and H̊ 1 (Ω) we have glossed over several
points. In the definition of the former space, we assumed that it is clear what is meant by
grad v when v ∈ L2 (Ω). If the reader is familiar with the theory of distributions, this is no
problem: she then knows that grad v in any case exists as a distribution, which may, or may
not, then belong to L2 . Briefly, given an L2 Rfunction v, a vector-valued L2 function w is
equal to grad v if and only if Ω v div φ dx = − Ω w ·φ dx for all C ∞ vector-valued functions φ
R
with compact support in Ω. A more subtle point is that in defining H̊ 1 (Ω), we have assumed
that it is clear what is meant by v|Γ for v ∈ H 1 (Ω). This is not so evident. For example,
there is certainly no way to make sense of v|Γ for an arbitrary function v ∈ L2 (Ω) (which
is defined only almost everywhere, and may not be defined anywhere on Γ). In fact, it can
be shown that there is a unique bounded map γ : H 1 (Ω) → L2 (Γ) such that γv = v|Γ for
all v ∈ H 1 (Ω) ∪ C ( Ω̄). This is an example of a trace theorem, and requires some effort to
establish. By v|Γ we simply mean γv, for any v ∈ H 1 (Ω).
The weak formulation is in many ways a very natural formulation of the Dirichlet problem
for Poisson’s equation. One indication of this is that it is quite simple to establish existence
and uniqueness of weak solutions. One first establishes Poincaré’s inequality, which states
that there exists a constant c depending only on the domain Ω such that kukL2 (Ω) ≤ ckukH 1 (Ω)
for all u ∈ H̊ 1 (Ω). This is fairly elementary; a good exercise is to prove it in the one-
dimensional case where Ω is a bounded p interval (what is the best constant c?). It 1follows
1
that on the space H̊ (Ω), the quantity kgrad ukL2 is a norm equivalent to the full H norm,
and hence the left-hand side of (6.8) defines an inner product on H̊ 1 (Ω) which is equivalent
to the H 1 inner product. Existence and uniqueness of a weak solution is then an immediate
consequence of the Riesz representation theorem.
Remark. Besides the weak formulation of the boundary value problem (6.6), there is
a closely related variational formulation. In this we seek u ∈ H̊ 1 (Ω) which minimizes the
energy functional
Z Z
1 2
E(w) := | grad w| dx + f w dx
2 Ω Ω
over w ∈ H̊ 1 (Ω). If u is the solution of the weak formulation and w ∈ H̊ 1 (Ω) with w 6= u
but otherwise arbitrary, we may write w = u + v, with 0 6= v ∈ H̊ 1 (Ω), and then
Z Z Z Z Z
1 2 1 2
E(w) = | grad u| dx + grad u · grad v dx + | grad v| dx + f u dx + f v dx
2 Ω Ω 2 Ω Ω Ω
Z Z Z
1
= E(u) + grad u · grad v dx + f v dx + | grad v|2 dx.
Ω Ω 2 Ω
The term in brackets vanishes since u is the weak solution, and the final term is positive if
v 6= 0. Thus E(u) < E(w), and u is indeed the minimizer. Conversely, if u minimizes E over
3. FINITE ELEMENT METHODS 167
t2
Z Z Z
G(t) = E(u + tv) = E(u) + t grad u · grad v dx + f v dx + | grad v|2 dx,
Ω Ω 2 Ω
has its minimum at t = 0, and this immediately shows that u is a weak solution. Thus the
notion of a weak solution and a variational solution (a minimizer of the energy functional)
are equivalent for this problem. For problems which are not symmetric however (e.g., if the
PDE were ∆ u + ∂u/∂x = f ), there is no natural variational formulation, while the weak
formulation still applies.
3.2. Galerkin’s method. In the weak formulation, we seek a function in the trial space
H̊ (Ω) which satisfies the weak equation (6.8) for all v in the test space H̊ 1 (Ω). In Galerkin’s
1
method we choose a finite dimensional space Sh ⊂ H̊ 1 (Ω), and use it in place of H̊ 1 (Ω) as
trial and test space. That is, we seek uh ∈ Sh satisfying the discrete weak formulation
Z Z
grad uh · grad v dx = − f v dx for all v ∈ Sh .
Ω Ω
Let us show that such a function uh exists and is unique. Let {φ1 , . . . , φN } be any basis of
Sh . Then we are seeking uh = N
P
j=1 αj φj such that
Z Z
grad uh · grad φi dx = − f φi dx, i = 1, . . . , N.
Ω Ω
(By linearity, it is enough that the weak equation hold for each basis function.) This means
that
XN Z Z
αj grad φj · grad φi dx = − f φi dx.
j=1 Ω Ω
As a consequence we see that with the hat function basis, the stiffness matrix is very sparse
(there will be only a few nonzero entries per row, and this number will not increase when we
refine the mesh, as long as we don’t allow the triangle angles to decrease). Also the stiffness
matrix entries which are nonzero are nonetheless easily computed: they are sums of integrals
3. FINITE ELEMENT METHODS 169
of polynomials over only a few triangles (in fact, except for the diagonal entries of the stiffness
matrix, over two triangles). This adds greatly to the efficiency of the implementation of the
Galerkin method.
We may now roughly define the finite element method: it is Galerkin’s method using a
piecewise polynomial trial space with a local basis.
Let us now work out a simple example. We take Ω to be the unit square with a uniform
mesh. Namely we divide Ω into n × n subsquares of size h = 1/n and divide each of these
into two triangles using the positively sloped diagonal. See Figure 6.3.
Now if φ is a linear function, then ∂φ/∂x is constant, and we can find it by evaluating φ
at any two distinct points on a horizontal line, and taking a difference quotient. Since each
of our triangles has a horizontal and a vertical edge, and since we know the values of the
hat basis functions at the vertices, we can easily compute the partial derivatives of the basis
functions. These are shown in the following figure.
0
-1/h
1/h -1/h -1/h 0
It is then easy to compute the stiffness matrix. Writing φij for the basis function associ-
ated to the vertex xij = (ih, jh), we find
Z 4,
i = k, j = l,
grad φij · grad φkl dx = −1, i = k ± 1, j = l or i = k, j = l ± 1,
0, else.
In other words, the stiffness matrix for piecewise linear finite elements for the Laplace opera-
tor on the unit square using a uniform mesh is exactly the matrix of the five-point Laplacian.
If we set
Z
˜ 1
fij := 2 f φij .
h
P
and write the finite element solution as uh = i,j Uij φij , we have
From this fact and our earlier analysis of the five-point Laplacian, it is easy to derive
an O(h2 ) convergence estimate at the vertices. In fact, as we shall see, one of the great
strengths of the finite element method is that there is a very natural approach to the error
analysis (which does not involve relating it to finite difference methods). The most natural
estimates are obtained in H 1 (Ω) and L2 (Ω) (error estimates in L∞ (Ω) can also be obtained,
but are more complicated). Below we shall prove, in more general circumstances, that if the
solution u ∈ H 2 (Ω), then
ku − uh kH 1 (Ω) ≤ ChkukH 2 (Ω) , ku − uh kL2 (Ω) ≤ Ch2 kukH 2 (Ω) ,
for some constant C. Note that unlike our finite difference estimates the norms are norms of
functions on Ω, not just at the mesh vertices. Note also that we only require that u ∈ H 2 ,
not even C 2 , to obtain O(h2 ) convergence. By contrast in the finite difference case we needed
u ∈ C 4 . For example, if the function f is merely in L2 , then it may not even be defined at
the mesh points, and the standard finite difference method is not meaningful, while the finite
element method is applicable and will still deliver second order convergence in this case.
Most important, the same error estimates hold on a quite arbitrary domain with an
arbitrary triangulation. In this case h is to be interpreted as the diameter of the largest
triangle in the triangulation. The constant C in the estimates will depend on the domain,
but not on the triangulation (except that we will need to enforce a bound on the smallest
angle of a triangle). The derivation of such error estimates will be discussed later. The point
to note now is the power and flexibility of the finite element method in providing second
order convergent schemes on unstructured meshes. If we were to try to derive such schemes
directly, e.g., by Taylor expansions, it would be very messy indeed.
3.4. Application to more general problems. Another great strength of finite ele-
ment methods is the ease with which they can be adapted to a wide variety of problems.
3. FINITE ELEMENT METHODS 171
3.4.1. More general elliptic PDEs. For example, suppose we replace Poisson’s equation
∆ u = f with a more general second order PDE
2 X 2
X ∂ ∂u ∂u
aij + bi + cu = f.
i,j=1
∂x i ∂x j i=1
∂x i
Here the coefficients aij , bi , and c may be functions of x. Once again, we may multiply by a
test function v ∈ H̊ 1 (Ω) and integrate over Ω by parts to obtain a weak formulation of the
Dirichlet problem in the form (6.9). The only difference is that now
Z X
∂u ∂v X ∂u
B(u, v) = aij − bi v − cuv dx.
Ω i,j ∂xj ∂xi i
∂xi
Restricting the trial and test functions to Sh , we obtain a finite element method as before.
If the PDE is elliptic, which means that the matrix aij (x) is symmetric positive-definite,
uniformly in x, then the behavior of the finite element method for this problem will be very
similar to that for the Poisson problem. Thus the finite element method is well able to
handle variable coefficients, anisotropic equations, and lower order terms.
We can even allow the coefficients to depend on the solution u, and so have a nonlinear
PDE. In that case the form B(u, v) will be linear in v but nonlinear in u. Again the finite
element method can be applied, although of course the resulting system of algebraic equations
will be nonlinear.
3.4.2. Neumann boundary conditions. Yet another great strength of finite element meth-
ods is their flexibility in handling different boundary conditions (which can be very tricky
for finite difference methods). Consider for example Poisson’s equation on a polygon but
suppose that some sides are subject to the Dirichlet boundary condition u = 0 and some to
the Neumann boundary condition, so the problem is to find u satisfying
∂u
∆ u = f in Ω, u = 0 on ΓD , = 0 on ΓN ,
∂n
where ΓD and ΓN are disjoint open subsets of Γ such that Γ = Γ̄D ∪ Γ̄N . The first thing you
might think to do is to seek u in a subspace of H 1 (Ω) satisfying both boundary conditions,
i.e., in
{ v ∈ H 1 (Ω) | v|ΓD ≡ 0, ∂v/∂n|ΓN ≡ 0 }.
However, this does not work, because there is no way to define ∂v/∂n for v ∈ H 1 . Such a
function has a well defined restriction to Γ (or ΓD ) but its first derivatives, which are merely
L2 functions, do not. To see our way around this problem, let us multiply Poisson’s equation
by a smooth test function v and integrate over Ω.
Green’s formula for integration by parts shows us the way around this difficulty. For any
smooth u and v we have
Z Z Z
∂u
grad u · grad v dx = − ∆ u v dx + v ds.
Ω Ω Γ ∂n
If u satisfies Poisson’s equation, then
Z Z
∆ u v dx = f v dx,
Ω Ω
172 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
Define
1
HD (Ω) = { v ∈ H 1 (Ω) | v|ΓD ≡ 0 }.
Note that in this space the Dirichlet boundary condition has been imposed, but the Neumann
boundary condition has been ignored (since there is no way to make sense of it in H 1 ). This
leads us to the weak formulation for the mixed Dirichlet/Neumann boundary value problem:
1
Find u ∈ HD (Ω) such that
Z Z
1
grad u · grad v dx = − f v dx for all v ∈ HD (Ω).
Ω Ω
Just as for the pure Dirichlet problem, as an easy consequence of the Riesz representation
theorem and the Poincaré inequality, this problem has a unique solution.
In deriving the weak formulation, we have shown that if u is a classical solution to the
boundary value problem then it satisfies this weak formulation. Conversely, if u solves the
weakly formulated problem, and u is C 2 , then we can integrate by parts to find that
Z Z Z
∂u 1
− ∆ u v dx + v ds = − f v dx for all v ∈ HD (Ω).
Ω Γ ∂n Ω
Taking first v to be smooth and compactly supported in Ω, we conclude that ∆ u = f in Ω.
Therefore
Z
∂u
v ds = 0
Γ ∂n
1
for all v ∈ HD (Ω). Since such a function can be arbitrary on ΓN , we conclude that ∂u/∂n = 0
on ΓN .
To summarize: the weak formulation for the mixed Dirichlet/Neumann boundary value
problem has a unique solution. This coincides with the classical solution whenever it is C 2
and whenever a classical solution exists. Note that the Dirichlet and Neumann boundary
conditions are treated completely differently in the weak formulation. The Dirichlet condition
is imposed a priori by building it into the trial space. The Neumann condition is not built
into the trial space, but arises as a consequence of the weak formulation. The terminology
used for this is that the Dirichlet condition is an essential boundary condition, while the
Neumann condition is natural.
Once we have the weak formulation we can use Galerkin’s method with any subspace
1
Sh of HD (Ω). This leads to a symmetric positive definite matrix problem. As long as we
arrange that each triangle edge in the boundary belongs entirely to either ΓD or ΓN we can
easily construct a piecewise linear finite element space:
1
M0D (Th ) = M01 (Th ) ∩ HD
1
(Ω).
A local basis is given by the hat functions at all the triangulation vertices except those
belonging to Γ̄D .
We didn’t consider the case of pure Neumann conditions because the boundary value
problem ∆ u = f in Ω, ∂u/∂n = 0 on Γ is not well-posed. Green’s theorem implies that
3. FINITE ELEMENT METHODS 173
R
there is no solution unless Ω f = 0, and if there is a solution, we can add any constant to it
to get another solution. If we consider instead the differential equation − ∆ u + u = f , or,
more generally, − div(A grad u) + cu = f where A is a symmetric positive definite matrix
and c > 0, this problem goes away and the considerations above apply equally well to the
pure Neumann problem (ΓN = Γ, ΓD = ∅).
3.4.3. Inhomogeneous boundary conditions. Thus far we have considered homogeneous
Dirichlet and Neumann boundary conditions. Now we discuss inhomogeneous boundary
conditions. Natural boundary conditions are straightforward. If ∂u/∂n = g on ΓN , then for
1
any test function v ∈ HD (Ω),
Z Z
∂u
v ds = gv ds,
Γ ∂n ΓN
1
and so the weak formulation becomes: Find u ∈ HD (Ω) such that
Z Z Z
1
grad u · grad v dx = − f v dx + gv ds for all v ∈ HD (Ω).
Ω Ω ΓN
This is again of the form B(u, v) = F (v), where now F (v) contains an extra term arising
from the Neumann data.
Essential boundary conditions need to be built into the trial space. That is, if the
boundary condition is u = g on Γ (for simplicity suppose ΓN = ∅), we seek
u ∈ Hg1 (Ω) := { v ∈ H 1 (Ω) | v|Γ ≡ g }.
The weak equations are still
Z Z
1
grad u · grad v dx = − f v dx for all v ∈ HD (Ω),
Ω Ω
that is, the test space remains homogeneous. To see that there is still a unique solution,
choose any function ug ∈ H 1 (Ω) such that ug |Γ = g. Then
Hg1 (Ω) = { ug + v | v ∈ H̊ 1 (Ω) },
and the weak equations are satisfied by u = ug + u0 if and only if u0 ∈ H̊ 1 (Ω) and
B(u0 , v) = F (v) − B(ug , v) for all v ∈ H̊ 1 (Ω).
For the finite element solution we thus can again use M̊01 (Th ) as test space, but we cannot
use as trial space M01 (Th ) ∩ Hg1 (Ω), since, unless g happens to be piecewise linear, this space
is empty. Instead we use M01 (Th ) ∩ Hḡ1 (Ω) where ḡ is some piecewise linear approximation to
g (with respect to the partition of Γ into edges of triangles of Th ), e.g., its piecewise linear
interpolant, or L2 (Γ)-projection.
3.4.4. Robin boundary conditions. As another example, we consider Poisson’s problem
with Robin boundary conditions, which model Newton’s law of cooling at the boundary (heat
flow through the boundary is proportional to the difference between the body’s temperature
and the outside temperature). This gives the boundary condition
∂u
= α(g − u)
∂n
174 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
where g is the outside temperature and α is a positive constant (positive since heat flow out
of the domain is positively proportional to −∂u/∂n and heat should flow out if u exceeds g.
Replacing g with αg we come to a boundary value problem like
∂u
∆ u = f in Ω, + αu = g on Γ.
∂n
Since the boundary condition involves first derivatives, it cannot be imposed in H 1 (Ω).
Therefore the Robin boundary condition will prove to be a natural boundary condition. To
find the correct weak formulation, we multiply by a test function and integrate by parts to
obtain
Z Z Z
∂u
grad u · grad v dx − v dx = − f v dx.
Ω Γ ∂n Ω
Using the boundary condition we can rewrite this is as
Z Z Z Z
grad u · grad v dx + αuv dx = − f v dx + gv dx.
Ω Γ Ω Γ
The weak formulation is thus again of the form: Find u ∈ V such that B(u, v) = F (v) for
all v ∈ V , where V = H 1 (Ω), as for the pure Neumann problem, but now
Z Z Z Z
B(u, v) = grad u · grad v dx + αuv dx, F (v) = − f v dx + gv dx.
Ω Γ Ω Γ
In view of the Poincaré inequality, B is again a bounded symmetric bilinear form on H 1 ×H 1
and F is a bounded linear form. Moreover B(u, u) ≥ kgrad uk2L2 , and B(u, u) = 0 only if
u ≡ 0 (since for such u, grad u = 0 and u = 0 on Γ). From this it follows (by a small argument
which we omit) that B is equivalent to the usual inner product in H 1 (Ω). Thus Robin
boundary conditions can be incorporated easily into the weak formulation, and therefore
into a finite element discretization.
3.4.5. Curved boundaries. Finally we consider, briefly, the case where Ω has a curved
rather than polygonal boundary. This doesn’t affect the weak formulation, but the design
of finite element subspaces of H 1 (Ω) or HD 1
(Ω) or H̊ 1 (Ω) is non-trivial and has engendered
many algorithms, codes, and papers. By now curved boundaries are handled routinely in
the finite element method, but they do require additional effort.
In the case of natural boundary conditions, there is one obvious possibilitity. We may
triangulate a curved domain using ordinary triangles except for a layer of triangles containing
one curved edge near the boundary. See the figure.
We may then specify a space of piecewise linear functions as before, by determining a
function on each triangle, straight or curved, by giving its vertex values. The only difficulty
with this approach is that it may not be straightforward to compute the necessary integrals
in the stiffness matrix.
In the case of Dirichlet boundary conditions there is a considerable additional difficulty.
Suppose we have a curvilinear triangle with two vertices on the boundary connected by a
curve e contained in the boundary. A linear function on the triangle which vanishes at the
two vertices will vanish on the entire straight line connecting them, not on the curve e. One
way to surmount this problem is not to face it. Instead, simply replace the original domain
Ω with a polygonal domain Ωh obtained by interpolating the vertices on the boundary
by a polygonal curve. This of course introduces an additional source of error. In fairly
3. FINITE ELEMENT METHODS 175
Figure 6.5. A portion of a triangulation using curvilinear triangles near the boundary.
general circumstances it can be shown that this new error doesn’t degrade the accuracy
of finite element methods based on piecewise linear finite elements, but it does degrade
the accuracy of higher order finite elements such as will be discussed below. This can be
overcome by simultaneously using higher order polynomial interpolation to the boundary,
e.g., approximating the curved edges of triangles by parabolic curves when using quadratic
finite elements. Yet another possibility is not to use polynomials trial functions at all on the
curved triangles. Instead one can construct a smooth mapping of a straight-edged reference
triangle onto a curvilinear triangles and use polynomial functions on the reference triangle.
The trial functions used on the curvilinear triangle are then the composition of the inverse
mapping to the reference triangle and polynomials on the reference triangle. A strategy
which turns out to be relatively easy to implement and to maintain good accuracy is to use
a polynomial map from the reference polynomial to the true polynomial using polynomials
as the same degree as the trial functions on the reference triangle. This scheme is known as
isoparametric finite elements.
3.5. Other finite element spaces. We have thus seen many examples of boundary
value problems for which the trial and test spaces are H 1 (Ω) or a subspace of it incorporating
essential boundary conditions. For subspaces we have only considered piecewise linear finite
elements. One may also use piecewise polynomials of higher degree, and this turns out to
give finite element methods with higher rates of convergence.
We begin in one dimension: Ω = (0, 1), Th = {I1 , . . . , In }, with In = [xn−1 , xn ], 0 = x0 <
x1 < · · · < xN = 1. In this case we studied the piecewise polynomial spaces M0p (Th ) for
any degree p > 0 in Chapter 1. We may use as a set of degrees of freedom the value of the
function at the nodes xn and at p − 1 points placed inside each element. This leads us to a
local basis. Typical basis elements for p = 2 are shown in Figure 6.6.
In 2 dimensions we can construct higher degree finite element spaces in a similar manner.
If T is a triangle, we can uniquely specify a quadratic function on T by giving its value at
the three vertices and the three edge midpoints. See Figure 6.7. (Proof: since there are six
coefficients and six degrees of freedom it suffices to show that a quadratic vanishing at these
six points is identically zero. Since it vanishes at three points on each edge, it must vanish
on each edge. If the ith edge is given by li = 0 where li is a linear polynomial, then the
quadratic must be divisible by l1 l2 l3 , which implies that it must be zero.)
176 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
Figure 6.6. Some local basis functions for piecewise quadratic functions us-
ing a uniform partition of the unit interval into 10 equal elements. On the
axis, vertical lines indicate element boundaries; circles indicate nodes.
1.5
0.5
−0.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Now suppose we specify a piecewise quadratic function by giving values at all the nodes,
that is, the vertices and edge midpoints of the triangulation. If two triangles share a com-
mon edge, the two quadratic polynomials on the edge obtained by restricting the quadratic
polynomials on each of the two triangles to the edge will agree at three points on the edge.
Since a quadratic funtion on a line is determined by its value at three points, the restrictions
will agree. Thus the piecewise quadratic will be continuous. This shows that the values at
the nodes do indeed form a set of degrees of freedom for the space M02 (Th ) of continuous
piecewise quadratics with respect to the triangulation Th . The dimension of this space is
thus the sum of the number of vertices and the number of edges, and we have a local basis.
Similar considerations apply to higher degree elements. The figure shows the nodal
configuration for continuous piecewise cubics and quartics.
3.6. Finite element approximation theory. We have seen that for many 2nd order
elliptic boundary value problems, the weak formulation is of the form:
Find u ∈ V such that
B(u, v) = F (v) for all v ∈ V ,
where V is some closed subspace of H 1 (Ω) incorporating essential boundary conditions,
B : V × V → R is a bounded bilinear, and F : V → R is a bounded linear form. In addition
to the boundedness,
|B(v, w)| ≤ Ckvk1 kwk1 , v, w ∈ V,
for some constant C, we shall also assume coercivity in the sense that
B(v, v) ≥ γkvk21 , v ∈ V,
where γ is a positive constant. (This assumption is satisfied in many cases, although it can
be weakened in various ways. If B is also symmetric—which we don’t assume—then the
boundedness and coercivity together mean that B gives an inner product equivalent to the
usual one.) The Galerkin solution is defined as uh ∈ Sh such that
B(uh , v) = F (v) for all v ∈ Sh .
We then have B(uh , v) = B(u, v) for all v ∈ Sh , so if χ is an arbitrary element of Sh ,
B(uh − χ, v) = B(u − χ, v) for all v ∈ Sh . Choosing v = uh − χ and using the coercivity and
boundedness, we get
γkuh − χk21 ≤ B(uh − χ, uh − χ)
= B(u − χ, uh − χ)
≤ Cku − χk1 kuh − χk1 .
Thus kuh − χk1 ≤ (C/γ)ku − χk1 , and kuh − uk1 ≤ (1 + C/γ)ku − χk1 . Since χ ∈ Sh is
arbitrary, this gives
(6.10) ku − uh k1 ≤ c inf ku − χk1 ,
χ∈Sh
where c = 1 + C/γ. This says that when measured in H 1 , the error in the Galerkin ap-
proximation is no worse than a constant factor times the error in the best approximation
to u from Sh (with the constant independent of the particular solution u and the particular
subspace Sh ). This property of the finite element solution is called quasioptimality.
The fundamental quasioptimality result (6.10) reduces the error in a Galerkin approxi-
mation to a question of approximation theory. We studied this question in some detail in
Chapter 1.6.2. There we obtained the following theorem.
Theorem 6.13. Let there be given a family of triangulations {Th } of a polygonal domain
Ω and let h = maxT ∈Th diam(T ). Let r be a positive integer. For each h let Πh : C(Ω) →
M0r (Th ) denote the nodal interpolant. Then there is a constant c such that
ku − Πh ukL∞ (Ω) ≤ chr+1 ku(r+1) kL∞ (Ω) for all u ∈ C r+1 (Ω̄),
ku − Πh ukL2 (Ω) ≤ chr+1 ku(r+1) kL2 (Ω) for all u ∈ H r+1 (Ω).
178 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
If, moreover, the family of triangulations is shape regular, then there is a constant C such
that
kgrad(u − Πh u)kL∞ (Ω) ≤ Chr ku(r+1) kL∞ (Ω) for all u ∈ C r+1 (Ω̄),
kgrad(u − Πh u)kL2 (Ω) ≤ Chr ku(r+1) kL2 (Ω) for all u ∈ H r+1 (Ω).
3.7. Error estimates. The combination of the quasioptimality estimate (6.10) and the
bounds on interpolation error of the last subsection immediately gives an H 1 error estimate
for the finite element method using piecewise linear elements:
ku − uh k1 ≤ ChkD2 ukL2 (Ω) ,
or simply
ku − uh k1 ≤ Chkuk2 ,
where the norm on the right-hand side is the Sobolev 2 norm. For elements of degree r the
analogous result is
ku − uh k1 ≤ Chr kukr+1 .
In these estimates the constant C doesn’t grow as h tends to zero as long as the meshes
remain shape regular.
Thus the error in the finite element method with piecewise linear elements converges to
0 with order h in H 1 (Ω) as the mesh is refined. Since the method is closely related to the
five point Laplacian when applied to Poisson’s equation with a uniform mesh on the square,
we might expect convergence with order h2 . In fact we can obtain such a result by looking
at the rate of convergence in L2 rather than H 1 .
To be definite, let us consider the Dirichlet problem for Laplace’s equation, so that the
bilinear form is
Z
B(u, v) = grad u · grad v dx,
Ω
This is nothing other than the weak formulation of the boundary value problem
− ∆ φ = u − uh in Ω, φ = 0 on Γ,
that is the Dirichlet problem for Poisson’s equation where the error u − uh is taken as the
forcing term. At this point we have to invoke an elliptic regularity theorem. Namely if the
domain Ω is convex, then it is known that the solution φ to the boundary value problem
belongs to H 2 (Ω) and there exists a constant c such that kφk2 ≤ cku − uh k0 ; that is, the
Sobolev 2-norm of the solution is bounded by the L2 norm of the forcing term. (The same
result holds when the boundary of Ω is smooth, but not in general if Ω is a non-convex
polygon.)
4. DIFFERENCE METHODS FOR THE HEAT EQUATION 179
where we have used the H 1 error estimate for interpolation and the elliptic regularity result,
and where we are using the same letter C for various constants. Combining these estimates
we have shown that
ku − uh k0 ≤ Chku − uh k1 ,
that is, we pick up an additional power of h in passing from the H 1 to the L2 norm of the
error. Thus
ku − uh k0 ≤ Ch2 kuk2
for piecewise linear finite elements. Similarly,
ku − uh k0 ≤ Chr+1 kukr+1
for finite elements of degree r.
Remarks. 1. The bound on the L2 norm of the error preceded by writing the norm
squared in the form B(u − uh , φ) for an auxiliary function φ defined by a boundary value
and then using the Galerkin equation. This approach is known as the Aubin-Nitsche duality
argument or sometimes just “Nitsche’s trick.” The same idea can be used to obtain a variety
of different estimates for a variety of different Galerkin methods. 2. The duality argument
requires H 2 elliptic regularity, which in turn requires that the polygonal domain be convex.
In fact, for a non-convex polygonal domain, it will usually not be true that ku−uh k0 = O(h2 )
even if the solution u is smooth.
Let us suppose that Ω is the unit square in R2 . Then we have a simple discretization of
the Laplacian, namely the 5-point Laplacian ∆h (mapping functions on Ω̄h to functions on
Ωh . Thus we seek a function uh : Ω̄h × [0, T ] satisfying
∂uh
= c ∆h uh + f for x ∈ Ωh , t ∈ [0, T ],
∂t
uh = 0 for x ∈ Γh , t ∈ [0, T ],
uh = u0 for x ∈ Ωh , t = 0.
Since at any time t, uh is just the finite collection of numbers uh (ih, jh, t), we may view the
above problem as the initial value problem for a system of (N − 1)2 ordinary differential
equations. The process of reducing the evolutionary PDE to a system of ODEs by using
a finite difference approximation of the spatial operator is called semi-discretization or the
method of lines. This is not a full discretization, since we still have to chose a numerical
method to solve the ODEs. In principal, any of the methods we studied in Chapter 5 could
be used to obtain a full discretization. We shall investigate some of the simplest possibilities.
First we consider the forward Euler method. For simplicity, let us drop down to one
space dimension, so Ω = (0, 1). This is mainly a notational convenience; the analysis in 2D
is very similar. Let the spatial mesh size be denoted h = 1/N , and the time step k = T /M ,
and write Unj = uh (nh, jk). Then the fully discrete system is
j j
Unj+1 − Unj Un+1 − 2Unj + Un−1
(6.15) =c + fnj , 0 < n < N, j = 0, 1, . . . M − 1,
k h2
(6.16) U0j = UNj = 0, j = 0, 1, . . . , M,
(6.17) Un0 = u0 (nh), 0 < n < N.
We call this the centered difference/forward difference method for the heat equation. Since
the Euler method is explicit, we don’t have to solve any linear equations to get from (Unj )n
to (Unj+1 )n . Indeed,
j j
(6.18) Unj+1 = (1 − 2λ)Unj + λUn+1 + λUn−1 + kfnj , 0 < n < N, j = 0, 1, . . . , M − 1,
where λ = ck/h2 .
Figure 6.9 shows the result of this method applied with c = 1, h = 1/20, and k = 1/1200
for the first plot, k = 1/600 for the second. We take 40 time-steps in the first plot, 20 in the
second, and so reach T = 1/30 in each case. The initial data was taken, rather arbitrarily, to
be u0 (x) = (x − x2 )(x2 + sin 2πx), and the forcing function f was taken to be zero. We see
that the first computation gives very reasonable results (and we could have extended it for
a much longer time without problem), while the second computation becomes unreasonable
after a few time steps. In fact further experimentation shows that this is controlled by the
size of the time step in relation to the spatial mesh size. If λ ≤ 1/2 (i.e., k ≤ h2 /(2c)), the
computation proceeds reasonably, while if λ > 1/2 the computed solution becomes oscillatory
with an exponentially increasing amplitude.
To analyze the situation, consider first the truncation error
j j
uj+1 − ujn u − 2ujn + un−1
τnj = n
− c n+1 − fnj ,
k h2
4. DIFFERENCE METHODS FOR THE HEAT EQUATION 181
Figure 6.9. The heat equation discretized using central differences and for-
ward Euler, with two different time steps (k = h2 /3 on the left, k = 2h2 /3 on
the right). The top plots show the results at all time steps; the bottom figures
only at the final time.
0.25 1
0.2
0.15
0.5
0.1
u
u
0.05
0
0
−0.05
−0.1 −0.5
1 1
0.8 0.035 0.8 0.035
0.6 0.03 0.6 0.03
0.025 0.025
0.4 0.02 0.4 0.02
0.015 0.015
0.2 0.01 0.2 0.01
0.005 0.005
0 0 0 0
x x
t t
0.08 2
0.07
1.5
0.06
1
0.05
0.5
0.04
0.03
0
0.02
−0.5
0.01
−1
0
−0.01 −1.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
If we let E j = maxn |ejn | denote the maximum norm of the error at the jth time step, we get
E j+1 ≤ E j + kτ
where τ = maxn,j |τnj |. It follows that
(6.20) E j ≤ E 0 + jkτ = jkτ
for all j. Since we only integrate up to a fixed time T , jk ≤ T , we have maxn,j |ejn | ≤
T τ ≤ C(k + h2 ). Since k ≤ h2 /(2c), the error is O(h2 ). In particular, we have established
182 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
This is a stability result: it says that the linear map which takes the initial data to the
fully discrete solution is bounded if the data is measured in the discrete max norm over the
interval and the solution in the discrete space-time max norm, and the bound (which is 1)
does not blow-up as the mesh size is decreased. In view of our past experience, we should not
be suprised that a method which is stable and consistent (in the sense that the truncation
error tends to zero with mesh size), is convergent.
Another very useful way to analyze stability and convergence is to use Fourier analysis,
as we did for 5-point Laplacian earlier in this chapter. To get the idea, first recall how the
continuous problem (6.12)–(6.14) may be solved in terms of Fourier series. We expand the
solution at any given time a Fourier sine series (we only use sines, and not cosines, in view
of the Dirichlet boundary conditions):
∞
X
u(x, t) = am (t) sin mπx, x ∈ I.
m=1
Assume, for simplicity, that the forcing function f vanishes, and substitute the expansion
into the differential equation to get
∞
X ∞
X
a0m (t) sin mπx = −c am (t)m2 π 2 sin mπx,
m=1 m=1
The values am (0) can be determined from the Fourier sine expansion of the initial data:
∞
X
u0 (x) = am (0) sin mπx, x ∈ I.
m=1
Thus we see that all the modes that are present in the initial data are damped exponentially
with increasing time, with the higher frequency modes being damped most quickly. For this
reason heat evolution is a smoothing process.
Now let us do the same thing for the semi-discrete problem. Recall the notations we
used to introduce the discrete Fourier sine bases. With Ih = { nh | 0 ≤ n ≤ N } and
I¯h = Ih ∪ {0, 1}, we let L(Ih ) denote the set of real-valued functions on Ih which may
be viewed as functions on I¯h by extension by zero. On L(Ih ) we use the inner product
P −1
hu, vih = h N k=1 u(kh)v(kh), and the orthogonal basis {φm | m = 1, . . . , N − 1 } given by
4. DIFFERENCE METHODS FOR THE HEAT EQUATION 183
φm (x) = sin πmx, x ∈ I¯h . These are eigenvalues of the 1D discrete Laplacian Dh2 :
4 πmh
Dh2 φm = −λm φm , λm = 2 sin2 .
h 2
The eigenvalues satisfy
4
8 ≤ λ1 < λ2 < · · · < λN −1 < 2 .
h
Proceeding as for the continuous solution, at any time t we write the semi-discrete solution
PN −1
uh (t, · ) = m=1 ahm (t)φm . Then
N −1 N −1
∂uh X dahm X
= φm , Dh2 uh =− ahm λm φm .
∂t m=1
dt m=1
Thus the semi-discrete equations give
dahm
= −cλm ahm so ahm (t) = ahm (0)e−cλm t ,
dt
h
where the numbers am (0) are the coefficients in the discrete Fourier sine transform of the
initial data:
N
X −1
u0 (x) = ahm (0) sin πmx, x ∈ I¯h .
m=1
Thus the solution of the semi-discrete system may be written as
N
X −1
uh (x, t) = ahm (0)e−cλm t sin πmx, x ∈ I¯h .
m=1
Again all the modes that are present in the discretized initial data are damped exponentially
with increasing time.
Finally, consider the fully discrete centered difference/forward difference method. Let U j
be the solution at time t = jk (i.e., U j (nh) = Unj ). Write
N
X −1
j
U (x) = Ajm φm (x).
m=1
The difference equations then give
N
X −1 N
X −1 N
X −1
Aj+1
m φm = Ajm φm − ck Ajm λm φm i.e., Aj+1 j
m = (1 − ckλm )Am .
m=1 m=1 m=1
It follows that
N
X −1
Ajm = (1 − ckλm )j ahm (0), Uj = (1 − ckλm )j ahm (0)φm .
m=1
Now λm ≤ 4/h for all m, so ckλm ≤ 4ck/h , and so, if we assume that ck/h2 ≤ 1/2, we
2 2
get ckλm ≤ 2 and |1 − ckλm | ≤ 1 for all m. Thus in this case (or at least if strict inequality
holds), we qualitative behavior of the continuous solution, that all modes of the initial data
are damped, is also present in the discrete case as well. On the other hand, if ck/h2 > 1/2,
184 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
then for h sufficiently small we will have |1 − ckλm | > 1 for larger values of m, and this
means that high frequency components of the initial data will increase exponentially with
increasing time step. This explains the behavior we saw earlier.
The same ideas can be used to establish a rigorous stability result. Suppose that Unj satsi-
fies the fully discrete centered difference/forward difference equations (6.15)–(6.17). Writing
U j , f j for the restrictions of U and f to t = jk, we have
Now I + ckDh2 is a symmetric operator on L(Ih ), so its operator norm with respect to
the discrete L2 norm on L(Ih ) is simply the magnitude of its largest eigenvalue. Now the
eigenvectors of the operator I + ckDh2 are again the φm , with corresponding eigenvalues
1 − ckλm . If ck/h2 ≤ 1/2, then maxm |1 − ckλm | ≤ 1, and hence k(I + ckDh2 )vkh ≤ kvkh for
any v ∈ L(Ih ). Thus from (6.21), we get
kU j+1 kh ≤ kU j kh + kkf j k, j = 0, 1, . . . , M − 1.
Thus, under the hypothesis ck/h2 ≤ 1/2 we have show that the fully discrete solution is
bounded (in the norm displayed on the left-hand side of (6.22) by an appropriate norm on
the data U 0 and f , with constants that don’t depend on h and k. Because of the condition
ck/h2 ≤ 1/2, which we know is not only sufficient but necessary for stability, the centered
difference/forward difference method is called conditionally stable.
Once we have stability, we obtain a convergence result in the same way as we did earlier
for the 5-point Laplacian. For the error ejn = Unj − ujn we have
j j
ej+1 − ejn e − 2ejn + en−1
n
= c n+1 − τnj , 0 < n < N, j = 0, 1, . . . M − 1,
k h2
ej0 = ejN = 0, j = 0, 1, . . . , M,
e0n = 0, 0 < n < N,
where τnj is the local truncation error. It follows from the stability result that
Of course
We did not have to make any assumption on the relation between k and h to obtain this result:
the centered difference/forward difference method is unconditionally stable. Combining this
with the bounds on the truncation error, we find obtain an error estimate
max kej kh = O(k + h2 )
0≤j≤M
a model problem. Some generalizations are variable coefficients c = c(x, t), which result in
curves rather than lines as characteristics, lower order terms,
∂u ∂u
+c + du = f,
∂t ∂x
hyperbolic systems, where u(x, t) takes values in Rn and c is an n × n matrix, hyperbolic
problems in two or more space dimensions like
∂u ∂u ∂u
+c +d = 0,
∂t ∂x ∂y
and nonlinear hyperbolic equations such as (inviscid) Burger’s equation
∂u ∂u
+u = 0,
∂t ∂x
in which the coefficients depend on the solution. Hyperbolic problems of higher order (i.e.,
involving second or higher partial derivatives.)
Suppose we have a system of the form ∂u/∂t + C∂u/∂x = 0 where u(x, t) ∈ Rn and C
is an n × n matrix with real eigenvalues (e.g., a symmetric matrix). Say C = S −1 DS, with
S invertible and D a diagonal matrix. If we change dependent variables by v = S −1 u, then
we get ∂v/∂t + D∂v/∂x = 0, i.e., ∂vi /∂t + di ∂vi /∂x = 0, i = 1, . . . , n. Thus the hyperbolic
system decouples into n advection equations whose speeds are the eigenvalues of the original
coefficient matrix.
As an example, consider the wave equation ∂ 2 w/∂t2 − ∂ 2 w/∂x2 = 0. Let u1 = ∂w/∂t,
u2 = ∂w/∂x. Then
∂ u1 0 −1 ∂ u1
+ = 0.
∂t u2 −1 0 ∂x u2
Thus
0 −1 1 1 −1 0
C= = S −1 DS, S= , D= .
−1 0 1 −1 0 1
Thus we can find the solution from u1 + u2 , which is just a wave moving to the left, and
u1 − u2 , a wave moving to the right.
5.1. Difference methods for the advection equation. In simple cases, hyperbolic
problems can be solved by determining the characteristics (which often involves solving
ODEs), and then determining the solution along the characteristics (again often an ODE
problem). This method of characteristics is a viable numerical methods in some cases.
However it range of applicability is too limited for many important hyperbolic problems
which arise, for example it cannot be easily applied to hyperbolic systems in several space
dimensions. In this section we will study instead difference methods for hyperbolic problems.
For simplicity, we will investigate them only for the simple model problem of the advection
equation.
∂u ∂u
+c = 0.
∂t ∂x
We suppose that c > 0, so the solution is a wave travelling to the right.
188 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
Consider first the most obvious difference methods for the advection equation. We use
forward differences to discretize the time derivative, and three different possibilities for the
space derivative: forward differences, backward differences, and centered differences. Thus
the three methods are:
Unj+1 − Unj U j − Unj
forward-forward + c n+1 = 0,
k h
j
Unj+1 − Unj U j − Un−1
forward-backward +c n = 0,
k h
Unj+1 − Unj U j − Un−1
j
forward-centered + c n+1 = 0.
k 2h
If we set λ = ck/h, these can be written
j
forward-forward Unj+1 = −λUn+1 + (1 + λ)Unj ,
j
forward-backward Unj+1 = (1 − λ)Unj + λUn−1 ,
λ j λ j
forward-centered Unj+1 = − Un+1 + Unj + Un−1 .
2 2
The truncation error is clearly O(k + h) for the first two methods and O(k + h2 ) for the
third.
Include numerical results here.
Numerical experiments suggest that if λ is sufficiently small, the forward-backward
method is stable and convergent, but not for larger λ, i.e., that the forward-backward
method is conditionally stable. On the other hand the forward-forward method and the
forward-centered method appear to be unstable for any positive value of λ.
In fact, the non-convergence of the forward-forward method is easy to establish, even
without considering stability. The solution to the advection equation at a point x at time t
depends only on the initial data at the point x − ct at time 0—in fact it equals the initial
data there. (Other hyperbolic problems, such as the wave equation, the solution at a point x
at time t may depend on the initial data on an interval, not just a point, but the existence of
a bounded domain of dependence is typical feature of hyperbolic equations. Now consider the
forward-forward difference method. It is easy to see that the value at a mesh point x = nh at
a time t = jk depends only on the inital data at the mesh points in the interval [x, x + ct/λ].
Now this interval doesn’t contain the point x − ct, for any positive value of λ. Hence, if
we choose initial data which is equal to 1 at x − ct, but identically zero on [x, ∞), the true
solution of the advection equation will satisfy u(x, t) = 1, but the numerical solution will
be zero, and will remain zero as h, k → 0. In short, the numerical domain of dependence
fails to include the true domain of dependence, which is necessary for a convergent method.
This necessary condition, which fails for the forward-forward difference method, is called the
Courant-Friedrichs-Levy condition, or CFL condition.
If we apply the CFL condition to the forward-backward method, we see that the method
can only be conditionally convergent. Indeed, the numerical domain of dependence is the
interval [x−ct/λ, x], and this contains the true domain of dependence if and only if 0 < λ ≤ 1.
Hence 0 < λ ≤ 1 is a necessary condition for convergence. In fact, we shall see, that the
method is stable and convergent if and only if this condition is met. (Note: we are assuming
5. DIFFERENCE METHODS FOR HYPERBOLIC EQUATIONS 189
c > 0, so λ > 0. If c < 0, then the forward-backward method never converges, but the
forward-forward method converges for 0 > λ ≥ −1.)
One should not think, however, that the CFL condition is generally sufficient for conver-
gence. For example, the CFL condition for the forward-centered scheme is |λ| ≤ 1, but the
method turns out to be unconditionally unstable.
Conditional stability in the max norm is easy to establish for the forward-backward
method. If we consider the method, including a forcing term in the equation, we get
j
Unj+1 = (1 − λ)Unj + λUn−1 + kfnj .
If we assume that 0 ≤ λ ≤ 1, we easily deduce that
kU j+1 k∞ ≤ kU j k∞ + kkf j k∞ ,
and so
M
X −1
j 0
max kU k∞ ≤ kU k∞ + k kf j k∞ ,
0≤j≤M
j=0
i.e., stability with respect to the both the initial data and the forcing function.PFrom this,
−1
the usual argument shows that the max norm of the error is bounded by k M j
j=0 kτ k∞
where τ is the truncation error, and so we get O(k + h) convergence.
If λ > 1, however, the magnitudes of the coefficients 1 − λ and λ sum to more than
1 and this argument fails (as, in fact, does max norm stability). Similarly the sum of the
magnitudes of the coefficients for the forward-forward scheme, 1 + λ and −λ, exceeds 1 for
any positive λ, and the same holds for the coefficients of the forward-centered scheme.
It is important to point out that the forward-forward method is unconditionally unstable
for advection to the right, and the forward-backward method is unconditionally unstable for
advection to the left. Since the wave equation involves the superposition of both of these,
neither scheme is stable for the wave equation.
The Lax–Friedrichs method is a variant of the forward-centered method which maintains
O(k + h2 ) accuracy and which is conditionally stable for advection to the right or left. The
scheme is
j j j j
Unj+1 − (Un+1 + Un−1 )/2 Un+1 − Un−1
+c = 0,
k 2h
or
j j
Unj+1 = (1/2 − λ/2)Un+1 + (1/2 + λ/2)Un−1 .
It isn’t hard to see that the method is stable if |λ| ≤ 1. The truncation error is O(k + h2 +
h2 /k), which is O(h) if λ is held-fixed.
Note that the Lax–Friedrichs method can be rewritten
j j j j
Unj+1 − Unj Un+1 − Un−1 ch Un+1 − 2Unj + Un−1
+c − = 0.
k 2h 2λ h2
Thus the method suggests discretization of the equation
∂u ∂u ch ∂ 2 u
+c − = 0.
∂t ∂x 2λ ∂x2
190 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
Since the eigenvalues 1 − λ + λe−2πimh lie on a circle of radius |λ| around 1 − λ, we get
kSk ≤ 1 if and only if 0 ≤ λ ≤ 1.
We now give several further examples of von Neumann analysis:
The forward-centered difference method for the advection equation: The eigenvalues are
λ λ
− e2πimh + 1 + e−2πimh = 1 − iλ sin 2πmh.
2 2
6. HYPERBOLIC CONSERVATION LAWS 191
Every eigenvalue has magnitude greater than 1, showing that the method is indeed uncon-
ditionally unstable.
Lax-Friedrichs method for the advection equation: The eigenvalues are
1 λ 1 λ
( − )e2πimh + ( + )e−2πimh = cos 2πmh − λi sin 2πmh.
2 2 2 2
The method is stable if |λ| ≤ 1.
Backward-centered difference method for the advection equation: The method is
Unj+1 − Unj U j+1 − Un−1
j+1
+ c n+1 = 0,
k 2h
so
SU j+1 − U j = 0 or U j+1 = S −1 U j ,
where S has as eigenvalues
e2πimh − e−2πimh
1+λ = 1 − λi sin 2πmh.
2
Thus all the eigenvalues of S have modulus greater than 1, and so the norm of S −1 is less
than 1. The method is unconditionally stable.
Von Neumann stability analysis applies to a wide variety of evolution equations and
difference methods, in fact to virtually any equation with constant coefficients and any
difference method on a uniform mesh. In the case of parabolic problems it is very close to the
Fourier analysis we considered earlier, except that it assumes periodic rather than Dirichlet
boundary conditions. As a final example, we analyze the centered in space, forward in time
difference method for the heat equation, this time with periodic boundary conditions. The
method is
j j
Unj+1 = Unj + λ(Un+1 − 2Unj + Un−1 ),
λ = ck/h2 . The von Neumann eigenvalues are
1 + λ(e2πimh + e−2πimh − 2) = 1 + 2λ(cos 2πmh − 1).
Since 0 ≥ cos 2πmh − 1 ≥ −2 (with both equalities possible), the eigenvalues range from 1
to 1 − 4λ, and to have stability, we need 1 − 4λ ≥ −1 or λ ≤ 1/2. We have thus recovered
the stability condition.
flows into the interval from the left is F (a, t) (this is negative if the quantity is flowing out of
the interval at a) and the rate at which it flows in from the right isR −F (b, t). The Rtotal amount
t t
of material that flows in over some time interval [t1 , t2 ] is then t12 F (a, t) dt − t12 F (b, t) dt.
Now suppose that the quantity is conserved. That is, the difference between the quantity
in some interval at some time t1 and the quantity in the same interval at a later time t2 is
entirely accounted for by the amount flowing in and out the end points of the interval. We
may express this by the equation
Z b Z b Z t2 Z t2
(6.23) u(x, t2 ) dx − u(x, t1 ) dx = F (a, t) dt − F (b, t) dt.
a a t1 t1
This equation is to hold for all a < b and all t1 < t2 . This is an integral form of a conservation
law.
Now suppose that the both u and F are smooth functions. Then we may use the funda-
mental theorem of calculus to write (6.23) as
Z t2 Z b
∂u ∂F
(x, t) + (x, t) dxdt.
t1 a ∂t ∂x
This will hold for all choices of intervals if and only if
∂u ∂F
+ = 0.
∂t ∂x
This is the differential form of the conservation law.
STOPPED HERE
Consider the nonlinear first order hyperbolic equation
∂u ∂u
(6.24) + c(u) = 0, x ∈ R, t > 0,
∂t ∂x
which describes the transport of some quantity with a velocity that depends on the amount
of the quantity present. We suppose that the inital data u(x, 0) = u0 (x) is given. We may
solve this problem by the method of characteristics. Assume that u(x, t) is a smooth solution,
and let x0 be any point. A characteristic curve X(t) is defined by the ODE initial value
problem
dX
(6.25) (t) = c u(X(t), t) , X(0) = x0 .
dt
Then u is constant on the characteristic, because
d ∂u ∂u
u X(t), t = + c(u) X(t), t = 0.
dt ∂t ∂x
Thus u X(t), t = u X(0), 0 = u0 (x0 ) for all t. Therefore the ODE (6.25) is trivial. It
just says that dX/dt equals the constant value c u0 (x0 ) , so X(t) is the linear function
X(t) = x0 + c u0 (x0 ) t.
Thus the characteristics for the nonlinear advection equation (6.24) are straight lines.
The solution u is constant on each characteristic line, with the slope of the line equal to
1/c(u).
EXERCISES 193
Figure 6.10. . . .
Exercises
3. Show that with the same choice of coefficients as in the last problem the scheme ∆∗ v = 0 is
a sixth order accurate approximation of the homogeneous equation ∆u = 0.
194 6. NUMERICAL SOLUTION OF PARTIAL DIFFERENTIAL EQUATIONS
4. Consider the solution of the Poisson equation with zero Dirichlet boundary conditions on a
hexagon. Develop a seven-point Laplacian using mesh points lying at the vertices of a grid
of equilateral triangles, as shown below. Prove convergence of the method and exhibit the
rate of convergence.
5. Find a weak formulation for the one-dimensional boundary value problem
−(au0 )0 + bu0 + cu = f in (0, 1), u(0) = α, u(1) + 2u0 (1) = β,
where a, b, c, f : [0, 1] → R are given.
6. Consider the solution to one-dimensional Poission equation
u00 = f in (0, 1), u(0) = u(1) = 0,
using piecewise linear finite element on an arbitrary partition of the interval. Prove that the
finite element solution uh coincides with the interpolant Πh u. Note: this result is special to
the Poisson equation in one-dimension. The analogue in two dimensions is certainly false.
7. a) Let I = (a, b) be an interval. Prove the one-dimensional Poincaré inequality
kukL2 (I) ≤ cku0 kL2 (I)
for u ∈ H 1 (I) such that u(a) = 0. Try to get the correct value for the constant c. In
particular make clear how it depends on the length of the interval.
b) Prove the Poincaré inequality for H̊ 1 functions on the unit square.
8. a) Let T̂ be the triangle with vertices â1 = (0, 0), â2 = (1, 0), â3 = (0, 1). Find the formulas
for the three linear nodal basis function λ̂i which satisfy λ̂i (âi ) = δij .
b) Same problem but now find all six quadratic nodal basis functions on T̂ .
c) Now let T be an arbitrary triangle with vertices a1 , a2 , a3 . Find the formulas for the
linear nodal basis functions in this case.
9. Obtain stability and convergence for the centered difference/backward difference method for
the heat equation using the discrete max norm in time and space.
10. Consider the use of centered differences in space and Crank-Nicolson in time for the advection
equation. Use von Neumann analysis to show unconditional stability of this method.
11. The reverse Lax–Friedrichs scheme for the advection equation is
j+1 j+1
(Un+1 + Un−1 )/2 − Unj+1 j+1
Un+1 j+1
− Un−1
+c = 0.
k 2h
Investigate the consistency, order, and stability of this scheme.
CHAPTER 7
1. Introduction
In this section we return to the question of solving linear systems Au = f , A ∈ Rn×n ,
f ∈ Rn given, and u ∈ Rn is sought. We have in mind mostly the case where A arises from
discretization of a PDE (which is why we have chosen to use u and f rather than x and b for
the vectors). For example, A might be −Dh2 or −∆h , the discrete Laplacian in one or two
dimensions, or it might be the stiffness matrix from a finite element method, or the linear
system which arises at each time step from the discretization of an evolutionary PDE by an
implicit method such as backward differences in time or Crank-Nicolson. Therefore A may
be a very large matrix, but it is also very sparse. In fact the number of non-zero elements in
the matrix A is generally O(n) rather than O(n2 ). E.g., for the 5-point Laplacian it is about
5n. We shall only consider the case where A is symmetric positive definite (SPD). This is
both because that is an important case, and because the theory is far simpler and better
developed in that case.
First let us recall earlier results. We may of course use Cholesky factorization. This takes
roughly n3 /6 multiplications and additions. However this ignores the sparsity of A. If A has
a banded structure with semibandwidth d, that is aij = 0 if |i − j| ≥ d, then each step of the
Cholesky algorithm preserves this structure, and we can suppress the steps that zero entries
d or more positions below the diagonal. Careful operation counting reveals that a Cholesky
factorization then costs about nd2 /4 operations. For example, if A = −Dh2 so d = 1, and we
have only O(n) operations, and so have an optimal algorithm (no operation could require
less than one operation—it must take at least one operation to compute each component
of the solution). However, if we consider the 5-point Laplacian on the unit square using a
mesh spacing of h = 1/N , then the matrix size is n × n with n = (N − 1)2 ≈ h−2 and the
semibandwidth is N − 1 ≈ h−1 . Thus Cholesky factorization can be implemented in about
h−4 /4 = O(n2 ) operations. This is significantly better than what would occur if we were to
ignore sparsity—then we would require h−6 /6 = O(n3 ) operations—but it is not optimal.
In this chapter we will consider iterative methods, which start with an initial guess u0
and construct iterates u1 , u2 , . . . which—hopefully—converge to the exact solution.
A method which we have already discussed is the conjugate gradient method, which we
derived as a line-search method for minimizing F (x) = uT Au/2 − uT f (the minimum occurs
exactly at the solution of Au = f ). Due to the sparsity of A, each iteration of the conjugate
gradient method only requires O(n) operations. For this method we proved that the error
e = u − ui converges linearly to 0:
kei k ≤ Cri ,
195
196 7. SOME ITERATIVE METHODS OF NUMERICAL LINEAR ALGEBRA
2. Classical iterations
Now we consider some classical iterative methods to solve Au = f . One way to motivate
such methods is to note that if u0 is some approximate solution, then the exact solution u
may be written u = u0 + e and the error e = u − u0 is related to the residual r = f − Au0
by the equation Ae = r. That is, we can express u as a residual correction to u0 : u =
u0 + A−1 (f − Au0 ). Of course, this is not a practical solution method since computing
e = A−1 (f − Au0 ) by solving Ae = r is as difficult as the original problem of solving for u.
But suppose we have some nonsingular matrix B which approximates A−1 but is less costly
to apply. We are then led to the iteration u1 = u0 + B(f − Au0 ), which can be repeated to
give
(7.1) ui+1 = ui + B(f − Aui ), i = 0, 1, 2, . . . .
Of course the effectiveness of such a method will depend on the choice of B. For speed of
convergence, we want B to be close to A−1 . For efficiency, we want B to be easy to apply.
Some typical choices of B are:
• B = ωI for some ω > 0. This is just the method of steepest descents with a constant
step size ω. As we shall see, this method will converge for positive definite A if ω
is a sufficiently small positive number. This iteration is often called the Richardson
method.
• B = D−1 where D is the diagonal matrix with the same diagonal elements as A. Then
this is called the Jacobi method.
• B = E −1 where E is the lower triangular matrix with the same diagonal and subdi-
agonal elements of A. This is the Gauss–Seidel method.
2. CLASSICAL ITERATIONS 197
Remark. Another way to derive the classical iterative methods is to give a splitting of
A as P + Q for two matrices P and Q where P is in some sense close to A but much easier
to invert. We then write the equations as P u = f − Qu, which suggests the iteration
um+1 = P −1 (f − Qum ).
Since Q = A − P , this iteration may also be written
ui+1 = ui + P −1 (f − Aui ).
Thus this iteration coincides with (7.1) when B = P −1 .
Sometimes the iteration (7.1) is modified to
ui+1 = (1 − α)ui + α[ui + B(f − Aui )], i = 0, 1, 2, . . . ,
for a real parameter α. If α = 1, this is the unmodified iteration. For 0 < α < 1 the iteration
has been damped, while for α > 1 the iteration is amplified. The damped Jacobi method will
come up below when we study multigrid. The amplified Gauss–Seidel method is known as
SOR (successive over-relaxation). This terminology is explained in the next two paragraphs.
Before investigating their convergence, let us particularize the classical iterations to the
discrete Laplacian −Dh2 in one or two dimensions. In one dimension, the equations are
−um+1 + 2um − um−1
= f m , m = 1, . . . , N − 1,
h2
where h = 1/N and u0 = uN = 0. The Jacobi iteration is then simply
um−1
i + um+1
i h2
um
i+1 = + f m, m = 1, . . . , N − 1,
2 2
The error satisfies
em−1
i + em+1
i
em
=i+1 ,
2
so at each iteration the error at a point is set equal to the average of the errors at the
neighboring points at the previous iteration. The same holds true for the 5-point Laplacian
in two dimensions, except that now there are four neighboring points. In an old terminology,
updating the value at a point based on the values at the neighboring points is called relaxing
the value at the point.
For the Gauss–Seidel method, the corresponding equations are
um−1 m+1
i+1 + ui h2 m
um
i+1 = + f , m = 1, . . . , N − 1,
2 2
and
em−1 m+1
i+1 + ei
em
i+1 = , m = 1, . . . , N − 1.
2
We can think of the Jacobi method as updating the value of u at all the mesh points
simultaneously based on the old values, while the Gauss–Seidel method updates the values
of one point after another always using the previously updated values. For this reason the
Jacobi method is sometimes referred to as simultaneous relaxation and the Gauss–Seidel
method as successive relaxation (and amplified Gauss–Seidel as successive overrelaxation).
Note that the Gauss–Seidel iteration gives different results if the unknowns are reordered.
198 7. SOME ITERATIVE METHODS OF NUMERICAL LINEAR ALGEBRA
(In fact, from the point of view of convergence of Gauss–Seidel, there are better orderings
than just the naive orderings we have taken so far.) By contrast, the Jacobi iteration is
unaffected by reordering of the unknowns.
To investigate the convergence of (7.1) we write it as
um+1 = (I − BA)um + Bf = Gum + Bf,
where the iteration matrix G = I − BA. The equation u = Gu + Bf is certainly satisfied
(where u is the exact solution), and so the classical iterations may be viewed as one-point
iterations for this fixed point equation, as studied in Chapter 4.2. The error then satisfies
em+1 = Gem , and the method converges for all starting values e0 = u − u0 if and only
if limm→∞ Gm = 0. Recall that this holds if and only if the spectral radius ρ(G) < 1
(Corollary 4.4), and then the rate of convergence is ρ(G). Since G = I −BA, the convergence
condition is that all the eigenvalues of BA must lie strictly inside the unit circle in the
complex plane centered at 1. If BA has real eigenvalues (which will always be the case if B
is symmetric, since then BA is symmetric with respect to the inner product hu, viA = uT Av),
then the condition becomes that all the eigenvalues of BA belong to the interval (0, 2).
As a first example, we consider the convergence of the Richardson method. The matrix
A, being SPD, has a full set of eigenvalues
0 < λmin (A) = λ1 ≤ λ2 ≤ · · · ≤ λn = λmax (A) = ρ(A).
The eigenvalues of BA = ωA are then ωλi , i = 1, . . . , n, and the iteration converges if and
only if 0 < ω < 2/λmax .
Theorem 7.1. Let A be an SPD matrix. Then the Richardson iteration um+1 = um +
ω(f − Aum ) is convergent for all choices of u0 if and only if 0 < ω < 2/λmax (A). In this
case the rate of convergence is
max(|1 − ωλmax (A)|, |1 − ωλmin (A)|).
For example, if we consider A = −Dh2 , the discrete Laplacian in one dimension, and choose
ω = h2 /4 (so ω ≈ 1/λmax (A)), the Richardson iteration converges with rate 1−h2 λmin (A)/4 =
1 − O(h2 ). Thus the converge is very slow (we will need O(h−2 ) iterations).
Note that for A = −Dh2 the Jacobi method coincides with the Richardson method with
ω = h2 /2. Since λmax (A) < 4/h2 the Jacobi method is convergent. But again convergence is
very slow, with a rate of 1 − O(h2 ). In fact for any 0 < α ≤ 1, the damped Jacobi method
is convergent, since it coincides with the Richardson method with ω = αh2 /2.
For the Richardson, Jacobi, and damped Jacobi iterations, the approximate inverse B is
symmetric, but this is not the case for Gauss–Seidel, in which B is the inverse of the lower
triangle of A. Of course we get a similar method if we use B T , the upper triangle of A. If we
take two steps of Gauss–Seidel, one with the lower triangle and one with the upper triangle,
the iteration matrix is
(I − B T A)(I − BA) = I − (B T + B − B T AB)A,
so this double iteration is itself a classical iteration with the approximate inverse
(7.2) B̄ := B T + B − B T AB.
2. CLASSICAL ITERATIONS 199
This iteration is called symmetric Gauss–Seidel. Now, from the definition of B̄, we get the
identity
(7.3) kvk2A − k(I − BA)vk2A = hB̄Av, viA .
It follows that hB̄Av, viA ≤ kvk2A , and hence that λmax (B̄A) ≤ 1. Thus the symmetrized
Gauss–Seidel iteration is convergent if and only if λmin (B̄A) > 0, i.e., if and only if B̄A
is SPD with respect to the A inner product. This is easily checked to be equivalent to B̄
being SPD with respect to the usual inner product. When this is the case (7.3) implies that
k(I − BA)vkA < kvkA for all nonzero v, and hence the original iteration is convergent as
well.
Remark. In fact the above argument didn’t use any properties of the original ap-
proximate inverse B. So what we have really proved is that given any approximate in-
verse matrix B, if we symmetrize by the formula (7.2) then the symmetrized iteration
ui+1 = ui + B̄(f − Aui ) is convergent if and only if B̄ is SPD, and, in that case, the
original iteration ui+1 = ui + B(f − Aui ) is convergent as well.
B̄ = B T + B − B T AB = B T (B −1 + B −T − A)B
= B T [(D − L) + (D − LT ) − (D − L − LT )]B = B T DB,
which is clearly SPD whenever A is. Thus we have proven:
Theorem 7.2. The Gauss–Seidel and symmetric Gauss–Seidel iterations are convergent
for any symmetric positive definite linear system.
It is worth remarking that the same result is not true for the Jacobi iteration: although
convergence can be proven for many of the SPD matrices that arise from discretizations of
PDE, there exists SPD matrices for which Jacobi iteration does not converge. As to the
speed of convergence for Gauss–Seidel when applied to the discrete Laplacian, the analysis
is much trickier than for Jacobi, but it can again be proven (or convincingly demonstrated
via simple numerical experiments) that for A = −Dh2 the rate of convergence is again just
1 − O(h2 ), as for Jacobi, although the constant in the O(h2 ) term is about twice as big for
Gauss–Seidel as for Jacobi.
Thus while the classical iterations have a certain elegance, and do converge for typical
SPD problems arising from elliptic PDE, they converge very slowly. In fact, they are not
competitive with the conjugate gradient method. One good use of the classical iterations,
however, is to precondition conjugate gradients. As long as the approximate inverse B is
SPD, we may use it as a preconditioner. The Jacobi preconditioner, also known as diagonal
preconditioning often has minimal effect. Indeed for the discrete Laplacian it has no effect
at all, since the diagonal is constant. The symmetric Gauss–Seidel preconditioner is a bit
more helpful.
In fact, we can show that conjugate gradients preconditioned by some SPD approximate
inverse always converges faster than the corresponding classical iterative method. For if λ is
200 7. SOME ITERATIVE METHODS OF NUMERICAL LINEAR ALGEBRA
Table 7.1. Operation counts for solving linear systems for the discrete Lapla-
cian in one and two dimensions. For the iterative methods, the total number
of operations to reduce the error by a given factor is the product of the number
of operations per iteration times the number of iterations required.
The last quantity is strictly less than ρ for all ρ ∈ (0, 1).
√ (For ρ small it is about ρ/2, while
for ρ ≈ 1 − with small, it is approximately 1 − 2.) Thus the rate of convergence
of PCG with B as a preconditioner is better than that of the classical iteration with B as
approximate inverse.
3. Multigrid methods
Figure 7.1 shows the result of solving a discrete system of the form −Dh2 uh = f using
the Gauss–Seidel iteration. We have take h = 1/128, and chosen a smooth right-hand side
vector f which results in the vector uh which is plotted as a dashed line in each of the plots.
The initial iterate u0 , which is shown in the first plot, was chosen at random, and then the
iterates u1 , u2 , u5 , u50 , and u500 are shown in the subsequent plots. In Figure 7.2, the relative
error kuh − ui k/kuh k is plotted for i = 0, 1, . . . , 50, in both the l∞ and the l2 norms.
These numerical experiments illustrate the following qualitative properties, which are
typical of the Gauss–Seidel iteration applied to matrices arising from the discretization of
elliptic PDEs.
• If we start with a random error, the norm of the error will be reduced fairly quickly
for the first few iterations, but the error reduction occurs much more slowly after that.
3. MULTIGRID METHODS 201
90
80
70
60
50
40
30
20
10
0
0 5 10 15 20 25 30 35 40 45 50
• After several iterations the error is much smoother, but not much smaller, than ini-
tially. Otherwise put, the highly oscillatory modes of the error are suppressed much
more quickly by the iteration than the low frequency modes.
202 7. SOME ITERATIVE METHODS OF NUMERICAL LINEAR ALGEBRA
The first observation is valid for all the methods we have studied: Richardson, Jacobi,
damped Jacobi, and Gauss–Seidel. The second obervation—that Gauss–Seidel iteration
smooths the error—is shared damped Jacobi with α < 1, but not by Jacobi itself.
If we take the Richardson method with ω = 1/λmax (A) for the operator A = −Dh2 ,
it is very easy to see how the smoothing property comesPn about. The initial error can be
expanded in terms of the eigenfunctions of A: e0 = m=1 ci sin mπx. The mth component
in this expansion is multiplied by 1 − λm /λmax = 1 − λm /λn at each iteration. Thus the
high frequency components, m ≈ n, are multiplied by something near to 0 at each iteration,
and so are damped very quickly. Even the intermediate eigenvalues, λm ≈ λn /2 are damped
reasonably quickly (by a factor of about 1/2 at each iteration). But the low frequency modes,
for which λm λn , decrease very slowly.
This also explains the first observation, that the norm of the error decreases quickly
at first, and then more slowly. The norm of the error has contributions from all modes
present in the initial error. Those associated to the higher frequency modes disappear in a
few iterations, bringing the error down by a significant fraction. But after that the error is
dominated by the low frequency modes, and so decays very slowly.
The same analysis applies to damped Jacobi with positive damping, and shows that
undamped Jacobi doesn’t have the smoothing property: the mth mode is multiplied by
about 1 − 2λm /λn , and so convergence is very slow for low frequency modes and also the
highest frequency modes λm ≈ λn . For the intermediate modes, λm ≈ λn /2, convergence is
very fast.
Establishing the smoothing property for Gauss–Seidel is more complicated, since the
eigenfunctions of the Gauss–Seidel iteration don’t coincide with those of A even for A = −Dh2 .
However both numerical study and careful analysis show that Gauss–Seidel does indeed have
the smoothing property for discretized elliptic operators.
The idea behind the multigrid method is to create an iterative method which reduces all
components of the residual quickly by putting together two steps. First it applies the approx-
imate inverse from Gauss–Seidel or another classical iterative method with the smoothing
property to the residual. This greatly reduces the high frequency components of the resid-
ual, but barely reduces the low frequency components. The new residual, being relatively
smooth, can then be accurately approximated on a coarser mesh. So, for the second step,
the residual is (somehow) transferred to a coarser mesh, and the equation solved there, thus
reducing the low frequency components. On the coarser mesh, it is of course less expensive
to solve. For simplicity, we assume for now that an exact solver is used on the coarse mesh.
Finally this coarse mesh solution to the residual problem is somehow transferred back to the
fine mesh where it can be added back to our smoothed approximation.
Thus we have motivated the following rough outline of an algorithm:
1. Starting from an initial guess u0 apply a fine mesh smoothing iteration to get an
improved approximation ū.
2. Transfer the residual in ū to a coarser mesh, solve a coarse mesh version of the problem
there, transfer the solution back to the fine mesh, and add it back to ū to get ū¯.
¯ for u1 and thus have described an iteration to get from u0 to u1 (which we can
Taking ū
then apply again to get from u1 to u2 , and so on). In fact it is much more common to also
apply a fine mesh smoothing at the end of the iteration, i.e., to add a third step:
3. MULTIGRID METHODS 203
but PH as we described it, consists only of 0’s and 1’s. Therefore one commonly takes a
different choice for PH , namely PH = (1/2)QTH . This means that the transferred coarse grid
function doesn’t just take the value of the corresponding fine grid function at the coarse grid
point, but rather uses a weighted average of the fine grid function’s values at the point in
question and the fine grid points to the left and right (with weights 1/4, 1/2, 1/4). With
this choice, QH Ah PH is symmetric; in fact, QH Ah PH = AH . This is a useful formula. For
operators other than the Ah = −Dh2 , we can use the same intergrid transfer operators,
namely QH given by (7.4) and PH = (1/2)QTH , and then define the coarse grid operator by
AH = QH Ah PH .
Remark. In a finite element context, the situation is simpler. If the fine mesh is a
refinement of the coarse mesh, then a coarse mesh function is already a fine mesh function.
Therefore, the operator QH can be taken simply to be the inclusion operator of the coarse
mesh space into the fine mesh space. The residual in u0 ∈ Sh is most naturally viewed as
a functional on Sh : v 7→ (f, v) − B(u0 , v). It is then natural to transfer the residual to the
coarse mesh simply by restricting the test function v to SH . This operation ShT → SH T
is
exactly the adjoint of the inclusion operator SH → Sh . Thus the second step, solving the
coarse mesh problem for the restricted residual is obvious in the finite element case: we find
eH ∈ SH such that
B(eH , v) = (f, v) − B(ū, v), v ∈ SH ,
¯ = ū + eH ∈ Sh .
and then we set ū
Returning to the case of finite differences we have arrived at the following two-grid
iterative method to solve Ah uh = fh .
uh = twogrid(h, Ah , fh , u0 )
input: h, mesh size (h = 1/n with n even)
Ah , operator on mesh functions
fh , mesh function (right-hand side)
u0 , mesh function (initial iterate)
output: uh , mesh function (approximate solution)
for i = 0, 1, . . . until satisfied
1. presmoothing: ū = ui + Bh (fh − Ah ui )
2. coarse grid correction:
2.1. residual computation: rh = fh − Ah ū
2.2. restriction: H = 2h, rH = PH rh , AH = PH Ah QH
2.3. coarse mesh solve: solve AH eH = rH
2.4. prolongation: eh = QH eH
2.5. correction: ū ¯ = ū + eh
3. postsmoothing: uh ← ui+1 = ū ¯ + BhT (fh − Ah ū
¯)
end
In the smoothing steps, the matrix Bh could be, for example, (D − L)−1 where D is
diagonal, L strictly lower triangular, and Ah = D − L − LT . This would be a Gauss–Seidel
smoother, but there are other possibilities as well. Besides these steps, the major work is in
the coarse mesh solve. To obtain a more efficient algorithm, we may also solve on the coarse
mesh using a two-grid iteration, and so involving an even coarser grid. In the following
multigrid algorithm, we apply this idea recursively, using multigrid to solve at each mesh
level, until we get to a sufficiently coarse mesh, h = 1/2, at which point we do an exact solve
(with a 1 × 1 matrix!).
uh = multigrid(h, Ah , fh , u0 )
input: h, mesh size (h = 1/n with n a power of 2)
Ah , operator on mesh functions
fh , mesh function (right-hand side)
u0 , mesh function (initial iterate)
output: uh , mesh function (approximate solution)
if h = 1/2 then
uh = A−1h fh
else
for i = 0, 1, . . . until satisfied
1. presmoothing: ū = ui + Bh (f − Ah ui )
2. coarse grid correction:
2.1. residual computation: rh = fh − Ah ū
2.2. restriction: H = 2h, rH = PH rh , AH = PH Ah QH
2.3. coarse mesh solve: eH = multigrid(H, AH , rH , 0)
2.4. prolongation: eh = QH eH
2.5. correction: ū ¯ = ū + eh
3. postsmoothing: uh ← ui+1 = ū ¯ + BhT (f − Ah ū
¯)
end
end if
Figure 7.3 shows two iterations of this multigrid algorithm for solving the system −Dh2 uh =
f , h = 1/128, considered at the beginning of this section. Compare with Figure 7.1. The
fast convergence of the multigrid algorithm is remarkable. Indeed, for the multigrid method
discussed here it is possible to show that the iteration is linearly convergent with a rate
independent of the mesh size. This means that the number of iterations needed to obtain a
desired accuracy remains bounded independent of h. It is also easy to count the number of
operations per iteration. Each iteration involves two applications of the smoothing iteration,
plus computation of the residual, restriction, prolongation, and correction on the finest mesh
level. All those procedures cost O(n) operations. But then, during the coarse grid solve, the
same procedures are applied on the grid of size 2h, incurring an additional cost of O(n/2).
Via the recursion the work will be incurred for each mesh size h, 2h, 4h, . . . . Thus the total
work per iteration will be O(n + n/2 + n/4 + . . . + 1) = O(n) (since the geometric series
206 7. SOME ITERATIVE METHODS OF NUMERICAL LINEAR ALGEBRA
sums to 2n). Thus the total work to obtain the solution of the discrete system to any desired
accuracy is itself O(n), i.e., optimal. For a fuller introduction to multigrid, including the
theoretical analysis, see [1].
Other things that could go here. Some more numerical results showing independence
of h. V-cycle diagram, discussion of multiple smoothings, W-cycle; more precise conver-
gence statement. Full multigrid. Multigrid for finite elements; connection with adaptivity.
Numerical results, e.g., from black hole research.
SOR theory might make some good exercises.
Exercises
1. Let A be a tridiagonal matrix with all the diagonal entries equal to 3 and all the subdiagonal
and superdiagonal entries equal to −1. Determine for which values of the real parameter ω
the iteration xi+1 = xi + ω(b − Axi ) converges to the solution of Ax = b for any choice of
initial iterate x0 .
2. Consider the linear system: find u ∈ Rn and p ∈ Rm such that
Au + Bp = f, B T u = g.
Here A ∈ Rn×n is symmetric positive definite, B ∈ Rn×m has rank m, f ∈ Rn , and g ∈ Rm .
a) Prove that this system is nonsingular.
b) The Uzawa iteration for this system proceeds as follows.
1. Jinchao Xu, An introduction to multilevel methods, Wavelets, multilevel methods and elliptic PDEs (Le-
icester, 1996) (M. Ainsworth, J. Levesley, M. Marletta, and W. A. Light, eds.), Oxford Univ. Press, New
York, 1997, pp. 213–302.
207