The function to integrate. This can be given as a function pointer, a delegate, or a struct/class which defines opCall().
The lower limit of integration.
The upper limit of integration.
(optional) The requested relative accuracy.
(optional) The requested absolute accuracy.
Note: This function is different from the other integrateXXX() routines in this module in that it allows a and b to take on the special values Real.infinity and -Real.infinity, where Real is the floating-point type being used.
// Let's integrate the function // // log(x) // f(x) = ---------- // 2 // 1 + 100 x // // from x=0 to x=infinity. real f(real x) { return log(x)/(1 + 100*x*x); } auto result = integrate(&f, 0.0L, real.infinity, 0.001L); real exact = -PI * log(10.0)/20.0; assert (abs(result.value - exact) < result.error);
Integrate a function from a to b.
This module contains a lot of different integration routines, and _integrate() aims to be a simple interface to some of these. Currently, it only calls the integrateQAGS() and integrateQAGI() routines, but this may change in the future. In particular, it should take into account whether a function is oscillatory, if it has discontinuities and singularities in the integration interval, and so on.