Re: [R] newton.method

2010-08-02 Thread sammyny
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]

Re: [R] newton.method

2010-08-02 Thread Ravi Varadhan
what I am talking about. Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of sammyny Sent: Monday, August 02, 2010 4:49 AM To: r-help@r-project.org Subject: Re: [R] newton.method I have this function: function(x) -0.3*x*exp

Re: [R] newton.method

2010-08-02 Thread Berend Hasselman
sammyny wrote: 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))) .. The newton method is not generating good result. for( x in

Re: [R] newton.method

2010-08-02 Thread sammyny
Thanks everyone for their help. I am able to see things more clearly now. cheers, Samit -- View this message in context: http://r.789695.n4.nabble.com/newton-method-tp2306111p2310426.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] newton.method

2010-07-30 Thread Prof. John C Nash
Sometimes it is easier to just write it. See below. On 10-07-30 06:00 AM, r-help-requ...@r-project.org wrote: Date: Thu, 29 Jul 2010 11:15:05 -0700 (PDT) From: sammynysj...@caa.columbia.edu To:r-help@r-project.org Subject: Re: [R] newton.method Message-ID:1280427305687-2306895.p...@n4

Re: [R] newton.method

2010-07-30 Thread sammyny
/SendEmail.jtp?type=nodenode=2308224i=2 Subject: Re: [R] newton.method Message-ID:[hidden email]http://user/SendEmail.jtp?type=nodenode=2308224i=3 Content-Type: text/plain; charset=us-ascii newton.method is in package 'animation'. Thanks Ravi. BBSolve/BBOptim seems to work very

[R] newton.method

2010-07-29 Thread sammyny
Hi, Is this method broken in R? I am using it to find roots of the following function: f(x) = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100 It is giving an answer of -38.4762403 which is not even close (f(x) = 2.903809e+25 for x=-38.4762403). The answer should be around

Re: [R] newton.method

2010-07-29 Thread David Winsemius
On Jul 29, 2010, at 4:32 AM, sammyny wrote: Hi, Is this method broken in R? ?newton.method No documentation for 'newton.method' in specified packages and libraries: you could try '??newton.method' If you are asking about a non-base function, you are asked by the Posting Guide

Re: [R] newton.method

2010-07-29 Thread Dennis Murphy
Hi: Interesting. Try the following; f is copied and pasted directly from your e-mail: f - function(x) 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100 curve(f, -3, 8) # plot it in a localized region abline(0, 0, lty = 2) There are two places where the function

Re: [R] newton.method

2010-07-29 Thread Ravi Varadhan
29, 2010 8:28 am Subject: Re: [R] newton.method To: sammyny sj...@caa.columbia.edu Cc: r-help@r-project.org Hi: Interesting. Try the following; f is copied and pasted directly from your e-mail: f - function(x) 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100

Re: [R] newton.method

2010-07-29 Thread sammyny
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

Re: [R] newton.method

2010-07-29 Thread Berend Hasselman
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

Re: [R] newton.method

2010-07-29 Thread Yihui Xie
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 =