1
©2009 by L. Lagerstrom
Polynomials
• For an introduction to the basic concepts, see the
associated video clip
• Writing a polynomial
• Polynomial coefficient notation
• The polyval function
• Polynomial coefficient arithmetic
• Polynomial multiplication, division, and derivatives
• Polynomial roots
• A common error
©2009 by L. Lagerstrom
Working with Polynomials
We often work with polynomials in math, science, and engineering.
Sometimes we get a polynomial for a result and want to plot it. Other
times we have some data and want to fit a polynomial curve to the
data (something we will learn how to do in a later lesson).
Another common task is to find the roots of a polynomial (the values
that yield a value of 0 for the polynomial). If it's a quadratic (second
order) polynomial, we can simply use the quadratic formula. But if it's
a higherorder polynomial, there may be no simple way to find the
roots.
Fortunately, Matlab provides a "roots" function that will calculate the
roots for any polynomial. To use it, however, we have to learn a new
way to write a polynomial, called "polynomial coefficient notation."
Along the way, we will also learn about several other polynomial
related functions that use this notation.
©2009 by L. Lagerstrom
Writing a Polynomial
Mathematically we write a polynomial as (for example):
Reminder: if we wanted to substitute a value for x and calculate the
result using Matlab we would write:
x = 3.8;
y = x^4 + 2*x^3  7*x^2 + 6*x  3;
If we wanted to substitute many x values into the polynomial and plot
the results, we might write (note the use of dot operators):
x = 3:0.1:3;
y = x.^4 + 2*x.^3  7*x.^2 + 6*x  3;
plot(x,y)
3
6
7
2
)
(
2
3
4

+

+
=
x
x
x
x
x
y
©2009 by L. Lagerstrom
Polynomial Coefficient Notation
Consider the polynomial from the previous slide:
We note that all we really need to specify this polynomial is the
coefficients. That is, if we list the coefficients as 1, 2, 7, 6 and 3, in
that order, and have the understanding that we write the terms of the
polynomial in descending order of the term exponents (i.e., the x
4
, x
3
,
x
2
, x
1
, and x
0
terms), then we have fully specified the polynomial.
This is known as "polynomial coefficient notation," because instead
of writing the whole polynomial, we just write the coefficients. In
Matlab we implement this by defining the coefficients in a row vector.
For example:
a = [1
2
7
6
3];
(We use "a" for the variable name because we often write a general
polynomial as a
n
x
n
+ a
n1
x
n1
+ .
.. + a
2
x
2
+ a
1
x
1
+ a
0
x
0
.)
3
6
7
2
)
(
2
3
4

+

+
=
x
x
x
x
x
y