scipy.optimize.newton

scipy.optimize.newton(func, x0, fprime=None, args=(), tol=1.48e-08, maxiter=50)

Find a zero using the Newton-Raphson or secant method.

Find a zero of the function func given a nearby starting point x0. The Newton-Raphson method is used if the derivative fprime of func is provided, otherwise the secant method is used.

Parameters :

func : function

The function whose zero is wanted. It must be a function of a single variable of the form f(x,a,b,c...), where a,b,c... are extra arguments that can be passed in the args parameter.

x0 : float

An initial estimate of the zero that should be somewhere near the actual zero.

fprime : function, optional

The derivative of the function when available and convenient. If it is None (default), then the secant method is used.

args : tuple, optional

Extra arguments to be used in the function call.

tol : float, optional

The allowable error of the zero value.

maxiter : int, optional

Maximum number of iterations.

Returns :

zero : float

Estimated location where function is zero.

See also

brentq, brenth, ridder, bisect

fsolve
find zeroes in n dimensions.

Notes

The convergence rate of the Newton-Raphson method is quadratic while that of the secant method is somewhat less. This means that if the function is well behaved the actual error in the estimated zero is approximately the square of the requested tolerance up to roundoff error. However, the stopping criterion used here is the step size and there is no guarantee that a zero has been found. Consequently the result should be verified. Safer algorithms are brentq, brenth, ridder, and bisect, but they all require that the root first be bracketed in an interval where the function changes sign. The brentq algorithm is recommended for general use in one dimensional problems when such an interval has been found.

Previous topic

scipy.optimize.bisect

Next topic

scipy.optimize.fixed_point

This Page