This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/optimize.html
optimize {base}R Documentation

One Dimensional Optimization

Description

The function optimize searches the interval from lower to upper for a minimum or maximum of the function f with respect to its first argument.

The function uses Fortran code (from Netlib) based on algorithms given in the reference.

Usage

optimize(f=, interval=, lower=min(interval),
        upper=max(interval), maximum=FALSE,
        tol=.Machine$double.eps^0.25, ...)

Arguments

f

the function to be optimized. The function is either minimized or maximized over its first argument depending on the value of maximum.

interval

a vector containing the end-points of the interval to be searched for the minimum.

lower

the lower end point of the interval to be searched.

upper

the upper end point of the interval to be searched.

tol

the desired accuracy.

...

additional arguments to f.

Value

A list with components minimum (or maximum) and objective which give the location of the minimum (or maximum) and the value of the function at that point.

References

Brent, R. (1973). Algorithms for Minimization without Derivatives. Englewood Cliffs N.J.: Prentice-Hall.

See Also

nlm, uniroot.

Examples

f <- function (x,a) (x-a)^2
xmin <- optimize(f, c(0, 1), tol=0.0001, a=1/3)
xmin

[Package base version 0.60 ]