optim_doc: lsqnonlin

Next: lsqcurvefit, Previous: quadprog, Up: Compatibility functions [Index]

### 7.3 Non-linear residual minimization

This function is for Matlab compatibility. It attempts to work like `lsqnonlin` by calling nonlin_residmin.

Function File: lsqnonlin (fun, x0)
Function File: lsqnonlin (fun, x0, lb, ub)
Function File: lsqnonlin (fun, x0, lb, ub, options)
Function File: [x, resnorm, residual, exitflag, output, lambda, jacobian] = lsqnonlin (…)

  Solve nonlinear least-squares (nonlinear data-fitting) problems

      min [EuclidianNorm(f(x))] .^ 2
       x

  fun computes residuals from given parameters. The initial guess of the parameters x0 must be provided while the bounds lb and ub) can be set to the empty matrix (`[]`) if not given.

  `lsqnonlin` may also be called with a single structure argument with the fields `fun`, `x0`, `lb`, `ub`, and `options`, resembling the separate input arguments above. For compatibility reasons, field `fun` may also be called `objective`. Additionally, the structure must have the field `solver`, set to `"lsqnonlin"`.

  options can be set with `optimset`. Follwing Matlab compatible options are recognized:

  `Algorithm` String specifying backend algorithm. Currently available "lm_svd_feasible" only.

  `TolFun` Minimum fractional improvement in objective function in an iteration (termination criterium). Default: 1e-6.

  `TypicalX` Typical values of x. Default: 1.

  `MaxIter` Maximum number of iterations allowed. Default: 400.

  `Jacobian` If set to "on", the function fun must return a second output containing a user-specified Jacobian. The Jacobian is computed using finite differences otherwise. Default: "off"

  `FinDiffType` "centered" or "forward" (Default) type finite differences estimation.

  `FinDiffRelStep` Step size factor. The default is sqrt(eps) for forward finite differences, and eps^(1/3) for central finite differences

  `OutputFcn` One or more user-defined functions, either as a function handle or as a cell array of function handles that an optimization function calls at each iteration. The function definition has the following form:

  `stop = outfun(x, optimValues, state)`

  `x` is the point computed at the current iteration. `optimValues` is a structure containing data from the current iteration in the following fields: "iteration"- number of current iteration. "residual"- residuals. `state` is the state of the algorithm: "init" at start, "iter" after each iteration and "done" at the end.

  `Display` String indicating the degree of verbosity. Default: "off". Currently only supported values are "off" (no messages) and "iter" (some messages after each iteration).

  Returned values:

  x

    Position of minimum.

  resnorm

    Scalar value of objective as squared EuclidianNorm(f(x)).

  residual

    Value of solution residuals f(x).

  exitflag

    Status of solution:

    `0`

      Maximum number of iterations reached.

    `2`

      Change in x was less than the specified tolerance.

    `3`

      Change in the residual was less than the specified tolerance.

    `-1`

      Output function terminated the algorithm.

  output

    Structure with additional information, currently the only field is `iterations`, the number of used iterations.

  lambda

    Structure containing Lagrange multipliers at the solution x sepatared by constraint type (lb and ub).

  jacobian

    m-by-n matrix, where jacobian(i,j) is the partial derivative of fun(i) with respect to x(j) Default: lsqnonlin approximates the Jacobian using finite differences. If `Jacobian` is set to "on" in options then fun must return a second argument providing a user-sepcified Jacobian .

  This function is a compatibility wrapper. It calls the more general `nonlin_residmin` function internally.

  See also: lsqcurvefit, nonlin_residmin, nonlin_curvefit.

Next: lsqcurvefit, Previous: quadprog, Up: Compatibility functions [Index]