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);

Find a root in \([a, b]\) by Brent's method: bisection, secant and inverse quadratic interpolation.

Exceptions

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