Defines the floating-point numbers, machine epsilon and the unit roundoff, proves the relative-error bound that every rounded operation obeys, and separates the conditioning of a problem (which no algorithm can repair) from the stability of an algorithm (which a better algorithm can).
NoteOriginal
What it means. A computer does not do arithmetic in R. It works in a finite set of numbers, and every operation lands on the nearest member of that set. The single fact worth carrying away is quantitative: in IEEE double precision each operation commits a relative error of at most 1.11×10−16, and that is all the arithmetic itself does to you. Everything else — the catastrophic loss of digits, the answer that is wrong in the third place — comes from how those tiny errors are propagated by the formula you chose, or from the problem itself being hypersensitive to its data. Keeping those two apart is the whole content of this unit.
Definition(Floating-point numbers, machine epsilon, unit roundoff)Original
Fix a base β≥2, a precisiont≥1 and exponent bounds emin≤emax. The set of normalised floating-point numbers is
F={0}∪{±mβe−t+1:βt−1≤m≤βt−1,m∈Z,emin≤e≤emax}.
Writing m in base β displays the familiar form ±(d0.d1d2⋯dt−1)β×βe with the leading digit d0=0; the condition m≥βt−1 is exactly that normalisation. A non-zero x∈F with exponent e satisfies βe≤∣x∣<βe+1, and the spacing between neighbouring elements of F in that range — one unit in the last place, ulp — is βe−t+1. The spacing is therefore not uniform: it is proportional to the magnitude, which is the defining feature of a floating-point system and the reason relative error, not absolute error, is the natural currency here.
Two numbers measure the fineness of F near 1:
the machine epsilonεM=β1−t, the gap between 1 and the next larger element of F;
the unit roundoffu=21β1−t=21εM, half that gap.
Usage differs between books and between software: some call u the machine epsilon, and some programming environments report εM under that name. This unit uses the two symbols above throughout, and every statement below is in terms of u.
Let fl:R→F be round to nearest: fl(x) is the element of F closest to x, ties broken by any fixed rule. Say x is in range if βemin≤∣x∣≤(β−β1−t)βemax, the largest element of F being (βt−1)βemax−t+1=(β−β1−t)βemax. Below the lower bound the number underflows, above the upper bound it overflows.
The IEEE-754 binary64 format ("double precision") is β=2, t=53, emin=−1022, emax=1023, so
the smallest positive normalised number is 2−1022=2.2250738585072014×10−308 and the largest finite number is (2−2−52)21023=1.7976931348623157×10308. Since 53log102=15.95, a double carries just under sixteen decimal digits.
Definition(The rounding error of one operation)Original
Let x∈R be in range. Then
fl(x)=x(1+δ)for some δ with ∣δ∣≤u.
If moreover a,b∈F, ∗ is one of +,−,×,÷ (with b=0 for ÷), and the exact value a∗b is in range, then the IEEE-754 requirement that an operation return the correctly rounded exact result gives
fl(a∗b)=(a∗b)(1+δ),∣δ∣≤u,
and likewise fl(a)=a(1+δ) with ∣δ∣≤u. This pair of statements is called the standard model of floating-point arithmetic.
Idea of the proofOriginal
Everything follows from the spacing. The numbers of F between two consecutive powers βe and βe+1 sit on a uniform grid of mesh βe−t+1. Rounding to the nearest grid point costs at most half a mesh in absolute terms; dividing that by ∣x∣≥βe turns it into a relative bound in which the exponent e cancels. The cancellation of e is the whole point: the bound is the same everywhere in range, which is why floating point is useful across three hundred orders of magnitude. The second half of the statement is then not a separate fact but a definition honoured: the hardware is required to compute a∗b exactly and then round, so the only error is the rounding already bounded.
ProofOriginal
Let x be in range; by symmetry take x>0, and let e be the integer with βe≤x<βe+1. Being in range forces emin≤e≤emax.
The grid. The elements of F with exponent e are the numbers mβe−t+1 for integers m with βt−1≤m≤βt−1. They run from βe up to βe+1−βe−t+1 in steps of βe−t+1. Two cases complete the grid. If e<emax, the next element of F is βe+1 (exponent e+1, m=βt−1), one further step along, so the whole closed interval [βe,βe+1] is covered by grid points of spacing βe−t+1. If e=emax, then βe+1∈/F, but the largest element of F is βe+1−βe−t+1 and x being in range means x does not exceed it; so x again lies in the gridded part.
Rounding cost. By step 1, x lies between two consecutive grid points of spacing βe−t+1, hence within 21βe−t+1 of the nearer one. Since fl(x) is the nearest element of all of F, it is at least as close:
∣fl(x)−x∣≤21βe−t+1.
Relative form. Divide by x and use x≥βe:
x∣fl(x)−x∣≤βe21βe−t+1=21β1−t=u.
Setting δ=(fl(x)−x)/x gives fl(x)=x(1+δ) with ∣δ∣≤u, which is the first claim.
Operations. IEEE-754 specifies that +,−,×,÷ and return the correctly rounded value of the exact mathematical result. So the computed value of a∗b is fl(a∗b) with a∗b the exact real number, and step 3 applied to that real number gives the stated bound. □
Remark(Where the hypotheses are used)Original
In range. The bound x≥βe in step 3 is the only place normalisation enters, and it is where the proof fails on underflow. Below βemin the grid stops shrinking: IEEE-754 fills that gap with subnormal numbers, multiples of βemin−t+1, so only the absolute bound ∣fl(x)−x∣≤21βemin−t+1 survives. For x=2−1080 in binary64 the nearest representable numbers are 0 and 2−1074, and the relative error of rounding is of order 1. Overflow is worse still: there is no bound at all, the result being ∞.
Round to nearest. Step 2 uses it. With truncation toward zero the error is at most a whole step rather than half, and the bound doubles to ∣δ∣≤εM=2u; the error also acquires a systematic sign, so it accumulates linearly over a long computation instead of partly cancelling.
One operation at a time. The model governs each operation separately. It says nothing about a sequence of them, and no amount of staring at it will tell you the error of a formula; that requires propagating the δ's through the formula, which is what the condition number below does.
a,b already in F. The second half assumes the operands are representable. If they are themselves rounded data the two errors compose, giving (1+δ1)(1+δ2)=1+δ1+δ2+O(u2): relative errors add to first order.
Remark(Subtraction is innocent: cancellation reveals error, it does not create it)Original
A subtraction of nearly equal numbers is often blamed for a loss of accuracy. The blame is misplaced, and sharply so.
Write F∗ for F together with the subnormals, the integer multiples of βemin−t+1 of modulus below βemin, which IEEE-754 provides.
Lemma (Sterbenz). Let β=2 and let a,b∈F be positive with 21b≤a≤2b. Then a−b∈F∗, so fl(a−b)=a−bexactly.
Proof. Take a≥b (otherwise swap and negate, which changes nothing). Let e be the exponent of b, so 2e≤b<2e+1 and b is an integer multiple of 2e−t+1. Since a≥b the exponent of a is some ea≥e, so a is a multiple of 2ea−t+1, hence of 2e−t+1; so is the difference. The hypothesis a≤2b gives 0≤a−b≤b<2e+1. Set v=a−b and suppose v>0. Let e′ be the integer with 2e′≤v<2e′+1; then e′≤e, and v, being a multiple of 2e−t+1=2e−e′⋅2e′−t+1, is a multiple of 2e′−t+1. If e′≥emin, then v=m2e′−t+1 with 2t−1≤m<2t, a normalised element of F. If e′<emin, then v<2emin while v is a multiple of 2e−t+1 and e≥emin, so v is a multiple of 2emin−t+1: a subnormal. Either way v∈F∗, and v=0 is in F trivially. □
So when two close numbers are subtracted, the subtraction itself is error-free. What happens is that the errors already present in the operands, which were small relative to the operands, are now large relative to the much smaller difference. The worked example below shows this happening digit by digit: the square root is rounded, the subtraction is exact, and the answer is wrong in the third decimal place.
Definition(Conditioning of a problem, stability of an algorithm)AdaptedAdapted from Strauss (2008), §1.5, the stability requirement for well-posedness and the ill-conditioned matrix with a very small eigenvalue, pp. 26-27
Regard a problem as a map f:X→Y from data to answer. Its relative condition number at x measures how much a relative perturbation of the data is magnified in the answer:
For a differentiable scalar f with f(x)=0 this is κf(x)=∣xf′(x)∣/∣f(x)∣. A problem is ill-conditioned when κf is large; Strauss (Strauss (2008), §1.5, p. 27) introduces the word for the matrix case, where the data are the right-hand side of Au=b and a very small eigenvalue of A magnifies a perturbation of b (the matrix condition number ∥A∥∥A−1∥ is treated in Matrix norms and condition numbers). Conditioning is a property of the problem: it is there before any algorithm is chosen, and no algorithm removes it, because the data themselves are only known to within a rounding.
An algorithm is a second map f~:X→Y, the one the machine actually computes. It is backward stable if for every x there is a nearby x~ with
f~(x)=f(x~),∥x∥∥x~−x∥=O(u):
the computed answer is the exact answer to a slightly different question. Backward stability is a property of the algorithm, and two algorithms for the same problem can differ in it completely. The two notions combine in one inequality, proved by the definition of κf: if f~(x)=f(x~) with relative backward error η, then
∥f(x)∥∥f~(x)−f(x)∥≤κf(x)η+o(η).
Forward error ≲ condition number × backward error. A large forward error therefore has exactly two possible causes, and the inequality tells you which: either κf is large, in which case the problem is to blame and a different algorithm will not help, or the algorithm is unstable and should be replaced.
Remark(Rounding error and truncation error are different things)AdaptedAdapted from Riley, Hobson & Bence (2006), Ch. 27, introduction, pp. 984-985
Riley, Hobson and Bence (Riley, Hobson & Bence (2006), Ch. 27, pp. 984-985) separate two sources of numerical error, and the distinction is used throughout this part of the handbook. Rounding error comes from the finite precision with which a value is stored, and is what this unit is about; it is governed by u and does not improve when you refine a discretisation. Truncation error (also called discretisation error) comes from the approximation built into the numerical procedure itself — replacing a derivative by a difference quotient (Finite-difference approximations), an integral by a finite sum (Numerical quadrature), a function by a polynomial (Polynomial and spline interpolation) — and it shrinks as the step h shrinks. The two run in opposite directions as h→0: truncation error falls like a power of h while rounding error, divided by h or h2 in a difference quotient, grows. The optimal step is where they cross, and it is never zero.
Method(Diagnosing and curing a loss of accuracy)Original
Estimate the condition number of the problem at your data, from κf=∣xf′(x)∣/∣f(x)∣ for a scalar problem or from ∥A∥∥A−1∥ for a linear system. If κf≈10k, expect to lose k of your sixteen digits no matter what you do. Stop here if k is large: the fix is a reformulation of the problem, better data, or extended precision — not a better algorithm.
If the problem is well conditioned but the answer is bad, the algorithm is unstable. Look for the step at which a quantity much smaller than its inputs is formed. That step is where previously harmless relative errors become visible.
Remove the cancellation algebraically, using an identity that computes the small quantity directly instead of as a difference:
x+1−x=x+1+x1,1−cosx=2sin22x,ln(1+x)by its series for small x.
For the roots of ax2+bx+c, compute the root of larger modulus by the usual formula with the sign of b chosen to add, then obtain the other from the product of the roots, x1x2=c/a.
4. Reorder the arithmetic where you cannot remove the cancellation: sum a series from the small terms upward, and pivot before eliminating. Pivoting is the standard instance: Gaussian elimination with interchange (Riley, Hobson & Bence (2006), §27.3.1, pp. 995-996) reorders the equations before each elimination so that the largest remaining coefficient occupies the diagonal position, which bounds the multipliers by 1 and stops the rounding errors growing. Same problem, same arithmetic count, different stability (Solving linear systems numerically).
5. Re-run in higher precision and compare. Agreement to k digits between double and quadruple precision is evidence, not proof, that k digits are right; disagreement is proof that they are not.
Example(A well-conditioned problem that a natural formula gets wrong in the third decimal place)Original
Take the quadratic
x2−2bx+1=0,b=107,
whose roots are r±=b±b2−1 with r+r−=1. We want the small root r−. All of what follows is IEEE binary64 arithmetic.
Step 1: the problem is perfectly conditioned. Treat b as the datum. From r−=b−b2−1,
A relative perturbation of b changes r− by the same relative amount. Nothing about this problem is delicate.
Step 2: the natural formula, step by step.b=107 is in F. So is b2=1014, since 1014=214⋅514 and 514=6103515625<253; so is b2−1=99999999999999<253, and both operations are exact. The square root is not exact: its true value is
99999999999999=9999999.99999995000000000125…,
and the nearest double is
fl(b2−1)=9999999.99999994970858097076416015625,
low by 2.914×10−10. That is a relative error of 2.91×10−17, comfortably inside the guaranteed u=1.11×10−16: the square root did its job.
Step 3: the subtraction, which is exact. The operands satisfy 21b≤fl(b2−1)≤2b, so by the lemma above the subtraction commits no error at all and returns the exact difference of the two stored numbers,
which rounds to the double 5.029141902923584×10−8.
Step 4: compare. The true root, to twenty digits, is
r−=107+1014−11=5.0000000000000125×10−8.
So the computed value is wrong by 2.914×10−10 — precisely the error made in step 2, carried through unchanged — and its relative error is 5.83×10−3. Two correct digits out of sixteen, from a problem with κ=1 and an arithmetic that never erred by more than 3×10−17 relatively.
Step 5: the stable formula. Using r−=1/(b+b2−1) there is no subtraction of near-equals. The same square root, now added to b, gives the double
r−stable=5.000000000000013×10−8,
with relative error 1.02×10−16, that is 0.92u: full accuracy. The two formulas are the same function of b on paper and differ by a factor of 5.7×1013 in accuracy. That factor is the difference between an unstable algorithm and a stable one, and the condition number κ=1 is what tells us the blame lies there and not with the question.
Application(Variance, and why one-pass formulas are banned in production code)Original
Reducing a long record — a time series of temperatures, a run of detector counts, a Monte Carlo sample (Monte Carlo methods) — to a mean and a variance is the most-performed calculation in the applied sciences, and the textbook identity
s2=n−11(i∑xi2−n1(i∑xi)2)
is attractive because it needs one pass and two accumulators. It is also a subtraction of two nearly equal large numbers whenever the data have a large mean compared with their spread, which is the normal situation for an instrument reading around a baseline.
Take the five values xi=108+i, i=1,…,5, whose mean is exactly 108+3 and whose sample variance is exactly 41(4+1+0+1+4)=2.5. In binary64: ∑xi=500000015 is formed exactly, but ∑xi2 has the exact value 50000003000000055, which is not representable — 5×1016 lies in [255,256), where the spacing of F is 255−52=8 — and the machine returns the correctly rounded 50000003000000056. On the other side, (∑xi)2=250000015000000225 lies in [257,258), where the spacing is 32, and rounds to 250000015000000224; dividing by n=5 gives 50000003000000044.8, which rounds to 50000003000000048. The difference of the two stored numbers is 8, and the formula returns
snaive2=48=2.0against the true 2.5,
an error of 20% with data that are integers and a calculation with four correct inputs. The two-pass form s2=n−11∑i(xi−xˉ)2, which subtracts before squaring, returns 2.5 exactly.
The same arithmetic lies behind three familiar rules of practice: subtract a reference value from a geophysical record before computing its statistics; compute differences of total energies in molecular dynamics by accumulating the difference rather than differencing the totals; and, in least-squares fitting, avoid forming the normal-equation matrix at all. Arfken, Weber and Harris (Arfken, Weber & Harris (2013), Exercise 5.1.3, Note, p. 267) record what happens if you do: fitting a power series on [0,1] produces the Hilbert matrix Aij=1/(i+j+1), whose determinant at n=5 is already 3.7×10−12 and whose system they describe as becoming ill-conditioned and unstable. That is case 1 of the method above and not case 2 — the problem is ill-conditioned, so the cure is to change the problem, by orthogonalising the basis (General properties of orthogonal polynomials) or by solving the least-squares problem through a QR or singular-value decomposition (Singular value decomposition) instead of through the normal equations.
Bisection, Newton-Raphson and the secant method for a scalar equation, with the error recursions that give them orders 1, 2 and 1.618, the hypotheses each one needs, and the ways Newton's method fails when they are dropped.
What it means. Three algorithms, and the whole of the engineering choice between them sits in one line each. Bisection cannot fail and cannot be fast: it buys one bit per step, and you can say in advance how many steps you need. Newton is fast when it works — the number of correct digits doubles each step — and it works only near the root, needs the derivative, and fails in several instructive ways. The secant method is Newton with the derivative replaced by a difference quotient: slightly slower per step, but it costs one function evaluation instead of two, which makes it the better buy when the derivative is expensive. Production code uses all three: bracket with bisection, finish with the other two.
Definition(Roots, multiplicity, order of convergence)AdaptedAdapted from Riley, Hobson & Bence (2006), §27.2, Eqs. (27.18)-(27.19), p. 993
Let f be real-valued on an interval. A root (or zero) of f is a point ξ with f(ξ)=0. If f is m times differentiable at ξ and
f(ξ)=f′(ξ)=⋯=f(m−1)(ξ)=0,f(m)(ξ)=0,
the root has multiplicitym; a root of multiplicity 1 is simple, and simple is exactly the condition f′(ξ)=0.
An iterative method produces x0,x1,x2,…; write en=xn−ξ for the error. Suppose xn→ξ with xn=ξ for all n. The method converges with order p≥1 and asymptotic error constant C if
∣en∣p∣en+1∣⟶C∈(0,∞).
Order 1 with C<1 is called linear convergence (a fixed number of extra correct digits per step, namely −log10C of them); order 2 is quadratic (the number of correct digits doubles). Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.2, Eqs. (27.18)-(27.19), p. 993) give the corresponding criterion for a one-point iteration xn+1=F(xn) with F smooth and F(ξ)=ξ: the iteration is of order N when F′(ξ)=⋯=F(N−1)(ξ)=0. For this to match the definition above exactly one must add, in our own voice, that F(N)(ξ)=0, since otherwise the limiting constant C is zero and the order is higher than N. Either way the criterion follows by expanding F(ξ+en) in a Taylor series (Taylor's theorem). They note that the error form of the definition is the more general one, since it does not require the iteration to be a differentiable function of a single previous iterate — and indeed neither bisection nor the secant method is of that form.
Method(The three methods and their rates)AdaptedAdapted from Riley, Hobson & Bence (2006), §27.1.3 Eq. (27.9) p. 990 for (a), §27.1.4 Eqs. (27.10)-(27.11) pp. 990-991 for (b), and §27.2 pp. 992-994 for the order of convergence; Kreyszig (1978), §5.1, Problem 15, pp. 305-306 for the local hypothesis in (b). Part (c) is our own: neither source treats the unbracketed secant method
(a) Bisection. Let f be continuous on [a,b] with f(a)f(b)<0. Put [a1,b1]=[a,b] and, for n≥1,
The test must be the non-strict one. If a midpoint lands exactly on a root, so that f(xn)=0, the rule then keeps that point as the new right-hand endpoint and the bracket never loses it; with < in its place the rule would throw the root away and the conclusion below would be false (take f(x)=x−21 on [0,1], where x1=21 is the root and the strict test sends the bracket off to 1).
Then an↑ξ and bn↓ξ for a limit ξ with f(ξ)=0, and for every n
∣xn−ξ∣≤2nb−a.
The bound is known before the computation starts: reaching a tolerance τ takes n=⌈log2((b−a)/τ)⌉ steps and n evaluations of f.
(b) Newton-Raphson. Let ξ be a simple root of f and let f be twice continuously differentiable on a closed interval I containing ξ in its interior. There is a δ>0 such that for every starting point x0 with ∣x0−ξ∣≤δ the iteration
xn+1=xn−f′(xn)f(xn)
is well defined, stays in [ξ−δ,ξ+δ] and converges to ξ, with
en2en+1⟶2f′(ξ)f′′(ξ).
The order is therefore 2 whenever f′′(ξ)=0, and better than 2 when f′′(ξ)=0.
(c) Secant method. Under the same hypotheses on f and ξ, there is a δ>0 such that for distinct x0,x1 in [ξ−δ,ξ+δ] the iteration
xn+1=xn−f(xn)f(xn)−f(xn−1)xn−xn−1
is well defined and converges to ξ, with
enen−1en+1⟶2f′(ξ)f′′(ξ),
and the errors satisfy K∣en∣≤θFn for constants K>0 and θ<1, where F0=F1=1 and Fn+1=Fn+Fn−1 are the Fibonacci numbers. If in addition ∣en+1∣/∣en∣p→C∈(0,∞) for some p, then
p=21+5=1.6180339887…
and C=∣f′′(ξ)/2f′(ξ)∣p−1. Each step costs one new evaluation of f and none of f′. Part (c) is not taken from either source — Riley, Hobson and Bence treat only the bracketed chord method of their §27.1.2, and Kreyszig's problems concern one-point iterations — and the proof below establishes it in full.
Idea of the proofOriginal
All three are one idea applied three times: replace f near the current guess by something whose root you can write down, and take that root as the next guess.
Bisection replaces f by its sign alone. One bit of information per evaluation, and a bracket that is never lost — which is why its error bound is a theorem rather than a hope.
Newton replaces f by its tangent at xn. Taylor's theorem says the tangent misses f by a term in en2, and dividing that miss by the slope converts it directly into the next error: one squaring per step.
The secant method replaces f by the line through the last two points. That line misses f by a term in enen−1 rather than en2, so each step multiplies two old errors instead of squaring one. Taking logarithms turns the recursion ∣en+1∣∼K∣en∣∣en−1∣ into the Fibonacci recursion, and the golden ratio appears because that is how fast the Fibonacci numbers grow.
The bracket survives. We show inductively that f(an)f(bn)≤0 for every n; it holds at n=1 because f(a)f(b)<0. Suppose it holds at n. If f(an)f(xn)≤0, the rule puts [an+1,bn+1]=[an,xn] and the invariant is the test itself. Otherwise f(an)f(xn)>0, and multiplying the inductive hypothesis f(an)f(bn)≤0 by this positive number gives f(an)2f(xn)f(bn)≤0; since f(an)=0 this forces f(xn)f(bn)≤0, which is the invariant for [an+1,bn+1]=[xn,bn]. In either case the half kept is one across which f does not keep a strict sign. The inequality has to be the non-strict one from here on: as soon as some f(xn) vanishes the product is 0 rather than negative, and that is exactly the case the rule must not discard.
The lengths. By construction bn+1−an+1=21(bn−an), so bn−an=(b−a)/2n−1.
A common limit.(an) is non-decreasing, (bn) is non-increasing, an<bn, and the gap tends to 0; so both converge to one point ξ∈[a,b], and an≤ξ≤bn for every n.
It is a root.f is continuous, so f(an)→f(ξ) and f(bn)→f(ξ). Passing to the limit in f(an)f(bn)≤0 gives f(ξ)2≤0, hence f(ξ)=0. This is the step that uses continuity, and it is the intermediate value theorem in the form we need.
The bound.xn is the midpoint of [an,bn] and ξ lies in that interval, so ∣xn−ξ∣≤21(bn−an)=(b−a)/2n.
(b) Newton-Raphson. Fix δ0>0 with J=[ξ−δ0,ξ+δ0]⊂I. Since f′ is continuous and f′(ξ)=0, shrinking δ0 makes f′ non-vanishing on J. Put
K=2minJ∣f′∣maxJ∣f′′∣<∞,
both extrema being attained because J is compact and f′,f′′ continuous.
One step, exactly. Let xn∈J. Apply Taylor's theorem with the Lagrange remainder (Taylor's theorem) to f about xn, evaluated at ξ: there is ηn between xn and ξ with
0=f(ξ)=f(xn)+f′(xn)(ξ−xn)+21f′′(ηn)(ξ−xn)2.
Rearrange into the iteration. Divide by f′(xn)=0 and use xn+1=xn−f(xn)/f′(xn):
This identity is exact; no term has been discarded. It is the whole proof, and everything else is bookkeeping.
3. Staying put. Choose δ≤δ0 with θ:=Kδ<1. If ∣en∣≤δ then ∣en+1∣≤Ken2≤Kδ∣en∣=θ∣en∣≤δ, so the iterates never leave [ξ−δ,ξ+δ], where f′ does not vanish and the next step is defined.
4. Convergence, and how fast. Multiplying step 2 by K gives K∣en+1∣≤(K∣en∣)2, so by induction K∣en∣≤θ2n→0: the error is squashed by one squaring per step, which is the doubling of correct digits. Finally xn→ξ forces ηn→ξ (it is trapped between xn and ξ) and f′(xn)→f′(ξ) by continuity, so the exact relation of step 2 gives en+1/en2→f′′(ξ)/2f′(ξ).
(c) Secant method. The tangent of Newton is replaced by a chord, and the Taylor remainder by the error of linear interpolation.
Lemma (error of a chord). Let f be twice continuously differentiable on an interval J, let u=v in J, let p be the line through (u,f(u)) and (v,f(v)), and let z∈J. Then f(z)−p(z)=21f′′(η)(z−u)(z−v) for some η∈J.
Proof of the lemma. For z∈{u,v} both sides vanish. Otherwise set Kz=(f(z)−p(z))/((z−u)(z−v)) and g(x)=f(x)−p(x)−Kz(x−u)(x−v). Then g vanishes at the three distinct points u,v,z, so by Rolle's theorem g′ vanishes at two distinct points between them and g′′ at one, say η. Since p′′≡0, g′′(η)=f′′(η)−2Kz=0. □ (This is the case n=1 of the interpolation error formula of Polynomial and spline interpolation.)
One step, exactly. Let p be the chord through (xn−1,f(xn−1)) and (xn,f(xn)), with slope sn=(f(xn)−f(xn−1))/(xn−xn−1). The secant formula says exactly that xn+1 is the root of p, so p(x)=sn(x−xn+1), and at x=ξ,
The slope is a derivative. By the mean value theorem sn=f′(ζn) for some ζn between xn−1 and xn; in particular sn=0 once both iterates are in a neighbourhood of ξ on which f′ does not vanish, so the step is defined.
Staying put, and convergence. With J, K as in part (b), step 2 gives ∣en+1∣≤K∣en∣∣en−1∣. Choose δ with θ:=Kδ<1. If ∣en−1∣,∣en∣≤δ then ∣en+1∣≤Kδ2=θδ≤δ, so all iterates stay in [ξ−δ,ξ+δ]. Writing ϵn=K∣en∣, the recursion reads ϵn+1≤ϵnϵn−1 with ϵ0,ϵ1≤θ, so by induction ϵn≤θFn where F0=F1=1 and Fn+1=Fn+Fn−1. Since Fn→∞, en→0.
Where the golden ratio comes from. The Fibonacci numbers satisfy Fn=(φn+1−(−φ)−n−1)/5 with φ=(1+5)/2, so Fn grows like φn: the number of correct digits is multiplied by φ at each step, which is the sense in which the order is φ. For the sharper statement, assume ∣en+1∣/∣en∣p→C. Then ∣en∣≈C∣en−1∣p and step 2 gives
C∣en∣p≈K∗∣en∣∣en−1∣with K∗=2f′(ξ)f′′(ξ).
Substituting ∣en∣=C∣en−1∣p on both sides,
Cp+1∣en−1∣p2≈K∗C∣en−1∣p+1.
For this to hold as ∣en−1∣→0 the exponents must agree, p2=p+1, whose positive root is p=φ; the coefficients then give Cp=K∗, that is C=K∗1/p=K∗p−1, using 1/φ=φ−1. □
Remark(Where the hypotheses are used, and how Newton fails without them)AdaptedAdapted from Riley, Hobson & Bence (2006), §27.1.4, the behaviour near a stationary point, p. 991
Bisection uses continuity and nothing else — no derivative, no smoothness, not even a formula for f. What it does need is the sign change f(a)f(b)<0, and that is a real restriction: f(x)=x2 has a root on [−1,1] and no sign change, so bisection cannot be started, while f(x)=1/x has a sign change on [−2,1] and no root, so what the method converges to need not be a root if f is discontinuous: the rule produces x1=−21, x2=41, x3=−81, x4=161,⋯→0, which is the pole and not a zero. (The bracket has to be chosen so that no midpoint is the pole itself; on [−1,1] the first midpoint is 0 and f(x1) is undefined.) Step 4 of the proof is where continuity enters and where the 1/x example breaks down. If the bracket contains several roots, bisection finds one of them and gives no warning about the others.
Newton uses f′(ξ)=0 to divide in step 2 of the proof. At a root of multiplicity m≥2 it still converges, but only linearly. Write f(x)=(x−ξ)mg(x) with g(ξ)=0; then f/f′=(x−ξ)g/(mg+(x−ξ)g′) and
so the error is multiplied by 1−1/m each step: at a double root it merely halves, and reaching 10−15 from 10−1 takes about 47 steps instead of 4. The same algebra shows the cure when m is known: iterating with xn+1=xn−mf(xn)/f′(xn) gives en+1=en2g′(xn)/(mg(xn)+eng′(xn))→en2g′(ξ)/(mg(ξ)), and quadratic convergence is restored.
Newton uses f∈C2 for the Lagrange remainder in step 1. Dropping it costs the rate and sometimes the convergence: f(x)=sign(x)∣x∣1/3 has the single root 0 and is differentiable away from it, but f/f′=3x, so Newton reads xn+1=−2xn and the iterate doubles in modulus and alternates in sign from any starting point.
Newton uses "x0 close enough", which is step 3 of the proof, and this is the hypothesis that fails in practice. Three ways:
A small derivative throws the iterate far.Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.1.4, p. 991) note that the scheme behaves badly when some xn falls near a stationary point of f, where f′(xn)≈0, and that a nearby maximum or minimum can leave the iterates hopping across the root rather than closing on it.
It can cycle. For f(x)=x3−2x+2 and x0=0: f(0)=2, f′(0)=−2, so x1=1; then f(1)=1, f′(1)=1, so x2=0. The iteration repeats 0,1,0,1,… for ever, and the only real root, −1.769292354…, is never approached.
It can converge to the wrong root, when f has several and the tangent at x0 points at a different one. Nothing in the method expresses a preference.
The contraction-mapping view explains why all of this is local: Kreyszig (Kreyszig (1978), §5.1, Problem 15, pp. 305-306) sets the exercise of showing that g(x)=x−f(x)/f′(x) is a contraction in some neighbourhood of a simple zero, so Banach's fixed point theorem (The contraction mapping theorem) applies there and says nothing anywhere else.
The secant method needs f(xn)=f(xn−1) to divide, and it keeps no bracket, so an iterate can leave the neighbourhood and never come back. Its bracketed cousin, in which the two points are always kept on opposite sides of the root — Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.1.2, Eq. (27.8), pp. 988-989) call it linear interpolation; it is also known as false position — is safe but slow, because, as they observe, when the curvature of f keeps one sign near the root one endpoint tends to stay frozen, and the convergence degrades to linear.
Floating-point arithmetic sets a floor on all three. Near a simple root the computed f carries an absolute error of roughly u times the size of the terms making it up (Floating-point arithmetic and error), so f cannot be distinguished from zero within a band of width ≈noise/∣f′(ξ)∣ around ξ, and no method can do better. For the example below the noise in f is about 1.1×10−16×18.4≈2×10−15 and ∣f′(ξ)∣=11.16, giving a floor of about 1.8×10−16. One unit in the last place at 2.09 is 2−51=4.4×10−16, so the floor sits at about 0.4 of an ulp: full double precision is attainable here, and the last bit is the only thing in doubt. At a double root the floor is 2noise/∣f′′(ξ)∣ instead, typically around 10−8: half the digits are simply not there, whatever the algorithm.
Method(Solving f(x)=0 in one variable)AdaptedAdapted from Riley, Hobson & Bence (2006), §27.1, the four schemes and the closing recommendation to combine them, pp. 985-992
Bracket first. Evaluate f on a coarse grid over the range of interest and find a pair a<b with f(a)f(b)<0. Plot f if you can; most root-finding disasters are failures to look at the function. If f has a root of even multiplicity there is no sign change, and you must bracket the minimum of ∣f∣ instead.
Bisect a few times to get inside the basin of the fast methods, say until bn−an is a per cent of the original bracket. This costs ⌈log2100⌉=7 evaluations and buys the guarantee.
Switch to a fast method.
If f′ is available cheaply and analytically, iterate xn+1=xn−f(xn)/f′(xn).
If not, iterate the secant formula from the current bracket endpoints. Never form f′ by a finite difference merely to feed Newton: that costs two evaluations per step, the same as the secant method gets two steps out of, and it introduces a truncation error the secant method does not have.
Guard the fast step. Keep the bracket [an,bn] up to date. If a proposed xn+1 falls outside it, or if the step has not at least halved, ∣xn+1−xn∣>21∣xn−xn−1∣, discard it and bisect instead. Both tests use only computed quantities; the error ∣xn−ξ∣ itself is of course not available, which is why the step length and the bracket width stand in for it. This hybrid inherits the guarantee of bisection and the speed of Newton; some combination of a bracketing method with Newton-Raphson at the end is what Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.1, p. 992) recommend for most situations.
Stop on the step, not on the residual. Terminate when ∣xn+1−xn∣≤τ(1+∣xn+1∣), with a relative tolerance τ no smaller than a few times the unit roundoff, and cap the iteration count. A small ∣f(xn)∣ on its own means nothing: it is small whenever f′ is small, whether or not xn is near a root.
Choose by cost. Per function evaluation, Newton multiplies the number of correct digits by 21/2=1.414 (two evaluations, f and f′, buy one squaring) while the secant method multiplies it by φ=1.618 (one evaluation per step). So when f′ costs about as much as f, the secant method is the more efficient of the two; Newton wins when f′ is nearly free, as it is for a polynomial evaluated by Horner's rule.
Example(The three methods on x3−2x−5=0)Original
Take f(x)=x3−2x−5, the equation Newton himself used. Then f(2)=−1<0 and f(3)=16>0, so there is a root in (2,3); and f′(x)=3x2−2≥10>0 there, so the root is unique in the interval and simple. To twenty digits,
ξ=2.0945514815423265915.
The asymptotic error constant predicted by the theorem is
Bisection on [2,3].x1=2.5, x2=2.25, x3=2.125, x4=2.0625, x5=2.09375, x6=2.109375; the errors are 0.4054, 0.1554, 0.03045, −0.03205, −0.0008015, 0.01482. They are not monotone — only the bound ∣xn−ξ∣≤2−n is — and x5 happens to be far better than x6. To guarantee 10−10 requires 2−n≤10−10, that is n≥log21010=33.22, so 34 evaluations of f.
Newton from x0=2.f(2)=−1, f′(2)=10, so x1=2−(−1)/10=2.1. Next, f(2.1)=9.261−4.2−5=0.061 and f′(2.1)=3(4.41)−2=11.23, so x2=2.1−0.061/11.23=2.0945681211041852. Continuing:
n
xn
en=xn−ξ
en/en−12
0
2
−9.4551×10−2
1
2.1
5.44852×10−3
0.60946
2
2.09456812110418522
1.66396×10−5
0.56051
3
2.09455148169819930
1.55873×10−10
0.56297
4
2.09455148154232659
1.36783×10−20
0.5629790
The last column converges to 0.5629789458, the predicted constant, and log10∣en∣=−1.02,−2.26,−4.78,−9.81,−19.86 doubles at each step. Reaching 1.6×10−10 at x3 costs three evaluations of f and three of f′; bisection needed 34 evaluations for 10−10.
Secant from x0=2, x1=3. The first step is x2=3−16×(3−2)/(16−(−1))=3−16/17=35/17=2.0588235294117647. Continuing:
n
xn
en
en/(en−1en−2)
2
2.05882352941176471
−3.5728×10−2
0.41733
3
2.08126365984502285
−1.32878×10−2
0.41075
4
2.09482414609405235
2.72665×10−4
0.57434
5
2.09454943103524732
−2.05051×10−6
0.56595
6
2.09455148122759912
−3.14727×10−10
0.5629174
7
2.09455148154232695
3.63319×10−16
0.5629794
Again the last column tends to 0.5629789458. The measured order, log∣en+1∣/log∣en∣, takes the successive values 1.596, 1.671, 1.625, 1.632, 1.623, 1.622, 1.620 as the iteration proceeds, against the predicted φ=1.6180.
The cost comparison. Reaching x6, with error 3.1×10−10, takes six evaluations of f (two to start, one per step thereafter) and none of f′. Newton reached the comparable error 1.6×10−10 at x3, also after six evaluations — but three of them were of f′. With a cubic polynomial the derivative is nearly free and the two methods tie; with an f whose derivative must be assembled by hand or by automatic differentiation, the secant method does the same work for half the code and half the cost.
Application(Wien's displacement law)Original
The spectral radiance of a black body per unit wavelength is Planck's function
Bλ(T)=λ52hc2ehc/λkBT−11.
Where does it peak? Write x=hc/(λkBT), so that λ∝1/x and Bλ∝x5/(ex−1). Setting the derivative to zero,
dxdlogex−1x5=x5−ex−1ex=0⟺5(1−e−x)=x,
so the peak is at the positive root of
g(x)=x−5+5e−x=0.
There is no closed form, which is why this calculation is a root-finding problem and has been since 1893. The root is simple: g′(x)=1−5e−x, and at a root 5e−x=5−x, so g′(x∗)=x∗−4, which is not zero unless x∗=4 — and g(4)=5e−4−1=−0.9084=0. So Newton's theorem applies.
Newton from x0=5.g(5)=5e−5=0.03368973 and g′(5)=1−5e−5=0.96631027, so
x1=5−0.966310270.03368973=4.96513569583650.
Then g(x1)=2.07153×10−5 gives x2=4.96511423175260, and g(x2)=8.03594×10−12 gives
x3=4.96511423174428,
with g(x3)=1.2×10−24: sixteen correct digits after three steps, and the errors 3.5×10−2, 2.1×10−5, 8.3×10−12, 1.2×10−24 show the doubling plainly. Bisection from the bracket [4,6] would need ⌈log2(2/(5×10−16))⌉=⌈51.83⌉=52 evaluations for the same accuracy.
The physical constant. With the SI defining values h=6.62607015×10−34Js, c=299792458ms−1 and kB=1.380649×10−23JK−1, so that hc/kB=1.4387768775×10−2mK, the Wien displacement constant is
in the green. The same equation with 5 replaced by 3 gives the peak of the spectrum per unit frequency, at a different wavelength — the two peaks disagree because a spectral density transforms with the Jacobian dν/dλ, and this is the standard trap that the root-finding step makes concrete rather than removing. Root finding of exactly this kind appears throughout physics whenever a dispersion relation, an equation of state or a transcendental eigenvalue condition has to be inverted: the quantisation condition for a finite square well, the Kepler equation E−esinE=M of orbital mechanics, whose root is simple for every eccentricity e<1 because the derivative 1−ecosE is at least 1−e>0, and the bisection-plus-Newton solvers inside every equation-of-state routine.
The unique polynomial through n+1 points, in Lagrange and Newton form, with the exact error formula that explains both its accuracy near the nodes and Runge's divergence away from them, and the cubic spline that replaces it when the nodes are many and equally spaced.
What it means. You have a function at a finite set of points — a table, a measurement, the output of an expensive code — and you want it in between. There is exactly one polynomial of degree n through n+1 points, and an exact formula for what it misses. The formula carries two lessons that pull in opposite directions. Near the nodes, and for a handful of them, polynomial interpolation is extremely accurate and underwrites almost every other method in this part: quadrature rules, finite differences and finite elements are all obtained by integrating or differentiating an interpolant. Pushed to many equally spaced nodes it fails spectacularly, and the cure is not a better polynomial but a different object: a chain of low-degree pieces glued smoothly, the spline.
Let x0<x1<⋯<xn be nodes, distinct points of an interval [a,b], and let f0,…,fn be prescribed values; when they come from a function we write fi=f(xi). A polynomial pinterpolates these data if p(xi)=fi for i=0,…,n. Write Pn for the real polynomials of degree at most n, a vector space of dimension n+1.
The Lagrange basis for the nodes is
ℓk(x)=j=0j=k∏nxk−xjx−xj,k=0,…,n,
each ℓk∈Pn with ℓk(xi)=δik; the denominators are non-zero precisely because the nodes are distinct. The Lagrange form of the interpolant is
p(x)=k=0∑nfkℓk(x).
The divided differencef[xi,xi+1,…,xi+k] is defined as the coefficient of xk in the polynomial of degree at most k that interpolates the data at the k+1 nodes xi,…,xi+k — its leading coefficient. In particular f[xi]=fi. The Newton form of the interpolant is
the monic node polynomial of degree n+1, which governs the error.
Method(Existence, uniqueness, the Newton recursion and the error)Original
Let x0,…,xn be distinct nodes in [a,b].
(i) Existence and uniqueness. For any values f0,…,fn there is exactly one p∈Pn with p(xi)=fi for every i, and it is given by either the Lagrange form or the Newton form above; the two are the same polynomial written in two bases.
(iii) The error. Suppose in addition that f is n+1 times continuously differentiable on [a,b] and fi=f(xi). Then for every x∈[a,b] there is a point ξx in the open interval spanned by x,x0,…,xn with
a product of one factor that depends only on f and one that depends only on where the nodes are put.
Idea of the proofOriginal
Uniqueness is the engine, and it is one line: two interpolants of the same data differ by a polynomial of degree at most n with n+1 roots, so they are equal. Existence is then free, because the Lagrange basis writes an interpolant down. The Newton form and its recursion are uniqueness used twice: the difference of the interpolants on x0,…,xk and on x0,…,xk−1 vanishes at the first k nodes and has degree k, so it must be the leading coefficient times (x−x0)⋯(x−xk−1) — which telescopes into the Newton form.
The error formula is Rolle's theorem counted carefully. Fix a point x away from the nodes and define the constant that would make the formula true; then the function f−p−(that constant)w has n+2 zeros, namely the n+1 nodes and x. Each application of Rolle costs one zero and gains one derivative, so after n+1 applications something of the form f(n+1)−(n+1)!(constant) has a zero, and that identifies the constant.
ProofOriginal
(i) Uniqueness. Let p,q∈Pn both interpolate the data. Then p−q∈Pn vanishes at the n+1 distinct nodes. A non-zero real polynomial of degree at most n has at most n roots, so p−q≡0. This is the only place the distinctness of the nodes is used, and it is used decisively.
Existence. Each ℓk lies in Pn, being a product of n linear factors, and ℓk(xi)=δik because the factor (xi−xi) appears in the numerator when i=k while at xi=xk numerator and denominator coincide. Hence ∑kfkℓk lies in Pn and takes the value fi at xi.
The Newton form. Let pk∈Pk interpolate the data at x0,…,xk, so pn=p and p0≡f0. The difference dk=pk−pk−1 lies in Pk and vanishes at x0,…,xk−1, because both interpolants agree with the data there. So dk has the k roots x0,…,xk−1 and degree at most k, which forces
dk(x)=ckj=0∏k−1(x−xj)
for a constant ck; comparing coefficients of xk, ck is the leading coefficient of pk, which is by definition f[x0,…,xk]. Summing p=p0+∑k=1ndk gives the Newton form.
(ii) The recursion. Let u∈Pk−1 interpolate at xi,…,xi+k−1 and v∈Pk−1 interpolate at xi+1,…,xi+k. Define
q(x)=xi+k−xi(x−xi)v(x)−(x−xi+k)u(x).
Then q∈Pk. At x=xi the first term vanishes and q(xi)=u(xi)=fi; at x=xi+k the second vanishes and q(xi+k)=v(xi+k)=fi+k; at an interior node xm with i<m<i+k both u and v equal fm, so q(xm)=fm((xm−xi)−(xm−xi+k))/(xi+k−xi)=fm. So q interpolates at all k+1 nodes, and by uniqueness it is the interpolant. Reading off the coefficient of xk on both sides gives the stated recursion, the left side being f[xi,…,xi+k] and the right (f[xi+1,…,xi+k]−f[xi,…,xi+k−1])/(xi+k−xi).
(iii) The error. If x is one of the nodes both sides vanish, so let x be none of them; then w(x)=0. Put
K=w(x)f(x)−p(x),g(t)=f(t)−p(t)−Kw(t).
g is n+1 times continuously differentiable on [a,b], since f is and p,w are polynomials.
g vanishes at the n+2 distinct points x0,…,xn (where f=p and w=0) and x (by the choice of K).
Rolle's theorem applied to each of the n+1 intervals between consecutive zeros gives n+1 distinct zeros of g′, strictly inside the interval Ix spanned by x,x0,…,xn. (This is the engine that also produces the Lagrange remainder in Taylor's theorem, and the two results coincide in the limit: running all the nodes together at one point x0 turns p into the Taylor polynomial of order n and w into (x−x0)n+1, and the formula below into the Lagrange remainder.) Repeating, g′′ has n zeros there, and after n+1 applications g(n+1) has at least one zero ξx in the interior of Ix.
Differentiate g exactly n+1 times: p(n+1)≡0 because degp≤n, and w(n+1)≡(n+1)! because w is monic of degree n+1. So g(n+1)(t)=f(n+1)(t)−K(n+1)!, and g(n+1)(ξx)=0 gives K=f(n+1)(ξx)/(n+1)!.
Substituting K back into its definition gives the formula. The bound follows by taking absolute values and maximising the two factors separately. □
Remark(Where the hypotheses are used, and Runge's phenomenon)AdaptedAdapted from Kreyszig (1978), §6.6, the remark that a single interpolating polynomial is good near the nodes but may depart badly away from them, pp. 357-358
Distinct nodes. Used in uniqueness and in the Lagrange denominators. If two nodes merge, the interpolation conditions become inconsistent (different values) or redundant (equal values); the right generalisation is Hermite interpolation, which prescribes derivatives at repeated nodes, and the spline construction below uses the two-node case of it.
f∈Cn+1. Used in steps 1 and 4 of part (iii). Without it the formula says nothing: ∣x∣ on [−1,1] is continuous and interpolated by polynomials of every degree, and the equispaced interpolants diverge.
The formula is an identity, not an estimate, but it is not a convergence theorem. As n grows, (n+1)! in the denominator races against two growing quantities: max∣f(n+1)∣ and max∣w∣. Nothing forces the race to be won. Indeed it is lost in the standard example, due to Runge. Take
f(x)=1+x21on [−5,5],
a function that is smooth on the real line, and interpolate it at n+1 equally spaced nodes. Computing the maximum of ∣f−pn∣ on a grid of 20001 points gives 1.9157 at n=10 and 59.822 at n=20: not convergence but divergence, and all of it within one spacing of the endpoints, while near the middle the interpolant is excellent. Kreyszig (Kreyszig (1978), §6.6, pp. 357-358) records exactly this behaviour — good near the nodes, badly off away from them — as the reason to prefer piecewise polynomials.
It is the node polynomial that can be controlled, not f(n+1). For the same n=20 on [−5,5], max∣w∣ is 1.1142×1011 with equally spaced nodes. Choosing instead the Chebyshev nodes, the zeros of T21 rescaled to the interval,
xi=5cos2(n+1)(2i+1)π,i=0,…,n,
makes w the monic polynomial of degree 21 of smallest maximum modulus on [−5,5], with max∣w∣=2(10/4)21=4.5475×108 (the minimax property): smaller by a factor of 245. The computed interpolation errors fall accordingly, to 0.10915 at n=10 and 0.015334 at n=20 — now decreasing with n. The nodes crowd towards the endpoints, which is precisely where the equispaced interpolant misbehaved.
Method(Cubic spline interpolation)AdaptedAdapted from Kreyszig (1978), §6.6, the definition of Y(P_n), Theorem 6.6-1 and the minimum property (6), pp. 357-360
Let P:a=t0<t1<⋯<tn=b be a partition, with hj=tj+1−tj. A cubic spline on P is a function y∈C2[a,b] whose restriction to each [tj,tj+1] is a polynomial of degree at most 3; write S3(P) for the set of them, a vector space.
(i) Existence and uniqueness (Kreyszig, Theorem 6.6-1 (Kreyszig (1978), §6.6, Thm 6.6-1, pp. 358-359)). Given values f0,…,fn and two numbers κa,κb, there is exactly one y∈S3(P) satisfying the n+3 conditions
y(tj)=fj(j=0,…,n),y′(a)=κa,y′(b)=κb.
It is found by solving for the nodal slopes kj=y′(tj), j=1,…,n−1, the tridiagonal system
with k0=κa and kn=κb known, after which y on [tj,tj+1] is the unique cubic with the values fj,fj+1 and slopes kj,kj+1 at the two ends.
(ii) Minimum curvature (Kreyszig, Eq. (6) (Kreyszig (1978), §6.6, pp. 359-360)). If f∈C2[a,b] and y is the spline of part (i) built from fj=f(tj), κa=f′(a), κb=f′(b), then
∫ab(y′′(t))2dt≤∫ab(f′′(t))2dt,
with equality if and only if f=y. Among all twice-differentiable functions through the data with those end slopes, the spline is the one of least total squared curvature — which is why a draughtsman's flexible rod, minimising its bending energy, takes a spline's shape, and why the object is named after the rod.
Idea of the proofOriginal
A cubic on one subinterval is determined by the values and the slopes at its two ends, so prescribing one slope per node already forces the pieces to agree in value and in slope at every node. The second derivative is the only thing left to arrange, and it gives one equation per interior node — exactly as many equations as there are unknown slopes. That the resulting matrix is invertible is the one analytic fact needed, and it comes free: the diagonal entry 2(hj−1+hj) beats the sum hj+hj−1 of its neighbours by a factor of two, and a strictly diagonally dominant matrix is non-singular.
The minimum property is an integration by parts. The spline's third derivative is constant on each subinterval, so integrating y′′′ against f′−y′ piece by piece produces only the differences of f−y at the nodes, and those are zero because y interpolates f. Hence y′′ is orthogonal in L2 to f′′−y′′, and Pythagoras does the rest.
ProofAdaptedAdapted from Kreyszig (1978), §6.6, the proof of Theorem 6.6-1 through the Hermite cubic and the continuity of the second derivative, and the integration by parts giving (6), pp. 358-360
(i) Work on one subinterval first. Fix j, write h=hj and s=(t−tj)/h∈[0,1].
The Hermite cubic is unique. A cubic p with prescribed p(tj),p(tj+1),p′(tj),p′(tj+1) is unique: the difference of two such cubics has double zeros at tj and at tj+1, so it is divisible by (t−tj)2(t−tj+1)2, a polynomial of degree 4; a cubic divisible by a quartic is zero.
Checking the four conditions is direct: at s=0 the values are H00=1 and H01=H10=H11=0; at s=1, H01=1 and the others vanish; and dp/dt=(dp/ds)/h with H00′(0)=H01′(0)=H11′(0)=0, H10′(0)=1, and H00′(1)=H01′(1)=H10′(1)=0, H11′(1)=1.
3. Two derivatives of the pieces. Differentiating twice in t,
Assemble. Define y on [tj,tj+1] by step 2, for every j, using one slope kj per node. By construction the pieces agree in value and in first derivative at every interior node, so y∈C1[a,b] whatever the kj. Membership of C2 is the condition that the two expressions of step 3 agree at each interior node tj, 1≤j≤n−1: the right-hand end of the piece on [tj−1,tj] against the left-hand end of the piece on [tj,tj+1],
with Δj=fj−fj−1. Multiplying by 21hj−1hj and collecting the k's on the left gives exactly the stated tridiagonal system.
5. The system is uniquely solvable. It has n−1 equations in the n−1 unknowns k1,…,kn−1, with k0 and kn known and moved to the right-hand side. In row j the diagonal entry is 2(hj−1+hj) and the off-diagonal entries are hj and hj−1, all positive, so
a contradiction. (Kreyszig (Kreyszig (1978), §6.6, p. 359) draws the same conclusion from his Theorem 5.2-1 on iterative solution under a row-sum condition; the argument above is the direct one.) So the slopes exist and are unique, and with them so is y by step 1. That proves (i).
(ii) Let f∈C2[a,b] and let y be the spline built from its values and end slopes, so that f−y vanishes at every node and f′−y′ vanishes at a and b.
Integrate by parts. Since y′′ is continuous and y′′′ exists and is continuous on the interior of each subinterval,
The boundary term vanishes because f′−y′ is zero at both ends; this is the step that uses the prescribed end slopes.
2. The remaining integral vanishes. On [tj,tj+1] the function y is a cubic, so y′′′=cj is constant there, and
where the last step used ∫y′′(f′′−y′′)=0 twice over, in the form ∫f′′y′′=∫(y′′)2. The left side is non-negative, which is the inequality.
4. Equality. Equality forces ∫ab(f′′−y′′)2=0, and since f′′−y′′ is continuous, f′′≡y′′. Then f−y is affine; it vanishes at t0 and t1, two distinct points, so f≡y. □
Remark(Why exactly two extra conditions, and which to choose)Original
The count in Theorem (i) — n+1 interpolation conditions plus 2 end conditions — is not a coincidence but the dimension of S3(P):
dimS3(P)=n+3.
To see it, build a spline left to right. Its restriction to [t0,t1] is an arbitrary cubic: 4 parameters. On each later subinterval the cubic must match the value, the slope and the second derivative inherited at the left endpoint, which fixes three of its four coefficients and leaves one free (equivalently, the constant y′′′ on that piece). That is 1 parameter for each of the remaining n−1 subintervals, so 4+(n−1)=n+3 in all. Interpolation at the n+1 nodes is n+1 independent linear conditions, so exactly two degrees of freedom remain and exactly two end conditions are needed.
Which two is a modelling choice, and the theorem above covers one of them. Clamped (or complete) splines prescribe y′(a) and y′(b), as Kreyszig does; use them when the end slopes are known, as they are when the data come from a function you can differentiate. Natural splines instead set y′′(a)=y′′(b)=0; they need no extra information and are the ones that minimise the bending integral over all interpolants rather than over those with given end slopes, but they lose accuracy near the ends, since a smooth f rarely has vanishing curvature there. Periodic splines match y′ and y′′ at the two ends and are the right choice for data on a circle. Each choice replaces the first and last rows of the same tridiagonal system.
Method(Interpolating in practice)Original
Decide how many nodes the interpolant will use at once. Few (two to six) and local: use a polynomial. Many: use a spline, or a global polynomial only if you are free to place the nodes.
If you may choose the nodes, choose Chebyshev nodes, xi=2a+b+2b−acos2(n+1)(2i+1)π, which minimise max∣w∣ and so the error bound. If the nodes are given and equally spaced, do not raise the degree: interpolate locally on a short window of nodes and move the window.
Build the Newton form, not the Lagrange form, when you will evaluate at many points. Form the divided-difference table by the recursion, column by column; there are n(n+1)/2 entries beyond the data, each costing two subtractions and a division, so about 23n2 operations once. Evaluate by nesting,
which costs n multiplications, n subtractions and n additions: 3n operations per point, against about 2n2 for the Lagrange form evaluated as written. Adding one more node costs one more column, O(n) work, with nothing rebuilt.
4. For a spline, assemble and solve the tridiagonal system. Never call a general linear solver: eliminating one subdiagonal entry costs a division and two multiply-subtracts, and back substitution three operations per row, so the whole solve is about 8n operations, against the roughly n3/3 that Kreyszig (Kreyszig (1978), §5.2, p. 307) quotes for the usual direct methods on a dense system (Solving linear systems numerically). Then store the four Hermite coefficients per subinterval and evaluate by locating the subinterval with a binary search, O(logn), followed by three multiply-adds.
5. Check the result against the error formula rather than against your expectations: compute max∣w∣ on the interval of interest, bound ∣f(n+1)∣ if you can, and compare with the observed difference at a point that is not a node. If the two disagree by orders of magnitude, a node is wrong or the data are not samples of a smooth function.
6. Never interpolate noisy data. The interpolant reproduces the noise exactly and its derivatives amplify it. Fit instead, by least squares (Orthogonal projection and least squares) or with a smoothing spline.
Example(Quadratic interpolation and a cubic spline, on the same three points)Original
Take f(x)=lnx at the three nodes x0=1, x1=2, x2=4, so
f0=0,f1=ln2=0.6931471806,f2=ln4=1.3862943611,
and estimate ln3. The exact value is 1.0986122887.
The quadratic interpolant, Newton form. The divided-difference table:
As a check, the Lagrange form at x=3 uses ℓ0(3)=(1−2)(1−4)(3−2)(3−4)=−31, ℓ1(3)=(2−1)(2−4)(3−1)(3−4)=1, ℓ2(3)=(4−1)(4−2)(3−1)(3−2)=31, giving 0⋅(−31)+0.6931471806+31(1.3862943611)=1.1552453009: the same number, as uniqueness requires.
The error, and the point ξ it names. The actual error is
The formula predicts f(3)−p(3)=3!1f′′′(ξ)w(3) with f′′′(x)=2/x3 and w(3)=(3−1)(3−2)(3−4)=−2, that is −2/(3ξ3). Solving −2/(3ξ3)=−0.0566330122 gives ξ3=11.7716971 and
ξ=2.2748164,
which does lie in (1,4), as the theorem says it must. The crude bound, with max[1,4]∣f′′′∣=2 attained at x=1, is ∣error∣≤62×2=0.667: true but twelve times too pessimistic, which is typical, since the bound maximises the two factors at different points.
The clamped cubic spline on the same data. Take n=2 with t0=1,t1=2,t2=4, so h0=1, h1=2, and clamp with the true end slopes κa=f′(1)=1 and κb=f′(4)=0.25. Here Δ1=f1−f0=0.6931471806 and Δ2=f2−f1=0.6931471806. There is one interior node, so the tridiagonal system is a single equation (j=1):
The spline's error is 1.0986122887−1.1000792648=−0.0014669761, smaller than the quadratic's by a factor of 38.6 — on the same three data points, with no new information except the two end slopes. As a check on the construction, the second derivative from the left-hand piece at t1=2 is
Application(How big does a table have to be?)Original
Before every physical calculation that uses a tabulated quantity — an opacity, an equation of state, a collision cross-section, a radiative transfer coefficient, the output of an expensive simulation sampled on a grid — someone must decide how finely to tabulate. The error formula answers that question in one line, and the answer decides the size of the file.
Suppose a function is to be tabulated at spacing h and read back by linear interpolation between the two neighbouring entries. That is the case n=1 of the error formula: on [x0,x0+h] the node polynomial w(x)=(x−x0)(x−x0−h) has maximum modulus h2/4 at the midpoint, so
∣f−p∣≤2max∣f′′∣⋅4h2=8h2max∣f′′∣.
For f=sin on [0,π], where max∣f′′∣=1, an accuracy of 10−6 needs h≤8×10−6=2.828×10−3, that is ⌈π/h⌉=1111 intervals and 1112 stored values. Evaluating the interpolant on a fine grid near x=π/2 with h=π/1111 gives a largest error of 9.995×10−7 — the bound is attained to four digits here, because f′′ is nearly constant across one interval.
Now read the same table back with a cubic through the four nearest entries, evaluating only in the central interval. Then n=3, and on that central interval w(x)=(x−x0)(x−x1)(x−x2)(x−x3) has maximum modulus at the midpoint, where the four factors are 23h,21h,−21h,−23h, giving max∣w∣=169h4. Hence
∣f−p∣≤4!max∣f(4)∣⋅169h4=1283h4max∣f(4)∣,
and for sin the same 10−6 now needs only h≤(128×10−6/3)1/4=8.082×10−2: 39 intervals and 40 stored values, with one extra entry beyond each end to supply the four-point stencil for the outermost intervals. Direct computation with h=0.0808 around x=π/2 gives a largest error of 9.984×10−7, against the predicted bound 9.990×10−7. The table shrinks by a factor of 28, at the cost of four multiply-adds instead of one per lookup — which is why almost every production table is read with a cubic rule, and why a smooth spline is used when the reader also needs derivatives, as it does when the table feeds a Newton iteration (Root finding) or a differential-equation solver (Integrators for ODEs).
The same error formula is the common ancestor of the rest of this part. Integrating the interpolant over the nodes gives the quadrature rules and their error terms (Numerical quadrature); differentiating it gives the finite-difference formulas and their truncation errors (Finite-difference approximations); and interpolating by piecewise polynomials on a mesh, exactly as the spline does, gives the shape functions of the finite element method (The finite element method).
The trapezium and Simpson rules with their exact error terms, the expansion of the trapezium error in even powers of the spacing that makes Richardson extrapolation and the Romberg table work, and the Gauss rules, whose n nodes buy exactness to degree 2n-1 because they are the zeros of an orthogonal polynomial.
What it means. An integral that has no closed form is still a number, and a quadrature rule is a recipe that returns it: sample the integrand at finitely many points and take a weighted sum. Every rule in use is got by integrating an interpolant (Polynomial and spline interpolation), so the interpolation error formula hands over the quadrature error formula, and the whole subject is the question of where to put the nodes. Two answers dominate. Keep the nodes equally spaced, which you must when the data are a table, and use many short panels: that is the trapezium and Simpson rules, and the trapezium rule turns out to have an error series in even powers of the spacing alone, which can be extrapolated away two orders at a time. Or choose the nodes freely, in which case they should be the zeros of an orthogonal polynomial, and n of them give exactness to degree 2n−1 instead of n−1: twice the return for the same number of function evaluations.
Definition(Quadrature rule, degree of exactness, interpolatory and composite rules)AdaptedAdapted from Kreyszig (1978), §4.11, the process (3) and the uniqueness argument (8)-(10), pp. 277-279
Let w be a non-negative weight function on (a,b) with ∫abw<∞ and all moments μk=∫abxkw(x)dx finite, as in General properties of orthogonal polynomials. The unweighted case is w≡1 on a bounded interval.
A quadrature rule with n nodes is a choice of distinct points x1,…,xn in [a,b] and real weightsW1,…,Wn, used as
Q(f)=i=1∑nWif(xi)≈I(f)=∫abf(x)w(x)dx.
Both I and Q are linear functionals on C[a,b], and so is the error functional
E(f)=I(f)−Q(f).
The rule has degree of exactnessd if E vanishes on every polynomial of degree at most d and not on some polynomial of degree d+1. Kreyszig regards Q as a bounded functional on C[a,b] with norm ∑i∣Wi∣, which is the point of view his convergence theorem needs.
The rule is interpolatory if its weights are
Wi=∫abℓi(x)w(x)dx,ℓi(x)=j=i∏xi−xjx−xj,
the Lagrange basis of Polynomial and spline interpolation for these nodes; equivalently, Q(f)=I(p) where p is the interpolant of f at the nodes. For any prescribed nodes these are the unique weights with degree of exactness at least n−1, because exactness on 1,x,…,xn−1 is a linear system whose matrix is a Vandermonde matrix in the distinct nodes, hence invertible.
Newton-Cotes rules are the interpolatory rules on equally spaced nodes with w≡1. A composite rule splits [a,b] into N panels of equal length and applies one short Newton-Cotes rule on each. Writing h=(b−a)/N, xj=a+jh and fj=f(xj), the two in universal use are the composite trapezium rule
T(h)=h(21f0+f1+f2+⋯+fN−1+21fN)
and, for N even, the composite Simpson rule
S(h)=3h(f0+4f1+2f2+4f3+⋯+2fN−2+4fN−1+fN).Method(The two Newton-Cotes rules and their errors)AdaptedAdapted from Riley, Hobson & Bence (2006), §27.4.1, (27.36)-(27.38), pp. 1002-1003, and §27.4.2, (27.39)-(27.40) and the error statement, p. 1004
Take w≡1 throughout this statement.
(i) One trapezium panel. If f∈C2[c,c+h] then there is a ξ∈(c,c+h) with
∫cc+hf(x)dx−2h(f(c)+f(c+h))=−12h3f′′(ξ).
The rule has degree of exactness 1.
(ii) One Simpson panel. If f∈C4[c,c+2h] then there is a ξ∈(c,c+2h) with
The rule has degree of exactness 3, one more than the degree of the parabola it integrates.
(iii) Composite trapezium. If f∈C2[a,b] there is an η∈(a,b) with
I−T(h)=−12(b−a)h2f′′(η).
(iv) Composite Simpson. If f∈C4[a,b] and N is even there is an η∈(a,b) with
I−S(h)=−180(b−a)h4f(4)(η).
Riley, Hobson and Bence state (iii) and (iv) with the mean value replaced by an average of the derivative over [a,b], in their equation (27.38) and the corresponding line for Simpson; the mean-value forms above are the same statements made exact, and are what is proved below.
Idea of the proofOriginal
Each error functional kills polynomials up to some degree, so Taylor's theorem with integral remainder, applied with exactly that many terms, writes the error as a fixed kernel integrated against a derivative of f. The kernel does not depend on f at all; it can be computed once from the rule. If it happens to have one sign — and for these two rules it does — the integral is squeezed between the extreme values of that derivative, and the intermediate value theorem produces the point ξ. The constant in front is then read off by feeding the rule a single monomial.
The extra degree of exactness in Simpson's rule, degree 3 from a parabola, is the symmetry of the panel: the error functional is even about the midpoint, so it annihilates the odd function (x−c−h)3 for free.
The composite statements follow by summing the panels and averaging: a sum of N values of a continuous function is N times one of its values.
ProofOriginal
Lemma (Peano kernel). Let E be a linear functional on Ck[a,b] of the form E(f)=∫abfw−∑iWif(xi), and suppose E vanishes on every polynomial of degree at most k−1. Then for f∈Ck[a,b],
where u+=max(u,0) and Ex means E applied in the variable x with t held fixed. If moreover K does not change sign on [a,b], then there is a ξ∈(a,b) with
E(f)=k!f(k)(ξ)E(xk).
Proof of the lemma. Taylor's theorem with integral remainder (Taylor's theorem) at the left endpoint gives, for every x∈[a,b],
the upper limit being extended to b because the truncated power vanishes for t>x. Apply E. The polynomial part has degree k−1 and is annihilated by hypothesis. In the remaining term E is a finite combination of an integral in x and n point evaluations in x, all of which commute with the t-integral, the integrand (x,t)↦(x−t)+k−1f(k)(t) being bounded and measurable on the square and continuous off the diagonal. That gives the kernel formula.
Now suppose K≤0 throughout (the case K≥0 is the same with the inequalities reversed), and put m=min[a,b]f(k), M=max[a,b]f(k), which exist because f(k) is continuous on a compact interval. Multiplying m≤f(k)(t)≤M by K(t)≤0 reverses the inequalities, and integrating gives
M∫abK≤E(f)≤m∫abK.
Taking f(x)=xk, whose k-th derivative is the constant k!, in the kernel formula gives ∫abK=E(xk)/k!, which is therefore non-positive and, for the two rules below, non-zero. Hence E(f)/∫abK lies between m and M, and since f(k) is continuous it attains that value at some ξ; the intermediate value theorem gives ξ in the open interval unless f(k) is constant, in which case any interior point serves. □
(i) The trapezium panel. Translate so that c=0; the rule is Q(f)=2h(f(0)+f(h)) and E annihilates 1 and x by direct substitution, so take k=2. For t∈(0,h),
using (0−t)+=0. This is ≤0 on [0,h] and vanishes only at the two endpoints, so the lemma applies. Finally
E(x2)=∫0hx2dx−2h(0+h2)=3h3−2h3=−6h3,
so E(f)=f′′(ξ)(−h3/6)/2!=−h3f′′(ξ)/12. Degree of exactness is exactly 1 because E(x2)=0.
(ii) The Simpson panel. Translate so that the panel is [−h,h] with midpoint 0; the rule is Q(f)=3h(f(−h)+4f(0)+f(h)). Substituting 1,x,x2 gives E=0 in each case (∫−hhx2=2h3/3 and 3h(h2+0+h2)=2h3/3), and E(x3)=0 because both the integral over a symmetric interval and the symmetric weighted sum vanish for an odd function. So E annihilates P3 and we take k=4. For t∈[0,h], the three evaluation points contribute only through x=h, since (−h−t)+=(0−t)+=0, and
The average f′′ lies between the smallest and the largest of the f′′(ξj), hence between minf′′ and maxf′′, so by the intermediate value theorem f′′=f′′(η) for some η∈(a,b). With Nh=b−a this is (iii). Part (iv) is identical, summing part (ii) over the N/2 double panels and using (N/2)h5=(b−a)h4/2, which with the 1/90 gives (b−a)h4/180. □
Method(The trapezium error runs in even powers of h)Original
Let q≥1 and f∈C2q[a,b], and let T(h) be the composite trapezium rule with h=(b−a)/N. Then
Two features matter and neither is obvious from part (iii) of the previous statement. Only even powers of h occur. And every coefficient depends on f only through the two endpoints: if f is periodic with period b−a, or if all its odd derivatives agree at the two ends, every c2p vanishes and the trapezium rule converges faster than any power of h.
Method(Richardson extrapolation and the Romberg table)Original
(i) One extrapolation. Suppose a computable quantity satisfies A(h)=A+chp+O(hr) as h→0, with r>p>0 and c independent of h. Then
Anew(h)=2p−12pA(h/2)−A(h)=A+O(hr):
the leading error term is cancelled exactly, at the cost of one more evaluation of A.
(ii) Romberg. Let hi=(b−a)/2i and Ri,0=T(hi), and define
Ri,k=4k−14kRi,k−1−Ri−1,k−1,1≤k≤i.
If f∈C2k+2[a,b] then Ri,k−I=O(hi2k+2), so each column of the table gains two orders of accuracy over the one to its left, and the diagonal Ri,i converges very fast.
(iii) The first column is Simpson.Ri,1 is exactly the composite Simpson rule with spacing hi. So Simpson's rule is not a separate idea: it is one Richardson step applied to the trapezium rule.
The table costs nothing beyond the trapezium sums, and those are nested: the nodes of T(hi−1) are half the nodes of T(hi), so
T(hi)=21T(hi−1)+hij odd,0<j<2i∑f(a+jhi),
and the whole table through row i costs 2i+1 evaluations of f in all.
Idea of the proofOriginal
The even-power expansion is the Euler-Maclaurin formula of Euler-Maclaurin summation, which compares a sum over integers with an integral, rescaled to spacing h. Each derivative in that formula picks up one factor of h from the chain rule and the whole formula is multiplied by one more factor of h to turn a sum into a trapezium rule; since only odd-order derivatives occur in Euler-Maclaurin, only even powers of h survive. The interior values of f cancel in telescoping pairs, which is why only the endpoints appear.
Given such an expansion, extrapolation is just solving two equations for two unknowns: A(h) and A(h/2) both estimate A, with errors in the known ratio 2p, so the combination that eliminates the error term is forced. Doing it repeatedly, each time against the next surviving power, is the Romberg table.
ProofOriginal
The even-power expansion. Put g(s)=f(a+sh) for s∈[0,N], so g∈C2q[0,N] and g(m)(s)=hmf(m)(a+sh). Euler-Maclaurin summation with parameter q applied to g on the integer interval [0,N] gives
Multiply by h and read each piece back in terms of f. On the left, h∑j=0Ng(j)=T(h)+2h(f0+fN), because T halves the two end values. On the right, the substitution x=a+sh gives h∫0Ng=∫abf, the half-sum term is 2h(f0+fN) and cancels, and hg(2p−1)(s)=h2pf(2p−1)(a+sh), which at s=N and s=0 gives h2pf(2p−1)(b) and h2pf(2p−1)(a). Likewise h∣Rq∣≤h⋅(2q)!∣B2q∣h2q⋅h1∫ab∣f(2q)∣. Hence
by the fundamental theorem of calculus, which doubles the bound. This proves the statement, and the case q=1 reproduces the order h2 already known from the mean-value form.
(i) Richardson. Write A(h)=A+chp+ρ(h) with ∣ρ(h)∣≤Chr. Then
since 2p(h/2)p=hp makes the two c-terms cancel, and the remainder is bounded by (2p2−r+1)Chr/(2p−1).
(ii) Romberg. Induct on k. For k=0 the previous statement with q=k+1=1 gives Ri,0−I=O(hi2). Suppose that for some k≥1, and for f∈C2k+2,
Ri,k−1=I+p=k∑mdphi2p+O(hi2m+2)
for coefficients dp independent of i — which is true at k=1 by the even-power expansion with q as large as the smoothness allows. Applying (i) with p replaced by 2k (so 2p becomes 4k) to the pair (Ri−1,k−1,Ri,k−1), where hi=hi−1/2, cancels the h2k term and leaves an expansion starting at hi2k+2 with coefficients again independent of i. That is the inductive step, and it needs f∈C2k+2 for the expansion to reach that far.
(iii) Simpson. With h=hi and 2h=hi−1,
Ri,1=34T(h)−T(2h).
Write out both sums. T(h)=h(21f0+f1+⋯+fN−1+21fN) with N even, and T(2h)=2h(21f0+f2+f4+⋯+fN−2+21fN), which uses only the even-indexed nodes. Then
Method(Gauss rules)AdaptedAdapted from Riley, Hobson & Bence (2006), §27.4.3, the scheme and the exactness to degree 2n-1, pp. 1005-1007
Let w be a weight on (a,b) as above, let (πn) be its monic orthogonal family (General properties of orthogonal polynomials), and let x1<x2<⋯<xn be the zeros of πn, which that unit shows to be real, simple and interior to (a,b). Let Wi=∫abℓiw be the interpolatory weights for these nodes. Then:
Exactness.E(f)=0 for every polynomial f of degree at most 2n−1.
And no more.E(πn2)=∫abπn2w>0, and πn2 has degree 2n; so the degree of exactness is exactly 2n−1. No n-node rule whatever can do better.
Positive weights.Wi=∫abℓi2w>0 for every i, and ∑iWi=μ0=∫abw.
Uniqueness. It is the only n-node rule with degree of exactness 2n−1.
Error. If f∈C2n[a,b] there is a ξ∈(a,b) with
E(f)=(2n)!f(2n)(ξ)∫abπn(x)2w(x)dx.
Gauss-Legendre. For w≡1 on [−1,1] the nodes are the zeros of the Legendre polynomial Pn and Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.4.3, p. 1006) give the weights as
Wi=(1−xi2)Pn′(xi)22,
tabulating them to ten decimals for n up to 20 in their Table 27.8, p. 1008. Since Pn has leading coefficient (2n)!/(2n(n!)2) and ∫−11Pn2=2/(2n+1) (Legendre polynomials), the error constant is
which is 32,458,1758,11025128 for n=1,2,3,4. A general interval is reached by the affine substitution x=2a+b+2b−az, which multiplies the integral by (b−a)/2.
Other weights absorb whatever is awkward about the integrand, and Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.4.3, pp. 1005, 1009) list the standard ones: e−x on (0,∞) for Gauss-Laguerre, e−x2 on R for Gauss-Hermite, and (1−x2)±1/2 on (−1,1) for the two Gauss-Chebyshev families, whose nodes and weights they give in closed form, xi=cosn(i−21)π with all weights equal to π/n in the first-kind case.
Method(Convergence as the number of nodes grows)AdaptedAdapted from Kreyszig (1978), §4.11, Theorems 4.11-3 (Polya) and 4.11-4 (Steklov), pp. 279-280
Let w≡1 on [a,b] and let Qn, n=1,2,…, be a sequence of rules, Qn having n nodes and n weights Wi(n), each exact on polynomials of degree at most n−1.
Polya.Qn(f)→∫abf for every f∈C[a,b]if and only if there is a constant c with
i=1∑nWi(n)≤cfor all n.
Steklov. If every weight is non-negative, this bound is automatic, since taking f≡1 gives ∑iWi(n)=b−a; so such a sequence converges for every continuous f.
By part 3 of the previous statement the Gauss rules have positive weights, so Steklov's theorem applies to them: Gauss quadrature converges for every continuous integrand as n grows. The equally spaced Newton-Cotes rules do not have this property. Computing their weights exactly, all are positive up to 8 nodes; at 9 nodes negative weights appear for the first time and ∑i∣Wi(n)∣/(b−a)=6857/4725=1.4512, at 11 nodes it is 152921/49896=3.0648, and the quantity grows without bound thereafter. Raising the order of a single Newton-Cotes rule is therefore not a convergent strategy, which is the reason composite rules exist.
Idea of the proofOriginal
Everything about Gauss rules comes from one division. A polynomial f of degree 2n−1 can be divided by πn to give f=qπn+r with q and r of degree below n. The rule does not see the quotient term at all, because every node is a root of πn; the integral does not see it either, because πn is orthogonal to everything of lower degree, which is exactly what q is. What is left on both sides is the remainder r, of degree below n, on which any interpolatory rule is exact. The two sides therefore agree — and the argument plainly fails at degree 2n, where q can be constant and ∫qπnw need not vanish.
Positivity of the weights is the same trick run on ℓi2, which has degree 2n−2 and so is integrated exactly, while the rule evaluates it as Wi.
The error formula replaces the interpolant at n points by the Hermite interpolant that also matches n derivatives: it has degree 2n−1, so the rule integrates it exactly, and the difference f−H carries the square of the node polynomial, which has a fixed sign.
Polya's theorem is the uniform boundedness principle in disguise: the rules are bounded functionals on C[a,b], they already converge on the polynomials, which are dense, and a family of functionals that converges on a dense set converges everywhere precisely when its norms are bounded.
ProofOriginal
1. Exactness. Let degf≤2n−1. Polynomial division by the monic πn gives f=qπn+r with degq≤n−1 and degr≤n−1. Then
I(f)=∫abqπnw+∫abrw=0+I(r),
the first integral vanishing because πn is orthogonal to every polynomial of degree below n (General properties of orthogonal polynomials) and degq≤n−1. On the other side, πn(xi)=0 for every node, so
Q(f)=i∑Wi(q(xi)πn(xi)+r(xi))=Q(r).
Finally I(r)=Q(r) because the rule is interpolatory and degr≤n−1. Hence E(f)=0.
2. The degree is not higher. Take f=πn2, of degree 2n. Every node is a root, so Q(f)=0, while I(f)=∫πn2w>0 because w≥0 is a weight and πn2≥0 is not identically zero. For an arbitrary n-node rule with nodes yi, the same argument with ∏i(x−yi)2 shows no n-node rule is exact on all of P2n.
3. Positivity.ℓi2 has degree 2n−2≤2n−1, so by part 1,
∫abℓi2w=j∑Wjℓi(xj)2=Wi,
since ℓi(xj)=δij. The left side is strictly positive: ℓi2w≥0 and ℓi2 is a non-zero polynomial, so it is bounded below by a positive constant on some subinterval where w is not almost everywhere zero. Taking f≡1 in part 1 gives ∑iWi=μ0.
4. Uniqueness. Suppose nodes y1,…,yn and weights V1,…,Vn give a rule exact on P2n−1. Put u(x)=∏i(x−yi), monic of degree n. For any polynomial q with degq≤n−1 the product qu has degree at most 2n−1, so
∫abquw=i∑Viq(yi)u(yi)=0,
each u(yi) being zero. So u is a monic polynomial of degree n orthogonal to Pn−1, and the monic orthogonal polynomial with that property is unique, so u=πn and the yi are the Gauss nodes. The weights are then forced, being the unique ones exact on Pn−1.
5. The error formula. Let f∈C2n[a,b] and let H be the Hermite interpolant of f at the nodes: the unique polynomial of degree at most 2n−1 with H(xi)=f(xi) and H′(xi)=f′(xi) for every i. (Uniqueness: a difference of two such polynomials has a double root at each of the n nodes, hence is divisible by πn2, of degree 2n; a polynomial of degree at most 2n−1 divisible by one of degree 2n is zero. Existence then follows because the 2n interpolation conditions are a square linear system on the 2n-dimensional space P2n−1, and a square system with trivial kernel is solvable.)
Pointwise remainder. Fix x in [a,b] that is not a node, and set λ=(f(x)−H(x))/πn(x)2 and g(s)=f(s)−H(s)−λπn(s)2. Then g vanishes at the n nodes and at x, that is at n+1 distinct points, so by Rolle's theorem g′ vanishes at n interior points of the gaps; and g′ also vanishes at each of the n nodes, because f′=H′ there and πn2 has a double root. These 2n zeros of g′ are distinct, the nodes not being among the interior points just produced. Applying Rolle 2n−1 more times, g(2n) has a zero ζ in (a,b). Since H(2n)≡0 and πn2 is monic of degree 2n, so that (πn2)(2n)≡(2n)!, this gives λ=f(2n)(ζ)/(2n)!. Hence for every x in [a,b], nodes included,
f(x)−H(x)=(2n)!f(2n)(ζx)πn(x)2.
Integrate. Let m and M be the minimum and maximum of f(2n)/(2n)! on [a,b]. Then mπn(x)2≤f(x)−H(x)≤Mπn(x)2 for every x. Multiply by w≥0 and integrate:
m∫abπn2w≤∫ab(f−H)w≤M∫abπn2w.
By part 1 the rule is exact on H, and H agrees with f at the nodes, so ∫abHw=Q(H)=Q(f) and the middle quantity is exactly E(f). Dividing by the positive number ∫πn2w puts E(f)/∫πn2w between m and M; the continuous function f(2n)/(2n)! attains that value at some ξ, interior unless it is constant. □
Polya and Steklov. These are Theorems 4.11-3 and 4.11-4 of Kreyszig (Kreyszig (1978), §4.11, pp. 279-280); his proof identifies ∥Qn∥=∑i∣Wi(n)∣, notes that the polynomials are dense in C[a,b] by the Weierstrass approximation theorem and that convergence already holds on them by exactness, and then appeals to the characterisation of weak* convergence for a sequence of functionals on a Banach space, which requires exactly a uniform bound on the norms (Uniform boundedness and open mapping theorems, Weak convergence).
Remark(Where the hypotheses are used)Original
f∈C2 for the trapezium rule, C4 for Simpson, C2n for the n-point Gauss rule. These enter at exactly one place each: the Peano lemma needs f(k) continuous to squeeze the kernel integral and to apply the intermediate value theorem, and the Gauss proof needs f(2n) continuous for the same reason. Drop the smoothness and the formulas say nothing. For f(x)=x on [0,1], whose second derivative is unbounded at the origin, the composite trapezium error is not O(h2) but O(h3/2): at N=4,8,16,32,64,128,256 panels the computed errors are 2.3384×10−2, 8.5364×10−3, 3.0855×10−3, 1.1077×10−3, 3.9586×10−4, 1.4101×10−4, 5.0118×10−5, falling by factors 0.365,0.361,0.359,0.357,0.356,0.355, which are creeping down to 2−3/2=0.3536 and not to 2−2=0.25. Romberg extrapolation on such an integrand is worse than useless, because it extrapolates a power that is not there.
The kernel must not change sign. That is what converts a bound into an equality with a definite point ξ. It holds for the trapezium and Simpson panels, as computed, and for every Gauss rule, because there the role of the kernel is played by πn2≥0. It fails for Newton-Cotes rules of high order, which is another face of their negative weights.
Distinct nodes. Used for the Lagrange basis and so for the very existence of interpolatory weights; the Gauss nodes are distinct because the zeros of an orthogonal polynomial are simple.
w≥0. Used three times: for ∫πn2w>0, for the positivity of the weights, and in the last step of the error proof, where multiplying an inequality by w must not reverse it. A signed weight destroys all three.
Exactness on Pn−1 in Polya's theorem is what makes the rules converge on the dense set of polynomials; the uniform bound on ∑∣Wi∣ is what transfers that to all of C[a,b]. Neither alone suffices, and Kreyszig's statement is an equivalence, so the bound is not merely convenient.
Periodicity is a hypothesis too. The final remark of the even-power expansion is not an approximation but an identity: for a smooth periodic integrand over a full period every c2p vanishes, and the plain trapezium rule is spectrally accurate. This is why Fourier and spectral codes (Spectral methods) integrate with the trapezium rule and nothing fancier, and why The discrete Fourier transform and the FFT computes Fourier coefficients by an equally weighted sum.
Method(Choosing and running a quadrature)Original
Decide whether you may choose the nodes. If the integrand is a table, you may not: use a composite rule on the nodes you have, Simpson if their number is odd (an even number of panels), the trapezium rule otherwise. If you can evaluate f anywhere, use a Gauss rule or Romberg.
Check the smoothness first, not last. Count how many continuous derivatives the integrand has on the closed interval. An endpoint singularity (an inverse square root, a logarithm) invalidates every error formula here; remove it by substitution, by splitting off an analytically integrable piece, or by choosing a Gauss weight that contains it, as Gauss-Chebyshev contains (1−x2)−1/2.
For a smooth integrand on a finite interval, use Gauss-Legendre. Map to [−1,1] by x=2a+b+2b−az, take the nodes and weights from a table such as Table 27.8 (Riley, Hobson & Bence (2006), p. 1008), and multiply the result by (b−a)/2. Estimate the error by comparing the n-point and 2n-point rules; the n-point error is well approximated by their difference, since the 2n-point value is far more accurate.
For a tabulated or repeatedly refined integrand, build the Romberg table. Compute T(h0) with one panel; then double the number of panels, reusing all previous values through T(hi)=21T(hi−1)+hi∑j oddf(a+jhi); then fill the row by Ri,k=(4kRi,k−1−Ri−1,k−1)/(4k−1). Stop when ∣Ri,i−Ri−1,i−1∣ is below the tolerance, and report Ri,i.
Never extrapolate further than the smoothness allows. Column k of the Romberg table presupposes f∈C2k+2. If the diagonal stops improving, or starts getting worse, the expansion has run out: stop at the last column that was still improving.
Watch the rounding floor. Each column of the Romberg table amplifies rounding error by roughly (4k+1)/(4k−1)≤5/3, so the floor is only a few times the floor of T itself, about nεmax∣f∣ for n evaluations with unit roundoff ε (Floating-point arithmetic and error). Refining beyond that point buys nothing: the error stops falling and begins to rise.
In several dimensions, do not use a product rule beyond three or four dimensions. A product of n-point rules costs nd evaluations. Beyond that use Monte Carlo, whose error is O(M−1/2) independently of the dimension (Monte Carlo methods).
Example(One integral, four rules, with the predicted error constants checked)Original
Take
I=∫01exdx=e−1=1.718281828459045,
an integral whose exact value is known, so that every error below is an error and not an estimate. All derivatives of f(x)=ex equal ex, which makes the predicted constants explicit.
Trapezium rule. With N panels and h=1/N, the predicted error is I−T(h)=−h2eη/12 for some η∈(0,1), that is T(h)−I=h2eη/12. The computed values are
N
T(h)
T(h)−I
12(T(h)−I)/h2
η
1
1.8591409142
1.4086×10−1
1.690309
0.524911
2
1.7539310925
3.5649×10−2
1.711165
0.537174
4
1.7272219046
8.9401×10−3
1.716495
0.540284
8
1.7205185922
2.2368×10−3
1.717835
0.541065
Every η lies in (0,1), as the theorem requires, and the fourth column settles on e−1=1.718282, the value forced by the even-power expansion: its leading coefficient is c2=121[f′(1)−f′(0)]=(e−1)/12, so 12(T−I)/h2→e−1 and η→ln(e−1)=0.541325.
Simpson's rule. The prediction is S(h)−I=h4eη/180:
N
S(h)
S(h)−I
180(S(h)−I)/h4
2
1.7188611519
5.7932×10−4
1.668451
4
1.7183188419
3.7013×10−5
1.705580
8
1.7182841547
2.3262×10−6
1.715091
again approaching e−1. Each halving of h divides the error by about 16, as an h4 rule must.
Romberg. Build the table from T(1),T(21),…,T(161), which together use 17 evaluations of f because the nodes are nested. The entries, and in brackets their errors:
Two checks on the construction. The second column reproduces the Simpson values above exactly (1.718861152 and 1.718318842 are S(21) and S(41)), as part (iii) of the Richardson statement says it must. And the errors in each column fall by the predicted factors: column 0 by 4, column 1 by 16, column 2 by 64. Seventeen evaluations have produced thirteen correct digits, where the plain trapezium rule with the same 17 evaluations gives four.
Gauss-Legendre. Substituting x=(z+1)/2 turns I into 21∫−11e(z+1)/2dz. The two-point rule has z=±1/3, both weights 1, so the nodes in x are 0.211324865 and 0.788675135 with weights 21 each:
The three-point rule has z=0,±3/5 with weights 98,95, so x=0.112701665,0.5,0.887298335 with weights 95⋅21=0.277777778, 98⋅21=0.444444444, 0.277777778:
Check these against the error formula. On [0,1] the constant is 21⋅2−2n∫−11πn2dz/(2n)!, the 2−2n coming from differentiating e(z+1)/2 in z and the 21 from the Jacobian. For n=2, with ∫π22=8/45, this is 21⋅161⋅248/45=2.31481×10−4, and (I−G2) divided by it is 1.665146, so ξ=ln1.665146=0.509913∈(0,1). For n=3, with ∫π32=8/175, the constant is 21⋅641⋅7208/175=4.96032×10−7, giving 1.661358 and ξ=0.507636∈(0,1). Both error formulas are confirmed to six figures.
The scoreboard. Counting evaluations of f: Gauss with 3 points reaches 8.2×10−7; Simpson needs 9 points to reach 2.3×10−6, and the trapezium rule would need h2(e−1)/12≤8.24×10−7, that is h≤2.399×10−3 and about 418 points, to match the three-point Gauss rule. Romberg, which pays the trapezium rule's evaluations but extrapolates them, reaches 3×10−14 with 17.
Application(Matrix elements, cross-sections and the finite element method)Original
Almost every integral a physicist actually computes is a quadrature, and the choice of rule is dictated by the structure of the integrand rather than by taste.
Angular integrals in scattering and radiative transfer. A phase function or a scattering amplitude is integrated over μ=cosθ∈[−1,1] against a weight of 1. The integrand is usually well approximated by a polynomial of modest degree in μ — that is precisely what a truncated Legendre expansion says — so Gauss-Legendre with the number of nodes set by the retained order is exact, not approximate. A radiative-transfer code that keeps L Legendre moments uses an n-point Gauss-Legendre angular grid with 2n−1≥2L, and the discrete ordinates of such codes are nothing but Gauss nodes. If instead the integrand carries (1−μ2)−1/2, as grazing-incidence problems do, Gauss-Chebyshev puts the singularity in the weight and the quadrature never evaluates it.
Matrix elements in quantum mechanics and quantum chemistry. An expectation value ∫ψ∗O^ψ over an infinite range with a Gaussian or exponential envelope is exactly what Gauss-Hermite and Gauss-Laguerre are built for: the envelope is the weight, so it is handled analytically, and the rule needs only to resolve the polynomial prefactor. A harmonic-oscillator matrix element between states n and m has a prefactor of degree n+m in the oscillator coordinate, so ⌈(n+m+1)/2⌉ Gauss-Hermite nodes evaluate it exactly, in arithmetic with no truncation error at all.
Element integrals in the finite element method. Assembling a stiffness matrix (The finite element method) means evaluating one small integral per element, millions of times. The integrands are products of polynomial shape functions and a Jacobian, of known degree, so a Gauss rule of just sufficient order is used and the quadrature is exact to rounding. This is why Gauss rules are hard-wired into finite element codes: the alternative, refining a composite rule until it converges, would multiply the cost of assembly by a large factor and give a worse answer.
Periodic integrands. Orbit averages, time averages over a cycle, and the Fourier coefficients of a periodic signal are integrals over a full period of a smooth periodic function. There the even-power expansion collapses entirely and the equally spaced trapezium rule is the optimal rule, converging faster than any power of the spacing. Using Simpson's rule instead — as is often done by reflex — is strictly worse, because its unequal weights break the symmetry that produced the collapse.
A warning from the error constants. Every statement above about accuracy multiplies a power of h by a high derivative of the integrand. A resonance of width Γ in a cross-section has f(2n)∼Γ−2n near the peak, so the error constant is astronomically large until h≲Γ. No amount of extrapolation repairs this; the integral must be split at the resonance and the narrow piece resolved on its own scale. The error formula is useful exactly because it tells you this before the computation rather than after.
Gaussian elimination as an LU factorization with row interchanges, its cubic cost and why the interchanges are not optional; the Jacobi and Gauss-Seidel iterations and the spectral radius that decides whether they converge; and the conjugate gradient method, which minimises the energy norm of the error over a Krylov subspace and converges at a rate set by the square root of the condition number.
What it means. Solving Ax=b is the inner loop of almost every computation in applied science, and there are exactly two strategies. A direct method does a fixed amount of arithmetic — about n3/3 multiply-add pairs — and returns the answer; its only enemy is rounding, and the whole content of the subject is the row interchanges that keep rounding under control. An iterative method produces a sequence converging to the answer; it never touches a matrix entry that is zero, so it is the only option when n is a million and A is sparse, and its content is the question of how fast the sequence converges. This unit gives the direct method, the two classical iterations, and the one iteration that is not classical and not stationary — the conjugate gradient method — which in a precise sense extracts the best possible answer from the work it has done.
Definition(LU factorization, partial pivoting, splitting, residual)AdaptedAdapted from Riley, Hobson & Bence (2006), §8.18.2, Eq. (8.125)-(8.126), pp. 296-297, and §27.3.1, p. 995; Kreyszig (1978), §5.2, the splitting A = B - G and the iteration (9), p. 309
Let A be a real n×n matrix and b∈Rn.
An LU factorization of A is A=LU with Lunit lower triangular (ℓii=1, ℓij=0 for j>i) and U upper triangular. Given one, Ax=b is solved by forward substitutionLy=b followed by back substitutionUx=y, each a triangular system solved one entry at a time.
A permutation matrixP is the identity with its rows permuted; PA is A with its rows permuted the same way. Gaussian elimination with partial pivoting is the algorithm that, at step k, exchanges row k with the row below it carrying the largest entry of column k in modulus, then eliminates below the diagonal. Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.3.1, p. 995) call this "elimination with interchange" and give the reason: it stops a small number arriving on the diagonal and being divided by.
A splitting of A is a decomposition A=M−N with M invertible and cheap to invert. It defines the stationary iteration
with iteration matrixC. Writing A=D−L−U with D the diagonal, −L the strictly lower part and −U the strictly upper part, the two classical choices are
Jacobi: M=D,Gauss-Seidel: M=D−L.
Stakgold and Holst write the same thing as xm+1=xm+B(b−Axm) with B=M−1 an approximate inverse of A, so that C=I−BA is the error propagator; Jacobi is B=D−1 and Gauss-Seidel is B=(D−L)−1.
For an approximation x^ the residual is r=b−Ax^ and the error is x−x^=A−1r. They are different things, and κ(A)=∥A∥∥A−1∥ of Matrix norms and condition numbers is exactly the factor by which they may differ in relative terms.
Method(Gaussian elimination: existence, pivots, and cost)Original
Let A be n×n.
(i) Without pivoting.A has an LU factorization with L unit lower triangular if and only if the elimination never meets a zero pivot; a sufficient condition is that every leading principal submatrix A1:k,1:k is nonsingular, k=1,…,n. When it exists and A is nonsingular — equivalently, when U has no zero on its diagonal — the factorization is unique. (For singular A it need not be: (0000)=LU for every unit lower triangular L and U=0.)
(ii) With pivoting. For every nonsingular A there is a permutation matrix P with
PA=LU,
L unit lower triangular and U upper triangular and nonsingular. Partial pivoting produces such a P, and the multipliers it produces satisfy ∣ℓij∣≤1 for all i>j.
(iii) Cost. Factorization costs
k=1∑n−1(n−k)2=3n3−2n2+6n
multiply-subtract pairs together with n(n−1)/2 divisions, so 32n3+O(n2) individual floating-point operations. Each subsequent right-hand side costs n(n−1) further multiply-subtract pairs and n divisions, that is O(n2): solving k systems with the same matrix costs n3/3+kn2, not kn3/3. Kreyszig (Kreyszig (1978), §5.2, p. 307) quotes the figure as "about n3/3 arithmetical operations", counting a multiply and the subtraction that follows it as one; the two counts agree up to that convention.
(iv) Determinant.detA=det(P)−1∏iuii=(−1)s∏iuii, where s is the number of row interchanges. This is the only practical way to compute a determinant of even moderate size; the cofactor expansion of Determinants costs n! operations.
(v) Growth. With partial pivoting, every intermediate entry satisfies
i,jmaxuij≤2n−1i,jmaxaij,
and the bound is attained. The quantity on the left over the quantity on the right is the growth factor, and it is what controls how much accuracy the elimination can lose.
Idea of the proofOriginal
Elimination is a factorization in disguise. Subtracting ℓik times row k from row i is multiplication on the left by a matrix that differs from the identity in one entry; the product of all of them is unit lower triangular, and so is its inverse, whose entries are precisely the multipliers with no further arithmetic. So the triangular array of multipliers that elimination throws away isL, and the final upper triangular array is U. That is why one factorization serves any number of right-hand sides.
Pivoting enters because the algorithm divides by the pivot. If the pivot is small relative to the entries below it, the multipliers are large, the updated entries are large, and the original data are swamped: the computation loses the information it was given. Choosing the largest available pivot bounds every multiplier by 1, and the growth statement is the worst that can then happen, each elimination step at most doubling the largest entry.
The cost is one sum: at step k a square block of side n−k is updated, one multiply-subtract per entry.
ProofOriginal
(i) and (ii). Run the elimination. Suppose that after k−1 steps the matrix has the form A(k), zero below the diagonal in the first k−1 columns. If every entry of column k on or below the diagonal is zero, then the first k columns of A(k) are linearly dependent; since A(k)=GA for an invertible G (a product of the elementary operations so far), that would make A singular. So for nonsingular A some entry in that part of column k is non-zero, and partial pivoting brings the largest in modulus, say apk(k), onto the diagonal by exchanging rows k and p. The multipliers are then
ℓik=akk(k)aik(k),i>k,so∣ℓik∣≤1
by the choice of pivot. Writing Ek for the unit lower triangular matrix that performs step k's eliminations and Pk for its row exchange, n−1 steps give En−1Pn−1⋯E1P1A=U. Pushing all the permutations to the right — each Pj past an Ei with i<j only permutes the two rows of the multiplier column of Ei, producing another unit lower triangular matrix with the same entries reordered — turns this into E~PA=U with P=Pn−1⋯P1 and E~ unit lower triangular. Then L=E~−1 is unit lower triangular, and PA=LU. If no interchange is ever needed, P=I and (i) holds; a non-zero pivot at step k is available without interchange exactly when detA1:k,1:k=0, since that determinant equals u11⋯ukk by the same factorization restricted to the leading block.
Uniqueness. If L1U1=L2U2 with both Li unit lower triangular and both Ui nonsingular upper triangular, then L2−1L1=U2U1−1. The left side is unit lower triangular and the right side is upper triangular, and a matrix that is both is the identity. Hence L1=L2 and U1=U2.
(iii) Cost. At step k the multipliers for rows k+1,…,n cost n−k divisions. Each of those n−k rows is then updated in columns k+1,…,n, which is n−k entries, each one multiply and one subtract: (n−k)2 pairs. Summing over k=1,…,n−1 and substituting j=n−k,
Forward substitution computes yi=bi−∑j<iℓijyj, costing i−1 pairs, so n(n−1)/2 in all and no divisions (the diagonal of L is 1); back substitution computes xi=(yi−∑j>iuijxj)/uii, costing n−i pairs and one division, so n(n−1)/2 pairs and n divisions.
(iv) Taking determinants in PA=LU and using detL=1 (unit triangular) and detP=(−1)s gives the formula.
(v) Growth. At step k the updated entries are aij(k+1)=aij(k)−ℓikakj(k). Since ∣ℓik∣≤1,
So the largest modulus at most doubles at each of the n−1 steps, giving the factor 2n−1. The bound is attained by the matrix with 1 on the diagonal, −1 strictly below it and 1 throughout the last column: computing with it for n=3,4,5,6 gives growth factors exactly 4,8,16,32, that is 2n−1. □
Method(Stationary iterations: when they converge)AdaptedAdapted from Stakgold & Holst (2011), §10.6, Algorithm 10.6.1, the error recursion (10.6.4) and Theorem 10.6.1, p. 773, and (10.6.27)-(10.6.30) and Theorem 10.6.4, pp. 799-800; Kreyszig (1978), §5.2, Theorem 5.2-1 with (5) and (7), p. 309, and 5.2-2, 5.2-3, pp. 310-312
Let A=M−N be a splitting and C=M−1N=I−M−1A the iteration matrix, so that the error em=x−xm obeys em+1=Cem and hence em=Cme0.
(i) The exact criterion. The iteration converges to x for every starting vector x0 if and only if
ρ(C)<1,
ρ being the spectral radius. This is Theorem 10.6.1 of Stakgold and Holst (Stakgold & Holst (2011), §10.6, p. 773), and the asymptotic error reduction per step is ρ(C): the number of steps to gain one decimal digit is −1/log10ρ(C).
(ii) A checkable sufficient condition, with error bounds. If
α:=∥C∥∞=jmaxk=1∑n∣cjk∣<1
then the iteration converges, and Kreyszig's Theorem 5.2-1 (Kreyszig (1978), §5.2, Thm 5.2-1 and Eq. (7), p. 309) gives the bounds, in the max metric d(x,y)=maxj∣xj−yj∣,
d(x(m),x)≤1−ααd(x(m−1),x(m))≤1−ααmd(x(0),x(1)).
The first is computable from two successive iterates and is the one to use as a stopping test; the second is computable in advance.
(iii) Jacobi.CJ=D−1(L+U)=I−D−1A, that is xjm+1=(bj−∑k=jajkxkm)/ajj, which needs ajj=0. Condition (ii) becomes strict row diagonal dominance,
k=j∑∣ajk∣<∣ajj∣(j=1,…,n),
which is Kreyszig's row sum criterion (12*).
(iv) Gauss-Seidel.CGS=(D−L)−1U, that is xjm+1=(bj−∑k<jajkxkm+1−∑k>jajkxkm)/ajj: the components already updated in the current sweep are used immediately. Kreyszig states, without proof, that strict row diagonal dominance is sufficient for this iteration too.
(v) The two are not comparable. Kreyszig's Problems 5 and 6 (p. 313) exhibit a 3×3 system on which Jacobi diverges and Gauss-Seidel converges, and another on which Jacobi converges and Gauss-Seidel diverges. Neither method dominates the other in general. What is true in the important special case is recorded by Stakgold and Holst (Stakgold & Holst (2011), §10.6, p. 800): for consistently ordered matrices with Property A — which the standard finite-difference Laplacian is — ρ(CGS)=ρ(CJ)2, so Gauss-Seidel does in one sweep what Jacobi does in two.
(vi) The bad news for discretized PDEs. For the box-method discretization of Poisson's equation on a uniform mesh of spacing h, Stakgold and Holst give ρ(CJ)=cosπh and ρ(CGS)=cos2πh, both of the form 1−O(h2), while the optimally relaxed SOR iteration achieves 1−O(h). As h→0 all of them approach 1: the classical iterations slow down without limit as the mesh is refined. This is the reason multigrid and preconditioned Krylov methods exist (Relaxation methods for elliptic problems).
Idea of the proofOriginal
Everything follows from em=Cme0. A matrix power tends to zero exactly when every eigenvalue has modulus below one: the Jordan form turns Cm into blocks λm times a polynomial in m, and an exponential beats a polynomial in either direction. The sufficient condition is cruder and cheaper: an induced norm dominates the spectral radius, so a norm below one forces the spectral radius below one, and it does so with a constant one can compute from the matrix entries without finding a single eigenvalue. Kreyszig gets it as a contraction on Rn with the max metric, and the error bounds are then nothing but the standard bounds of the Banach fixed point theorem.
The difference between Jacobi and Gauss-Seidel is that Gauss-Seidel overwrites in place. It costs the same arithmetic and less storage, and on the matrices that come from discretizing an elliptic equation it halves the number of sweeps — but that is a property of those matrices, not a theorem about the two methods.
ProofOriginal
(i) Subtracting x=Cx+d from xm+1=Cxm+d gives em+1=Cem, hence em=Cme0, so the question is whether Cm→0.
If ρ(C)≥1: take an eigenvalue λ with ∣λ∣≥1 and an eigenvector v=0, and start at x0=x−v, so e0=v. Then em=λmv does not tend to 0.
If ρ(C)<1: put C=SJS−1 in Jordan form (Jordan normal form). It suffices that Jm→0, and J is block diagonal, so it suffices that Jkm→0 for one Jordan block Jk=λI+N of size s, where N is nilpotent with Ns=0. Since λI and N commute, the binomial theorem gives
Jkm=t=0∑s−1(tm)λm−tNt,
a sum of s terms each bounded by mt∣λ∣m−t∥N∥t/t!. With ∣λ∣<1 each mt∣λ∣m tends to 0, because mt∣λ∣m=exp(tlogm−mlog(1/∣λ∣))→0. Hence Jkm→0.
so T is a contraction with constant α on the complete metric space (Rn,d). The Banach fixed point theorem (The contraction mapping theorem) gives a unique fixed point, convergence from any start, and exactly the two error bounds quoted. (Consistency with (i): ρ(C)≤∥C∥∞=α<1, since an induced norm bounds the spectral radius.)
(iii)M=D is invertible precisely when no diagonal entry vanishes, and then CJ=I−D−1A has entries cjk=−ajk/ajj for k=j and 0 for k=j. So α=maxj∑k=j∣ajk∣/∣ajj∣, and α<1 is the stated dominance.
(iv)M=D−L is lower triangular with the ajj on the diagonal, hence invertible under the same condition, and solving Mxm+1=Uxm+b one row at a time from the top gives the component formula, since row j involves xkm+1 only for k<j. The claim about diagonal dominance is Kreyszig's and is reported, not proved, here: he states at the end of §5.2 that condition (12) is sufficient for the Gauss-Seidel iteration as well, referring the reader elsewhere for better conditions.
(v) and (vi) are quoted from the two sources as stated; no proof is offered here. □
Method(The conjugate gradient method)AdaptedAdapted from Stakgold & Holst (2011), §10.6, Algorithm 10.6.2 with B = I, p. 778, the Krylov minimisation and minimax reduction, p. 779, and the contraction bound (10.6.9), p. 780
Let A be symmetric positive definite, b given, x the exact solution. Write (u,v)A=uTAv and ∥u∥A=(u,u)A1/2 for the energy inner product and norm, and
Ki=span{r0,Ar0,…,Ai−1r0}
for the i-th Krylov subspace. The method of Hestenes and Stiefel is Algorithm 10.6.2 of Stakgold and Holst (Stakgold & Holst (2011), §10.6, p. 778) with the preconditioner taken to be the identity: starting from any x0, with r0=b−Ax0 and p0=r0,
Each step costs one matrix-vector product, two inner products and three vector updates; A is never modified and need not even be stored, only applied.
Then, in exact arithmetic and as long as ri=0:
Orthogonality.(ri,rj)=0 and (pi,Apj)=0 for j<i, and Ki=span{r0,…,ri−1}=span{p0,…,pi−1}.
Optimality.xi is the unique minimiser of ∥x−u∥A over the affine subspace u∈x0+Ki. No method that uses only the vectors Ajr0 can do better in this norm.
Finite termination.xi=x for some i≤n; more sharply, for some i≤ the number of distinct eigenvalues of A.
Rate. With κ=κ2(A)=λmax/λmin,
∥x−xi∥A≤2(κ+1κ−1)i∥x−x0∥A,
which is Stakgold and Holst's bound (10.6.9) with B=I. Compare a stationary iteration, whose rate involves κ itself rather than κ: the number of conjugate gradient steps needed for a fixed accuracy grows like κ, not like κ.
Positive definiteness is used throughout and cannot be dropped: (p,Ap) appears in a denominator, and ∥⋅∥A is a norm only for positive definite A.
Idea of the proofOriginal
For symmetric positive definite A, solving Ax=b is the same as minimising the quadratic ϕ(u)=21uTAu−bTu, since ϕ(u)=21∥x−u∥A2−21xTAx. Steepest descent takes the negative gradient, which is the residual, and immediately wastes its work: the next step undoes part of the previous one. The conjugate gradient fix is to search instead along directions that are orthogonal in the energy inner product, so that minimising along a new direction never spoils the minimisation already achieved along the old ones. The iterate after i steps is then the exact minimiser over the whole i-dimensional space searched so far, not merely over the last line.
The miracle — and it is specific to symmetric A — is that building such a direction needs only the previous one. The space searched after i steps is the Krylov space, and the single number β suffices to keep the new direction energy-orthogonal to all its predecessors, because a symmetric matrix applied to a vector of one Krylov space lands in the next, and everything earlier has already been orthogonalised away.
Optimality over Krylov spaces then converts the convergence question into a question about polynomials: which polynomial of degree i equal to 1 at the origin is smallest on the spectrum of A? If the spectrum is clustered the answer is tiny, which is why preconditioning works; if the spectrum fills an interval [λmin,λmax], the answer is given by Chebyshev polynomials and produces the κ rate.
ProofOriginal
1. Orthogonality. We prove by induction on i the statement Hi: the vectors r0,…,ri are mutually orthogonal, p0,…,pi are mutually A-orthogonal, and
span{r0,…,ri}=span{p0,…,pi}=Ki+1.
H0 holds because p0=r0 and K1=span{r0}. Assume Hi and ri+1=0.
Step 1: ri+1⊥pj for j≤i. For j=i,
(ri+1,pi)=(ri,pi)−αi(Api,pi).
Now pi=ri+βipi−1 and ri⊥pi−1 (that is Hi: pi−1∈Ki=span{r0,…,ri−1} and ri is orthogonal to each of those), so (ri,pi)=(ri,ri), and the definition of αi makes the right side vanish. For j<i: (ri,pj)=0 because pj∈Ki, and (Api,pj)=0 by the A-orthogonality in Hi. Hence (ri+1,pj)=0.
Since span{p0,…,pi}=span{r0,…,ri} by Hi, step 1 also gives ri+1⊥rj for j≤i.
Step 2: pi+1 is A-orthogonal to p0,…,pi. From rj+1=rj−αjApj we get Apj=(rj−rj+1)/αj whenever αj=0, which holds because (pj,Apj)>0 and (rj,rj)>0. For j<i,
by the definition of βi+1. This is where the formula for β comes from: it is the unique choice that makes the new direction A-orthogonal to the last one, and steps 1 and 2 show that this one condition secures orthogonality to all the others for free.
Step 3: the spans.ri+1=ri−αiApi with ri∈Ki+1 and pi∈Ki+1, so Api∈Ki+2 and ri+1∈Ki+2; likewise pi+1=ri+1+βi+1pi∈Ki+2. Conversely span{r0,…,ri+1} has dimension i+2 (the rj are non-zero and mutually orthogonal), is contained in Ki+2, and dimKi+2≤i+2; so the two are equal, and the same argument applies to the pj, which are non-zero and mutually A-orthogonal. That is Hi+1.
2. Optimality. By construction xi∈x0+Ki. Let ei=x−xi; then Aei=b−Axi=ri, so for every v∈Ki,
(ei,v)A=(Aei,v)=(ri,v)=0
by part 1. So ei is A-orthogonal to Ki, that is, xi is the A-orthogonal projection of x onto the affine subspace x0+Ki. For any other u=xi+w with w∈Ki,
3. Finite termination. The non-zero residuals are mutually orthogonal in Rn, so there are at most n of them and ri=0, hence xi=x, for some i≤n. For the sharper count, let λ1,…,λm be the distinct eigenvalues of A and put q(λ)=∏j=1m(1−λ/λj), a polynomial of degree m with q(0)=1. Since xi−x0∈Ki, we may write xi=x0+s(A)r0 with degs≤i−1, and then
and conversely every such qi arises from some u∈x0+Ki. By part 2, ∥ei∥A=min{∥q(A)e0∥A:degq≤i,q(0)=1}. Taking i=m and the q above, q(A)=0 because q vanishes at every eigenvalue and A is diagonalisable (Spectral theorem for Hermitian matrices); hence ∥em∥A=0.
4. Rate. Expand e0=∑kckvk in an orthonormal eigenbasis Avk=λkvk. Then ∥q(A)e0∥A2=∑kq(λk)2λkck2≤(maxk∣q(λk)∣)2∥e0∥A2, so by part 2
The last minimax problem is solved by the Chebyshev polynomial Ti rescaled to [λmin,λmax] and normalised at the origin (Chebyshev polynomials); Stakgold and Holst (Stakgold & Holst (2011), §10.6, Eq. (10.6.9) and Exercises 10.5.2-10.5.3, pp. 779-780) carry out that step and record the resulting bound, which is the one quoted. □
Remark(Where the hypotheses are used)Original
Pivoting is not a refinement; without it the algorithm can return nonsense on a perfectly conditioned problem. Take
εx1+x2=1,x1+x2=2,ε=10−17,
whose exact solution is x1=1/(1−ε), x2=(1−2ε)/(1−ε), both equal to 1 to sixteen digits. Its condition number is κ2=2.618: the problem is as well conditioned as a problem can be. Eliminating without pivoting uses the multiplier 1/ε=1017; in IEEE double precision 1−1017 and 2−1017 both round to −1017, the 1 and the 2 being lost entirely, so x2=1 and then x1=(1−x2)/ε=0. The computed answer is (0,1) against the true (1,1): one hundred per cent error. Exchanging the two rows first gives multiplier ε and returns (1,1) to full precision. The information destroyed is the coefficient 1 in the second equation, and what destroys it is the subtraction of a huge number from a small one — cancellation, in the sense of Floating-point arithmetic and error.
The growth factor is why "with partial pivoting" is enough in practice but not in theory. The bound 2n−1 of part (v) is attained, so there exist matrices on which elimination with pivoting loses n−1 bits. They are rare; on matrices arising from applications the growth factor is almost always below n. The theorem is what it is, and a code that must be certain checks the residual afterwards.
ρ(C)<1 is necessary and sufficient; ∥C∥<1 is only sufficient. The gap is real. Diagonal dominance is a sufficient condition for Jacobi, and Kreyszig's Problems 5 and 6 show it is not necessary and that the two classical methods do not dominate one another.
ajj=0 for both iterations. A zero on the diagonal makes M singular and the iteration undefined, even though the system may be perfectly solvable; a row exchange fixes it, so the hypothesis is about the arrangement of the equations, not about the problem.
Symmetry and positive definiteness for the conjugate gradient method. Symmetry is used in step 2 of the orthogonality proof, where (Ar,p)=(r,Ap), and it is what makes the short three-term recurrence possible. Positive definiteness is used for ∥⋅∥A to be a norm, for αi to have a non-zero denominator, and in part 4 where λk>0. Applied to a non-symmetric or indefinite matrix the recurrence can break down with a zero denominator; the family of methods for that case (GMRES, BiCGSTAB) must store or regenerate the whole Krylov basis.
Exact arithmetic for finite termination. Part 3 is a statement about exact arithmetic only. In floating point the orthogonality of the residuals is lost gradually and the method does not terminate at step n. This does not matter, because in practice it is stopped long before n on the strength of part 4 — which is a statement about the rate, and survives rounding.
The residual is not the error. If x^ is any approximation with residual r=b−Ax^, then x−x^=A−1r and ∥b∥=∥Ax∥≤∥A∥∥x∥, so
∥x∥∥x−x^∥≤∥A−1∥∥r∥⋅∥b∥∥A∥=κ(A)∥b∥∥r∥,
and Matrix norms and condition numbers shows this is attained. A tiny residual certifies a tiny error only when κ(A) is modest. Every stopping test on ∥r∥ is therefore a statement about the error only after multiplication by an estimate of κ.
Method(Choosing a solver)Original
Is the matrix sparse and large? If n≲104 and A is dense, factorize: the cost n3/3 is predictable and the answer is backward stable. If A is sparse with O(n) non-zeros and n is large, a dense factorization is impossible on both counts — fill-in destroys the sparsity and the cost is cubic — so iterate.
Factorize once, solve many times. Never form A−1. Compute PA=LU once at cost n3/3 and reuse it for every right-hand side at n2 each. Forming A−1 costs the same as n solves, needs n2 storage, and then each application still costs n2 — with a worse error.
Exploit structure before anything else. A tridiagonal system costs O(n), not O(n3) (Polynomial and spline interpolation uses this for splines, and Riley, Hobson and Bence (Riley, Hobson & Bence (2006), §27.3.3, p. 998) give the recurrence); a banded system of bandwidth m costs O(nm2); a symmetric positive definite system uses the Cholesky factorization A=RTR at half the cost of LU and needs no pivoting.
For an iterative solve, check the splitting first. Verify strict diagonal dominance; if it holds, Jacobi and Gauss-Seidel both converge and the row-sum constant α gives a usable a priori step count. If it fails, compute or estimate ρ(C) before spending time: an iteration with ρ just below 1 is worse than useless.
For symmetric positive definite A, use conjugate gradients and precondition it. The step count scales as κ, and preconditioning — solving M−1Ax=M−1b with M an easily invertible approximation to A — is the whole game, because it is the condition number of the preconditioned matrix that enters. Incomplete Cholesky and multigrid (Relaxation methods for elliptic problems) are the standard choices.
Stop on the right quantity. Use ∥r∥/∥b∥≤tol only with an estimate of κ(A) in hand; otherwise use the a posteriori bound of the stationary-iteration statement, which involves only successive iterates.
Always check afterwards. Compute the residual of the returned x^ in higher precision if you can. One step of iterative refinement — solve Aδ=r with the factorization you already have, set x^←x^+δ — costs n2 and typically recovers the digits lost to a large growth factor.
Example(The same three ideas on explicit numbers)Original
Part 1: elimination with interchange. Solve Ax=b with
A=13241−52−15,b=−1−227.
Step 1. The largest entry of column 1 in modulus is 3, in row 2: exchange rows 1 and 2. The multipliers are ℓ=1/3 for the (new) row 2 and ℓ=2/3 for row 3, both at most 1 in modulus as the theory promises. Subtracting:
3001311−317−137317−2−31385.
Step 2.∣−17/3∣>∣11/3∣, so exchange rows 2 and 3 — a second interchange, which plain elimination would not have made. The multiplier is (11/3)/(−17/3)=−11/17, and subtracting it gives the third row 6x3=18.
Back substitution.x3=3; then −317x2+317(3)=385 gives x2=−2; then 3x1+(−2)−3=−2 gives x1=1. So
x=(1,−2,3)T,
which substituted back into the three original equations gives 1−8+6=−1, 3−2−3=−2 and 2+10+15=27: the data exactly.
The factorization. The permutation sends the original rows to the order (2,3,1), and
Multiplying out, row 3 of LU is 31(3,1,−1)−1711(0,−317,317)+(0,0,6)=(1,4,2), the original first row, and the other two rows check the same way: PA=LU exactly. The determinant is detA=(+1)⋅3⋅(−317)⋅6=−102, the sign being + because two interchanges were made; expanding the 3×3 determinant by cofactors gives 0−68−34=−102 as well. The operation count predicted by part (iii) is n3/3−n2/2+n/6=9−4.5+0.5=5 multiply-subtract pairs and n(n−1)/2=3 divisions, which is exactly what the two steps above used: a 2×2 block updated at step 1 and a 1×1 at step 2, with three multipliers.
Part 2: Jacobi and Gauss-Seidel. Take the symmetric positive definite
A=4−10−14−10−14,b=2410,x=123,
the solution being exact as substitution confirms (4−2=2, −1+8−3=4, −2+12=10). The rows of ∣CJ∣ sum to 0.25, 0.5, 0.25, so α=0.5<1: strictly diagonally dominant, and both iterations converge. The eigenvalues of A are 4−2,4,4+2, so
the second computed from the eigenvalues of (D−L)−1U and agreeing exactly with the squaring relation Stakgold and Holst record for this class of matrix. Starting from x0=0 the maximum-norm errors are
sweep m
Jacobi
Gauss-Seidel
1
1.0000
8.7500×10−1
2
2.5000×10−1
2.1875×10−1
3
1.2500×10−1
2.7344×10−2
4
3.1250×10−2
3.4180×10−3
6
3.9062×10−3
5.3406×10−5
8
4.8828×10−4
8.3447×10−7
12
7.6294×10−6
The Gauss-Seidel errors fall by exactly 1/8 per sweep from m=2 on, which is ρ(CGS). The Jacobi errors alternate between factors 1/4 and 1/2 — the max-norm picks out different components on alternate sweeps — but over two sweeps they fall by 1/8=ρ(CJ)2, as the spectral radius requires. Gauss-Seidel reaches 10−6 in 8 sweeps (8.34×10−7) where Jacobi needs 14 (9.54×10−7 at sweep 14, against 3.81×10−6 at sweep 13). Kreyszig's a priori bound for Jacobi, with α=0.5 and d(x(0),x(1))=∥D−1b∥∞=2.5, predicts an error at most αm(1−α)−1(2.5)=5⋅2−m, which at m=12 is 1.22×10−3: a true bound, pessimistic here by a factor of 160, as a bound built from a norm rather than a spectral radius must be.
Part 3: conjugate gradients on the same system.κ2(A)=(4+2)/(4−2)=2.093836, so the predicted contraction factor is (κ−1)/(κ+1)=0.182676. From x0=0, so r0=p0=b and ∥x−x0∥A=xTAx=xTb=40=6.3246:
i
αi−1
xi
∥ri∥2
∥x−xi∥A
1
0.3125000
(0.6250000,1.2500000,3.1250000)
3.1125
1.5811
2
0.2484140
(0.8514190,2.0133556,3.0150250)
0.63751
0.30576
3
0.2300307
(1.0000000,2.0000000,3.0000000)
4.4×10−17
0
Three steps for a 3×3 matrix with three distinct eigenvalues, exactly as part 3 of the statement requires; the residual at step 3 is at the rounding level and the energy error is zero in our run. Check the bound of part 4 as well. At i=2 it reads
against the achieved 0.30576: the bound holds, with about 28% to spare. In ratio form the achieved contraction is 0.30576/6.3246=0.048345, comfortably under the allowed 2ρ2=0.066741. At i=1 it reads 2ρ(6.3246)=0.36535×6.3246=2.3107 against the achieved 1.5811: again true, again loose. The reason the bound has room is that it is a minimax value over the whole interval [λmin,λmax], whereas conjugate gradients only has to be small on the three points {4−2,4,4+2} actually in the spectrum; a finite spectrum is easier than a full interval, which is both why the bound has slack here and why clustering the spectrum by preconditioning pays.
Application(Where the cubic cost and the condition number decide the science)Original
Structural and finite element analysis. Assembling a finite element model (The finite element method) produces a symmetric positive definite stiffness matrix that is sparse and very large: a million degrees of freedom is routine, a billion is not unusual. A dense factorization would need 1018 operations and 1012 words of storage for the million-unknown case; a preconditioned conjugate gradient solve needs a few hundred matrix-vector products, each O(n). The condition number of a finite element stiffness matrix grows like h−2 as the mesh is refined, so κ∼h−1, and the unpreconditioned step count doubles when the mesh is halved — which is exactly why industrial codes are built around multigrid preconditioners that make κ independent of h.
Least squares and data fitting. Fitting m data with n parameters leads to the normal equations ATAc=ATy (Orthogonal projection and least squares), which are symmetric positive definite — but κ(ATA)=κ(A)2. Fitting a degree-12 polynomial in the monomial basis on [0,1] uses 13 coefficients, so the normal matrix is the 13×13 Hilbert matrix, whose spectral condition number we compute to be 5.6×1017 — the 12×12 one, belonging to the degree-11 fit, is already 1.7×1016 — and no algorithm whatever can return a meaningful answer in double precision: by the rule of thumb in Matrix norms and condition numbers, every digit is gone. The cure is not a better solver but a better basis — orthogonal polynomials (General properties of orthogonal polynomials) — or a QR factorization of A that never forms ATA and so works with κ(A) rather than its square.
Implicit time stepping. Every implicit integrator for a stiff system (Stability and stiff equations) and every implicit scheme for a parabolic PDE requires the solution of a linear system at every time step, with the same matrix if the step size is held fixed. That is the canonical case for factorizing once and reusing: the n3/3 is paid at the first step and n2 at every step thereafter. When the step size is adapted, the trade-off between refactorizing and iterating is the central implementation decision in the solver.
Circuit simulation and network flow. Modified nodal analysis produces a sparse, highly unsymmetric matrix whose structure follows the circuit topology, and here pivoting is not an academic concern: the entries span many orders of magnitude, from gate capacitances to supply resistances, and a pivot chosen by position rather than by magnitude will produce the (0,1) of the remark above in a circuit with a billion transistors. Production simulators use a pivoting strategy that balances the magnitude criterion against keeping the factorization sparse, which is the practical form of the growth-factor bound.
The three iterations every practical eigenvalue computation is built from - power iteration, whose error falls by the ratio of the two largest eigenvalues at each step; inverse iteration with a shift, which turns that ratio into a quantity the user controls and becomes cubically convergent when the shift is the Rayleigh quotient; and the QR algorithm, which is power iteration run on a whole nested family of subspaces at once - with their convergence rates, their costs and a residual bracket that says when to stop.
Note(What it means)AdaptedAdapted from Hassani (2013), §6.2, Eqs. (6.5)-(6.7) and Thm 6.2.5, pp. 173-174; Arfken, Weber & Harris (2013), §6.4, Finding a Diagonalizing Transformation, p. 314
The eigenvalues of an n×n matrix are the roots of its characteristic polynomial, a polynomial of degree n(Hassani (2013), Eq. (6.7), p. 173). From the fifth degree onwards there is no formula in radicals for the roots of a general polynomial, so there is no finite sequence of arithmetic operations and root extractions that produces the eigenvalues of a general matrix. Arfken, Weber and Harris (Arfken, Weber & Harris (2013), §6.4, p. 314) draw the practical conclusion: numerical diagonalization proceeds by successive approximation, and it has to.
Every method in use is therefore an iteration, and essentially all of them are built from one idea: multiply a vector by a matrix repeatedly and the direction of largest growth takes over. The three sections below are that idea, applied to A (power iteration), to (A−σI)−1 (inverse iteration, which lets you aim at any part of the spectrum you like), and to a whole nested family of subspaces at once (the QR algorithm, which is how a dense eigenvalue problem is actually solved). Forming the characteristic polynomial and sending it to a root finder (Root finding) is not on the list: its coefficients are catastrophically ill-conditioned functions of the matrix entries, and the information they carry about the small eigenvalues is destroyed before the root finder is called.
Definition(The iterations, the Rayleigh quotient and the residual)AdaptedAdapted from Kreyszig (1978), §9.2, Eq. (1) and Thm 9.2-1, p. 465, and Problems 8-9, p. 469; Stakgold & Holst (2011), §6.5, (6.5.17) and (6.5.19)-(6.5.20), pp. 401-402
Throughout, A∈Mn(C), vectors are columns, (x,y)=y∗x (the handbook's convention, linear in its first argument), and ∥x∥=(x,x)1/2.
The Rayleigh quotient of a non-zero vector q is
ρ(q)=(q,q)(Aq,q),
the name used by Kreyszig (Kreyszig (1978), §9.2, Problem 8, p. 469), who records that for a bounded self-adjoint operator the whole spectrum lies between the infimum and the supremum of ρ; for a Hermitian matrix with eigenvalues λ1≥⋯≥λn the extremes are attained, λ1=maxqρ(q) and λn=minqρ(q) (Quadratic forms and the Rayleigh quotient). The residual of a unit vector q is
η(q)=∥Aq−ρ(q)q∥,
which is ∥Kz−mz∥ in the notation of Stakgold and Holst (Stakgold & Holst (2011), §6.5, (6.5.19), p. 401), who read it as the standard deviation of a mass distribution on the eigenvalue axis.
Four iterations are defined below. In each, q0 is a unit vector chosen by the user.
Power iteration.qk+1=∥Aqk∥Aqk.
Inverse iteration with shift σ. Solve (A−σI)zk+1=qk and set qk+1=zk+1/∥zk+1∥. The shift σ is fixed, and A−σI is factorized once (Solving linear systems numerically).
Rayleigh quotient iteration. The same, but with the shift recomputed at every step: σk=ρ(qk), then (A−σkI)zk+1=qk and qk+1=zk+1/∥zk+1∥.
The QR iteration. Put A0=A. For k≥1, factor Ak−1=QkRk with Qk unitary and Rk upper triangular (Orthonormal bases and Gram-Schmidt) and multiply the factors back in the other order:
Ak−1=QkRk,Ak=RkQk.
Write Qˉk=Q1Q2⋯Qk and Rˉk=RkRk−1⋯R1 for the accumulated factors.
The angle θ(q,S)∈[0,π/2] between a unit vector q and a subspace S is defined by cosθ=∥PSq∥, with PS the orthogonal projector onto S; so sinθ=∥(I−PS)q∥ is the distance from q to S. Convergence "to an eigenvector" always means θ→0, never qk→v: an iterate is determined only up to a scalar of modulus one, and for a negative eigenvalue the sign genuinely alternates.
Method(Power iteration)Original
Let A be Hermitian with eigenvalues λ1,…,λn listed with multiplicity and ordered so that
∣λ1∣>∣λ2∣≥⋯≥∣λn∣,
and let v1,…,vn be a corresponding orthonormal eigenbasis (Spectral theorem for Hermitian matrices). The strict first inequality forces λ1 to be a simple eigenvalue. Let q0 be a unit vector with (q0,v1)=0, let θk be the angle between qk and span{v1}, and put D=maxi∣λ1−λi∣. Then for every k≥0:
tanθk≤λ1λ2ktanθ0, so θk→0 geometrically with ratio ∣λ2/λ1∣;
λ1−ρ(qk)≤Dsin2θk≤Dtan2θ0λ1λ22k,
so the eigenvector converges at the rate ∣λ2/λ1∣ and the eigenvalue estimate at the square of that rate. If in addition λ1 is the algebraically largest eigenvalue, then ρ(qk)≤λ1 for every k, so the estimates approach λ1 from below.
Idea of the proofOriginal
In the eigenbasis, multiplying by A multiplies the ith coordinate by λi. After k steps the coordinate along v1 has been multiplied by λ1k and every other coordinate by something no larger than λ2k in modulus, so the ratio of what we do not want to what we do want is multiplied by ∣λ2/λ1∣ each time. Normalising at every step changes nothing in that ratio; it only keeps the numbers inside the range of the floating-point format. The Rayleigh quotient does better than the vector because it is stationary at an eigenvector: the error in ρ is a weighted average of the gaps λ1−λi with weights equal to the squares of the unwanted coordinates.
ProofOriginal
Normalising at each step only rescales, so qk=Akq0/∥Akq0∥ by induction. Expand q0=∑icivi in the orthonormal eigenbasis, so ∑i∣ci∣2=1 and c1=(q0,v1)=0 by hypothesis.
The angle. Since Akq0=∑iciλikvi and the vi are orthonormal, the component of Akq0 along v1 has modulus ∣c1∣∣λ1∣k and the component orthogonal to v1 has norm (∑i≥2∣ci∣2∣λi∣2k)1/2. Dividing the second by the first — both are positive, the first because c1=0 and λ1=0 — gives the tangent of the angle exactly:
tanθk=∣c1∣∣λ1∣k(∑i≥2∣ci∣2∣λi∣2k)1/2.
By the ordering, ∣λi∣≤∣λ2∣ for every i≥2, so the numerator is at most ∣λ2∣k(∑i≥2∣ci∣2)1/2. Dividing, and recognising (∑i≥2∣ci∣2)1/2/∣c1∣ as tanθ0, gives claim 1.
The Rayleigh quotient. Write qk=∑idivi with ∑i∣di∣2=1. Hermiticity is used here: because the vi are orthonormal and Avi=λivi,
ρ(qk)=(Aqk,qk)=i∑λi∣di∣2.
Subtracting this from λ1=λ1∑i∣di∣2 and noting that the i=1 term cancels,
λ1−ρ(qk)=i≥2∑(λ1−λi)∣di∣2.
Every λi is real, again by Hermiticity, so this is a real number of modulus at most D∑i≥2∣di∣2. That sum is exactly sin2θk, since ∣d1∣=cosθk. The second inequality in claim 2 follows from claim 1 and sinθ≤tanθ.
One-sidedness. If λ1≥λi for all i, every term of the last display is non-negative, so λ1−ρ(qk)≥0. □
Remark(A residual bracket: when to stop)AdaptedAdapted from Stakgold & Holst (2011), §6.5, Thm 6.5.5 with (6.5.17) and (6.5.19), pp. 401-402
The bounds above contain θ0 and λ2/λ1, neither of which is known while the computation is running. The following bound uses only quantities already on hand, and it is where the residual η(q) earns its place.
Lemma. Let A be Hermitian and q a unit vector. Then the closed interval [ρ(q)−η(q),ρ(q)+η(q)] contains an eigenvalue of A.
Proof. Write q=∑idivi in an orthonormal eigenbasis, ∑i∣di∣2=1, and ρ=ρ(q). Then Aq−ρq=∑i(λi−ρ)divi, so by orthonormality η(q)2=∑i(λi−ρ)2∣di∣2. If no eigenvalue lay within η(q) of ρ, every factor (λi−ρ)2 with di=0 would exceed η(q)2, and the sum would exceed η(q)2∑i∣di∣2=η(q)2, a contradiction. □
Stakgold and Holst (Stakgold & Holst (2011), §6.5, Thm 6.5.5, p. 402) state and prove this for a positive compact symmetric operator on a Hilbert space, where ρ and η are the mean and the standard deviation of the mass distribution that the trial element z puts on the eigenvalue axis, and they note that the result is Chebyshev's inequality in disguise. The proof above is that argument in finite dimensions. Two cautions carry over. First, the bracket names an eigenvalue, not the one you are chasing: to conclude that λ1∈[ρ−η,ρ+η] one needs to know in addition that no other eigenvalue is that close, which is the point of the source's condition m−σ>λ2. Second, the bracket is honest but pessimistic by roughly one factor of the residual, because by part 2 of the statement above the actual error in ρ is of order η2/gap once q is close.
Remark(Where the hypotheses are used, and the operator form of the same iteration)AdaptedAdapted from Stakgold & Holst (2011), §6.5, Exercise 6.5.2, p. 406
∣λ1∣>∣λ2∣ strictly. Used in step 1 to make the ratio in the numerator contract. It fails for A=diag(1,−1) and q0=(1,1)T/2: then qk=(1,(−1)k)T/2 for every k, the iteration oscillates for ever between two vectors, and ρ(qk)=0, which is not an eigenvalue at all. For a real non-symmetric matrix the same failure occurs whenever the dominant eigenvalues are a complex conjugate pair, as for a rotation matrix. When λ1 is a repeated eigenvalue the statement survives unchanged if λ2 is read as the largest modulus strictly below ∣λ1∣ and v1 is replaced by the whole λ1-eigenspace: the proof uses only that the unwanted coordinates are multiplied by something smaller.
(q0,v1)=0. Used to divide by ∣c1∣. In exact arithmetic an iteration started orthogonal to v1 stays orthogonal to it and converges to the dominant eigenvector of the rest of the spectrum. In floating point it does not: rounding injects a component along v1 of relative size about the unit roundoff u (Floating-point arithmetic and error), and from then on that component grows by ∣λ1/λ2∣ per step, so the iteration turns towards v1 after roughly ln(1/u)/ln∣λ1/λ2∣ additional steps. A random q0 makes the event c1=0 one of probability zero, which is why starting vectors are chosen at random in practice.
Hermiticity. Used twice in step 2 and nowhere in step 1. Claim 1 holds for any diagonalizable A with the constant tanθ0 replaced by a constant involving the condition number of the eigenvector matrix. Claim 2 does not: without an orthonormal eigenbasis the expansion ρ=∑iλi∣di∣2 is false, and the Rayleigh quotient converges only at the first-order rate ∣λ2/λ1∣k. Doubling the exponent is a reward for symmetry.
The normalisation. Nothing in the mathematics needs it; the floating-point format does. Without it the iterates grow or shrink like ∣λ1∣k and overflow or underflow within a few hundred steps.
The same iteration in a Hilbert space.Stakgold and Holst (Stakgold & Holst (2011), §6.5, Exercise 6.5.2, p. 406) set out the power iteration for a nonnegative symmetric Hilbert-Schmidt operator K in a form that avoids normalising at all: from a trial function f0 with Kf0=0 they form fn=Knf0, define the moments ak=(fi,fk−i) — a quantity that depends only on k, not on the split — and state that the quotients ak+1/ak increase monotonically and are bounded above by the largest eigenvalue λ1, with convergence to λ1 whenever f0 is not orthogonal to the first eigenfunction. Their hypothesis that f0 is not orthogonal to that eigenfunction is our c1=0; their monotonicity is a sharper statement than our part 2 and is bought with the extra hypothesis that K is nonnegative. The example below exhibits both in the same computation.
Method(Inverse iteration with a shift, and the Rayleigh quotient iteration)Original
Let A be Hermitian with eigenvalues λ1,…,λn and orthonormal eigenbasis v1,…,vn, and let σ∈R not be an eigenvalue of A.
The shifted inverse.(A−σI)−1 is Hermitian, has the same eigenvectors as A, and has eigenvalues (λi−σ)−1. Consequently its dominant eigenvalue corresponds to the eigenvalue of Anearestσ.
Inverse iteration. Suppose some λj is strictly nearest σ, that is ∣λj−σ∣<δ:=mini=j∣λi−σ∣, and let q0 be a unit vector with (q0,vj)=0. Let θk be the angle between the inverse iterate qk and span{vj}. Then
tanθk≤(δ∣λj−σ∣)ktanθ0,λj−ρ(qk)≤Dsin2θk,
with D=maxi∣λj−λi∣. The convergence factor ∣λj−σ∣/δ is at the user's disposal: it is small exactly when σ is a good guess.
3. Cubic convergence of the Rayleigh quotient iteration. Let qk be a unit vector, σk=ρ(qk), θk the angle from qk to span{vj} and δk=mini=j∣λi−σk∣. If σk is not an eigenvalue, then one step of inverse iteration with the shift σk produces qk+1 with
tanθk+1≤δk∣λj−σk∣tanθk≤δkDsin2θktanθk.
Once θk is small enough that δk is bounded below by half the gap between λj and the rest of the spectrum, the error is therefore cubed at every step.
Idea of the proofOriginal
Everything here is the previous theorem applied to a different matrix. Inverting turns the eigenvalue nearest σ — the one the power method is worst at finding — into the one of largest modulus, which the power method is best at finding (Riley, Hobson & Bence (2006), §8.13, p. 273). The cost is one linear solve per step instead of one matrix-vector product, and since the matrix A−σI is the same at every step it is factorized once. The Rayleigh quotient iteration then notices that a shift is only as good as the information behind it, and feeds the current eigenvalue estimate back in as the next shift. Each step gains twice over: the shift is better by the square of the angle, which is the Rayleigh quotient's own accuracy, and the step then reduces the angle in proportion to the shift error. Two times the error squared, once more linearly: the exponent is three.
ProofOriginal
Set B=(A−σI)−1. Since σ is real and A is Hermitian, A−σI is Hermitian, and it is invertible because σ is not an eigenvalue; the inverse of an invertible Hermitian matrix is Hermitian, as (B∗)=((A−σI)∗)−1=B. From Avi=λivi we get (A−σI)vi=(λi−σ)vi, and applying B to both sides and dividing by the non-zero scalar λi−σ gives Bvi=(λi−σ)−1vi. This is the familiar statement that the inverse keeps the eigenvectors and reciprocates the eigenvalues (Riley, Hobson & Bence (2006), §8.13, p. 273)(Arfken, Weber & Harris (2013), Exercise 6.4.5, p. 318), applied to the shifted matrix. The map t↦(t−σ)−1 is largest in modulus at the λi closest to σ, which proves the last clause.
The inverse iteration is the power iteration for B, since qk+1 is Bqk normalised. B is Hermitian with the same eigenvectors vi, and by hypothesis its eigenvalue (λj−σ)−1 is strictly largest in modulus, with the next largest of modulus 1/δ. The power iteration statement applied to B gives
tanθk≤(1/∣λj−σ∣1/δ)ktanθ0=(δ∣λj−σ∣)ktanθ0.
The Rayleigh quotient bound is part 2 of that statement applied to A itself — not to B — with vj in the role of v1: its proof used only that vj is a unit eigenvector of a Hermitian matrix and that sinθk is the norm of the part of qk orthogonal to it, both of which hold here.
The first inequality is a direct one-step estimate, and needs no assumption beyond the one made: that σk is not an eigenvalue. Expand qk=∑idivi in the orthonormal eigenbasis. One step of inverse iteration with the shift σk replaces qk by the normalisation of (A−σkI)−1qk=∑i(λi−σk)−1divi, which is defined because no λi equals σk. A tangent is unchanged by scaling, so, taking dj=0 (otherwise tanθk=∞ and there is nothing to prove),
where the inequality is ∣λi−σk∣≥δk for every i=j. (This is the computation behind part 2, run for a single step; part 2 itself may not be invoked here, because its hypothesis that λj is strictly nearest the shift is exactly what part 3 declines to assume. Without that hypothesis the estimate still holds, the factor merely failing to be smaller than 1.) For the second inequality, part 2 of the power iteration statement, applied to A and vj, bounds the shift error itself: ∣λj−σk∣=∣λj−ρ(qk)∣≤Dsin2θk. Substituting gives the stated bound. If θk is small enough that δk≥21mini=j∣λi−λj∣=:21g, then tanθk+1≤(2D/g)sin2θktanθk≤(2D/g)tan3θk, a cubic recursion, which contracts as soon as tan2θk<g/(2D). □
Method(The QR algorithm)Original
Let A∈Mn(C) and let Ak, Qˉk, Rˉk be as in the definition, with every Rk taken to have non-negative diagonal. Write Ej=span{e1,…,ej} for the span of the first j standard basis vectors.
Similarity.Ak=Qˉk∗AQˉk for every k. Every iterate therefore has the same eigenvalues, trace and determinant as A(Arfken, Weber & Harris (2013), Exercise 6.4.1, p. 317), and if A is Hermitian then so is every Ak.
It is power iteration on a flag.Ak=QˉkRˉk. If A is invertible, the first j columns of Qˉk are an orthonormal basis of AkEj, simultaneously for j=1,…,n.
Convergence. Suppose A=XΛX−1 is diagonalizable with Λ=diag(λ1,…,λn) and
∣λ1∣>∣λ2∣>⋯>∣λn∣>0,
and suppose every leading principal submatrix of X−1 is invertible, equivalently that X−1=LU with L unit lower triangular and U upper triangular (Solving linear systems numerically). Then there is a constant C, depending on A but not on k, such that for each j=1,…,n−1,
∣(Ak)mi∣≤Cλjλj+1kfor all i≤j<m,and(Ak)jj⟶λj as k→∞,
the last also for j=n. In particular the subdiagonal entries go to zero, the iterates become upper triangular in the limit, and the eigenvalues appear on the diagonal in order of decreasing modulus.
Idea of the proofOriginal
Run the power iteration on e1 and you get the dominant eigenvector. Run it on e1 and e2 at once and both columns swing towards v1, so the second carries no new information — unless you orthogonalize against the first at every step, which is exactly what taking a QR factorization does. What survives in column j is then the part of the dominant behaviour that the first j−1 columns have not already claimed, so the span of the first j columns converges to the invariant subspace belonging to the j largest eigenvalues, at the rate ∣λj+1/λj∣ set by the gap at that position in the list. The two lines of the algorithm, "factor and multiply back in the other order", do this for all j at once while keeping the matrix similar to A. Once the span of the first j columns is invariant, the block of Ak below the leading j×j corner vanishes; that happening for every j simultaneously is triangularity, and the diagonal of a triangular matrix is its spectrum.
ProofOriginal
1. Similarity. From Ak−1=QkRk and the unitarity of Qk we get Rk=Qk∗Ak−1, hence Ak=RkQk=Qk∗Ak−1Qk. Induction on k, with A0=A and Qˉ0=I, gives Ak=Qˉk∗AQˉk. A similarity transformation changes neither the characteristic polynomial nor therefore the eigenvalues, trace or determinant (Arfken, Weber & Harris (2013), Exercise 6.4.1, p. 317); and if A∗=A then Ak∗=Qˉk∗A∗Qˉk=Ak.
2. The power-iteration identity. For k=1 the claim A1=Qˉ1Rˉ1 is the factorization A=Q1R1. Assume Ak=QˉkRˉk. By part 1, AQˉk=QˉkAk, and Ak=Qk+1Rk+1 by definition, so
For the second sentence, let qˉ1,…,qˉn be the columns of Qˉk. Reading column i of Ak=QˉkRˉk and using that Rˉk is upper triangular gives Akei=∑m≤i(Rˉk)miqˉm, so AkEj⊆span{qˉ1,…,qˉj}. If A is invertible then so is Ak, so AkEj has dimension j and the inclusion is an equality. The qˉm are orthonormal because Qˉk is unitary.
3. Convergence. Fix j with 1≤j≤n−1 and write rj=∣λj+1/λj∣<1. Let x1,…,xn be the columns of X, so Axi=λixi, and let Sj=span{x1,…,xj}, which is A-invariant. Note A is invertible, since ∣λn∣>0.
Step (a): an explicit basis of AkEj. Using Ak=XΛkX−1 and the hypothesis X−1=LU,
Ak=XΛkLU=X(ΛkLΛ−k)ΛkU.
Both U and Λk are invertible and upper triangular, so ΛkU maps Ej onto Ej and
Nk is unit lower triangular. Split it into blocks along the jth row and column, Nk=(N11N210N22) with N11 of size j×j. Then NkEj is spanned by the columns of (N11N21), and multiplying on the right by the invertible (N11)−1 does not change that span, so
NkEj=column span of (IjΔk),Δk:=N21(N11)−1.
Step (b): Δk is small. The entries of N21 are Lim(λi/λm)k with i>j≥m; since the moduli decrease strictly, ∣λi/λm∣≤∣λj+1/λj∣=rj for all such i,m, so every entry is at most ℓrjk in modulus, where ℓ=maxi>m∣Lim∣. The matrix N11 is Ij plus a strictly lower triangular matrix whose entries are bounded by ℓ uniformly in k (each is Lim times a number of modulus below one); a strictly lower triangular j×j matrix is nilpotent of index j, so (N11)−1=∑p<j(Ij−N11)p is bounded in norm uniformly in k. Hence ∥Δk∥≤c1rjk for a constant c1 independent of k.
Step (c): AkEj is close to Sj, in both directions. By steps (a) and (b), AkEj is spanned by the vectors yi=xi+∑m>j(Δk)mixm for i≤j. Let u=∑i≤jciyi be any element of AkEj and put u0=∑i≤jcixi∈Sj. Then u=X(Δkcc) and u−u0=X(Δkc0), so
∥u−u0∥≤∥X∥∥Δk∥∣c∣and∥u∥≥σmin(X)∣c∣,
whence ∥u−u0∥≤εk∥u∥ with εk:=κ2(X)∥Δk∥≤C0rjk (Matrix norms and condition numbers). Exchanging the roles of u and u0 in the same two estimates — given w=∑i≤jcixi∈Sj, compare it with w′=∑i≤jciyi∈AkEj — gives dist(w,AkEj)≤εk∥w∥ as well. So, writing Pk and P for the orthogonal projectors onto AkEj and Sj, both ∥(I−P)Pk∥ and ∥(I−Pk)P∥ are at most εk, and from the identity Pk−P=Pk(I−P)−(I−Pk)P together with ∥Pk(I−P)∥=∥(I−P)Pk∥ (adjoints of each other, both projectors being self-adjoint),
∥Pk−P∥≤2εk.
Step (d): the block below the corner. Let i≤j<m. By part 2, qˉi∈AkEj and qˉm⊥AkEj, so (Ak)mi=(Aqˉi,qˉm) is a component of (I−Pk)Aqˉi and is bounded by its norm. Write qˉi=u0+r with u0∈Sj and ∥r∥≤εk, as step (c) permits. Then Au0∈Sj because Sj is invariant, so ∥(I−Pk)Au0∥≤εk∥Au0∥≤εk∥A∥(1+εk) by the second estimate of step (c), while ∥(I−Pk)Ar∥≤∥A∥εk. Adding, and assuming εk≤1 (true for large k),
∣(Ak)mi∣≤∥(I−Pk)Aqˉi∥≤3∥A∥εk≤Crjk.
Enlarging C to cover the finitely many small k with εk>1 gives the stated bound for all k.
Step (e): the diagonal. The trace of the leading j×j block of Ak is ∑i≤j(Aqˉi,qˉi)=tr(PkAPk)=tr(APk). Since ∣trM∣≤n∥M∥ and ∥A(Pk−P)∥≤2εk∥A∥ by step (c),
tr(APk)−tr(AP)≤2n∥A∥εkk→∞0.
In an orthonormal basis whose first j vectors span Sj, invariance makes A block upper triangular with leading block B the matrix of A restricted to Sj, and PAP is B in the corner and zero elsewhere; since Sj is spanned by eigenvectors for λ1,…,λj, tr(AP)=trB=λ1+⋯+λj. So the trace of the leading j×j block of Ak tends to λ1+⋯+λj for j=1,…,n−1, and for j=n it equals trA=λ1+⋯+λn exactly, by part 1. Subtracting consecutive cases,
(Ak)jj=(trace of leading j×j)−(trace of leading (j−1)×(j−1))⟶λj
for every j, the case j=1 needing only the first bracket. □
Remark(Where the hypotheses are used)Original
Distinct moduli, in part 3. Step (b) needs ∣λi/λm∣≤rj<1 for i>j≥m, which is exactly the strict ordering. Without it the algorithm need not converge at all: for A=(0110) the QR factorization is Q=A, R=I, so A1=RQ=A and every iterate equals A, whose off-diagonal entries never decay. Here λ=±1 have equal modulus. The same obstruction appears for every real matrix with a complex conjugate pair of eigenvalues, since a real iteration cannot converge to a real triangular matrix with non-real diagonal; the practical remedy is to stop at the real Schur form, in which such a pair survives as a 2×2 diagonal block, and to read its eigenvalues off directly.
The LU factorization of X−1. Used only in step (a), to arrange that AkEj is a graph over Sj. Without it the diagonal can converge to the eigenvalues in the wrong order. Take A=diag(1,2) with the eigenvalues listed as λ1=2, λ2=1, so that X=(0110) and X−1=X has a vanishing leading entry and no LU factorization. The moduli are distinct, but A is already upper triangular with Q1=I, so every iterate is diag(1,2) and (Ak)11=1=λ1. Nothing is lost numerically — the eigenvalues are still on the diagonal — but the clean ordering is.
∣λn∣>0. Used in part 2 to know that AkEj has dimension j. A singular A is handled by shifting: the eigenvalues of A+cI are λi+c, and the iteration is run on the shifted matrix.
Hermiticity is not assumed in any part of this statement, unlike the two earlier ones. What Hermiticity buys is part 1's last clause: every iterate stays Hermitian, so only half the matrix need be stored and touched, and the tridiagonal form of the method below is available.
Non-negative diagonal in Rk. A convenience, not a necessity: it makes the factorization unique for invertible Ak−1 (Orthonormal bases and Gram-Schmidt) and so makes "the" QR iteration well defined. Any other choice of phases changes each Ak by a diagonal unitary conjugation, which alters no modulus in the statement.
Method(Computing eigenvalues in practice)Original
Decide first which eigenvalues you need; that decides the algorithm.
Locate the spectrum cheaply. Gershgorin's theorem — every eigenvalue λ of C=(cjk) satisfies ∣cjj−λ∣≤∑k=j∣cjk∣ for at least one j(Kreyszig (1978), §5.2, Problem 4, p. 313) — costs O(n2) and brackets every eigenvalue in a union of discs. Use it to choose shifts and to check an answer for gross error.
The dominant eigenvalue only, with A large and sparse: power iteration. One matrix-vector product per step; cost per step is the cost of that product. Stop when η(qk) is below the tolerance, and report the bracket [ρ−η,ρ+η] of the lemma above. Expect ln(1/tol)/ln∣λ1/λ2∣ steps, so stop early and change method if the ratio is near one.
One eigenvalue near a known σ, or an eigenvector for an eigenvalue you already have: inverse iteration. Factor A−σI once with pivoted LU (Solving linear systems numerically), at cost 32n3 for a dense matrix and far less for a banded one, then reuse the factors each step at O(n2). Convergence factor ∣λj−σ∣/δ: a shift good to three digits usually gives the eigenvector in three or four steps.
Refining to full accuracy: switch to the Rayleigh quotient iteration once θ is small. It cubes the error, but A−σkI changes every step, so each step costs a fresh factorization. Two or three steps are enough; do not start from a poor guess, since the iteration is only locally convergent and can converge to an eigenvalue you did not want.
All the eigenvalues of a dense matrix: never iterate on the full matrix. First reduce A by unitary similarities to upper Hessenberg form (zero below the first subdiagonal), or to tridiagonal form if A is Hermitian. This costs O(n3) once and is exact in the sense that it terminates: counting a multiply and an add as one operation each, applying a Householder reflection to an m×p block costs 4mp, so the reduction costs about ∑k[4(n−k)2+4n(n−k)]≈310n3 in general and about 34n3 when symmetry lets the two-sided update be done at once.
Then run shifted QR with deflation. The Hessenberg form is preserved by a QR step, and this is what makes the algorithm affordable: with Givens rotations a Hessenberg QR step costs about 6n2 operations — n−1 rotations acting on two rows of length n−k+1 at 6 operations per column, about 3n2 in all, and the same again applying them from the right — against about 34n3 for a QR factorization of a full matrix. A tridiagonal step costs O(n). Use the shift σk=(Ak)nn, or Wilkinson's shift (the eigenvalue of the trailing 2×2 block nearer to (Ak)nn) when a real matrix may have complex eigenvalues. When ∣(Ak)n,n−1∣ falls below u(∣(Ak)n−1,n−1∣+∣(Ak)nn∣), accept (Ak)nn as an eigenvalue, deflate — delete the last row and column — and continue on the leading (n−1)×(n−1) block. With shifts this takes two or three steps per eigenvalue in practice, so the whole iteration costs O(n2) for a tridiagonal matrix and the 34n3 reduction dominates.
Eigenvectors. Accumulate Qˉk if you want them all, which multiplies the cost by several; for a few, run one or two steps of inverse iteration with the computed eigenvalue as the shift, which is cheaper and more accurate.
Check the answer. Compute η for each computed pair and use the bracket. Compare ∑iλi with trA and ∏iλi with detA, both invariant under the similarities used (Arfken, Weber & Harris (2013), Exercise 6.4.1, p. 317).
The older Jacobi method — repeated plane rotations, each chosen to annihilate one off-diagonal entry, with tan2θ=2aij/(ajj−aii), each rotation reducing the sum of squares of the off-diagonal entries by 2aij2(Arfken, Weber & Harris (2013), §6.4 and Exercise 6.4.9, pp. 314, 318) — is still the most transparent way to see that a symmetric matrix can be diagonalized by iteration, and is still used where accuracy on tiny eigenvalues matters. Arfken, Weber and Harris (Arfken, Weber & Harris (2013), §6.4, p. 314) describe it as superseded by more efficient though less transparent methods; step 6 is what superseded it.
Example(All three iterations on one 4×4 matrix)Original
the irrational ones computed to the digits shown and checked against ∑λi=trA=18 and ∏λi=detA=180. A is positive definite, and the ratios that govern the three algorithms are
(a) Power iteration, by hand to begin with. Start at q0=e1; the exact dominant eigenvector is v1=(0.6579120,0.5834795,0.4006479,0.2572641)T, so (q0,v1)=0.658=0 and the hypothesis holds. The unnormalised iterates Ake1 are integer vectors,
increase monotonically and stay below λ1=8.38270, exactly as that exercise asserts for a nonnegative symmetric operator.
Normalising at each step and recording the Rayleigh quotient, the angle to v1 and the residual:
k
ρ(qk)
λ1−ρ(qk)
sinθk
η(qk)
bracket
5
8.367694690
1.50×10−2
6.644×10−2
2.256×10−1
[8.14207,8.59332]
10
8.382615289
8.47×10−5
5.002×10−3
1.692×10−2
[8.36569,8.39954]
15
8.382699457
4.82×10−7
3.776×10−4
1.277×10−3
[8.38142,8.38398]
20
8.382699937
2.75×10−9
2.851×10−5
9.644×10−5
[8.38260,8.38280]
Every bracket contains λ1=8.3826999, as the lemma guarantees, and every one is pessimistic by about a factor of η, as predicted. The ratio of successive sinθk at k=20 is 0.5964665 and the ratio of successive Rayleigh errors is 0.3557723; the predicted values are λ2/λ1=0.5964665 and (λ2/λ1)2=0.3557723. The explicit bounds also hold with room to spare: tanθ0=1.1447, so part 1 allows tanθ20≤1.1447×0.596466520=3.72×10−5 against the observed 2.85×10−5, and with D=λ1−λ4=7.0915 part 2 allows 5.76×10−9 against the observed 2.75×10−9.
(b) Inverse iteration at an interior eigenvalue. Take σ=3.5, a guess at λ3. The distances are ∣λi−σ∣=4.883,1.5,0.1739,2.209, so λ3 is strictly nearest, δ=1.5, and the predicted convergence factor is 0.17385/1.5=0.11590. From q0=e1:
k
ρ(qk)
ρ(qk)−λ3
sinθk
1
3.374449339
4.83×10−2
1.607×10−1
3
3.326156621
6.76×10−6
2.032×10−3
5
3.326149859
1.23×10−9
2.716×10−5
The observed ratio sinθ5/sinθ4=2.716×10−5/2.347×10−4=0.1157 matches the predicted 0.1159. Five steps against the twenty of part (a), for an eigenvalue the power method cannot reach at all.
(c) Rayleigh quotient iteration. Start from q0=(0,0,1,1)T/2, for which ρ(q0)=5.5. The successive Rayleigh quotients and angles are
The iteration has found λ2=5. Cubing each angle predicts the next: (1.094×10−3)3=1.31×10−9 against 3.46×10−10, and (3.456×10−10)3=4.13×10−29 against 3.156×10−29. In double precision this would have reached full accuracy at step three; the computation above was done in 60-digit arithmetic so that the cubic law could be seen twice.
(d) The unshifted QR algorithm. The hypotheses of part 3 hold: the four moduli are distinct and non-zero, and the leading principal minors of X−1=XT (the eigenvector matrix is orthogonal here) are −0.6579, −0.3369, 0.7739, 1, all non-zero. The subdiagonal entries of Ak:
k
∣(Ak)21∣
∣(Ak)32∣
∣(Ak)43∣
10
1.692×10−2
6.605×10−2
8.256×10−6
20
9.644×10−5
1.123×10−3
6.307×10−10
30
5.497×10−7
1.905×10−5
4.900×10−14
The ratios of successive values at k=30 are 0.5964665, 0.6652300 and 0.3881816: each subdiagonal entry decays at exactly the ratio ∣λj+1/λj∣ belonging to its own position, confirming the rates in part 3. The diagonal at k=30 is (8.3826999,5.0000000,3.3261499,1.2911502), the eigenvalues in order of decreasing modulus.
Part 2 of the statement can be checked on the same run. The first column of Qˉk is the power iterate from e1, so column one of Ak below the diagonal should reproduce the power iteration of part (a): at k=20 its norm is 9.64399×10−5 and (A20)11=8.382699937, which are exactly the residual η(q20) and the Rayleigh quotient ρ(q20) in the table of part (a).
(e) Shifted QR. Repeat with the shift σk=(Ak)44 at every step, that is, factor Ak−σkI=Qk+1Rk+1 and set Ak+1=Rk+1Qk+1+σkI. Starting from ∣(A0)43∣=2:
with (A6)44=1.291150202885637, matching λ4 to all sixteen digits shown. The last three entries show the cubic law again, (3.54×10−3)3=4.4×10−8 and (1.12×10−8)3=1.4×10−24; this is the Rayleigh quotient iteration of part (c), hidden in the corner of the matrix. Six steps and one deflation, against the thirty of part (d) for a result still only accurate to seven digits in the first subdiagonal.
Application(Normal modes, and why nobody computes the whole spectrum)Original
Discretise −u′′=λu on (0,1) with u(0)=u(1)=0 by second differences on a grid of N=200 interior points, h=1/201 (Finite-difference approximations). The matrix is h−2 times the tridiagonal matrix with 2 on the diagonal and −1 beside it, and its eigenvalues are known exactly, λk=4h−2sin2(kπh/2), which makes it a fair test. The smallest is λ1=9.869403 against the continuum value π2=9.869604, a relative error of −2.0×10−5 of the expected size O(h2); the largest is λ200=1.6159×105.
A physicist wants the low modes: they are the ones the continuum problem has, and the high ones are discretisation artefacts. The numbers show why the choice of algorithm is not a detail.
Power iteration is useless here. It converges to the largest eigenvalue, and does so at the ratio λ199/λ200=0.9998168. Reaching ten digits would take ln(10−10)/ln(0.9998168)≈1.26×105 matrix-vector products, for an eigenvalue of no physical interest.
Inverse iteration is immediate. With σ=0 the convergence factor is λ1/λ2=0.2500153, so ten digits take ln(10−10)/ln(0.25)≈17 steps. Each step is one solve with a tridiagonal matrix, O(N) work after a single O(N) factorization (Solving linear systems numerically): the whole computation costs less than two steps of the power iteration cost on a dense matrix of the same size.
Shift-invert reaches the interior. For the tenth mode, put σ=985. The nearest eigenvalue is λ10=984.952862 at distance 0.0471 and the next nearest is λ9 at distance 186.9, so the convergence factor is 2.522×10−4: three steps shrink the eigenvector angle by (2.522×10−4)3=1.6×10−11, eleven digits in the eigenvector, and, by the squaring in part 2 of the power iteration statement, far more than that in the eigenvalue. (λ10 differs from the continuum 100π2=986.9604 by −2.0×10−3 in relative terms, a hundred times the error in λ1 — the discretisation error grows with the mode number, which is the real limit on how far up the spectrum this grid can be trusted.)
The same three-way choice recurs wherever a matrix eigenvalue problem comes out of physics: the normal modes of a structure or a molecule (Generalized eigenproblems and normal modes), the band energies of a tight-binding Hamiltonian, the stationary distribution of a Markov chain (the classic use of the power method, since the distribution is the dominant eigenvector), and the stability of a fixed point, where only the sign of the largest real part is wanted. For a dense matrix of moderate size, the reduction plus shifted QR of the method above returns the whole spectrum for a small multiple of n3 operations and is what every library routine does. For the very large sparse problems of quantum chemistry it is not available at any price: a dense n3 is unthinkable and even storing Qˉk is impossible, so one computes a few eigenvalues by Krylov subspace methods, built on the same matrix-vector product as the power iteration but extracting far more from it, exactly as the conjugate gradient method does for linear systems (Solving linear systems numerically). Arfken, Weber and Harris (Arfken, Weber & Harris (2013), §6.4, p. 314 and footnote) give the scale that this makes possible: a configuration-interaction calculation that obtained eigenvalues and eigenvectors of a matrix of dimension beyond 109.