Strange poly() results
Kevin McCoy
kevinm at aavatech.com
Mon Apr 30 16:48:34 CEST 2012
When I run the following:
clean(coeff(poly(roots(poly([1 1 1],"x","c")),"x","r"))) I get ...
ans =
1. + 0.4330127i 1. 1.
But I'm expecting ...
ans =
1. 1. 1.
The documentation says that roots() and poly() are inverse functions, that
is, if I construct a polynomial (using poly(pr,"x","r"), where pr are the
roots of a polynomial), then I should get back that original polynomial.
Here are some other outputs:
clean(coeff(poly(roots(poly([1 1],"x","c")),"x","r"))) --> 1. 1.
[correct]
clean(coeff(poly(roots(poly([1 0 1],"x","c")),"x","r"))) --> 1. 0. 1.
[correct]
clean(coeff(poly(roots(poly([1 0 0 1],"x","c")),"x","r"))) --> 0.625 +
0.2165064i 0.4330127i 0 1. [incorrect]
clean(coeff(poly(roots(poly([2 1 1],"x","c")),"x","r"))) --> 2. + 0.6614378i
1. 1. [incorrect]
However, if I change the code to only use the real part of poly() I get my
expected results:
clean(coeff(real(poly(roots(poly([1 1 1],"x","c")),"x","r")))) --> 1.
1. 1. [correct]
What am I doing wrong?
Thanks!
--
View this message in context: http://mailinglists.scilab.org/Strange-poly-results-tp3950900.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list