|See Also||snewton , dnlsq|
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
f (x ) = fval
ij ij ij
xfor 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,
brentreturns the current estimate of x and with
Otherwise, the return value of nfun is the number of evaluations of f that was used by
nfun = mfun + 1
)The returns the element-by-element a matrix valued function
)where x is a matrix with the same type and dimension as xini.
brentto compute the square roots of 1, 2, 3 and 4 (though we would normally use the sqrt function for this task).
function f(x) begin
fval = double(seq(4))
xini = 1d0 + rand(4, 1)
step = .1d0
mfun = 100
[x, nfun] = brent(function f, fval, xini, step, mfun)
which are the square roots of 1, 2, 3, and 4 respectively.