[Rd] BUG: polyroot() (PR#751)

Paul Gilbert pgilbert@bank-banque-canada.ca
Thu, 07 Dec 2000 10:18:29 -0500


I noticed with the original problem that there was a difference between R 1.1.1
and the R 1.2  snapshot from a few weeks ago. I would guess you are not running 1.2
since you get

>> polyeval(1:5,polyroot(1:5))
>[1] -2.220446e-16-2.664833e-16i -2.220446e-16-1.554475e-16i
>[3] -2.220446e-16+1.436839e-16i -2.220446e-16-5.076235e-16i

and with my snapshot I get
> polyeval(1:5,polyroot(1:5))
[1]  3.330669e-16+5.828671e-16i  3.330669e-16+2.220446e-16i
[3] -2.220446e-16-3.885781e-16i  3.330669e-16-5.828671e-16i

I expect you probably know more about the change than I do, but though I would warn
you anyway.

Polynomial root solutions can be notoriously ill conditioned, but the problem in the
bug report does not seem too bad. (At least the answer does not change much  with
small coefficient perturbations.)  One of the things I noticed in the bug report
problem was that polyroot did not seem to be giving complex conjugate pairs.
(Although, perhaps I did not look closely enough.) In your example it is not too bad
but does starts to show up:

print(polyroot(11:1), digits=12)
 [1]  0.953246161338+0.725110449959i -0.884658051302+0.959966734829i
 [3] -0.884658773085-0.959966532398i  0.953246339786-0.725110604788i
 [5]  0.442765752789+1.173740513854i -1.264630746148+0.357262003979i
 [7] -0.246722911623-1.262885538489i  0.442765716343-1.173740954848i
 [9] -0.246722399601+1.262885188965i -1.264631088498-0.357261261065i


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