Skip to content

num::romberg

Defined in header <quadrature/quadrature.hpp>

template <typename Float = double, std::invocable<Float> Func = scalar_fn>
Float romberg(Func &&f, Float a, Float b, Float tol = Float{1e-10},
              idx max_levels = 12);

Romberg numerical integration using Richardson extrapolation on trapezoidal sums.

Generates triangular tableau \(R(j, k)\) with successive error cancellations of order \(\mathcal{O}(h^{2(k+1)})\).

Template parameters

  • Float: Floating point scalar type.
  • Func: Integrand callable.

Parameters

  • f: Integrand function.
  • a: Lower limit.
  • b: Upper limit.
  • tol: Convergence tolerance on diagonal tableau entries (default: 1e-10).
  • max_levels: Maximum tableau extrapolation levels (default: 12).

Return value

Extrapolated integral approximation.