Skip to content

num::brent

Defined in header <roots/roots.hpp>

template <typename Float = double, bracketable_function<Float> Func = scalar_fn>
root_result<Float> brent(Func &&f, Float a, Float b, Float tol = Float{1e-10},
                         idx max_iter = 1000);

Brent's hybrid root solver (bisection + secant + inverse quadratic interpolation).

Combines the guaranteed convergence of bisection with the superlinear speed of secant and IQI methods. Standard choice for derivative-free robust 1D root-finding.

Template parameters

  • Float: Floating point type.
  • Func: Target function callable.

Parameters

  • f: Target function.
  • a: Left interval endpoint.
  • b: Right interval endpoint.
  • tol: Convergence tolerance on bracket width and residual (default: 1e-10).
  • max_iter: Maximum iterations (default: 1000).

Return value

root_result<Float> with root estimate and convergence metadata.

Exceptions

  • std::invalid_argument: If \(f(a) f(b) > 0\) (no sign change).

See also

bisection, newton, secant