num::bisection¶
Defined in header <roots/roots.hpp>
template <typename Float = double, bracketable_function<Float> Func = scalar_fn>
root_result<Float> bisection(Func &&f, Float a, Float b, Float tol = Float{1e-10},
idx max_iter = 1000);
Bisection method for finding a root on a bracketing interval \([a, b]\) where \(f(a) f(b) \le 0\).
Guaranteed linear convergence halving the interval width at each step: \(|x_k - x^*| \le \frac{b-a}{2^k}\).
Template parameters¶
Float: scalar floating-point type (double,float).Func: Function callableFloat(Float x).
Parameters¶
f: Target continuous function.a: Left interval endpoint.b: Right interval endpoint.tol: Error tolerance on interval radius and residual \(|f(x)|\) (default: 1e-10).max_iter: Maximum iterations (default: 1000).
Return value¶
root_result<Float> with root approximation, iteration count, final residual, and convergence status.
Exceptions¶
std::invalid_argument: If \(f(a)\) and \(f(b)\) have the same sign.