根
Polynomial roots
Syntax
Description
r = roots(
returns the roots of the polynomial represented byp
)p
as a column vector. Inputp
is a vector containingn+1
polynomial coefficients, starting with the coefficient ofxn。A coefficient of0
indicates an intermediate power that is not present in the equation. For example,p = [3 2 -2]
represents the polynomial
。
这根
function solves polynomial equations of the form
。Polynomial equations contain a single variable with nonnegative exponents.
Examples
Input Arguments
Tips
Use the
poly
function to obtain a polynomial from its roots:p = poly(r)
。这poly
function is the inverse of the根
function.Use the
fzero
function to find the roots of nonlinear equations. While the根
function works only with polynomials, thefzero
function is more broadly applicable to different types of equations.
Algorithms
这根
功能考虑p
成为与n+1
elements representing then
th degree characteristic polynomial of ann
-by-n
matrix,A
。这根of the polynomial are calculated by computing the eigenvalues of the companion matrix,A
。
A = diag(ones(n-1,1),-1); A(1,:) = -p(2:n+1)./p(1); r = eig(A)
这results produced are the exact eigenvalues of a matrix within roundoff error of the companion matrix,A
。However, this does not mean that they are the exact roots of a polynomial whose coefficients are within roundoff error of those inp
。