Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

sinh_sinh

template<class Real>
class sinh_sinh
{
public:
    sinh_sinh(size_t max_refinements = 9);

    template<class F>
    auto integrate(const F f,
                   Real tol = sqrt(std::numeric_limits<Real>::epsilon()),
                   Real* error = nullptr,
                   Real* L1 = nullptr,
                   size_t* levels = nullptr)->decltype(std::declval<F>()(std::declval<Real>())) const;;
};

The sinh-sinh quadrature allows computation over the entire real line, and is called as follows:

sinh_sinh<double> integrator;
auto f = [](double x) { return exp(-x*x); };
double error;
double L1;
double Q = integrator.integrate(f, &error, &L1);

Note that the limits of integration are understood to be (-∞, +∞).

Complex valued integrands are supported as well, for example the Dirichlet Eta function can be represented via:

which we can directly code up as:

template <class Complex>
Complex eta(Complex s)
{
   typedef typename Complex::value_type value_type;
   using std::pow;  using std::exp;
   Complex i(0, 1);
   value_type pi = boost::math::constants::pi<value_type>();
   auto f = [&, s, i](value_type t) { return pow(0.5 + i * t, -s) / (exp(pi * t) + exp(-pi * t)); };
   boost::math::quadrature::sinh_sinh<value_type> integrator;
   return integrator.integrate(f);
}

PrevUpHomeNext