Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ integrate_de()

template<typename F >
double stan::math::integrate_de ( const F &  f,
double  a,
double  b,
double  relative_tolerance,
double  absolute_tolerance,
int  max_refinements 
)
inline

Integrate a single variable function f from a to b using Boost's adaptive double-exponential quadrature, with QUADPACK-style mixed convergence criterion.

The integration succeeds (returns the Boost estimate Q) whenever error <= max(relative_tolerance * L1, absolute_tolerance) on each piece, where error and L1 are Boost's quadrature-error and L1-norm estimates for that piece. A larger error throws std::domain_error.

Setting absolute_tolerance to a small positive value escapes the pathological regime where the relative-tolerance test on its own is checking accumulated floating-point round-off against itself. This happens in particular under the zero-crossing split (see below) when one half of the split integrates to near-zero: the strict per-piece relative test on that half can fire spuriously. Setting it to zero (the default) reproduces the strict pure-relative-tolerance behaviour of integrate_1d.

The signature for f should be: double f(double x, double xc)

Unlike integrate_1d_gauss_kronrod, double-exponential quadrature computes a meaningful distance-to-boundary xc, and user functors may (and should, for accuracy near singular endpoints) use it. For a > 0, b > 0, xc is a - x for x closer to a, and b - x for x closer to b. xc is computed in a way that avoids the precision loss of computing a - x or b - x manually. For integrals that cross zero, xc can take values a - x, -x, or b - x depending on which integration limit is nearest. If either limit is infinite, xc is set to NaN.

Depending on whether or not a is finite or negative infinity and b is finite or positive infinity, a different version of the 1d quadrature algorithm from the Boost quadrature library is chosen.

Integrals that cross zero are broken into two, and the separate integrals are each integrated to the given tolerances. This is the pre-existing behaviour of integrate_1d, preserved here to maintain call-site compatibility.

Template Parameters
FType of f
Parameters
fthe function to be integrated
alower limit of integration
bupper limit of integration
relative_tolerancetarget relative tolerance passed to Boost quadrature
absolute_toleranceabsolute-error floor on the per-piece convergence test
max_refinementsmaximum refinement level passed to the constructor of the Boost quadrature class
Returns
numeric integral of function f

Definition at line 81 of file integrate_1d_double_exponential.hpp.