...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

The max interval halvings is the maximum number of times the interval can
be cut in half before giving up. If the accuracy is not met at that time,
the routine returns its best estimate, along with the `error`

and `L1`

, which allows the
user to decide if another quadrature routine should be employed.

An example of this is

double tol = std::sqrt(std::numeric_limits<double>::epsilon()); size_t max_halvings = 12; tanh_sinh<double> integrator(max_halvings); auto f = [](double x) { return 5*x + 7; }; double error, L1; double Q = integrator.integrate(f, (double) 0, (double) 1, &error, &L1); if (error*L1 > 0.01) { Q = some_other_quadrature_method(f, (double) 0, (double) 1); }

It's important to remember that the number of sample points doubles with each new level, as does the memory footprint of the integrator object. Further, if the integral is smooth, then the precision will be doubling with each new level, so that for example, many integrals can achieve 100 decimal digit precision after just 7 levels. That said, abscissa-weight pairs for new levels are computed only when a new level is actually required (see thread safety), none the less, you should avoid setting the maximum arbitrarily high "just in case" as the time and space requirements for a large number of levels can quickly grow out of control.