Section 9.1 Introduction to Polynomials
Polynomials are extremely useful functions used in many scientific and engineering applications. Polynomials can be evaluated efficiently and (think Taylor series approximation) can be used to approximate more complex functions.
A polynomial is simply a linear combination of integer powers of the independent variable \(x\text{:}\)
\begin{equation*}
f(x) = a_nx^n + a_{x-1}x^{n-1} + ... + a_1x + a_0
\end{equation*}
Here, \(a_n, a_{n-1}, ..., a_1, a_0\) are called the coefficients and we will restrict these to real numbers. The highest power of x that occurs with a nonzero coefficient \((n)\) is the degree or order of the polynomial.
Note that these \(n+1\) coefficients (some of them could be zero) completely describe a unique \(n^{th}\) degree polynomial.
Here are some of the computational benefits of working with polynomials:
Polynomials can be stored in very compact form (all you need to know are the coefficients).
Polynomials can easily be added, multiplied, integrated, and differentiated.
Polynomials can be used to approximate much more complicated functions.
Polynomials are continuous functions of \(x\) which can be evaluated at any \(x\text{.}\)
MATLAB has several built-in functions and features that allow us to easily work with polynomials. Each polynomial is stored simply as a vector of coefficients. Here is an example:
The polynomial \(f(x) = x^5 - 12.1x^4 + 40.59x^3 - 17.01x^2 - 71.95x + 35.88\) is of order 5 and so we need to store 6 coefficients, namely:
\begin{align*}
a_5 \amp = \amp 1\\
a_4 \amp = \amp -12.1\\
a_3 \amp = \amp 40.59\\
a_2 \amp = \amp -17.01\\
a_1 \amp = \amp -71.95\\
a_0 \amp = \amp 35.88
\end{align*}
In MATLAB, polynomials are represented by a row vector of their coefficients, from highest to lowest:
Returning to our example, we thus store the polynomial \(f\) as
f = [1, -12.1, 40.59, -17.01, -71.95, 35.88]
Let’s take a look at some more examples:
\(g(x) = x^8 + 1\)
This polynomial is of degree 8 and thus needs to be stored as a 9-element row vector:
g = [1, 0, 0, 0, 0, 0, 0, 0, 1]
Activity 9.1.
Why is it not sufficient to only store the non-zero coefficients?
Here is another example: \(h(x) = x^5 - 3x^3 + 7x\text{.}\) In MATLAB we store this function as:
Activity 9.2.
Express the polynomials
\begin{equation*}
p(x) = 2x^3 - 3x^2 + x + 5
\end{equation*}
\begin{equation*}
q(x) = 3x^4 + x^2 + 2x - 4
\end{equation*}
as row vectors of coefficients.
Please put your MATLAB code into the textbox.