The NEWTON function solves a system of n non-linear equations in n dimensions using a globally-convergent Newton's method. The result is an n -element vector containing the solution.
NEWTON is based on the routine
newt
described in section 9.7 of
Numerical Recipes in C: The Art of Scientific Computing
(Second Edition), published by Cambridge University Press, and is used by permission.
A scalar string specifying the name of a user-supplied IDL function that defines the system of non-linear equations. This function must accept an n -element vector argument X and return an n -element vector result.
For example, suppose the non-linear system is defined by the following equations:
y 0 = x 0 + x 1 - 3, y 1 = x 0 2 + x 1 2 - 9
We write a function NEWTFUNC to express these relationships in the IDL language:
NEWTON calls an internal function named
fmin()
to determine whether the routine has converged to a local minimum rather than to a global minimum (see
Numerical Recipes
, section 9.7). Use the CHECK keyword to specify a named variable which will be set to 1 if the routine has converged to a local minimum or to 0 if it has not. If the routine does converge to a local minimum, try restarting from a different initial guess to obtain the global minimum.
Use NEWTON to solve an n-dimensional system of n non-linear equations. Systems of non-linear equations may have multiple solutions; starting the algorithms with different initial guesses enables detection of different solutions.
X = [1.0, 5.0] ; Provide an initial guess as the algorithm's starting point.
result = NEWTON(X, 'newtfunc') ; Compute the solution.
PRINT, result ; Print the result.
X = [1.0, -1.0] ; Try a different starting point.
result = NEWTON(X,'newtfunc') ; Compute the solution .