A multi-dimensional root finder based on the Levenberg-Marquardt optimization algorithm1 . The LM algorithm is an iterative technique that finds a local minimum of a function that is expressed as the sum of squares of nonlinear functions. It has become a standard technique for nonlinear least-squares problems and can be thought of as a combination of steepest descent and the Gauss-Newton method. When the current solution is far from the correct one, the algorithm behaves like a steepest descent method: slow, but guaranteed to converge. When the current solution is close to the correct solution, it becomes a Gauss-Newton method2 .
Part of MathLib, a diverse library of mathematical functions.
RootFinder
requires the user to provide an analytic Jacobian (or the single analytic derivative in the case of one function and one independent variable) in order to work. See the examples below.Find a shared root of N
real-valued functions each containing M
independent variables.
func |
An (array of) instance(s) of AbstractFunction, where each instance returns a single scalar value of type SimpleNumber. These are the functions |
jacobian |
An (array of) instance(s) of AbstractFunction, where each instance returns a single scalar value of type SimpleNumber. This is the Jacobian: a matrix of all first-order partial derivatives of a scalar-valued function |
x0 |
An (array of) instance(s) of SimpleNumber. This denotes the initial guess |
param |
An optional Collection or single instance of SimpleNumber. This may be used for supplying any additional function parameters. |
opts |
An instance of Array holding 4 optional parameters which are used in the stopping criteria of the algorithm. The first parameter |
An Array holding the location x_r
of the shared root.
First example: solving a system of two equations in two unknowns
2x_1 - x_2 - e^{-x_1} = 0 -x_1 + 2x_2 - e^{-x_2} = 0
with initial guess x_0 = [-5, -5]
.
Second example: finding a root of one equation in one unknown
2x-e^{-x} = 0
with initial guess x_0 = 0
.