Contents | Previous | Next | Subchapters |

Syntax |
`dnlsqb(function ` fval`, ` xini`, ` xlow`, ` xup`, ` delta`, ` maxit`, ` level`)` |

See Also | nlsqbox , linlsqb |

Uses the Gauss-Newton method to solve the problem

minimize |*f*(*x*)|^2 with respect to *x*

such that *xlow* <= *x* <= *xup*

The return value of
`dnlsqb`

is a value of

The function calls

`(`

`, `

`)`

and

`(`

`, `

`, `

`)`

evaluate *f*(*x*)

and its derivative.
The vector *f*(*x*)

.
The input value of *f*(*x*)

as a column vector with the same type as *f*(*x*)

as a matrix with the same type and row dimension as
*df*_*out*(*i*, *j*)

is the derivative of the *f*(*x*)

with respect to the

The real or double-precision column vector

|*x*(*i*) - *xmin*(*i*)| __<__ *delta* * (*xup*(*i*) - *xlow*(*i*))

where `|`*f*(*x*)|^2

is less than delta times its value.
The integer scalar

The integer scalar `dnlsqb`

.
If `dnlsqb`

fails to converge, the message
"dnlsqb failed to converge" is printed.
If *level* __>__ 1

,
the messages "begin dnlsqb" is printed before the first iteration
and if the method converges, "dnlsqb converged" is printed at the end.
In addition, the value of `|`*f*(*x*)|^2

is printed at each iteration.
If *level* __>__ 2

,
the value of *x*

is printed at each iteration.
The example below solves the problem

minimize [exp(*x*(1)) - exp(1.)]^2 + [exp(*x*(2)) - exp(2.)]^2

with respect to *x* such that

-1 __<__ *x*(1) __<__ +1

-1 __<__ *x*(2) __<__ +1

The solution to this problem is
*x*(1) = 1

and
*x*(2) = 1

.
```
```

clear

function fval(x, f_out, df_out) begin

f_out = {exp(x(1)) - exp(1.), exp(x(2)) - exp(2.)}

if arg(0) >= 3 then ...

df_out = diag(exp(x))

end

xini = { 0., 0.}

xlow = { -1., -1.}

xup = { +1., +1.}

delta = 1e-4

maxit = 10

level = 2

argmin = dnlsqb(function fval, xini, xlow, xup, delta, maxit, level)

print "argmin' =", argmin'