[R] Problem : solving a equation with R , fail with uniroot function

Ben Bolker bolker at ufl.edu
Wed Jun 10 02:33:35 CEST 2009




Peter Alspach wrote:
> 
> Tena koe Yann
> 
> It may not be the only problem, but you are missing an operator between
> (bb0+x+1) and (bb1-x-1).
> 
> 

And fixing that typo and viewing the function shows that it 
is a bit problematic on this interval anyway ...  (diverges
at x = 1, closer look shows it's pretty nasty -- I haven't stopped
to think about its behavior very carefully, but it will clearly
take some effort.  If you're lucky there is a typo and the
real function is better behaved!)

test <- function(x,bb0=-3,bb1=5,c0=2,r0=0) {
   ((exp(c0-r0)*(bb0+x)*(bb1-x))/((bb0+x+1)*(bb1-x-1))-1)}


uniroot(test,c(-100,100))$root
curve(test(x),from=-100,to=100)
curve(test(x),from=1.00001,to=10)
abline(h=0,col=2)
-- 
View this message in context: http://www.nabble.com/Problem-%3A-solving-a-equation-with-R-%2C-fail-with-uniroot-function-tp23953174p23953614.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list