Numerical Methods

All books

Convergence, and how to measure it

What this page answers

The class pages say a method converges. This page says how fast, and how to measure the rate when the answer is the thing you do not have. It settles the question a tolerance asks: if the step is halved, how much smaller does the error become?

A rate is a promise about the shape of the error, not a promise that the error is small. The difference matters before the asymptotic regime, where most real computations start.

The mathematics

Write the error after a step of size hh as

E(h)=Chp+O(hp+1).E(h) = C h^p + O(h^{p+1}).

The number pp is the order of the method, and CC is a constant that depends on the problem but not on hh. Halve the step and the leading term falls by 2p2^p: first order by 2, second order by 4, fourth order by 16.

That gives the observed order. With errors at hh and h/2h/2,

p≈log⁡2E(h)E(h/2).p \approx \log_2 \frac{E(h)}{E(h/2)}.

When the exact answer is unknown, the errors are unknown too. But the same argument works on three approximations. If fhf_h is the computed value at step hh, then fh−fh/2f_h - f_{h/2} has the same leading behaviour as E(h)E(h), so

p≈log⁡2∣fh−fh/2∣∣fh/2−fh/4∣.p \approx \log_2 \frac{|f_h - f_{h/2}|}{|f_{h/2} - f_{h/4}|}.

This is the Richardson estimate. It needs no exact answer, only three runs, and it is the reason a convergence table is evidence rather than decoration.

The same three values give an extrapolated answer. If the leading error is ChpC h^p, then

f0≈fh/2+fh/2−fh2p−1f_0 \approx f_{h/2} + \frac{f_{h/2} - f_h}{2^p - 1}

removes it, leaving the next term. Repeated extrapolation is the idea behind Romberg integration and behind the deferred-correction schemes in a solver.

What a rate does not promise

An order is an asymptotic statement. At large hh the O(hp+1)O(h^{p+1}) term can dominate, and the observed order can be anything. A method can be second order on a smooth solution and first order on a solution with a kink, because the expansion it assumes does not exist. And once E(h)E(h) reaches the round-off floor, halving hh makes the error larger, not smaller.

So a convergence table has three regions: pre-asymptotic, where the order is noise; asymptotic, where it is the method's order; and round-off, where it turns over. Reading the table means knowing which region you are in.

The check. For f(x)=exf(x)=e^x at x=1x=1, the forward difference has order 1 and the central difference order 2. The table below shows observed orders of 1.05 and 2.00 at h=0.1h=0.1, which is the arithmetic the page claims.

Figure 1

Predict. On log-log axes, how much lower is the central error than the forward error at the same step? Test. Move from one marker to the next on each line and read the change. Explain. Why the exponent, not the constant, is what the slope shows.

The code

The program computes both differences for four step sizes and prints the error and the observed order at each.

The two difference formulas and the convergence table
import math

x0 = 1.0
exact = math.exp(x0)

def forward(h):
    return (math.exp(x0 + h) - math.exp(x0)) / h

def central(h):
    return (math.exp(x0 + h) - math.exp(x0 - h)) / (2 * h)

print("h        forward error   order   central error   order")
previous = {"forward": None, "central": None}
for k in range(4):
    h = 0.2 / 2**k
    row = [f"{h:.5f}"]
    for name, method in (("forward", forward), ("central", central)):
        error = abs(method(h) - exact)
        if previous[name] is None:
            order = ""
        else:
            order = f"{math.log2(previous[name] / error):.2f}"
        previous[name] = error
        row += [f"{error:.3e}", f"{order:>6}"]
    print("  ".join(row))
h        forward error   order   central error   order
0.20000  2.909e-01          1.816e-02        
0.10000  1.406e-01    1.05  4.533e-03    2.00
0.05000  6.910e-02    1.02  1.133e-03    2.00
0.02500  3.426e-02    1.01  2.832e-04    2.00

The forward column approaches 1 and the central column sits at 2. The first forward estimate is 1.05 rather than 1.00 because h=0.1h=0.1 is not yet small enough for the h2h^2 term to be negligible. That is the pre-asymptotic region, visible in one row.

The theory

The expansion exists when the function has enough continuous derivatives. For a forward difference the Taylor series gives

f(x+h)−f(x)h=f′(x)+h2f′′(x)+O(h2),\frac{f(x+h)-f(x)}{h} = f'(x) + \frac{h}{2}f''(x) + O(h^2),

so p=1p=1 and C=f′′(x)/2C=f''(x)/2. For the central difference the hh terms cancel and the leading error is −h2f′′′(x)/6-h^2 f'''(x)/6, so p=2p=2.

Richardson extrapolation assumes the same expansion and a known pp. If the observed order is not stable across two refinements, the assumption is wrong and the extrapolated value is not more accurate. The check is cheap: compare the observed order before and after the extrapolation.

Round-off enters as a second term with the opposite slope. The difference quotient divides by hh, so an absolute error ϵ\epsilon in each value becomes ϵ/h\epsilon/h in the result. The total error is roughly Chp+ϵ/hC h^p + \epsilon/h, which has a minimum at h∼ϵ1/(p+1)h \sim \epsilon^{1/(p+1)}. Making hh smaller than that makes the answer worse. The turnover is not a bug in the method; it is the arithmetic of subtraction.

The sources for the rate and its verification are in sources.yaml. Roache's Verification and Validation in Computational Science and Engineering is the reference for the convergence table as evidence. LeVeque's Finite Difference Methods for Ordinary and Partial Differential Equations gives the expansions.

What this cost

One run per step size, so a three-grid table costs three solves. Richardson extrapolation needs no extra solve and gains one order when its assumptions hold. The observed order costs one extra run beyond the two values a reader would already have.

What it will not do: it will not validate the model, and it will not detect a wrong equation. A method can converge beautifully to the wrong answer. That is the next page's subject.

Back to the map

Home is the summary this page works under. Error, and what a tolerance is says how large the error is; this page says how fast it shrinks. Knowing the answer is right turns the rate into evidence about a model rather than only about a step size.

Settings

Colour scheme

Light or dark pages. Your colour and layout stay the same.

Colour

The paper, ink and lettering. Your layout stays the same.

Quiet colours
Bold colours
Layout

How pages are arranged. Your colours stay the same.

Reading offline

Keep this book on this device and read it offline.