optimize(f, interval, lower = min(interval), upper = max(interval), tol = .Machine$double.eps^.25, maximum = F, keep.xy = F, ...)
Function values should be computed in C or Fortran within the outer S-Plus function for greater efficiency.
For multivariate minimization, see nlminb.
Dongarra, J. J., and Grosse, E. (1987). Distribution of mathematical software via electronic mail, Communications of the ACM 30, pp. 403-407.
quadratic <- function( x, c2, c1, c0) {c0 + x*(c1 + x*c2)} optimize(quadratic, interval = c(1,3), max = T, keep.xy = T, c2 = -1, c1 = 4, c0 = 0)quadratic <- function( x, c2, c1, c0, nf = 0, all = list( x = NULL, y = NULL)) {value <- c0 + x*(c1 + x*c2) attributes(value) <- list( nf = nf + length(x), all = list( x = c(all$x, x), y = c(all$y, value))) value} optimize(quadratic, lower = 1, upper = 3, max = T, c2 = -1, c1 = 4, c0 = 0)