![]() |
Home | Libraries | People | FAQ | More |
#include <boost/math/quadrature/tanh_sinh.hpp> #include <boost/math/quadrature/exp_sinh.hpp> #include <boost/math/quadrature/sinh_sinh.hpp> namespace boost{ namespace math{ template<class Real> class tanh_sinh { public: tanh_sinh(size_t max_refinements = 15, const Real& min_complement = tools::min_value<Real>() * 4) template<class F> Real integrate(const F f, Real a, Real b, Real tolerance = tools::root_epsilon<Real>(), Real* error = nullptr, Real* L1 = nullptr, std::size_t* levels = nullptr) template<class F> Real integrate(const F f, Real tolerance = tools::root_epsilon<Real>(), Real* error = nullptr, Real* L1 = nullptr, std::size_t* levels = nullptr) }; template<class Real> class exp_sinh { public: exp_sinh(size_t max_refinements = 9); template<class F> Real integrate(const F f, Real a, Real b, Real tol = sqrt(std::numeric_limits<Real>::epsilon()), Real* error = nullptr, Real* L1 = nullptr, size_t* levels = nullptr) const; template<class F> Real integrate(const F f, Real tol = sqrt(std::numeric_limits<Real>::epsilon()), Real* error = nullptr, Real* L1 = nullptr, size_t* levels = nullptr) const; }; template<class Real> class sinh_sinh { public: sinh_sinh(size_t max_refinements = 9); template<class F> Real integrate(const F f, Real tol = sqrt(std::numeric_limits<Real>::epsilon()), Real* error = nullptr, Real* L1 = nullptr, size_t* levels = nullptr) const; }; }}
These three integration routines provide robust general purpose quadrature,
each having a "native" range over which quadrature is performed.
For example, the sinh_sinh
quadrature integrates over the entire real line, the tanh_sinh
over (-1, 1), and the exp_sinh
over (0, ∞). The latter integrators also have auxilliary ranges
which are handled via a change of variables on the function being integrated,
so that the tanh_sinh
can
handle integration over (a, b), and exp_sinh
over (a, ∞) and(-∞, b).
The integrate
methods which
do not specify a range always integrate over the native range of the method,
and generally are the most efficient and produce the smallest code, on
the other hand the methods which do specify the bounds of integration are
the most general, and use argument transformations which are generally
very robust. The following table summarizes the ranges supported by each
method:
Integrator |
Native range |
Other supported ranges |
Comments |
---|---|---|---|
tanh_sinh |
(-1,1) |
(a,b) |
Special care is taken for endpoints at or near zero to ensure that abscissa values are calculated without the loss of precision that would normally occur. Likewise when transforming to an infinite endpoint, the additional information which tanh_sinh has internally on abscissa values is used to ensure no loss of precision during the transformation. |
exp_sinh |
(0,∞) |
(a,∞) |
|
sinh_sinh |
(-∞,∞) |