Skip to content

num::newton

Defined in header <roots/roots.hpp>

template <typename Float = double, std::invocable<Float> Func = scalar_fn,
          std::invocable<Float> DFunc = scalar_fn>
root_result<Float> newton(Func &&f, DFunc &&df, Float x0, Float tol = Float{1e-10},
                          idx max_iter = 1000);

Find a root by Newton's method: \(x_{k+1} = x_k - f(x_k) / f'(x_k)\).