Skip to main content
Logo image

Section 9.4 Root Finding

The roots or zeros of a function, including polynomials, are the values of the argument at which the function evaluates to zero.
The Fundamental Theorem of Algebra states that an nth degree polynomial has n roots:
  • These roots are not necessarily distinct (some roots occur with higher multiplicity)
  • Not all roots are necessarily real (they can also be complex)
The root finding problem is one of the oldest in numerical approximation dating back to 1700 BC, yet it is still a topic of research.
There are many techniques and algorithms used to find (approximate) roots or zeros of functions: bisection, Newton’s Method, secant method, Müller’s Method.
In MATLAB, we can easily find the roots of a polynomial using the roots function:
r = roots(p)
Here, \(p\) is a row vector of polynomial coefficients. The result \(r\) is a column vector of the roots of the polynomial.
Example:
>> p = [1 -12.1 40.59 -17.015 -71.95  35.88];
>> r = roots(p)
r =
     6.5000      % n roots of an nth order polynomial
     4.0000
     2.3000
    -1.2000
     0.5000

Activity 9.4.

Find the zeros (roots) of the polynomials
\begin{equation*} f(x) = x^3 - x^2 - 2x \end{equation*}
\begin{equation*} g(x) = x^4 - x^3 - 2x^2 \end{equation*}
Please put your MATLAB code into the textbook.

Subsection 9.4.1 Degenerate Roots

Consider the polynomial \(p(x) = x^2\text{.}\) This polynomial only has one x-value, at which it takes the value 0, namely x = 0. Since the graph of p does not cross the x-axis at x=0, this root is actually of multiplicity greater than 1 and is called a degenerate root. MATLAB figures this out and lists such roots multiple times in the vector of roots (according to multiplicity). Take a look:
>> p = [1, 0, 0]
p =
    1  0  0
>> r = roots(p)
r =
    0
    0

Activity 9.5.

Find a polynomial \(h\) that has zeros at 0, 1 and 2.
Please express the polynomial as a MATLAB polynomial and put your vector into the textbox.
How did you accomplish this? Unless you have magic powers, most likely you multiplied together x, (x-1) and (x-2).
Note that the roots of a polynomial by themselves actually define the polynomial, up to multiplication by a scalar.
If the roots of a polynomial are known, MATLAB can actually construct the polynomial, that is, the coefficients of the polynomial, assuming that the leading coefficient equal 1. Here is an example: Suppose we wanted to find a polynomial with roots 6.5, 4, 2.3, 0.5 and -1.2. We know that the polynomial is given by
\begin{equation*} f(x) = (x - 6.5)(x - 4)(x - 2.3)(x + 1.2)(x - 0.5) \end{equation*}
But in order to find the polynomial coefficients we’d actually have to multiply through. MATLAB does this for us:
>> r = [6.5; 4; 2.3; 0.5; -1.2]
r =
     6.5
     4.0
     2.3
     0.5
    -1.2
Note that this is a column vector of the roots. The command poly finds the polynomial for us:
>> p = poly(r)
p =
    1.00  -12.10  40.59  -17.02  -71.95  35.88