MATLAB: Limitation on poly and roots functions

MATLABpolypolynomialroots

Dear All,
I have a query regarding the maximum polynomial order that can be treated using "roots" or "poly" functions. I am facing following problem:
P= Polynomial of order N=512;
R=roots(P);
P1=poly( R );
Coefficients of P are not equal to P1.
Coefficients match for lower orders such as N=8, 16, 64, 128. I shall appreciate if anyone could explain this to me or suggest what I am missing here. Thanks in advance.
Asim

Best Answer

Note from the documentation: "For vectors, roots and poly are inverse functions of each other, up to ordering, scaling, and roundoff error."
So these are not perfect inverses of each other. I ran your test through a loop of N=1:1024 using random inputs and for each iteration P==P1. However I'm sure there's some cases out there where they won't be exactly equal, particularly with larger values. Are you seeing very small differences, or are they significant? If they are small then I would guess it is expected.