Nonlinear Equations
*******************

Octave can solve sets of nonlinear equations of the form

     F (x) = 0

using the function fsolve, which is based on the MINPACK subroutine hybrd.

 -- Loadable Function: [X, INFO] = fsolve (FCN, X0)
     Given FCN, the name of a function of the form f (X) and an initial starting point X0, fsolve solves the set of equations such that f(X) == 0.

 -- Loadable Function: fsolve_options (OPT, VAL)
     When called with two arguments, this function allows you set options parameters for the function fsolve.  Given one argument, fsolve_options returns the value of the corresponding option.  If no arguments are supplied, the names of all the available options and their current values are displayed.

Here is a complete example.  To solve the set of equations

     -2x^2 + 3xy   + 4 sin(y) = 6
      3x^2 - 2xy^2 + 3 cos(x) = -4

you first need to write a function to compute the value of the given function.  For example:

     function y = f (x)
       y(1) = -2*x(1)^2 + 3*x(1)*x(2)   + 4*sin(x(2)) - 6;
       y(2) =  3*x(1)^2 - 2*x(1)*x(2)^2 + 3*cos(x(1)) + 4;
     endfunction

Then, call fsolve with a specified initial condition to find the roots of the system of equations.  For example, given the function f defined above,

     [x, info] = fsolve ("f", [1; 2])

results in the solution

     x =

       0.57983
       2.54621

     info = 1

A value of info = 1 indicates that the solution has converged.

The function perror may be used to print English messages corresponding to the numeric error codes.  For example,

     perror ("fsolve", 1)
          -| solution converged to requested tolerance