[Rd] PR#751
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
17 Jan 2001 08:01:11 +0100
mark0060@tc.umn.edu writes:
> I'd just like to report a possible R bug--or rather, confirm an existing one
> (bug #751).
>
> I have had some difficulty using the polyroot() function.
>
> For example, in Win 98, R 1.1.1,
>
> > polyroot(c(2,1,1))
>
> correctly (per the help index) gives the roots of 1 + (1*x) + (2*x^2) as
>
> [1] -0.5+1.322876i -0.5-1.322876i
Mm, no. The coefficients are by increasing degree, so these are the
roots of 2+x+x^2
> x<-polyroot(c(2,1,1))
> x
[1] -0.5+1.322876i -0.5-1.322876i
> 2+x+x^2
[1] -2.220446e-16+4.440892e-16i -2.220446e-16-4.440892e-16i
> However,
>
> > polyroot(c(-100,0,1))
>
> gives the roots of
>
> [1] 10+0i -10+0i
>
> which corresponds to -100 + x^2, not 1 - (100*x^2).
as it should.
>
> Also,
>
> > polyroot(c(0,0,0,1))
>
> gives
>
> [1] 0+0i 0+0i -10+0i
>
> which aren't all roots of x^3.
That one is way out, however. Even more "fun":
> polyroot(c(-100,0,1))
[1] 10+0i -10+0i
> x<- polyroot(c(0,0,0,1))
> x
[1] 0+0i 0+0i -10+0i
> x<-polyroot(c(2,1,1))
> x<- polyroot(c(0,0,0,1))
> x
[1] 0.0+0.000000i 0.0+0.000000i -0.5-1.322876i
I.e. the result of polyroot(c(0,0,0,1)) depends on the previous
polyroot calculation! So there's more to the problem than numerical
instability.
Thanks for pointing it out.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._