Dear Lorenzo, You could try the BB package:
# function we need the roots for fn1 <- function(x, a) - x^2 + x + a # plot curve(fn1(x, a = 5), -4, 4) abline(h=0, col = 2) # searching the roots in (-4, 4) # install.packages('BB') require(BB) BBsolve(par = c(-1, 1), fn = fn1, a = 5) values <- BBsolve(par = c(-1, 1), fn = fn1, a = 5)$par values # adding the roots to the plot points(values, c(0, 0), pch = 8, cex = 1.1, col = 4) HTH, Jorge On Sat, Sep 25, 2010 at 8:24 PM, Lorenzo Isella <> wrote: > Dear All, > I need to find the (possible multiple) zeros of a function f within an > interval. I gave uniroot a try, but it just returns one zero and I need to > provide it with an interval [a,b] such that f(a)f(b)<0. > Is there any function to find the multiple zeros of f in (a,b) without > constraints on the sign of f(a) and f(b)? > Many thanks > > Lorenzo > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.