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 crosses the x-axis, but not where
you were expecting. The graph suggests one root between -3 and -2 and
another between 7 and 8: Note that uniroot() takes an object of class
function as its first argument and a search interval as its second. It is
the R function that finds a zero of a univariate function. See ?uniroot for
details. (And f is a function object; try class(f).)

On Thu, Jul 29, 2010 at 1:32 AM, sammyny <sjain@caa.columbia.edu> wrote:

>
> 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
>

Which method? It is never (conveniently) mentioned...  Function? Package?

>
> 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 0.01-0.1. This
> function should converge..
>

> Even for a simple function like  f(x) = exp(-x) * x, it gives answer as
> 8.89210984 for which f(x) = 0.001222392 and I set tolerance to 10^-12..
>

I see handwaving and fulminating, but no code...

>
> Also, is there a non graphical version of newton method? I looked at
> nleqslv
> but have no idea how to use it..
>

> Thanks for your help.
>

HTH,
Dennis

> --
> View this message in context:
> http://r.789695.n4.nabble.com/newton-method-tp2306111p2306111.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.
>

	[[alternative HTML version deleted]]

