This module implements algorithms that for a given function f numerically solve the equation: $$ f(x) = 0 $$ The value x is called a root of the function f. The function f can be a function of one or more variables, in which case x is a vector.
A derivative-free root-finding algorithm for univariate functions. It has a performance comparable to the Brent's method. Only the first value returned by
f
is used, additional returned values are ignored. The root is assumed to be bracketed by the range (xl
, xu
). The function
stop
is called after every iteration of the algorithm and has the following signature: function(x, y, xl, xu, yl, yu)
where x
,
xl
, xu
are the current root estimate and the current bracketing interval (which shrinks toward the root) and y
, yl
,
yu
are the evaluations of f
at these points. If at any iteration the function stop
returns true
the algorithm
terminates and returns the same values that has been passed to stop(x, y, xl, xu, yl, yu)
.
A root-finding algorithm for univariate functions which uses the first derivative of the function to speed-up convergence. The first and second values returned by
f
are the evaluation of f
and the evaluation of the first derivative of f
. Additional returned values are ignored. The root is
assumed to be bracketed by the range (xl
, xu
). The function stop()
is used as explained in root.ridders()
. Moreover
the algorithm stops if at any iteration an exact root (y == 0
) is found in which case it returns the current values (x, y, xl, xu, yl, yu)
.
Under a number of circumstances the algorithm may fail to converge. In this case nil
and a string error message are returned.
A root-finding algorithm for univariate functions which uses the first and second derivatives of the function to speed-up convergence. The first, second and third
values returned by f
are the evaluation of f
and the evaluation of the first and second derivatives of f
. Additional returned
values are ignored. The root is assumed to be bracketed by the range (xl
, xu
). The function stop()
is used as explained in
root.ridders()
. Moreover the algorithm stops if at any iteration an exact root (y == 0
) is found in which case it returns the current values
(x, y, xl, xu, yl, yu)
. Under a number of circumstances the algorithm may fail to converge. In this case nil
and a string error message are
returned.