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.
Differences between TIBCO Enterprise Runtime for R and Open-source R
- the argument "keep.xy" is not supported in open-source R.
- Only two components of list are returned in open-source R implementation:
"objective", "minimum" or "maximum".
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 nlminb.
The optimize function may not be called
recursively, that is, f may not include a
call to optimize. Recursive calls would
overwrite information that is stored internally.
The optimise function is an alias of optimize function.
See Also
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)