[R] newton.method

Berend Hasselman bhh at xs4all.nl
Thu Jul 29 21:12:58 CEST 2010



sammyny wrote:
> 
> 
> If someone could point me a correct working version of newton method for
> finding roots and its usage, that would be helpful.
> 

You mentioned in your original post that you had no idea how to use nleqslv.
nleqslv provides a Broyden and Newton method with several different global
search  strategies for "difficult" functions.

Here it is an example using your function (which is not particulary
difficult if you look at the plot):

library(nleqslv)

# starting value -2
nleqslv(-2,f)

# starting value 8
nleqslv(8,f)

# manual multistart
for( x in seq(-3,8,1)) { z <- nleqslv(x,f); print(c(z$x,z$fvec))}

These example all use the Broyden method.

If you want the Newton method then you can do

for( x in seq(-3,8,1)) { z <- nleqslv(x,f,method="Newton");
print(c(z$x,z$fvec))}


/Berend
-- 
View this message in context: http://r.789695.n4.nabble.com/newton-method-tp2306111p2306973.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list