|
Contents | Previous | Next | Subchapters |
| Syntax |
[x, nfun] = brent(function f, fval, xini, step, mfun)
|
| See Also | snewton , dnlsq |
f (x ) = fval
ij ij ij
The real, double-precision or complex matrix xini
specifies the starting
point when Brent's method is applied to solve the
corresponding equation above.
The matrix fval has the same type and dimension as xini
and specifies the right hand side of the equation.
The scalar step has the same type as x and
specifies the initial step size with respect to
x for bracketing the minimum.
The integer scalar mfun
specifies the maximum number of evaluations of f to attempt.
If the method cannot not converge in mfun calls to f,
brent returns the current estimate of x and with
nfun = mfun + 1
Otherwise, the return value of nfun is the number of
evaluations of f that was used by brent
f(x)
The returns the
element-by-element
a matrix valued function f(x)
where x is a matrix with the same type
and dimension as xini.
brent to compute the
square roots of 1, 2, 3 and 4
(though we would normally use the sqrt
function for this task).
clear
function f(x) begin
return x^2.
end
fval = double(seq(4))
xini = 1d0 + rand(4, 1)
step = .1d0
mfun = 100
[x, nfun] = brent(function f, fval, xini, step, mfun)
print x
returns
{
1
1.41421
1.73205
2
}
which are the square roots of 1, 2, 3, and 4 respectively.