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.
Click to copy this expression
Polynomials cannot have negative or noninteger powers!
2. Define the coefficients of the polynomial in vector v.
Click to copy this expression
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.
Click to copy this expression
Click to copy this expression
4. Plot the polynomial p(x) and its roots.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Complex Coefficients
You can also use polyroots with complex coefficients.
1. Define a polynomial with complex coefficients.
Click to copy this expression
2. Define the vector of coefficients beginning with the constant term.
Click to copy this expression
3. Apply the polyroots function to vector v.
Click to copy this expression
Click to copy this expression
All roots are returned, both real and complex.