quadgr: Gaussian Quadrature with Richardson Extrapolation

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/quadgr.R

Description

Gaussian 12-point quadrature with Richardson extrapolation.

Usage

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

Arguments

f

integrand as function, 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

quadgr uses a 12-point Gauss-Legendre quadrature. The error estimate is based on successive interval bisection. Richardson extrapolation accelerates the convergence for some integrals, especially integrals with endpoint singularities.

Through some preprocessing infinite intervals can also be handled.

Value

List with value and rel.err.

Author(s)

Copyright (c) 2009 Jonas Lundgren for the Matlab function quadgr available on MatlabCentral under the BSD license.

R re-implementation by HwB, email: <[email protected]>, in 2011.

See Also

gaussLegendre

Examples

1
2
3
4
5
6
7
##  Dilogarithm function
flog <- function(t) log(1-t)/t
quadgr(flog, 1, 0, tol = 1e-12)
# value
# 1.6449340668482 , is pi^2/6 = 1.64493406684823
# rel.err
# 2.07167616395054e-13

Example output

$value
[1] 1.644934

$rel.err
[1] 2.071676e-13

pracma documentation built on June 21, 2017, 9:01 a.m.