Lecture notes for MS-C1650 Numerical Analysis, Aalto University
Last updated: 30.5.2024
Largely based the lecture transcript by Harri Hakula, 2021.
Intended learning outcomes. After the course, the student will be able to…
explain the fundamental concepts of numerical analysis, like condition number, stability, and convergence rate;
construct the floating point numbers;
discuss and employ basic numerical algorithms like Newton’s method;
use the Monte-Carlo method in basic problems in analysis and geometry;
apply different methods of interpolation polynomials and numerical quadrature rules;
understand the Euler scheme and linear multi-step methods for solving ordinary differential equations.
Floating-point numbers
The set of real numbers R is infinite in two ways: it is unbounded and continuous. In most practical computing, the second kind of infiniteness is more consequential than the first kind, so we turn our attention there first.
Instead of R, we shall introduce the set of floating-point numbers (floats) F. They come with different bases, precisions and exponent ranges, and other features. The basic representation is x=±(d0.d1d2…dp)k⋅ke. k∈N∖{1} is called base or radix, p∈N0:=N∪{0} is called the precision, di, i∈{0,…,p}, and the sequence of numbers (d0.d1d2…dp)k:=i=0∑pdik−i
is called mantissa or significand. The exponent e∈Z is bounded m≤e≤M, where m,M∈Z.
If k=10, we can read the usual decimal commas from the mantissa: (1.01)10=1⋅100+0⋅10−1+1⋅10−2=1.01.
If k=2, we have binary floats. In the binary case, we observe that we can always choose d0=1, hence saving one bit, which can be expressed by e. We refer to this as normalization. The mantissa is always contained in the interval [1,2).
Example. (Toy floating point system). Binary floats of the type (1.b1b2)2 with exponents e=−1,0,1.
Hence (1.00)2=1, (1.01)2=45, (1.10)2=23, and >(1.11)2=47. By multiplying with the exponents 2−1=21, 20=1, 21=2, we get the whole set:
e
1
45
23
2
25
3
21
85
43
Important quantity: (1.01)2−1=41, the so-called machine epsilon.
Define the machine epsilon by ε:=2−p=(1.00…01)2−1.
Rounding
For the rounding function round:R→F, we have 5 alternative definitions:
Rounding to nearest (default)
Rounding to +∞
Rounding to −∞
Rounding to 0
Rounding away from 0
It holds that round(x)=x(1+δ), where ∣δ∣<2ε, where ε denotes the machine epsilon. Note that usually δ depends on x.
There is a way to define the standard arithmetic operations on F such that a⊕b=round(a+b)=(a+b)(1+δ1), a⊖b=round(a−b)=(a−b)(1+δ2), a⊗b=round(ab)=ab(1+δ3), a⊘b=round(ba)=ba(1+δ4),b=0.
Here, generally δi=δj, i=j.
IEEE 754 “Double precision”
k=2, 64 bits, where:
The sign: 1 bit;
The exponent field 0≤ex≤2047: 11 bits, where e=ex−1023, and −1022≤e≤1023, where ex=0 and ex=2047 are special cases.
The mantissa 52 bits, precision p=52.
Exponent field
Number
Type of number
00…00=0
±(0.b1b2…b52)2⋅2−1022
0 or subnormal
00…01=1
±(1.b1b2…b52)2⋅2−1022
00…10=2
±(1.b1b2…b52)2⋅2−1021
…
…
01…11=1023
±(1.b1b2…b52)2⋅20
…
…
11…10=2046
±(1.b1b2…b52)2⋅21023
11…11=2047
±∞ if b1=b2=…=b52=0, otherwise NaN
exception
Thus, there are two zeros, two infinities and NaN which denotes “not a number”. The smallest positive normalized number is: (1.0)2⋅2−1022≈2.2⋅10−308.
The largest positive number is: (1.1…1)2⋅21023≈1.8⋅10308
The machine epsilon is: 2−52≈2.22⋅10−16.
Here’s an easy-to-follow video explaining floating point numbers (and a specific version of Newton’s algorithm).
Condition number and stability
Conditioning of problems
Assume that f:R→R “solution map” of the problem, input numbers x, x^, close in value, e.g. x^=round(x). Set y:=f(x), y^:=f(x^).
Definition. The absolute condition numberC(x) is defined by the relation ∣y−y^∣≈C(x)∣x−x^∣.
The relative condition numberK(x) is defined by the relation ∣∣yy−y^∣∣≈K(x)∣∣xx−x^∣∣
By the normalization, we guarantee that (relative error in the output)≈K(x)×(relative error in the input).
Now, y−y^=f(x)−f(x^)=→f′(x)asx^→xx−x^f(x)−f(x^)(x−x^)
Thus, C(x)=∣f′(x)∣.
Furthermore, yy−y^=f(x)f(x)−f(x^)=→f′(x)asx^→xx−x^f(x)−f(x^)xx−x^f(x)x
Thus, K(x)=∣∣f(x)xf′(x)∣∣.
Example.f(x)=2x, f′(x)=2. Thus, C(x)=2, K(x)=∣∣2x2x∣∣=1. This is a well-conditioned problem.
Example.g(x)=x, g′(x)=2x1. Thus, C(x) is becomes unbounded for x>0 close to zero, e.g. x≈10−8 yields C(x)≈104. On the other hand, K(x)=∣∣2xxx∣∣=21.
Stability of algorithms
Definition. An algorithm or numerical process is called stable if small changes in the input produce small changes in the output. It is called unstable if large changes in the output are produced by small changes in the input.
An algorithm is stable, if every step is well-conditioned (i.e. has a uniformly bounded condition number). It is unstable if any step is ill-conditioned (i.e. the condition number may become arbitrarily large).
Forward error analysis (FEA) is asking:
“How far are we from the true solution?”
Backward error analysis (BEA) is asking:
“Given the answer, what was the problem?”
Example.
Set: fl(x+y):=round(x)⊕round(y)=((x(1+δ1)+y(1+δ2))(1+δ3),
where ∣δi∣<2ε, i=1,2,3.
FEA: fl(x+y)=x+y+x(δ1+δ3+δ1δ3)+y(δ2+δ3+δ2δ3).
The absolute error is ∣fl(x+y)−(x+y)∣≤(∣x∣+∣y∣)(ε+4ε2).
The relative error is: ∣∣x+yfl(x+y)−(x+y)∣∣≤∣x+y∣(∣x∣+∣y∣)(ε+4ε2).
BEA: fl(x+y)=x(1+δ1)(1+δ3)+y(1+δ2)(1+δ3).
Thus the relative error for each term is less or equal to ε+4ε2.
Hence the sum of two floating point numbers is backwards stable.
Well-conditioned problems may have unstable algorithms. For stability, each step has to be well conditioned. Some ill-conditioned steps produce an unstable algorithm. Ill-conditioned problems cannot be reliably solved with a stable algorithm.
Example. Consider evaluating f(x)=1+x−1 for x close to zero. The relative condition number is: K(x)=∣∣f(x)xf′(x)∣∣=21+x(1+x−1)x =21+x(1+x−1)(1+x+1)x(1+x+1)=21+x1+x+1,
and K(0)=1.
Consider the following 3 steps;
t1:=1+x, well-conditioned, x close to 0.
t2:=t1, relatively well-conditioned, also absolutely well conditioned, because t1 is close to 1.
t3:=t2−1, ill-conditioned, relative condition number of this step: K3(t2)=∣∣t2−1t2∣∣, which becomes unbounded for t2 close to 1!
On the other hand, the problem is well-conditioned. Solve it by writing: f(x)=1+x−1=1+x+1(1+x+1)(1+x−1)=1+x+1x,
which can be evaluated directly close to zero.
Numerical differentiation
Recall Taylor’s theorem, for a twice differentiable function f:R→R, f(x)=f(x0)+f′(x0)(x−x0)+21(x−x0)2f′′(ξ),
for any x0,x∈R, where ξ∈[x0,x].
What is that ξ (= “xi”)? Under certain assumptions elementary functions have their series expansions. If the series is truncated, we have the Taylor polynomial. However, the residual has an explicit expression but due to application of an intermediate value theorem, the exact location of the point ξ is not known, i.e. “generic”.
By setting x:=z+h, x0:=z, we obtain the useful equivalent formula f(z+h)=f(z)+f′(z)h+21f′′(ξ)h2,
for every z,h∈R, ξ∈[z,z+h].
Rate of convergence (Q-convergence)
Let (xk) be an infinite sequence of real numbers. Let sk:=supl≥kxl, k∈N, be the supremum (i.e., the lowest upper bound) of the tail (that is, large indices l≥k) of (xk). Define the limsup (limes superior) as k→∞limsupxk:=k→∞limsk∈[−∞,+∞].
Other than a limit, it always exists, but can be ±∞. If (xk) is bounded, the limsup is the largest limit of a converging subsequence. If limk→∞xk∈(−∞,∞) exists, then limk→∞xk=limsupk→∞xk. The opposite is not true.
Examples. (1) xk:=(−1)k, then sk=1, and limsupk→∞xk=1.
(2) xk=sin(k), then sk=1, and limsupk→∞xk=1.
Assume that limk→∞xk=x and that there exists some large index M∈N such that xk=x for all k≥M. Then we define the following quantity for p≥0 C(p):=k→∞limsup∣xk−x∣p∣xk+1−x∣.
We observe that C(p∗)<∞ for some p∗>0 implies C(p)=0 for every 0≤p<p∗. If C(p∗)>0 for some p∗>0 then C(p)=∞ for any p>p∗.
Proof. By the submultiplicative property of limsup, C(p)=k→∞limsup∣xk−x∣p∣xk+1−x∣=k→∞limsup[∣xk−x∣p∗∣xk+1−x∣∣xk−x∣p∗−p] ≤(k→∞limsup∣xk−x∣p∗∣xk+1−x∣)⋅(k→∞limsup∣xk−x∣p∗−p)=C(p∗)⋅{0∞ifp<p∗,ifp>p∗. □
Thus, there exists a (possibly infinite) p∗ such that C(p)=⎩⎨⎧0C(p∗)∞if0≤p<p∗,ifp=p∗,ifp>p∗.
The number p∗ is called order of convergence for the sequence (xk) and determines the rate of convergence as follows:
If p∗=1 and C(1)=1 then we say the convergence is sublinear.
If p∗=1 and 1>C(1)>1 then we say the convergence is linear.
If p∗>1 or C(1)=0 then we say the convergence is superlinear.
If p∗=2 then we say the convergence is quadratic.
If p∗=3 then we say the convergence is cubic, etc.
When working with convergence estimates it is often useful to use the following approximation: ∣xk+1−x∣≈C∣xk−x∣p∗
for some constant C>0, not necessarily C(p∗).
Here, it is useful to look at the logarithmic behavior: log(∣xk+1−x∣)≈log(C∣xk−x∣p∗)=log(C)+log(∣xk−x∣p∗)=log(C)+p∗log(∣xk−x∣).
The rate of convergence can be used interchangeably with the order of convergence. However, there is some caution necessary, as different authors use different terminology here. Usually, the order of convergence always refers to the same thing, namely, the p∗-exponent in the denominator of the limit defining the order of convergence. Most confusingly, some authors call the order of convergence “rate of convergence”, as e.g. here. The English Wikipedia article calls it the order of convergence, whereas here the rate of convergence is the constant in the definition, which also determines the speed of convergence, together with the order of convergence. So, please always check the context, as the use of the terminology should be clear from it. If there is no definition, try to figure out what is meant in each text. As a rule of thumb: The “order of convergence” is a unique terminology in numerical analysis. The “rate of convergence” can mean at least two different things. I will use both words for the same thing, but will try to make clear what I mean from case to case. In any case, to be sure, use “order of convergence”. My PhD advisor usually said that in mathematics “it’s all hollow words” (meaning that one should check the definition).
Landau’s little o- and big O-notation
Copied from Wikibooks under a Creative Commons BY-SA 4.0 license.
The Landau notation is an amazing tool applicable in all of real analysis. The reason it is so convenient and widely used is because it underlines a key principle of real analysis, namely ‘‘estimation’’. Loosely speaking, the Landau notation introduces two operators which can be called the “order of magnitude” operators, which essentially compare the magnitude of two given functions.
The “little-o”
The “little-o” provides a function that is of lower order of magnitude than a given function, that is the function o(g(x)) is of a lower order than the function g(x). Formally,
Definition.
Let A⊆R and let c∈R.
Let f,g:A→R.
If limx→cg(x)f(x)=0 then we say that
"As x→c, f(x)=o(g(x))"
Examples.
As x→∞, (and m<n), xm=o(xn);
As x→∞, (and n∈N), logx=o(xn);
As x→0, sinx=o(1).
The “Big-O”
The “Big-O” provides a function that is at most the same order as that of a given function, that is the function O(g(x)) is at most the same order as the function g(x). Formally,
Definition.
Let A⊆R and let c∈R
Let f,g:A→R
If there exists M>0 such that limx→c∣∣g(x)f(x)∣∣<M then we say that
"As x→c, f(x)=O(g(x))"
Examples.
As x→0, sinx=O(x);
As x→2π, sinx=O(1).
Applications
We will now consider few examples which demonstrate the power of this notation.
Differentiability
Let f:U⊆R→R and x0∈U.
Then f is differentiable at x0 if and only if
There exists a λ∈R such that as x→x0, f(x)=f(x0)+λ(x−x0)+o(∣x−x0∣).
Mean Value Theorem
Let f:[a,x]→R be differentiable on [a,b]. Then,
As x→a, f(x)=f(a)+O(x−a).
Taylor’s Theorem
Let f:[a,x]→R be n-times differentiable on [a,b]. Then,
As x→a, f(x)=f(a)+1!(x−a)f′(a)+2!(x−a)2f′′(a)+…+(n−1)!(x−a)n−1f(n−1)(a)+O((x−a)n).
Finding roots of functions and fixed points
Let f:R→R be continuous. We are interested in methods for finding zeros, that is, roots of f, in other words, x∈R, such that f(x)=0.
Definition. If f:Rn→R, n∈N is k-times continuously differentiable, then we write f∈Ck(Rn) or just f∈Ck. For k=0, f∈C0 or f∈C(Rn) or f∈C([a,b]) just means that f is assumed to be continuous.
Bisection method
The intermediate value theorem for continuous functions implies that x1<x<x2 with f(x)=0 exists if f(x1)f(x2)<0, i.e., there is a sign change. The bisection method is based on halving the interval such that the sign condition is preserved. Note that, in principle, we have to look for intervals [x1,x2].
Let us analyze the convergence rate. Let [a,b] be an interval. After k steps the interval of analysis has length 2kb−a which converges to zero for k→∞. Let us look in a neighborhood of radius δ>0, so that 2kb−a≤2δ⇔2k+1≥δb−a⇔k≥log2(δb−a)−1.
Every step reduces the error by factor 21. The convergence rate is thus linear.
Newton’s method
Assume that f∈C1. For an initial value x0, consider the iteration xk+1=xk−f′(xk)f(xk)k=0,1,….
Heuristics. If f(x∗)=0 and f∈C2, by the Taylor’s expansion, 0=f(x∗)=f(x0)+(x∗−x0)f′(x0)+2(x∗−x0)2f′′(ξ)
for ξ∈[x0,x∗], and upon neglecting the 2nd order term, x∗≈x0−f′(x0)f(x0).
Theorem. If f∈C2 and x0 is sufficiently good (i.e. close to the root x∗) and if f′(x∗)=0, then Newton’s method converges quadratically.
Proof. By Taylor’s expansion, it follows that x∗=xk−f′(xk)f(xk)−2(x∗−xk)2f′(xk)f′′(ξk)
for some ξk∈[x∗,xk]. Take xk+1 from the method and subtract, xk+1−x∗=(x∗−xk)2≤D2f′(xk)f′′(ξk).
In other words, ∣xk+1−x∗∣≤D∣xk−x∗∣2,
as k→∞ and thus xk→x∗.
Hence the method is quadratic. Note that f′(xk) does not vanish by continuity if xk is close to x∗. □
What happens if f′(x∗)=0? xk+1−x∗=(x∗−xk)22→0f′(xk)f′′(ξk)
as k→∞.
By Taylor’s expansion (η=“eta”): f′(xk)==0f′(x∗)+(xk−x∗)f′′(ηk)=(xk−x∗)f′′(ηk)
for some ηk∈[x∗,xk], and hence xk+1−x∗=f′′(ηk)=(xk−x∗)f′′(ηk)(xk−x∗). The method has degenerated to a linear method!
Sometimes it can be difficult or computationally expensive to compute the derivative f′(xk). Newton 's method can be adapted by approximating the derivative by the differential quotient. The secant method is the following two-step recursive algorithm. xk+1=xk−f(xk)−f(xk−1)f(xk)(xk−xk−1),k=1,2,…
with two distinct starting points x0=x1. The convergence rate is 21+5≈1.62, the golden ratio.
Fixed point iteration
Definition. A point x∈R is called a fixed point of φ:R→R if φ(x)=x.
We could for instance use Newton’s method to find fixed points by setting f(x):=φ(x)−x.
Banach’s Fixed Point Theorem. Suppose that φ is a contraction, that is, there exists a constant L<1 such that ∣φ(x)−φ(y)∣≤L∣x−y∣
for all x,y∈R. Then there exists a unique fixed point x∗∈R of φ, i.e., φ(x∗)=x∗, and the fixed point iteration φn:=n-timesφ∘…∘φ satisfies limn→∞φn(x0)=x∗ for any starting point x0∈R. The convergence rate is at least linear.
Proof. We prove that the sequence {φk(x0)}k=0∞={xk}k=0∞ is a Cauchy sequence. Let k>j. Then, by the triangle inequality, ∣xk−xj∣≤(k−j)-summands∣xk−xk−1∣+∣xk−1−xk−2∣+…+∣xj+1−xj∣.
Furthermore, ∣xm−xm−1∣=∣φ(xm−1)−φ(xm−2)∣≤L∣xm−1−xm−2∣≤Lm−1∣x1−x0∣.
Hence, by the geometric series, ∣xk−xj∣≤Lj1−L1−Lk−j∣x1−x0∣.
If k>N, j>N, then ∣xk−xj∣≤LN1−L1∣x1−x0∣→0
as N→∞, which proves that {xk} is a Cauchy sequence. The linear convergence rate follows also from this estimate.
The existence of a fixed point follows from the continuity of φ (as contractions are uniformly continuous, in fact, even Lipschitz continuous) as follows. x∗=k→∞limxk=k→∞limxk+1=k→∞limφ(xk)=φ(k→∞limxk)=φ(x∗). □
Theorem. Assume that φ∈Cp for p≥1. Furthermore, assume that has a fixed point x∗ and assume that φ′(x∗)=φ′′(x∗)=…=φ(p−1)(x∗)=0 for p≥2 and G′(x∗)<1 if p=1. Then the fixed point sequence {φk(x0)} converges to x∗ at least with rate p, provided that the starting point x0 is sufficiently close to x∗. If, in addition, φ(p)(x∗)=0, then the rate of convergence is precisely p.
Proof. First note that by Banach’s fixed point theorem the limit indeed converges to x∗ for suitable starting points x0. By the Taylor expansion, xk+1−x∗=φ(xk)−φ(x∗)=l=1∑p−1l!φ(l)(x∗)(xk−x∗)l+p!G(p)(ξk)(xk−x∗)p
for some ξk between x∗ and xk. The sum will be left empty for the case p=1. Since φ(l)(x∗)=0 for 1≤l≤p−1, we get that ∣xk+1−x∗∣=p!∣φ(p)(ξk)∣∣xk−x∗∣p.
By continuity, there exists C>0 (with C<1 for p=1) such that p!∣φ(p)(ξk)∣≤C for ξk sufficiently close to x∗ (that is, for sufficiently large k). Thus, ∣xk+1−x∗∣≤C∣xk−x∗∣p
for large k, and thus the rate of convergence is at least p. Note that for p=1, this also proves convergence by ∣xk+1−x∗∣<<1∣φ(ξk)∣∣xk−x∗∣.
If φ(p)=0, then by continuity, there exists K>0 such that p!∣φ(p)(ξk)∣≥K
for ξK sufficiently close to x∗. Thus ∣xk+1−x∗∣≥K∣xk−x∗∣p
which implies that the rate of convergence cannot be higher than p. Thus the rate of convergence is precisely p. □
Note. From the above proof, we expect that close to the fixed point x∗ ∣xk+1−x∗∣≈p!∣φ(p)(x∗)∣∣xk−x∗∣p,
when φ′(x∗)=φ′′(x∗)=…=φ(p−1)(x∗)=0,
but φ(p)(x∗)=0.
Polynomial interpolation
Idea. Approximate a function f:R→R over [a,b] by a polynomial p such that in distinct data points (xi,yi), i=0,1,…,n, the approximation is exact, that is, f(xi)=yi=p(xi),for alli=0,1,…,n.
We may call xinode and yivalue.
We need at least 2 data points. We usually just assume that xi=xj for i=j.
Note. Interpolation polynomials are not per se unique, for instance the data {(−1,1),(1,1)} can be interpolated by p(x)=1, q(x)=x2, or r(x)=x4−x2+1. However, we will see later that p is the unique interpolation polynomial with degp≤1=n.
Example.(1,2), (2,3), (3,6), as data set {(xi,yi):i=0,1,2} on the interval [1,3].
We are looking for a polynomial p2(x)=∑j=02cjxj, which is chosen to be 2nd order, because we have 3 data points and 3 unknown coefficients.
We can formulate the problem in matrix form: ⎝⎛111x0x1x2x02x12x22⎠⎞⋅⎝⎛c0c1c2⎠⎞=⎝⎛y0y1y2⎠⎞,
which is a so-called Vandermonde matrix which has determinant det⎝⎛111x0x1x2x02x12x22⎠⎞=i<j∏(xj−xi)=0, and is thus invertible. Here, ⎝⎛111123149⎠⎞⋅⎝⎛c0c1c2⎠⎞=⎝⎛236⎠⎞.
As a result, c0=3, c1=−2, and c2=1, and thus, p2(x)=x2−2x+3.
The computational complexity of solving the linear system is O(n3). We used the natural basis for the polynomials. What would be the ideal basis? Definition. (Lagrange basis polynomials) Suppose that xi=xj if i=j. We call ϕi(x):=j=0i=j∏nxi−xjx−xj
the ith Lagrange basis polynomial.
The Lagrange interpolation polynomial is given by p(x):=i=0∑nyiφi(x).
Evaluating the Lagrange polynomials has the computational complexity O(n2).
Newton’s interpolation
Idea. Extend the natural basis: 1,x−x0,(x−x0)(x−x1),…,j=0∏n−1(x−xj).
Definition. Define Newton’s interpolation polynomials by pn(x)=a0+a1(x−x0)+…+anj=0∏n−1(x−xj)
in such a way that pn(xi)=yi.
Clearly, p(x0)=y0⇒a0=y0,
and p(x1)=a0+a1(x1−x0)=y1⇒a1=x1−x0y1−a0.
More generally, we have the lower triangular linear system ⎝⎛111⋮10x1−x0x1−x0⋮x1−x0⋯0(x2−x0)(x2−x1)⋮(x2−x0)(x2−x1)⋯0⋮⋯⋯∏j=0n−1(xn−xj)⎠⎞⎝⎛a0a1a2⋮an⎠⎞=⎝⎛y0y1y2⋮yn⎠⎞.
Example.p2(x)=a0+a1(x−1)+a2(x−1)(x−2) with the system ⎝⎛111012002⎠⎞⋅⎝⎛a0a1a2⎠⎞=⎝⎛236⎠⎞
and hence a0=2, a1=1, and a2=1 which yields p2(x)=x2−2x+3.
Uniqueness
Theorem. Interpolation polynomials with n+1 nodes xi, i=0,1,…,n are unique in the class of polynomials q with degq≤n.
Proof. (Idea). pn has at most n roots. Let pn and qn be two interpolating polynomials for the same set of data. Then pn(xj)=qn(xj)=0,for anyj=0,1,…,n.
Hence pn−qn has n+1 distinct roots. As deg(pn−qn)≤max(degpn,degqn)=n, the only polynomial with n+1 roots is the polynomial which is constantly zero. Hence, pn=qn.
We have used the corollary to the fundamental theorem of algebra which states that every non-constant real polynomial of degree m has at most m zeros. □
Divided differences
Let p be a Newton interpolation polynomial p(x)=a0+a1(x1−x0)+a2(x−x2)(x−x1)+…+anj=0∏n=1(x−xj).
Definition. The divided difference of order k, denoted by f[x0,x1,…,xk], is defined as the ak-coefficient of the Newton interpolation polynomial with data yi=f(xi), in other words, f[x0,x1,…,xk]:=ak.
One point: f[xj]=fj=yj.
Two points: f[xi,xj]=xj−xif[xj]−f[xi] which is the line spanned by the two points (xi,yi) and (xj,yj), i.e., y−yi=xj−xiyj−yi(x−xi).
Proof. (Idea). We have three interpolation polynomials p, q, r, where degp=k, degq=degr=k−1. p interpolates at x0,x1,…,xk, q interpolates at x0,x1,…,xk−1, and r interpolates at x1,…,xk. Claim. p(x)=q(x)+xk−x0x−x0=0forxi(r(x)−q(x)). x0: p(x0)=q(x0)=f0. x1,…,xk−1: p(xi)=q(xi). xk: p(xk)=q(xk)+=1xk−x0xk−x0(r(xk)−q(xk)=r(xk).
The highest order term has the coefficient k!p(k)(x)=xk−x0rk−1−qk−1,
where rk−1=f[x1,x2,…,xk]=(k−1)!r(k−1) and qk−1=f[x0,x2,…,xk−1]=(k−1)!q(k−1),
which can be proved by the general Leibniz rule. □
Interpolation error
Assume that f∈Cn+1. We are interested in the local (pointwise) error (residual) R(x):=f(x)−p(x),
where p is the interpolation polynomial with degp=n.
Fix data (xi,yi), yi=f(xi), i=0,1,…,n, xi=xj, i=j. Let x′ be an distinct extra point.
Define an auxiliary function: h(x)=f(x)−p(x)−cw(x),
where w(x)=j=0∏n(x−xj)
and c=w(x′)f(x′)−p(x′).
We find that h(xi)=0fori=0,1,…n.
Furthermore, h(x′)=f(x′)−p(x′)−w(x′)f(x′)−p(x′)w(x′)=0.
Hence h has n+2 distinct zeros. By Rolle’s theorem (see Differential and Integral Calculus 1), h(n+1) will have at least one zero. Let’s call this point ξ. h(n+1)(x)=f(n+1)−=0p(n+1)(x)−cw(n+1)(x)=f(n+1)(x)−c(n+1)!
Hence h(n+1)(ξ)=f(n+1)(ξ)−c(n+1)!=0
and thus c=(n+1)!f(n+1)(ξ).
We have proved that:
Theorem. If f∈Cn+1, the residual R=f−p at x has the form R(x)=(n+1)!f(n+1)(ξ)j=0∏n(x−xj).
Notice that, in general, R is not a polynomial, as ξ=ξ(x) depends nonlinearly on x.
Note. The constant c is a divided difference: f[x0,x1,…,xn,x]=(n+1)!1f(n+1)(ξ(x)),
which follows from the formula for R, R(n+1)=f(n+1) and R(xi)=f(xi) for i=0,1,…,n.
Piecewise interpolation
Setup. Fix a bounded interval [a,b] and a step size / mesh h:=nb−a
for some n∈N, where n is the number of subintervals.
Idea. Approximate the function on each subinterval using some low order interpolation polynomial such that the interpolation function is exact at the nodes.
Piecewise linear case: ℓi(x)=f(xi−1)xi−1−xix−xi+f(xi)xi−xi−1x−xi−1,x∈[xi−1,xi].
By the residual formula on each subinterval R(x)=(n+1)!f(n+1)(ξ)∏j=0n(x−xj), we get the interpolation error f(x)−ℓi(x)=2!f′′(ξ)(x−xi−1)(x−xi),
which simplifies if ∣f′′(x)∣≤M by maximization as follows ∣f(x)−ℓi(x)∣≤M8h2,x∈[xi−1,xi].
Note. If f′′ is bounded over the whole interval [a,b] then the error is the same over the whole interval.
Hermite interpolation
Piecewise interpolation by degree 3 polynomials p3(x)=∑j=03cjxj. As we have 4 coefficients, we need 4 constraints. We demand that not only the function but also the derivatives are exact at the nodes. Let p be a cubic interpolation polynomial on [xi−1,xi]. Then p′ is a quadratic polynomial. Recall that h=xi−xi−1.
We have the conditions:
p(xi−1)=f(xi−1),
p(xi)=f(xi),
p′(xi−1)=f′(xi−1),
p′(xi)=f′(xi).
Set p′(x)=f′(xi−1)xi−1−xix−xi+f′(xi)xi−xi−1x−xi−1+α(x−xi−1)(x−xi).
Integrating yields p(x)=−hf′(xi−1)∫xi−1x(t−xi)dt+hf′(xi)∫xi−1x(t−xi−1)dt+α∫xi−1x(t−xi−1)(t−xi)dt+C.
Plugging in xi−1 for x yields that C=f(xi−1). Plugging in xi for x and integrating yields α=h33(f′(xi−1)+f′(xi))+h36(f(xi−1)−f(xi)).
Splines
Let us construct a global piecewise interpolation function s∈C2 such that:
We do not impose exactness for derivatives.
We get a piecewise polynomial construction of cubic interpolation polynomials which is exact and has continuous 1st and 2nd derivatives.
This requires a global setup. All coefficients are defined first, only evaluation is piecewise. Setup. Let h=xi−xi−1 be constant. Define zi:=s′′(xi),i=1,…,n−1.
Now, s′′(x)=h1zi−1(xi−x)+h1zi(x−xi−1).
Denote s on the interval [xi−1,xi] by si. Integrating twice yields si(x)=h1zi−16(xi−x)3+h1zi6(x−xi−1)3+Ci(x−xi−1)+Di,
where si′(x)=−h1zi−12(xi−x)2+h1zi2(x−xi−1)2+Ci.
Set fi:=f(xi). We get that Di=fi−1−6h2zi−1
and Ci=h1[fi−fi−1+6h2(zi−1−zi)].
Now s has been defined over all subintervals. However, the zi are still unknown!
Using the condition for continuity of the derivatives si′(xi)=si+1′(xi) for all i yields 2hzi+h1[(fi−fi−1)+6h2(zi−1−zi)]=−2hzi+h1[(fi+1−fi)+6h2(zi−zi+1)],
for i=1,…,n−1.
In fact, this constitutes a triangular system: 32hzi+6hzi−1+6hzi+1=h1(fi+1−2fi+fi−1)=:bi.
The values z0 and zn at the interval boundary have to be moved to the right hand side, and thus: b1:=h1(f2−2f1+f0)−6hz0
and bn−1:=h1(fn−2fn−1+fn−2)−6hzn. z0 and zn can be chosen freely, for example to force that the 1st derivative of the spline is exact at the interval boundary points. If z0=zn=0, s is called a natural spline.
Bézier curves
Bézier curves are parametrized curves in R2, that is, r(t)=x(t)i+y(t)j,
where i:=(10), j:=(01) and x,y:[0,1]→R.
Bernstein polynomials
Define the Bernstein polynomialBkn(t), t∈[0,1], n∈N∪{0}, k=0,…,n, by Bkn(t):=(kn)tk(1−t)n−k.
Properties:
∑k=0nBkn(t)=1 (=(t+1−t)n),
0≤Bkn(t)≤1,
B0n(0)=Bnn(1)=1, otherwise, if k=0, Bkn(0)=0 and if k=n, Bkn(1)=0.
We have the combinatorial rule: Bkn(t)=(1−t)Bkn−1(t)+tBk−1n−1(t).
Bézier curves
Fix a finite set X={x0,x1…,xk} of control points xi∈Rn.
Definition. The convex hull of X is defined by conv(X)={y∈Rn:y=k=0∑kλixi,λi∈[0,1],k=0∑kλi=1}.
Definition. The Bézier curve βn is defined, βn(t)=k=0∑nxkBkn(t).
Sanity check: t=0, Bkn(0)=0, except B0n(0)=1. ⇒βn(0)=x0, ⇒βn(1)=xn.
We get closed curves if x0=xn.
What about the continuous tangents?
Recall that (kn)=k!(n−k)!n!. dtdBkn(t)=(kn)(ktk−1(1−t)n−k−(n−k)tk(1−t)n−k−1) =n[(k−1)!(n−k)!(n−1)!tk−1(1−t)n−k−(k)!(n−k−1)!(n−1)!tk(1−t)n−k−1] =n(Bk−1n−1(t)−Bkn−1(t)).
Therefore, dtdβn(t)=nk=0∑n(Bk−1n−1(t)−Bkn−1(t))xk =n[k=1∑nBk−1n−1(t)xk−k=0∑n−1Bkn−1(t)xk] =n[k=0∑n−1Bkn−1(t)xk+1−k=0∑n−1Bkn−1(t)xk] =Beˊziernk=0∑n−1(xk+1−xk)Bkn−1(t).
Hence, for the closed curves: {dtdβn(0)=n(x1−x0),dtdβn(1)=n(xn−xn−1).
For smoothness, we need that (x1−x0)∥(xn−xn−1), i.e., x1−x0 and xn−xn−1 are parallel.
Lifting
Control points define the curve but the converse is not true.
Consider: βn(t)=k=0∑nBkn(t)xk=k=0∑n+1Bkn+1(t)yk=αn+1(t).
Let us use the convention x−1=xn+1=0. We get the condition yk=(1−n+1k)xk+n+1kxk−1.
De Casteljau’s algorithm
For control points x0,x1,…,xn the algorithm of De Casteljau is as follows:
Define constant curves βi0(t)=xi.
Set βir(t)=(1−t)βir−1(t)+tβi+1r−1(t),r=1,…,n,i=0,…,n−r. Th
The algorithm terminates at β0n(t) and has (2n) operations.
There is also a reverse algorithm for splitting Bézier curves.
Numerical integration
Integration schemes are called quadratures. Therefore, numerical integration methods are simply called numerical quadratures.
Note. There are no simple integration schemes in higher dimensions. Already 2D-cases are complicated.
Newton-Cotes quadrature rules
Let f:[a,b]→R. Idea. Approximate ∫abf(x)dx=:I by the integral of an interpolation polynomial I≈∫abpk(x)dx=:Q(pk),
where pk is an interpolant of f over [a,b].
Let n=1: p1(x)=f(a)a−bx−b+f(b)b−ax−a,
so ∫abf(x)dx≈∫abp1(x)dx=2b−a[f(a)+f(b)]. ⇒ Trapezoidal rule!
Error formulation: ∫abf(x)dx−∫abp1(x)dx=21∫abf′′(ξ)(x−a)(x−b)dx.
Now, (x−a)(x−b)<0 for x∈(a,b).
Therefore, by the mean value theory of integration, =21f′′(η)∫ab(x−a)(x−b)dx. =−121(b−a)3f′′(η).
Composite rule:h=nb−a, xi=a+ih, i=0,…,n. ∫abf(x)dx≈2h[f(x0)+2f(x1)+…+2f(xn−1)+f(xn)].
Total error: O(h2)∼O(n21). We say that the method is quadratic.
Let n=2. When is a method exact for degree 2 (or lower)?
Note. In this context, exactness means, that the integral and the method give the exact same result for
polynomials of certain order.
∫abf(x)dx=A1f(a)+A2f(2a+b)+A3f(b),
where we call the Aiweights. ∫ab1dx=b−a⇒A1+A2+A3=b−a. ∫abxdx=2b2−a2⇒A1a+A2(2a+b)+A3b=2b2−a2. ∫abx2dx=31(b3−a3)⇒A1a2+A2(2a+b)2+A3b2=31(b3−a3).
Thus, A1=A3=6b−a
and A2=64(b−a).
As integrals and the methods are linear, this extends to all polynomials of deg≤2.
This is the so-called Simpson’s rule: ∫abf(x)dx≈6b−a[f(a)+4f(2a+b)+f(b)].
The associated composite rule becomes: ∫abf(x)dx≈6h[f(x0)+4f(x1)+2f(x2)+4f(x3)+…+4f(xn−1)+f(xn)].
Error for n=2: 4!5!1(b−a)5f(4)(η).
Error for the composite: O(h4). The method is exact for cubic polynomials!
Orthogonal polynomials
Define the inner product of two real-valued polynomials on [a,b] (depends on a and b!) by: ⟨p,q⟩=∫abp(x)q(x)dx.
The associated norm on [a,b] is given by ∥q∥:=(∫ab∣q(x)∣2dx)1/2. Definition. Two non-zero polynomials are said to be orthogonal on [a,b] if their inner product is zero. They are said to be orthonormal if they are orthogonal and have both norm 1.
In other words, orthogonality: ⟨p,q⟩=0, then we write p⊥q.
Orthonormality: p⊥q and ⟨p,p⟩=1=⟨q,q⟩.
Gram-Schmidt (GS) procedure. Idea. Transform a basis to an orthogonal one: {1,x,x2,…,xk,…}⟶{q0,q1,…,qk,…},orthonormal.
Note. The GS procedure depends on the inner product, and thus, here, on a and b.
The elements of the orthonormal basis are called orthogonal polynomials.
q0=∥1∥1=(∫ab12dx)1/21=b−a1.
For j=1,2,…, q~j(x)=xqj−1(x)−i=0∑j−1⟨xqj−1,qi⟩qi(x), and qj(x):=∥q~j∥q~j.
The new basis is (pairwise) orthonormal!
Above, as usually, we denote the polynomial p(x)=x with the symbol x.
Observation. By bilinearity, qj−1 is orthogonal to all polynomials of deg≤j−2.
Thus, ⟨xqj−1,qi⟩=⟨qj−1,xqi⟩=0,i≤j−3.
As a consequence, the GS procedure reduces to q~j(x)=xqj−1(x)−⟨xqj−1,qj−1⟩qj−1(x)−⟨xqj−1,qj−2⟩qj−2(x)
which is a three-term recurrence rule!
Note. The trick ⟨xqj−1,qi⟩=⟨qj−1,xqi⟩ relies heavily on the fact that the inner product is defined by an integral and that we are dealing with polynomials. The GS procedure works generally in pre-Hilbert spaces, however, then we do not expect this kind of simplification.
Claim. The GS procedure works. Proof. ⟨q~j,qj−1⟩=⟨xqj−1,qj−1⟩−i=0∑j−1⟨xqj−1,qi⟩=0except wheni=j−1, then it is=1⟨qi,qj−1⟩ =⟨xqj−1,qj−1⟩−⟨xqj−1,qj−1⟩=0. □
Gauss quadrature
Idea. Choose the nodes and the weights simultaneously.
One interval: ∫abf(x)dx=A0f(x1)+A1f(x1),
with weightsA0, A1, and nodesx0, x1, for n=1, this is a (n+1)=2-rule.
The coefficients are determined by the usual process: ∫ab1dx=b−a=A0+A1. ∫abxdx=2b2−a2=A0x0+A1x1. ∫abx2dx=31(b3−a3)=A0x02+A1x12.
The resulting system is nonlinear!
Let us use the orthogonal polynomials in the following way.
Theorem. Let x0,x1,…,xn be the roots of an orthogonal polynomial qn+1 on [a,b] of degree n.
Then ∫abf(x)dx≈i=0∑nAif(xi),
where Ai:=∫abφi(x)dx,φi(x)=j=0j=i∏nxi−xjx−xj,
is exact for all polynomials of degree 2n+1 or less.
Proof. Let f be a polynomial with degf=2n+1. By the polynomial division algorithm, f=qn+1pn+rn,
where degpn≤n and degrn≤n. Then, f(xi)==0qn+1(xi)pn(xi)+rn(xi)=rn(xi).
Integrate, ∫abf(x)dx==⟨qn+1,pn⟩=0∫abqn+1(x)pn(x)dx+∫abrn(x)dx =∫abrn(x)dx=i=0∑nAirn(xi)=i=0∑nAif(xi).
Because rn can be interpolated exactly with n+1 nodes. The last equality follows from the reasoning before. □
We can extend the notion of orthogonal polynomials to so-called weighted orthogonal polynomials with respect to the inner product ⟨p,q⟩w=∫abp(x)q(x)w(x)dx,
where w is a positive weight function.
One (mathematical) advantage: Works also on R=(−∞,∞).
Example. If w(x)=e−x, we get the so-called Laguerre polynomials. If w(x)=e−2x2, we get the so-called Hermite polynomials, which are meaningful in probability theory (the weight is the density of the Gaussian normal distribution up to multiplication by a normalization constant).
Theorem. The previous theorem holds a ⟨⋅,⋅⟩w-orthogonal polynomial qn+1 with Ai:=∫abφi(x)w(x)dx,φi(x)=j=0j=i∏nxi−xjx−xj.
Error formula.(n+1)-point rule with nodes x0,x1,…,xn: error=(2(n+1))!f(2(n+1))(ξ(x))j=0j=i∏n(x−xj)2. Where does the square come from?
We assume that the derivatives of f are continuous, therefore Hermite interpolation is the natural choice.
Example. Gauss rule on [−1,1], n=1. Notice, since we only want the roots, there is no need to normalize q~i, i=0,1,2. GS: q~0=1. q~1=x⋅1−⟨1,1⟩⟨x,1⟩⋅1=x−∫−111dx∫−11xdx⋅1=x,
where ⟨1,1⟩=2, and ⟨x,1⟩=0. q~2=x⋅x−⟨1,1⟩⟨x2,1⟩⋅1−⟨x,x⟩⟨x2,x⟩⋅x=x2−31,
where ⟨x,x⟩=⟨x2,1⟩=32 and ⟨x2,x⟩=0.
The resulting orthogonal polynomials on [−1,1] are called Legendre polynomials. q~2 (and q2) has the roots x=±31.
The associated Newton quadrature rule is: ∫−11f(x)dx=A0f(−31))+A1f(31).
Let us check exactness: ∫−111dx=2=A0+A1. ∫−11xdx=0=3−A0+3A1.
From this, we obtain easily that A0=A1=1. This weights could of course also been determined by integrating the Lagrange polynomials over [−1,1]. ∫abx2dx=32=1⋅(−31)2+1⋅(31)2. ∫abx3dx=0=1⋅(−31)3+1⋅(31)3.
Thus, the Newton quadrature is indeed exact up to degree 2n+1=3!
Probabilistic examples
Monte Carlo integration
Let Xi, i∈N, be i.i.d. (independent, identically distributed) random variables with meanμ and varianceσ2. Then for the arithmetic mean (also called Césaro sum) AN:=N1i=1∑NXi.
By the law of large numbers, we have almost surely N→∞limAN=μ.
We have that var(AN)=N21i=1∑Nvar(Xi)=Nσ2.
In order to get the right unit, we have to consider the standard deviation σ(AN)=Nσ. Consequence:
If our integration problem can be cast into an averaging problem, the convergence rate will be O(N1).
Note. The rate is independent of the spatial dimension.
Example. Estimating the value of π. The area of a circle is A=πr2. Set r=1. Consider the box V=[−1,1]×[−1,1] with volume ∣V∣=4. The ratio of the areas of circle enclosed by the box and the enclosing box is 4π. Let gi={1,if p is inside A,0,otherwise. Idea: Let us sample the points pi uniformly from V. In the limit, the number of “hits” over all samples tends to the ratio of the areas!
Buffon’s needle
Suppose we doing a random experiment with a large number of needles of same length L that we throw on the floor, which has parallel strips drawn on it which have all the same distance D to their neighboring strip.
What is the probability that a dropped needle intersects with a line?
Let y be the distance from the center of the needle to the closest line and let θ be the acute angle of the intersection point.
We assume, for simplicity, L=D=1.
Both y and θ are random variables with distribution y∼Unif([0,21]),
where y=0 means that the needle is centered on a line and y=21 means that y is perfectly centered between two lines. θ∼Unif([0,2π]),
where θ=0 means that the needle is parallel to the lines and θ=2π means that the needle is perpendicular to the lines.
We may assume that y and θ are independent random variables (why?).
By the law of sines, the condition for intersection with a line is 2y≤sinθ.
The joint probability distribution of two independent random variables is the product of the respective distributions on [0,2π]×[0,21]. Determining the probability requires calculation of the ratio of the area of the condition of intersection in relation to the total area 4π.
The condition is fulfilled by 21∫02πsinθdθ=21.
Thus the probability of intersection is 21/4π=π2.
By the law of large numbers, the ratio of needles intersecting the lines with all needles converges to π2≈0.6366. Hence, we have found yet another probabilistic algorithm to determine the value of π.
Initial value problems (IVPs)
Problem. (Not necessarily linear) ordinary differential equation (ODE), with initial value y0 at initial time t0 up to a finite time horizon T>t0: {y′(t)=f(t,y(t)),y(t0)=y0.
Assumptions. Existence and uniqueness of the solutions are understood (by e.g. Picard iteration).
Let us assume that f is continuous as a function from [t0,T]×R→R and Lipschitz continuous in the following sense:
There exists L>0 such that for every y,z∈R, t∈[t0,T], ∣f(t,y)−f(t,z)∣≤L∣y−z∣.
Euler’s method
Fix a constant step size h>0.
y0:=y(t0).
tk:=tk−1+h and yk+1=yk+hf(tk,yk), k=0,1,2…,.
Applying Taylor’s formula yields: y(tk+1)=y(tk)+hy′(tk)+2h2y′′(ξk)=y(tk)+hf(tk,y(tk))+2h2y′′(ξk),
with ξk∈[a,b].
We shall deal with two types of error:
(A) truncation error (local),
(B) global error.
Notation.y(tk) denotes the exact solution to the IVP at t=tk, whereas yk denotes the result of the method at step k.
For Euler, we get that hyk+1−yk=f(tk,yk)+local errorO(h)2hy′′(ξk).
Hence the Euler method is locally (in each point) or order 1.
The method is consistent: h→0limhyk+1−yk=y′(tk)=f(tk,y(tk)).
Note that k depends on h, which we omit in the notation.
What about the global error, that is, uniform convergence on [t0,T]? max∣y(tk)−yk∣→0 as h→0?
Theorem. Assume the following:
f is Lipschitz in the second component.
max∣y′′(tk)∣≤M for some global constant M>0.
y0→y(t0) as h→0.
Then Euler’s method is uniformly convergent to the exact solution on [t0,T] and the global error is O(h).
Proof. Set dj:=y(tj)−yj.
By Taylor and Euler: dk+1=dk+h[f(tk,y(tk))−f(tk,yk)]+2h2y′′(ξk).
We get that ∣dk+1∣≤∣dk∣+hL∣dk∣+2h2M=(1+hL)∣dk∣+2h2M.
We shall need a lemma on recursive inequalities.
Lemma. If for α,β>0, γk+1≤(1+α)γk+β,
then γn≤enαγ0+αenα−1β.
Proof. Iterating the inequality yields γn≤(1+α)2γn−2+[(1+α)+1]β≤(1+α)nγ0+[j=0∑n−1(1+α)j]β.
Note that by the Taylor formula, eα=e0+e0α+2α2eξ=1+α+2α2eξ
with ξ∈[0,α].
Hence 1+α≤1+α+>02α2eξ=eα.
And thus, γn≤enαγ0+1−(1−α)1−(1+α)nβ≤enαγ0+αenα−1β. □
Returning to the proof of the theorem, we get that ∣dk∣≤ekhL∣d0∣+LhekhL−12h2M.
Now for kh≤T−t0, kmax∣dk∣≤eL(T−t0)∣d0∣+LeL(T−t0)−12hM. ∣d0∣→0 as h→0 by the 3rd assumption. Hence, the method converges uniformly with linear convergence rate. □
Quadrature. Integral formulation of the IVP: y(t+h)=y(t)+∫tt+hf(s,y(s))ds,
apply your favorite quadrature rule, for instance: 2h[f(t,y(t))+f(t+h,y(t+h))]+O(h3).
Combined, we get: yk+1=yk+2h[f(tk,yk)+f(tk+1,yk+1)].
This method is implicit. Every step requires a solution of a nonlinear (fixed point) problem.
Heun’s method and Euler’s method are explicit.
Linear multistep methods
y(tk+1)=y(tk)+∫tktk+1f(s,y(s))ds.
Adams-Bashforth (explicit)
Interpolation nodes tk,tk−1,…,tk−m+1. Polynomial pm−1. yk+1=yk+∫tktk+1pm−1(s)ds=yk+hl=0∑m−1blf(tk−l,yk−l),
where bl=h1∫tktk+1⎝⎛j=0j=l∏m−1tk−l−tk−js−tk−j⎠⎞ds.
The truncation error is O(hm).
What methods can be recovered?
For m=1, l=0, we get b0=1 and yk+1=yk+hf(tk,yk),
and thus Euler’s method!
Adams-Moulton (implicit)
Add tk+1 as an interpolation node. Interpolation polynomial qm. yk+1=yk+∫tktk+1qm(s)ds=yk+hl=0∑mclf(tk+1−l,yk+1−l),
where cl=h1∫tktk+1⎝⎛j=0j=l∏mtk+1−l−tk+1−js−tk+1−j⎠⎞ds.
The truncation error is O(hm+1).
For m=0, l=0, we get c0=1 and yk+1=yk+hf(tk+1,yk+1),
which is the so-called backward Euler method (also called implicit Euler method)!
Why do we need multistep methods?
Bad Example. y′=−15y,y(0)=1.
Exact solution y(t)=e−15t. For h=41 Euler’s method oscillates about zero.
Adams-Moulton (trapezoidal method) works!
General form.
The general form of a linear multistep method is given for s∈N by j=0∑sakyn+j=hj=0∑sbjf(tn+j,yn+j),
where as=1 (normalization) and the coefficients a0,…,as−1 and b0,…,bs determine the method.
The method is called explicit if bs=0, and implicit otherwise.
We call the multistep method consistent if the truncation error is O(h) or better.
Theorem. The linear multistep method is consistent if and only if k=0∑s−1ak=−1
and k=0∑sbk=s+k=0∑s−1kak.
If, moreover, qk=0∑skq−1bk=sq+k=0∑s−1kqak,
for every q=1,…,p then the truncation error is O(h1+p).
(Here, we follow the non-standard convention that k0=0 if k=0).
See [Ernst Hairer, Gerhard Wanner, Syvert P. Nørsett. Solving Ordinary Differential Equations I: Nonstiff Problems. Springer, 2nd ed., 1993] for a proof.
The stability of multistep methods depends on the convergence of the initial values y1,…,ys−1 to y0 as h→0. The second condition yields a global error O(hp).
Example.m=1, a0+a1=0, 0⋅a0+1⋅a1=b1, and by the normalization assumption, a1=1, a0=−1, b1=1, and thus we get, yk+1=yk+hf(tk+1,yk+1)
backward Euler!
Example. (Good bad example)
yk+2−3yk+1+2yk=h[1213f(tk+2,yk+2)−35f(tk+1,yk+1)−125f(tk,yk)].
This method satisfies the first condition. For the second condition, p=q=1, we get that −1=1213, so the second condition is not satisfied and the method is not stable. Indeed,
for y′=0,y(0)=1,
which has the explicit solution y(t)=1, we consider a small perturbation of the initial value, δ>0,
so that y0=1,y1=1+δ, y2=3y1−2y0=1+3δ, ⋯ yk=3yk−1−2yk−2=1+(2k−1)δ.
Hence, for δ∼2−53, and k=100, we get the error ∼247.
We note, however, that the method is consistent and the exact differential equation is stable (in the mathematical sense), and the perturbation yδ(t)=1+δ converges uniformly to the exact solution y(t)=1 as δ→0.
Example. (Effect of rounding error)
Returning to the proof of convergence for Euler, for the rounding error δ>0, ∣dk+1∣≤(1+hL)∣dk∣+δ,
we get, ∣dk+1∣≤eL(T−t0)initial error or uncertainty∣d0∣+dominant term, if h is sufficiently smallLheL(T−t0)−1δ
Gradient descent
The following algorithm is widely used in machine learning, together with its probabilistic counterpart, the stochastic gradient decent (SDG).
The goal is to find the minima of a function f:D→R,D⊂Rd,
which is assumed suitably regular, e.g. f∈C1(D∖∂D).
Gradient descent algorithm.
For simplicity, assume that 0∈D.
For k=0,…,N, where N∈N, iterate:
Fix initial point w0:=0∈D.
wk+1 is obtained by moving away from wk in the opposite direction of the gradient of f at wk, with step size ηk+1>0, more precisely, wk+1:=wk−ηk+1∇f(wk),k=0,1,…,N.
The constants ηk are called learning rates.
After the Nth step, we may choose different outputs, as e.g. just wˉN:=wN or wˉN:=argmink=0,…,Nf(wk).
Less obviously, one may also choose wˉN:=N+11k=0∑Nwk,
which is particularly useful for the SDG.
Definition.f:Rd→R is called convex, if for every λ∈[0,1], x,y∈Rd, f(λx+(1−λy)≤λf(x)+(1−λ)f(y).
Note that if f is convex, f(i=0∑Nλixi)≤i=0∑Nλif(xi),
for every x0,x1,…,xN∈Rd, whenever λi∈[0,1] satisfy ∑i=0Nλi=1.
Continuously differentiable convex functions f:Rd→R enjoy the so-called subgradient property, i.e. f(x)−f(y)≤⟨∇f(x),x−y⟩,x,y∈Rd,
where ⟨⋅,⋅⟩ denotes the Euclidean scalar product.
Theorem. Let f:Rd→R be convex, continuously differentiable and L-Lipschitz continuous, i.e., ∣f(x)−f(y)∣≤L∣x−y∣,x,y∈Rd.
Let R>0, N∈N. Set m:=∣w∣≤Rminf(w),ηk:=η:=LN+1R.
Then for wˉN:=N+11k=0∑Nwk,
we have that f(wˉN)−m≤N+1RL.
Note. The point wˉN is doubly dependent on N; not only through the number of steps, but also through the choice of η.
Remark.
Assume that f has a global minimum in w∗∈Rd. Then, the above result ensures the convergence of f(wˉN) to the minimum f(w∗), provided that R≥∣w∗∣. Indeed, the claimed estimate, together with f(wˉN)−f(w∗)≥0 yields ∣f(wˉN)−f(w∗)∣≤N+1RL.
It is not guaranteed that {wˉN}N∈N converges to w∗ unless w∗ is the unique minimizer (e.g. if f is so-called strictly convex (i.e., the inequality in the definition of convexity is strict for λ∈(0,1)).
The convergence rate is sublinear unless f is so-called strongly convex (i.e., f−δ∣⋅∣2 is convex for some δ>0), which gives a linear convergence rate.
We start by proving an auxiliary result.
Lemma. Let v1,v2,…,vk+1,w∗ be a sequence of vectors in Rd, and let η>0. Setting w0=0 and wk:=wk−1−ηvkk∈N,
we get that k=0∑N⟨vk+1,wk−w∗⟩≤2η∣w∗∣2+2ηk=0∑N∣vk+1∣2.
In particular, we have that N+11k=0∑N⟨vk+1,wk−w∗⟩≤N+1RL,
for any R,L>0 such that η=LN+1R,
and ∣w∗∣≤R,∣vk∣≤L,k=1,…,N+1.
Proof. A direct computation shows (polarization identity) ⟨vk+1,wk−w∗⟩=2η1(∣wk−w∗∣2+η2∣vk+1∣2−∣wk−w∗−ηvk+1∣2)=2η1(∣wk−w∗∣2−∣wk+1−w∗∣2)+2η∣vk+1∣2.
Adding up with respect to k yields k=0∑N⟨vk+1,wk−w∗⟩=2η1k=0∑N(∣wk−w∗∣2−∣wk+1−w∗∣2)+2ηk=0∑N∣vk+1∣2.
The first term is a telescoping sum and w0=0, so that we get k=0∑N⟨vk+1,wk−w∗⟩=2η1(∣w∗∣2−∣wN−w∗∣2)+2ηk=0∑N∣vk+1∣2,
which proves the first assertion.
For the second assertion it is enough to observe that under our conditions 2η∣w∗∣2+2ηk=0∑N∣vk+1∣2≤2ηR2+2η(N+1)L2=RLN+1 □
Proof of the Theorem. Recalling that f is convex, we get that f(wˉN)=f(N+11k=0∑Nwk)≤N+11k=0∑Nf(wk).
Therefore, for any w∗∈argmin∣w∣≤Rf(w), we obtain by the Lemma, f(wˉN)−m=f(wˉN)−f(w∗)≤N+11k=0∑M(f(wk)−f(w∗))≤N+11k=0∑N⟨=:vk+1∇f(wk),wk−w∗⟩≤N+1RL. □
Ernst Hairer, Gerhard Wanner, Syvert P. Nørsett. Solving Ordinary Differential Equations I: Nonstiff Problems. Springer, 2nd ed., 1993.
Real Analysis, Wikibooks, Creative Commons BY-SA 4.0.
Stefano Pagliarani. An introduction to discrete-time stochastic processes and their applications. Lecture notes, Alma Mater Studiorum - Università di Bologna, 2024.
Harri Hakula. Numerical Analysis. Lecture transcript, Aalto University, 2021.