Learn R Programming

pracma (version 1.2.5)

romberg: Romberg Integration

Description

Romberg Integration

Usage

romberg(f, a, b, tol = .Machine$double.eps^(2/3), ...)

Arguments

f
function to be integrated.
a, b
end points of the interval.
tol
requested tolerance.
...
variables to be passed to the function.

Value

  • List of value and relative error.

Details

Simple Romberg integration with an explicit Richardson method applied to a series of trapezoidal integrals.

References

Mathews, J. H., and K. D. Fink (1999). Numerical Methods Using Matlab. Third Edition, Prentice Hall.

See Also

gauss_kronrod

Examples

Run this code
romberg(sin, 0, pi)  #  2.000000000000001 , rel.error: 6.6e-13
romberg(exp, 0, 1)   #  1.718281828459044 , rel.error: 3.6e-13
                     #  1.718281828459045 , i.e. exp(1) - 1

Run the code above in your browser using DataLab