@menu
* Introduction to minpack::
* Functions and Variables for minpack::
@end menu

@node Introduction to minpack, , , 
@section Introduction to minpack

@code{Minpack} is a Common Lisp translation (via @code{f2cl}) of the
Fortran library MINPACK, as obtained from Netlib.

@opencatbox
@category{Numerical methods}  @category{Optimization} @category{Share packages} @category{Package minpack}
@closecatbox

@node Functions and Variables for minpack, , ,
@section Functions and Variables for minpack

@deffn {Function} minpack_lsquares (@var{flist}, @var{varlist}, @var{guess} [, @var{tolerance}, @var{jacobian}])

Compute the point that minimizes the sum of the squares of the
functions in the list @var{flist}.  The variables are in the list
@var{varlist}.  An initial guess of the optimum point must be provided
in @var{guess}.  

The optional keyword arguments, @var{tolerance} and @var{jacobian}
provide some control over the algorithm.  @var{tolerance} is the
estimated relative error desired in the sum of squares.
@var{jacobian} can be used to specify the Jacobian.  If @var{jacobian}
is not given or is @code{true} (the default), the Jacobian is computed
from @var{flist}.  If @var{jacobian} is @code{false}, a numerical
approximation is used.

@code{minpack_lsquares} returns a list.  The first item is the
estimated solution; the second is the sum of squares, and the third
indicates the success of the algorithm.  The possible values are

@table @code
@item 0
improper input parameters.
@item 1
algorithm estimates that the relative error in the sum of squares is
at most @code{tolerance}. 
@item 2
algorithm estimates that the relative error between x and the solution
is at most @code{tolerance}. 
@item 3
conditions for info = 1 and info = 2 both hold.
@item 4
fvec is orthogonal to the columns of the jacobian to machine
precision. 
@item 5
number of calls to fcn with iflag = 1 has reached 100*(n+1).
@item 6
tol is too small. no further reduction in the sum of squares is
possible. 
@item 7
tol is too small. no further improvement in the approximate solution x
is possible. 
@end table

@example
/* Problem 6: Powell singular function */
(%i1) powell(x1,x2,x3,x4) := 
         [x1+10*x2, sqrt(5)*(x3-x4), (x2-2*x3)^2, 
              sqrt(10)*(x1-x4)^2]$
(%i2) minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], 
                       [3,-1,0,1]);
(%o2) [[1.652117596168394e-17, - 1.652117596168393e-18, 
        2.643388153869468e-18, 2.643388153869468e-18], 
       6.109327859207777e-34, 4] 
@end example

@example
/* Same problem but use numerical approximation to Jacobian */
(%i3) minpack_lsquares(powell(x1,x2,x3,x4), [x1,x2,x3,x4], 
                       [3,-1,0,1], jacobian = false);
(%o3) [[5.060282149485331e-11, - 5.060282149491206e-12, 
        2.179447843547218e-11, 2.179447843547218e-11], 
       3.534491794847031e-21, 5]
@end example

@end deffn

@deffn {Function} minpack_solve (@var{flist}, @var{varlist}, @var{guess} [, @var{tolerance}, @var{jacobian}])
Solve a system of @code{n} equations in @code{n} unknowns.
The @code{n} equations are given in the list @var{flist}, and the
unknowns are in @var{varlist}.  An initial guess of the solution must
be provided in @var{guess}.

The optional keyword arguments, @var{tolerance} and @var{jacobian}
provide some control over the algorithm.  @var{tolerance} is the
estimated relative error desired in the sum of squares.
@var{jacobian} can be used to specify the Jacobian.  If @var{jacobian}
is not given or is @code{true} (the default), the Jacobian is computed
from @var{flist}.  If @var{jacobian} is @code{false}, a numerical
approximation is used.

@code{minpack_solve} returns a list.  The first item is the
estimated solution; the second is the sum of squares, and the third
indicates the success of the algorithm.  The possible values are

@table @code
@item 0
improper input parameters.
@item 1
algorithm estimates that the relative error in the solution is
at most @code{tolerance}. 
@item 2
number of calls to fcn with iflag = 1 has reached 100*(n+1).
@item 3
tol is too small. no further reduction in the sum of squares is
possible. 
@item 4
Iteration is not making good progress.
@end table

@example
@end example

@end deffn

@c Local Variables: 
@c mode: texinfo
@c TeX-master: "include-maxima"
@c End: 
