In
numerical analysis, Romberg's method is used to estimate the
definite integral
In mathematics, an integral assigns numbers to functions in a way that describes displacement, area, volume, and other concepts that arise by combining infinitesimal data. The process of finding integrals is called integration. Along with di ...
by applying
Richardson extrapolation repeatedly on the
trapezium rule or the
rectangle rule
In mathematics, a Riemann sum is a certain kind of approximation of an integral by a finite sum. It is named after nineteenth century German mathematician Bernhard Riemann. One very common application is approximating the area of functions or ...
(midpoint rule). The estimates generate a
triangular array. Romberg's method is a
Newton–Cotes formula – it evaluates the integrand at equally spaced points.
The integrand must have continuous derivatives, though fairly good results
may be obtained if only a few derivatives exist.
If it is possible to evaluate the integrand at unequally spaced points, then other methods such as
Gaussian quadrature and
Clenshaw–Curtis quadrature are generally more accurate.
The method is named after
Werner Romberg (1909–2003), who published the method in 1955.
Method
Using
, the method can be inductively defined by
where
and
.
In
big O notation
Big ''O'' notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. Big O is a member of a family of notations invented by Paul Bachmann, Edmund Lan ...
, the error for ''R''(''n'', ''m'') is:
The zeroeth extrapolation, , is equivalent to the
trapezoidal rule with points; the first extrapolation, , is equivalent to
Simpson's rule with points. The second extrapolation, , is equivalent to
Boole's rule with points. The further extrapolations differ from Newton-Cotes formulas. In particular further Romberg extrapolations expand on Boole's rule in very slight ways, modifying weights into ratios similar as in Boole's rule. In contrast, further Newton-Cotes methods produce increasingly differing weights, eventually leading to large positive and negative weights. This is indicative of how large degree interpolating polynomial Newton-Cotes methods fail to converge for many integrals, while Romberg integration is more stable.
By labelling our
approximations as
instead of
, we can perform Richardson extrapolation with the error formula defined below:
Once we have obtained our
approximations
, we can label them as
.
When function evaluations are expensive, it may be preferable to replace the polynomial interpolation of Richardson with the rational interpolation proposed by .
A geometric example
To estimate the area under a curve the trapezoid rule is applied first to one-piece, then two, then four, and so on.

After trapezoid rule estimates are obtained,
Richardson extrapolation is applied.
*For the first iteration the two piece and one piece estimates are used in the formula The same formula is then used to compare the four piece and the two piece estimate, and likewise for the higher estimates
*For the second iteration the values of the first iteration are used in the formula
*The third iteration uses the next power of 4: on the values derived by the second iteration.
*The pattern is continued until there is one estimate.
*MA stands for more accurate, LA stands for less accurate
Example
As an example, the
Gaussian function is integrated from 0 to 1, i.e. the
error function
In mathematics, the error function (also called the Gauss error function), often denoted by , is a complex function of a complex variable defined as:
:\operatorname z = \frac\int_0^z e^\,\mathrm dt.
This integral is a special (non-elementary ...
erf(1) ≈ 0.842700792949715. The triangular array is calculated row by row and calculation is terminated if the two last entries in the last row differ less than 10
−8.
0.77174333
0.82526296 0.84310283
0.83836778 0.84273605 0.84271160
0.84161922 0.84270304 0.84270083 0.84270066
0.84243051 0.84270093 0.84270079 0.84270079 0.84270079
The result in the lower right corner of the triangular array is accurate to the digits shown.
It is remarkable that this result is derived from the less accurate approximations
obtained by the trapezium rule in the first column of the triangular array.
Implementation
Here is an example of a computer implementation of the Romberg method (in the
C programming language
''The C Programming Language'' (sometimes termed ''K&R'', after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as ...
):
#include
#include
void print_row(size_t i, double *R)
/*
INPUT:
(*f) : pointer to the function to be integrated
a : lower limit
b : upper limit
max_steps: maximum steps of the procedure
acc : desired accuracy
OUTPUT:
Rpax_steps-1
An axe ( sometimes ax in American English; see spelling differences) is an implement that has been used for millennia to shape, split and cut wood, to harvest timber, as a weapon, and as a ceremonial or heraldic symbol. The axe has ...
approximate value of the integral of the function f for x in ,bwith accuracy 'acc' and steps 'max_steps'.
*/
double romberg(double (*f)(double), double a, double b, size_t max_steps, double acc)
Here is an example of a computer implementation of the Romberg method in the
Javascript programming language.
/**
* INPUTS
* func = integrand, function to be integrated
* a = lower limit of integration
* b = upper limit of integration
* nmax = number of partitions, n=2^nmax
* tol_ae = maximum absolute approximate error acceptable (should be >=0)
* tol_rae = maximum absolute relative approximate error acceptable (should be >=0)
* OUTPUTS
* integ_value = estimated value of integral
*/
function auto_integrator_trap_romb_hnm(func, a, b, nmax, tol_ae, tol_rae)
References
*
*
*
*
*
*
* {{Citation , last1=Press, first1=WH , last2=Teukolsky, first2=SA , last3=Vetterling, first3=WT , last4=Flannery, first4=BP , year=2007 , title=Numerical Recipes: The Art of Scientific Computing, edition=3rd , publisher=Cambridge University Press, publication-place=New York, isbn=978-0-521-88068-8 , chapter=Section 4.3. Romberg Integration, chapter-url=http://apps.nrbook.com/empanel/index.html?pg=166
External links
ROMBINT– code for
MATLAB (author: Martin Kacenak)
Free online integration tool using Romberg, Fox–Romberg, Gauss–Legendre and other numerical methods
Numerical integration (quadrature)
Articles with example C code