Library: | nummath |
See also: | nmbracket nmgolden nmlinmin nmcongrad |
Quantlet: | nmbrent | |
Description: | Brent's method for the minimization of a given scalar function |
Usage: | min = nmbrent(func {,a,b,c,xtol}) | |
Input: | ||
func | name of function (string) whose minimum is to be found. The function should have just one scalar parameter x. As a result, the function should return a scalar. | |
a,b,c | optional scalars; a bracketing triplet for minimum of func, i.e., a < b < c and fb < fa, fb < fc; default values: results of nmbracket(func) | |
xtol | optional scalar; tolerance - fractional precision of the minimum; default xtol = 1e-8 | |
Output: | ||
min.xmin | minimum of func (isolated to a fractional precision of tol) | |
min.fmin | minimum function value f(xmin) |
library("nummath") nmbrent("sin",pi,1.3*pi,2*pi) ; the bracketed minimum is sin(3/2*pi) = -1
Contents of _tmp.xmin [1,] 4.7124 Contents of _tmp.fmin [1,] -1
library("nummath") min = nmbrent("sin") min.xmin min.fmin ; uses the quantlet nmbracket to bracket the minimum first...
; minimum in -pi/2: Contents of xmin [1,] -1.5708 Contents of fmin [1,] -1
library("nummath") ; ; definition of function ; proc(p)=ftion(x) p = cos((x+3*pi)/4) .* x^2 endp min=nmbrent("ftion") min
Contents of min.xmin [1,] 6.6506 Contents of min.fmin [1,] -28.275