![]() |
Stan Math Library
5.3.0
Automatic Differentiation
|
|
inline |
Return the integral of f from a to b using adaptive Gauss-Kronrod (G21,K21) quadrature, with tangents computed via finite differences over the integrand parameters.
Compute the integral of the single variable function f from a to b using adaptive Gauss-Kronrod (G21,K21) quadrature.
| F | Type of f |
| T_a | type of first limit |
| T_b | type of second limit |
| Args | types of parameter pack arguments |
| f | the functor to integrate | |
| a | lower limit of integration | |
| b | upper limit of integration | |
| [in,out] | msgs | the print stream for warning messages |
| args | additional arguments to pass to f |
a and b can be finite or infinite.
f should be compatible with reverse mode autodiff and have the signature: var f(double x, double xc, std::ostream* msgs, Args... args...);
It should return the value of the function evaluated at x. Any errors should be printed to the msgs stream. xc is unused (always NaN) here.
The integration algorithm terminates when the Boost estimate of the quadrature error satisfies error <= max(relative_tolerance * L1, absolute_tolerance) where L1 is the Boost estimate of the L1 norm of the integral.
Gradients of f that evaluate to NaN when the function evaluates to zero are set to zero themselves. This is due to the autodiff easily overflowing to NaN when evaluating gradients near the maximum and minimum floating point values (where the function should be zero anyway for the integral to exist).
| F | Type of f |
| T_a | type of first limit |
| T_b | type of second limit |
| Args | types of parameter pack arguments |
| f | the functor to integrate | |
| a | lower limit of integration | |
| b | upper limit of integration | |
| [in,out] | msgs | the print stream for warning messages |
| args | additional arguments to pass to f |
Definition at line 85 of file integrate_1d_gauss_kronrod.hpp.