The function newton.method() in the package 'animation' is merely for demonstration purpose instead of serious computation -- it illustrates how Newton's method works step by step. But I'm unable to reproduce your bogus results:
library(animation) par(pch = 20) ani.options(nmax = 50, interval = 0.5) newton.method(f, init = 2, tol = 10 * exp(-8)) # $root # [1] 7.419378 # # $value # [1] 1.211038e-07 # # $iter # [1] 17 ani.options(nmax = 50) newton.method(f, init = -1, rg = c(-4, 12))$root # about -2.44 ani.options(nmax = 50) newton.method(f, init = 4, rg = c(-4, 12))$root # 7.42 Regards, Yihui -- Yihui Xie <xieyi...@gmail.com> Phone: 515-294-6609 Web: http://yihui.name Department of Statistics, Iowa State University 3211 Snedecor Hall, Ames, IA On Thu, Jul 29, 2010 at 1:15 PM, sammyny <sj...@caa.columbia.edu> wrote: > > newton.method is in package 'animation'. > > Thanks Ravi. > BBSolve/BBOptim seems to work very well although I am not familiar with the > optimization methods being used there. Is there a way to specify a tolerance > in the function to get the required precision. > > I did something like this to use newton method. > require(animation) > newton.method(f, init=2, tol=10*exp(-8)) > But it gives bogus results. > > If someone could point me a correct working version of newton method for > finding roots and its usage, that would be helpful. > > cheers, > > Sam > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/newton-method-tp2306111p2306895.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. > ______________________________________________ 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.