Romberg integration
| Problem | Approximate for a smooth |
| Devised by | Werner Romberg (1955), building on Lewis Fry Richardson’s extrapolation (1911, 1927) and the Euler-Maclaurin formula (Euler 1735, Maclaurin 1742) |
| Accuracy | Column of the tableau has error ; the diagonal converges faster than any power of for analytic |
| Cost | evaluations for levels; every evaluation is reused |
| Read first | Newton-Cotes rules: midpoint, trapezoid and Simpson |
| API | RombergEngine, integrate_with_error, tableau |
Overview
The trapezoid rule is the simplest quadrature rule, and on its own it converges slowly: halving the step only quarters the error. Romberg integration turns it into a high-order method without any new function evaluations. It computes trapezoid estimates with panels and combines them so that the leading error terms cancel, one order at a time. The result is a triangular tableau whose columns converge at rates , and whose diagonal converges very quickly for smooth integrands.
Romberg integration is a good default for smooth integrands that are cheap to evaluate, and it is the textbook example of Richardson extrapolation, one of the most widely used ideas in numerical analysis.
Where it is used
Romberg integration shows how extrapolation turns a simple rule into a very accurate one.
- Smooth integrands. With a handful of function values it reaches high accuracy, as for integrals of analytic functions in physics and engineering formulas.
- Teaching extrapolation. The same Richardson idea improves finite-difference derivatives and ODE solvers.
History
The key ingredient is older than the method. In 1911 the meteorologist Lewis Fry Richardson, solving differential equations for stresses in masonry dams, noticed that if a computed result has an error proportional to , then combining results at two step sizes eliminates that error. With J. A. Gaunt he developed the idea in 1927 as “the deferred approach to the limit”.
Werner Romberg, a German mathematician who emigrated in 1933, settled in Norway in 1938 and later taught at the Norwegian Institute of Technology in Trondheim, published Vereinfachte numerische Integration (“Simplified numerical integration”) in 1955. He observed that the trapezoid rule’s error has a particularly clean structure, containing only even powers of , and that extrapolation could therefore be repeated indefinitely. The method’s convergence was analysed by Bauer, Rutishauser and Stiefel in 1963, and it became a staple of early scientific computing libraries.
The idea
The trapezoid rule and its error
With panels of width and nodes , the composite trapezoid rule is
Its error is not merely “”. The Euler-Maclaurin formula describes it exactly: if is smooth,
where are the Bernoulli numbers (, ). Two features make Romberg integration work. The coefficients do not depend on , and only even powers of appear. (Strictly the expansion is asymptotic rather than convergent, but truncating it after any term leaves a remainder of the next order.)
Richardson extrapolation
Write and . The combination that cancels is
This is exactly Simpson’s rule, obtained here without ever thinking about parabolas. The new estimates still have an expansion in even powers, now beginning at , so the trick can be repeated with factor to cancel , then to cancel , and so on.
The tableau
Let and define
Each column removes one more term of the Euler-Maclaurin expansion, so
Column 1 is Simpson’s rule, column 2 is Boole’s rule, and later columns are new rules that are not Newton-Cotes rules. The figure shows each column of the tableau for on logarithmic axes: the slopes are 2, 4, 6, 8 and 10, as the theory predicts.
Figure 2.6. Error of the Romberg columns.
Each level costs only the new midpoints
Halving keeps all the old nodes and adds the midpoints, so
Level therefore needs only new evaluations, and the whole tableau up to level uses values of . The extrapolation itself is a few arithmetic operations per entry.
When it does not help
Extrapolation assumes the Euler-Maclaurin expansion holds, which requires to be smooth on the closed interval. With the derivatives blow up at , the error expansion contains fractional powers such as , and extrapolating as though they were gains almost nothing. The singular convergence figure shows this.
The opposite extreme is just as instructive. If is periodic and smooth, all the because the endpoint derivatives cancel. The trapezoid rule is then already exponentially accurate on its own, and extrapolation can only spoil it.
Algorithm
- .
- For :
- .
- For : .
- Stop when is below the tolerance (the library requires before stopping, to avoid accidental early agreement).
- Return .
Only two rows need to be stored at any time.
Implementation
integrate_with_error
keeps the previous row and builds the next one in place:
let mut h = b - a;
let mut previous = vec![0.5 * h * (f(a) + f(b))];
for k in 1..=self.max_levels {
// Refine the trapezoid rule with the new midpoints.
let panels = 1usize << (k - 1);
let midpoints: f64 = (0..panels).map(|i| f(a + (i as f64 + 0.5) * h)).sum();
h *= 0.5;
let mut row = Vec::with_capacity(k + 1);
row.push(0.5 * previous[0] + h * midpoints);
let mut factor = 1.0;
for j in 1..=k {
factor *= 4.0;
let value = row[j - 1] + (row[j - 1] - previous[j - 1]) / (factor - 1.0);
row.push(value);
}
let error = (row[k] - previous[k - 1]).abs();
if k >= 3 && (error <= self.tolerance * row[k].abs() || error == 0.0) {
return Ok((row[k], error, k));
}
previous = row;
}
factorholds incrementally, so no powers are computed.- The returned error estimate, , is usually pessimistic. The diagonal converges so fast that the newer value is typically far more accurate than the difference suggests.
tableaureturns the whole triangle, which is useful for studying the method and for the exercises.
In practice
The tableau for , as computed by the library:
Table 2.7. A Romberg tableau.
| 0 | 1/1 | 1.859140914230 | ||||
| 1 | 1/2 | 1.753931092465 | 1.718861151877 | |||
| 2 | 1/4 | 1.727221904558 | 1.718318841922 | 1.718282687925 | ||
| 3 | 1/8 | 1.720518592164 | 1.718284154700 | 1.718281842218 | 1.718281828795 | |
| 4 | 1/16 | 1.718841128580 | 1.718281974052 | 1.718281828675 | 1.718281828460 | 1.718281828459 |
Exact value: .
Reading along a row, each extrapolation gains several digits. With 17 function evaluations, is correct to about 14 digits, while the trapezoid rule with the same evaluations has only three correct digits.
A complete program:
//! Romberg integration: the extrapolation tableau and the adaptive driver.
//!
//! Run with `cargo run -p lib_jsl_integration --example quadrature_romberg`.
use lib_jsl_integration::romberg::RombergEngine;
fn main() {
let exact = std::f64::consts::E - 1.0;
let engine = RombergEngine::new(0.0, 1.0);
// Row k uses the trapezoid rule with 2^k panels; column j removes the h^{2j} error term.
let table = engine.tableau(f64::exp, 4).unwrap();
for (k, row) in table.iter().enumerate() {
let errors: Vec<String> = row.iter().map(|v| format!("{:9.1e}", (v - exact).abs())).collect();
println!("k = {k}: {}", errors.join(" "));
}
// The driver adds rows until the diagonal stops changing.
let (value, estimate, levels) = engine.integrate_with_error(f64::exp).unwrap();
println!("∫₀¹ eˣ dx ≈ {value:.15} after {levels} levels (estimate {estimate:.1e}, true error {:.1e})", (value - exact).abs());
}
Strengths
- Very simple, with high order obtained from the most basic rule.
- Nested: every function value is reused at all later levels.
- A built-in error estimate from successive diagonal entries.
Weaknesses
- Evaluation counts double at each level (17, 33, 65, …), so the granularity is coarse.
- It requires smoothness on the closed interval, including at the endpoints; singularities or kinks remove the benefit entirely.
- For expensive integrands, Gaussian quadrature reaches the same accuracy with fewer evaluations; compare the smooth convergence figure.
Exercises
- Show algebraically that , Simpson’s rule, where is the midpoint and .
- Show that is Boole’s rule, with weights proportional to .
- Use
tableauon . Why are the trapezoid values in column 0 already more accurate than the extrapolated ones? - Apply Romberg integration to and estimate the convergence rate of each column. Explain the result using the term in the error expansion.
- Richardson extrapolation works for any expansion . Use it to improve the central difference , which has , and test it on at .
Hints and answers
- With and , .
- with the Simpson rule on 4 panels and on 2: combine the weights to find with factor for step .
- The integrand is periodic and analytic, so the trapezoid values converge geometrically and the Euler-Maclaurin series has no terms to eliminate. Extrapolation then only mixes in rounding error.
- The error expansion contains along with the even powers. Richardson steps remove but not , so every column converges at roughly the rate (the empirical rate of the limit) and Romberg’s advantage is lost.
- , so cancels the term and has error . For at and the error falls from about for the central difference to about .
Further reading
- W. Romberg, “Vereinfachte numerische Integration”, Det Kongelige Norske Videnskabers Selskabs Forhandlinger 28 (1955) 30–36.
- L. F. Richardson, “The approximate arithmetical solution by finite differences of physical problems involving differential equations”, Philosophical Transactions of the Royal Society A 210 (1911) 307–357.
- L. F. Richardson and J. A. Gaunt, “The deferred approach to the limit”, Philosophical Transactions of the Royal Society A 226 (1927) 299–361.
- F. L. Bauer, H. Rutishauser and E. Stiefel, “New aspects in numerical quadrature”, Proceedings of Symposia in Applied Mathematics 15, AMS (1963) 199–218.
- L. N. Trefethen and J. A. C. Weideman, “The exponentially convergent trapezoidal rule”, SIAM Review 56 (2014) 385–458. Why the plain trapezoid rule is so good for periodic functions.
- G. Dahlquist and Å. Björck, Numerical Methods in Scientific Computing, Vol. 1, SIAM, 2008, §3.4 and §5.2. A thorough treatment of extrapolation methods.