Function integrateQAGS

Calculate the integral of f(x) over the finite interval (a,b) using a general-purpose integration algorithm.

Result!Real integrateQAGS(Func, Real) (
  scope Func f,
  Real a,
  Real b,
  Real epsRel = cast(Real)1e-06,
  Real epsAbs = cast(Real)0
);

integrateQAGS() is an integrator based on globally adaptive interval subdivision in connection with extrapolation by the Epsilon algorithm, which eliminates the effects of integrand singularities of several types.

This is the most "intelligent" of the general-purpose finite-interval integration methods, and the one that best handles bad integrand behaviour. It is fairly expensive in terms of processing time, though, so if that is an issue you may want to investigate the integrand in more detail and try one or a combination of the more specialised integration methods.

Example

// This function has an internal singularity at x = 1/3.
double f(double x) { return 1/sqrt(abs(x-1.0/3)); }
auto i = integrateQAGS(&f, 0.0, 1.0);