gauss_kronrod.RdSimple Gaussian-Kronrod quadrature formula.
gauss_kronrod(f, a, b, ...)Gaussian quadrature of degree 7 with Gauss-Kronrod of degree 15 for error
estimation, the quadQK15 procedure in the QUADPACK library.
List of value and relative error.
Fausett, L. V. (2007). Applied Numerical Analysis Using Matlab. Second edition, Prentice Hall.
The function needs to be vectorized (though this could easily be changed), but the function does not need to be defined at the end points.
gauss_kronrod(sin, 0, pi) # 2.000000000000000 , rel.error: 1.14e-12
#> $value
#> [1] 2
#>
#> $rel.error
#> [1] 1.139977e-12
#>
gauss_kronrod(exp, 0, 1) # 1.718281828459045 , rel.error: 0
#> $value
#> [1] 1.718282
#>
#> $rel.error
#> [1] 0
#>
# 1.718281828459045 , i.e. exp(1) - 1