## NEWTON

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.

### Calling Sequence

Result = NEWTON( X, Vecfunc )

### Arguments

#### X

An n -element vector containing an initial guess at the solution of the system.

#### Vecfunc

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:

FUNCTION newtfunc, X

RETURN, [X[0] + X[1] -3.0, X[0]^2 + X[1]^2 - 9.0]

END

### Keywords

#### CHECK

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.

#### DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

#### ITMAX

The maximum allowed number of iterations. The default value is 200.

#### STEPMAX

The scaled maximum step length allowed in line search. The default value is 100.0.

#### TOLF

Set the convergence criterion on the function values. The default value is 1.0  ¥  10 -4 .

#### TOLMIN

Set the criterion for deciding whether spurious convergence to a minimum of the function ``` fmin()``` has occurred. The default value is 1.0  ¥  10 -6 .

#### TOLX

Set the convergence criterion on X . The default value is 1.0  ¥  10 -7 .

### Example

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.

IDL prints:

-0.000346127 3.00000

X = [1.0, -1.0] ; Try a different starting point.

result = NEWTON(X,'newtfunc') ; Compute the solution .

PRINT, result ; Print the result.

IDL prints:

2.99999 8.37117e-05