Functions > Solving and Optimization > Root and Linear System Solvers > Example: Finding the Roots of a Polynomial
Example: Finding the Roots of a Polynomial
Roots of a Polynomial
Use the polyroots function to find all the roots of a polynomial.
1. Define a polynomial function with no negative exponents.
Polynomials cannot have negative or noninteger powers!
2. Define the coefficients of the polynomial in vector v.
The column of v lists the coefficients in order of increasing powers of x. Note that vector v includes a zero coefficient because the polynomial does not contain an x squared.
3. Apply the function polyroots to the vector v.
4. Plot the polynomial p(x) and its roots.
Complex Coefficients
You can also use polyroots with complex coefficients.
1. Define a polynomial with complex coefficients.
2. Define the vector of coefficients beginning with the constant term.
3. Apply the polyroots function to vector v.
All roots are returned, both real and complex.
Was this helpful?