Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

quadgk

Adaptive Gauss-Kronrod Quadrature


Description

Adaptive Gauss-Kronrod Quadrature.

Usage

quadgk(f, a, b, tol = .Machine$double.eps^0.5, ...)

Arguments

f

integrand as function; needs to be vectorized, but may have singularities at the endpoints.

a, b

endpoints of the integration interval.

tol

relative tolerence.

...

Additional parameters to be passed to the function f.

Details

Adaptive version of the (7, 15)-point Gauss-Kronrod quadrature formula, where in each recursion the error is taken as the difference between these two estimated integrals.

The function f must be vectorized, though this will not be checked and may lead to strange errors. If it is not, use F = Vectorize(f).

Value

Value of the integration. The relative error should be of the same order of magnitude as the relative tolerance (or much smaller).

Note

Uses the same nodes and weights as the quadQK15 procedure in the QUADPACK library.

See Also

gauss_kronrod

Examples

##  Dilogarithm function
flog <- function(t) log(1-t)/t
quadgk(flog, 1, 0, tol = 1e-12)
# 1.644934066848128 - pi^2/6 < 1e-13

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.