$LastChangedDate: 2008-04-15 18:15:23 +0200 (Tue, 15 Apr 2008)
$lsqrsolveminimize the sum of the squares of nonlinear functions,
levenberg-marquardt algorithmCalling Sequence[x [,v [,info]]]=lsqrsolve(x0,fct,m [,stop [,diag]])
[x [,v [,info]]]=lsqrsolve(x0,fct,m ,fjac [,stop [,diag]])Parametersx0real vector of size n (initial estimate of
the solution vector).fctexternal (i.e function or list or string).minteger, the number of functions. m must be
greater than or equal to n.fjacexternal (i.e function or list or string).stopoptional vector
[ftol,xtol,gtol,maxfev,epsfcn,factor] the default
value is [1.d-8,1.d-8,1.d-5,1000,0,100]ftolA positive real number,termination occurs when both the
actual and predicted relative reductions in the sum of squares
are at most ftol. therefore,
ftol measures the relative error desired in
the sum of squares.xtolA positive real number, termination occurs when the
relative error between two consecutive iterates is at most
xtol. therefore, xtol
measures the relative error desired in the approximate
solution.gtolA nonnegative input variable. termination occurs when
the cosine of the angle between fct(x) and
any column of the jacobian is at most gtol
in absolute value. therefore, gtol measures
the orthogonality desired between the function vector and the
columns of the jacobian.maxfevA positive integer, termination occurs when the number
of calls to fct is at least maxfev by the
end of an iteration.epsfcnA positive real number, used in determining a suitable
step length for the forward-difference approximation. this
approximation assumes that the relative errors in the
functions are of the order of epsfcn. if
epsfcn is less than the machine precision,
it is assumed that the relative errors in the functions are of
the order of the machine precision.factorA positive real number, used in determining the initial
step bound. this bound is set to the product of factor and the
euclidean norm of diag*x if nonzero, or
else to factor itself. in most cases
factor should lie in the interval
(0.1,100). 100 is a
generally recommended value.diagis an array of length n.
diag must contain positive entries that serve as
multiplicative scale factors for the variables.x :real vector (final estimate of the solution vector).v :real vector (value of fct(x)).infotermination indicator0improper input parameters.1algorithm estimates that the relative error between
x and the solution is at most
tol.2number of calls to fcn reached3tol is too small. No further
improvement in the approximate solution x
is possible.4iteration is not making good progress.5number of calls to fcn has reached or
exceeded maxfev6ftol is too small. no further
reduction in the sum of squares is possible.7xtol is too small. no further
improvement in the approximate solutionx is
possible.8gtol is too small.
fvec is orthogonal to the columns of the
jacobian to machine precision.Descriptionminimize the sum of the squares of m nonlinear functions in n
variables by a modification of the levenberg-marquardt algorithm. the user
must provide a subroutine which calculates the functions. the jacobian is
then calculated by a forward-difference approximation.minimize sum(fct(x,m).^2) where
fct is function from R^n to
R^mfct should be :a Scilab function whose calling sequence is
v=fct(x,m) given x and
m.a character string which refers to a C or Fortran routine which
must be linked to Scilab.Fortran calling sequence should be
fct(m,n,x,v,iflag) where m,
n, iflag are integers,
x a double precision vector of size
n and v a double precision
vector of size m.C calling sequence should be fct(int *m, int *n, double
x[],double v[],int *iflag)fjac is an external which returns
v=d(fct)/dx (x). it should be :a Scilab functionwhose calling sequence is J=fjac(x,m) given
x and m.a character stringit refers to a C or Fortran routine which must be linked to
Scilab.Fortran calling sequence should be
fjac(m,n,x,jac,iflag) where m,
n, iflag are integers,
x a double precision vector of size
n and jac a double precision
vector of size m*n.C calling sequence should be fjac(int *m, int *n,
double x[],double v[],int *iflag)return -1 in iflag to stop the algoritm if the function or jacobian
could not be evaluated.ExamplesSee AlsoexternalqpsolveoptimfsolveUsed Functionslmdif, lmder from minpack, Argonne National Laboratory.