root_secant#

named_arrays.optimize.root_secant(function, guess, min_step_size=None, max_abs_error=None, max_iterations=100, damping=None, callback=None)#

Find the root of a given function using the secant method.

Parameters:
  • function (Callable[[InputT], OutputT]) – a scalar-valued or vector-valued function to find the root of.

  • guess (InputT) – an initial guess for the root

  • min_step_size (None | InputT) – Stop iterating if the step size falls below this value

  • max_abs_error (None | OutputT) – Maximum absolute error between zero and the function value. If the function value at the current root guess is below this value, the root is considered converged.

  • max_iterations (int) – Maxmimum number of iterations to carry out before a ValueError is raised.

  • damping (None | float) – If this parameter is equal to 1, it has no effect and is equivalent to the default, None (vanilla secant method). If this parameter is less than 1, the damped secant method is carried out. The damped secant method can address some of the failure modes of the secant method, particularly the problem of entering an infinite cycle

  • callback (None | Callable[[int, InputT, OutputT, AbstractArray], None]) – Optional callback function that is called on every iteration as callback(i, x, f, converged), where i is the current iteration, x is the current root guess, f is the current function value, and converged is an array storing the convergence state for every root being computed.

Return type:

InputT