Romberg's adaptive integration

romberg(f, a, b, m, tab = FALSE)

Arguments

f

function to integrate

a

the lowerbound of integration

b

the upperbound of integration

m

the maximum number of iterations

tab

if TRUE, return the table of values

Value

the value of the integral

Details

The romberg function uses Romberg's rule to calculate the integral of the function f over the interval from a to b. The parameter m sets the number of intervals to use when evaluating. Additional options are passed to the function f when evaluating.

See also

Other integration: adaptint(), gaussint(), giniquintile(), mcint(), midpt(), revolution-solid, simp38(), simp(), trap()

Other newton-cotes: adaptint(), giniquintile(), midpt(), simp38(), simp(), trap()

Examples

f <- function(x) { sin(x)^2 + log(x)}
romberg(f, 1, 10, m = 3)
#> [1] 18.48497
romberg(f, 1, 10, m = 5)
#> [1] 18.52473
romberg(f, 1, 10, m = 10)
#> [1] 18.52494