optimize
Univariate Optimization of a Function

Description

Approximates a local optimum of a continuous univariate function within a given interval.

Usage

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

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

Arguments

f a real-valued function of the form f(x,<additional arguments>), where x is the variable over which the optimization is to take place.
interval a vector of values whose maximum and minimum specify the interval over which the optimization is to take place. (Optional if both lower and upper are specified.)
... additional arguments for f.
lower left endpoint of the initial interval.
upper right endpoint of the initial interval.
tol desired length of the interval of uncertainty in the location of the optimum.
maximum logical, TRUE if a maximum is sought.
Value
a list containing the following elements :
minimum, maximum a point that is within tol of a local optimum of f in [lower,upper].
objective the value of f at the computed local optimum.
Method
Implements Brent's safeguarded polynomial interpolation procedure for univarite minimization based on the Fortran function fmin from NETLIB (Dongarra and Grosse 1987).
References
Brent, R. (1973). Algorithms for minimization without derivatives. Prentice-Hall, Englewood Cliffs, NJ, USA.
Dongarra, J. J., and Grosse, E. (1987). Distribution of mathematical software via electronic mail, Communications of the ACM 30, pp. 403-407.
Note
The optimum produced by optimize may not be a global optimum of f over [lower,upper] unless f happens to be unimodal on [lower,upper].
For multivariate minimization, see optim and nlminb.
The optimise function is an alias of optimize function.
See Also
nlminb, uniroot.
Examples
quadratic <- function(x, c2, c1, c0) {c0 + x*(c1 + x*c2)} 
optimize(quadratic, interval = c(1,3), maximum = TRUE, 
	c2 = -1, c1 = 4, c0 = 0) 
# Find saddlepoint of a bivariate function using recursive call.
# Use attributes to record where saddlepoint is.
f <- function(x, y) structure(abs(x+.25*y-1)^1.5 - abs(y-.5*x-2)^1.5 + 1, x=x, y=y)
fy <- function(x) optimize(f, x=x, interval=c(-5,5), maximum=TRUE)$objective
optimize(fy, interval=c(-5,5))
Package stats version 6.1.1-7
Package Index