[Rd] uniroot violates bounds?
Ben Bolker
bbo|ker @end|ng |rom gm@||@com
Sat Feb 18 18:28:22 CET 2023
c1 <- 4469.822
c2 <- 572.3413
f <- function(x) { c1/x - c2/(1-x) }; uniroot(f, c(1e-6, 1))
uniroot(f, c(1e-6, 1))
provides a root at -6.00e-05, which is outside of the specified
bounds. The default value of the "extendInt" argument to uniroot() is
"no", as far as I can see ...
$root
[1] -6.003516e-05
$f.root
[1] -74453981
$iter
[1] 1
$init.it
[1] NA
$estim.prec
[1] 6.103516e-05
I suspect this fails because f(1) (value at the upper bound) is
infinite, although setting interval to c(0.01, 1) does work/give a
sensible answer ... (works for a lower bound of 1e-4, fails for 1e-5 ...)
Setting the upper bound < 1 appears to avoid the problem.
For what it's worth, the result has an "init.it" component, but the
only thing the documentation says about it is " component ‘init.it’ was
added in R 3.1.0".
And, I think (?) that the 'trace' argument only produces any output
if the 'extendInt' option is enabled?
Inspired by
https://stackoverflow.com/questions/75494696/solving-a-system-of-non-linear-equations-with-only-one-unknown/75494955#75494955
cheers
Ben Bolker
More information about the R-devel
mailing list