I have this function: function(x) -0.3*x*exp(-(((log(x)+(0.03+0.3*0.3/2)*0.5)/(0.3*sqrt(0.5)))^2)/2)/(2*sqrt(2*pi*0.5)) + 0.03*exp(-0.03*0.5)*pnorm(-(log(x)+(0.03-0.3*0.3/2)*0.5)/(0.3*sqrt(0.5)))
uniroot is giving the correct results. > uniroot(f,c(0,10)) $root [1] 0.7347249 $f.root [1] -1.955740e-07 $iter [1] 12 $estim.prec [1] 6.103516e-05 The newton method is not generating good result. > for( x in seq(0,8,1)) { z <- nleqslv(x,f); print(c(z$x,z$fvec))} [1] NaN 1.340781e+154 [1] NaN 1.340781e+154 [1] 3.406704e+00 -5.608658e-09 [1] 3.340717e+00 -9.480243e-09 [1] 4.000000e+00 -5.470677e-11 [1] 5.000000e+00 -3.386274e-14 [1] 6.000000e+00 -3.559448e-17 [1] 7.000000e+00 -6.065006e-20 [1] 8.000000e+00 -1.581856e-22 In this case I am looking for largest value of 'x' such that f(x) >= 0 -- View this message in context: http://r.789695.n4.nabble.com/newton-method-tp2306111p2310041.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.