num::secant¶
Defined in header <roots/roots.hpp>
template <typename Float = double, std::invocable<Float> Func = scalar_fn>
root_result<Float> secant(Func &&f, Float x0, Float x1, Float tol = Float{1e-10},
idx max_iter = 1000);
Secant quasi-Newton root-finding method requiring two initial guesses \(x_0, x_1\).
Replaces the exact derivative with a finite difference chord: \(x_{k+1} = x_k - f(x_k) \frac{x_k - x_{k-1}}{f(x_k) - f(x_{k-1})}\). Superlinear convergence order \(\approx 1.618\).
Template parameters¶
Float: Floating point type.Func: Target function callable.
Parameters¶
f: Target function.x0: First initial guess.x1: Second initial guess.tol: Residual tolerance (default: 1e-10).max_iter: Maximum iterations (default: 1000).
Return value¶
root_result<Float> with root estimate and convergence metadata.