Non-Linear Solver Code Generated by ExprLib © MSSRC 1999-2008

ExprLib can be used to find zeros of a system of n functions in n variables:

f1(x1 ... xn) = 0
.
.
.
fn(x1 ... xn) = 0.


In this example, it will be assumed that the functions are represented by n expressions in n variables and that their partial derivatives are continuous. Only the ``front end'' for the solver will be given. This front end calls the MINPACK routine hybrj, a modified Powell hybrid method. Click here to see the FORTRAN code: source code You can use the default values below or enter your own values.

Required input values are:
  • A set of n expressions in n variables
  • An initial approximation to a solution of the system
Optional input values are
  • A nonnegative small double xtol. Termination occurs when the relative error between two consecutive iterates is at most xtol.

  • A positive integer maxfev. Termination occurs when the number of calls to the given functions has reached maxfev.

  • A positive double factor which is used in determining the initial step bound. This bound is set to the product of factor and the euclidean norm of diag*x (see below) if nonzero, or else to factor itself. In most cases factor should lie in the interval [0.1, 100.0]. 100.0 is a generally recommended value.

  • An integer mode. If mode = 1, the variables will be scaled internally. If mode = 2, the scaling is specified by the input diag (see below). Other values of mode are equivalent to mode = 1. In this demo mode is always set to 1.

  • An array diag of length n. If mode = 1 (see above), diag is internally set. If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables. If this value is input, the syntax (x1, ..., xn) must be used. In this demo, diag is always set internally.

Note: In this demo, the only symbolic constant available is PI (both letters in capitals). If other constants such as e are required, they need to be input as function values, e.g. exp(1.0).

The expressions must be input with a semicolon separating each expression (and a semicolon at the end).

expr1; expr2; ... exprn;

The initial approximation must be input in the form

x1=val1; x2=val2; ... xn=valn;

Spaces are irrelevant.

Note that all data is to be input using ANSI C syntax, e.g. 3.834e-20 and not 3.834d-20. ExprLib will translate the input into the proper form for FORTRAN.

In this demo, you are restricted to n expressions in n variables where n is less than or equal to 5.

By submitting a set of values, the FORTRAN generated for this problem will be returned. You can use this along with the solver source code to compile a solution using F77.

In addition, there is an integer output variable. The value is set as follows.
  • info = 0: improper input parameters.

  • info = 1: relative error between two consecutive iterates is at most xtol.

  • info = 2: maximum number of calls to the functions has reached maxfev.

  • info = 3: xtol is too small. No further improvement in the approximation is possible.

  • info = 4: iteration is not making good progress, as measured by the improvement from the last five jacobian evaluations.

n expressions in n variables (n<=5):
initial value:

xtol:

maxfev:

factor:

Comments, more information, problems? Click here