newton_raphson

ssapy.utils.newton_raphson(guess, f, fprime=None, eps=3e-16, maxiter=100, **kwargs)[source][source]

Find a root of a univariate function with known gradient using Newton-Raphson iterations.

Parameters:
  • guess (float) – Initial guess.

  • f (callable function of 1 argument.) – Function for which to find a zero. If fprime is None, then the return value of f should be a 2-tuple with the value of the function and the first derivative. If fprime is given separately, then f should just return the value of the function.

  • fprime (callable function of 1 argument, optional) – Derivative of f. Default None.

  • eps (float, optional) – Absolute tolerance for finding a zero. Default 3e-16.

  • maxiter (int, optional) – Maximum number of iterations to try. Default 100.

Returns:

solution

Return type:

float