roots
Polynomial roots
Syntax
Description
r = roots( returns the roots of the polynomial
represented by the coefficients in p)p as a column vector
r. Input p is a vector containing
n+1 polynomial coefficients, starting with the coefficient of
xn. For example, p = [3 2
-2] represents the polynomial . A coefficient of 0 indicates an intermediate
power that is not present in the equation.
The roots function solves polynomial equations
of the form .
Polynomial equations contain a single variable with nonnegative exponents.
Examples
Input Arguments
Tips
Use the
polyfunction to obtain a polynomial from its roots:p = poly(r). Thepolyfunction is the inverse of therootsfunction.Use the
fzerofunction to find the roots of nonlinear equations. While therootsfunction works only with polynomials, thefzerofunction is more broadly applicable to different types of equations.
Algorithms
The roots function considers p to
be a vector with n+1 elements representing the nth
degree characteristic polynomial of an n-by-n matrix, A.
The roots 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)
The 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 in p.
Extended Capabilities
Version History
Introduced before R2006a