Function integrateQAGI

Calculate the integral of f(x) over an infinite interval.

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

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

The infinite range is mapped onto a finite interval and subsequently the same strategy as in integrateQAGS() is applied.

To integrate f(x) over the interval (-∞,∞), use the first form. To integrate f(x) over the interval (-∞,a) or (a,∞) use the second form with inf=Infinite.lower or inf=Infinite.upper, respectively.

Example

// Slowly convergent integral over infinite interval,
// integrand with endpoint singularity.
double f(double x) { return (1 + 10*x)^^(-2) / sqrt(x); }
auto i = integrateQAGI(&f, 0.0, Infinite.upper, 1e-8);