uniroot(f, interval, lower = min(interval), upper = max(interval), tol = .Machine$double.eps^.25, keep.xy = F, f.lower = NA, f.upper = NA, ...)
Function values should be computed in C or Fortran within the outer S-Plus function for greater efficiency.
Dongarra, J. J., and Grosse, E. (1987). Distribution of mathematical software via electronic mail, Communications of the ACM 30, pp. 403-407.
cubic <- function(x, c2, c1, c0) {(x - c2) * (x - c1) * (x - c0)} uniroot(cubic, c(1,3), keep.xy = T, c2 = -2, c1 = 0, c0 = 2)cubic <- function(x, c2, c1, c0, nf = 0, all = list( x = NULL, y = NULL)) {value <- (x - 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} uniroot(cubic, lower = 1, upper = 3, c2 = -2, c1 = 0, c0 = 2)