ZEROSYS Function
Solves a system of n nonlinear equations, fi (x) = 0, using a modified Powell hybrid algorithm.
Usage
result = ZEROSYS(f, n)
Input Parameters
f—Scalar string specifying a user-supplied function to evaluate the system of equations to be solved. The f function accepts one parameter containing the point at which the functions are to be evaluated and returns the computed function values at the given point.
n—Number of equations to be solved and the number of unknowns.
Returned Value
result—An array containing a solution of the system of equations.
Input Keywords
Double—If present and nonzero, double precision is used.
Err_Rel—Stopping criterion. The root is accepted if the relative error between two successive approximations to this root is less than Err_Rel. Default: Err_Rel = SQRT(ε), where ε is the machine precision
Jacobian—Scalar string specifying a user-supplied function to evaluate the n × n Jacobian. The function accepts as parameter the point at which the Jacobian is to be evaluated and returns a two-dimensional matrix defined by result (i, j) = ∂fi/∂xj.
Itmax—Maximum allowable number of iterations. Default: Itmax = 200
XGuess—Array with N components containing the initial estimate of the root. Default: XGuess = 0
Output Keywords
Fnorm—Scalar with the value f 20 + ... + f 2n–1 at the point x.
Discussion
Function ZEROSYS is based on the MINPACK subroutine HYBRDJ, which uses a modification of the hybrid algorithm due to M.J.D. Powell. This algorithm is a variation of Newton’s Method, which takes precautions to avoid undesirable large steps or increasing residuals. For further discussion, see Moré et al. (1980).
Example
The following 2 × 2 system of nonlinear equations is solved:
f(x) = x0 + x1 – 3
f(x) = x02 + x12 – 9
.RUN
; Define the system through the function f.
FUNCTION f, x
RETURN, [x(0)+x(1)-3, x(0)^2+x(1)^2-9]
END
; Compute the solution and output the results.
PM, ZEROSYS('f', 2), $
Title='Solution of the system:', Format='(f10.5)'
; This results in the following output:
; Solution of the system:
; 0.00000
; 3.00000
Warning Errors
MATH_TOO_MANY_FCN_EVALS—Number of function evaluations has exceeded Itmax. A new initial guess can be tried.
MATH_NO_BETTER_POINT—Keyword Err_Rel is too small. No further improvement in the approximate solution is possible.
MATH_NO_PROGRESS—Iteration has not made good progress. A new initial guess can be tried.