|MATLAB Function Reference|
returns a column vector whose elements are the roots of the polynomial
r = roots(c)
c contains the coefficients of a polynomial, ordered in descending powers. If
n+1 components, the polynomial it represents is .
Note the relationship of this function to
p = poly(r), which returns a row vector whose elements are the coefficients of the polynomial. For vectors,
poly are inverse functions of each other, up to ordering, scaling, and roundoff error.
The polynomial is represented in MATLAB as
The roots of this polynomial are returned in a column vector by
The algorithm simply involves computing the eigenvalues of the companion matrix:
It is possible to prove that the results produced are the exact eigenvalues of a matrix within roundoff error of the companion matrix
A, but this does not mean that they are the exact roots of a polynomial with coefficients within roundoff error of those in