integrateQAG

Calculate the integral of f(x) over the finite interval (a,b) using a simple globally adaptive integrator.

This method is suitable for functions without singularities or discontinuities which are too difficult for integrateQNG(), and, in particular, for functions with oscillating behaviour of a non-specific type.

It is possible to choose between 6 pairs of Gauss–Kronrod quadrature formulae for the rule evaluation component. The pairs of high degree of precision are suitable for handling integration difficulties due to a strongly oscillating integrand, whereas the lower-order rules are more efficient for well-behaved integrands. The rule parameter may take on the following values, corresponding to 15-, 21-, 31-, 41-, 51-, and 61-point Gauss–Kronrod rules:

enum GaussKronrod { rule15, rule21, rule31, rule41, rule51, rule61 }
Result!Real
integrateQAG
(
Func
Real
)
(
scope Func f
,
Real a
,
Real b
,,
Real epsRel = cast(Real)1e-6
,
Real epsAbs = cast(Real)0
)

Examples

// Strongly oscillating integrand, better use highest-order rule.
double f(double x) { return cos(100 * sin(x)); }
auto i = integrateQAG(&f, 0.0, cast(double) PI, GaussKronrod.rule61);

Meta