Scientific Computing in Practice: Software, Validation & Reproducibility

an order-of-accuracy study

When a numerical method approximates a continuous problem, it commits a discretization error that depends on a step size — call it h, the spacing of your grid or the size of your time step. The method is supposed to be 'p-th order accurate', meaning the error behaves like C times h^p for small h: halve h and a second-order method (p=2) should cut the error by four, an first-order method by two. An order-of-accuracy study is the experiment that checks whether your code actually achieves the order the theory promises. It is one of the most powerful bug-detectors in scientific computing, because a wrong order almost always signals a coding mistake.

The procedure is concrete. Run your code on a problem with a known exact solution (often a manufactured one) at several decreasing step sizes — say h, h/2, h/4, h/8 — and record the error E(h) at each. If E(h) is approximately C h^p, then the ratio E(h) / E(h/2) should be about 2^p, so you can read off p directly: p is approximately log2( E(h) / E(h/2) ). A cleaner version plots log(E) against log(h); the points should fall on a straight line whose SLOPE is p. This 'observed order of accuracy' is the number you compare to the theoretical order. A second-order scheme that shows slope 2 on the log-log plot is behaving exactly as designed.

Why is this such a trusted certification? Because matching the predicted order is a stringent test: a code can give a plausible-looking answer on one mesh by luck, but it is very hard to accidentally produce the EXACT convergence RATE the math demands across several meshes unless the code is genuinely correct. When the observed order is lower than expected — a second-order scheme showing slope 1, or worse, slope 0 (no convergence) — that is a red flag pointing to a specific class of bug: a boundary condition applied to wrong order, a sign error, a mishandled term. Honest caveats: the asymptotic rate only appears once h is small enough to be in the 'asymptotic regime' (on coarse meshes the order can look wrong for innocent reasons), and once round-off dominates (h extremely small, or the error near machine epsilon) the clean rate breaks down. A study that ignores these two ends can be misread.

Testing a second-order finite-difference scheme, you measure max errors 4.0e-3, 1.0e-3, 2.5e-4 at h = 1/10, 1/20, 1/40. Each ratio is about 4, so log2(4) = 2: the observed order is 2, matching theory — the code is verified. If instead the errors were 4.0e-3, 2.0e-3, 1.0e-3 (ratios of 2), the observed order would be 1, signalling a bug that quietly dropped you to first order.

Halving h should cut a second-order method's error by four; the log-log slope reads off the observed order.

The clean rate only holds in the asymptotic regime: too coarse, and the order looks off for benign reasons; too fine, and round-off (near machine epsilon) ruins the trend. Read the order from the middle of the refinement sequence, not the extremes.

Also called
convergence studygrid refinement studymesh refinement study收斂研究網格細化研究