[R] roots of a function
Martin Maechler
maechler at stat.math.ethz.ch
Mon Nov 14 21:46:47 CET 2005
>>>>> "Alejandro" == Alejandro Veen <veen at stat.ucla.edu>
>>>>> on Mon, 14 Nov 2005 10:23:02 -0800 writes:
Alejandro> For finding the root of the following function I
Alejandro> have been using 'uniroot': f(p) = log(p-1) -
Alejandro> log(p) + 1/(p-1) - log(A) - B = 0
Alejandro> where 'p' is a scalar. However, I will have to
Alejandro> find this root repeatedly, so I would like to
Alejandro> suggest a starting value, which is not possible
Alejandro> with 'uniroot'. 'nlm' allows the use of starting
Alejandro> values, so I have been thinking of applying 'nlm'
Alejandro> to abs(f(p)). Is that the way to go or is there
Alejandro> a better way I don't know about?
No, using minimization instead of root finding is typically not
as efficient (particularly in one dimension).
But in some ways you *have* been using starting values for
uniroot() contrary to what you said:
uniroot even needs an starting *interval* in which to search.
If you know a lot about your function and its zero, just make
that initial interval appropriately small.
Alejandro> Thanks for your help,
you're welcome!
Martin
More information about the R-help
mailing list