Skip to main content
Logo image

Section 9.8 Derivatives

Derivatives of polynomials are quite simple to find - even by hand. Of course, MATLAB has a function to find derivatives, namely the polyder function. Not only can this function find the derivative of a polynomial, it can also find the derivative of the product or the quotient of two polynomials. Which of these is performed depends on how you call the function.
The most simple case is to simply find the derivative of a polynomial:
k = polyder(p)
Here, \(p\) is a row vector of coefficients of the polynomial to be differentiated and \(k\) is a row vector of coefficients of the resulting polynomial.
To find the derivative of the product of two polynomials, use:
k = polyder(p1, p2)     % derivative of the product
                        % of two polynomials
Of course, alternatively, you could use the conv function to fist multiply the polynomials and then the polyder function to take the derivative. But for large polynomials, letting the polyder function do all the work is more efficient.
Similarly, the polyder function can take the derivative of a quotient of polynomials (this is also known as a rational function). Since the result of this computation is most likely a quotient of two polynomials, the polyder function returns a numerator and a denominator polynomial coefficient vector:
[n d] = polyder(p1, p2)     % derivative of the quotient
                            % of two polynomials, result
                            % is two polynomials - numerator
                            % and denominator

Activity 9.8.

For the functions
\begin{equation*} f_1(x) = 3x^2 - 2x + 4 \end{equation*}
\begin{equation*} f_2(x) = x^2 + 5 \end{equation*}
find the derivatives of the following functions using MATLAB:
  1. \(\displaystyle f_1(x)\)
  2. \(\displaystyle f_1(x)\cdot f_2(x)\)
  3. \(\displaystyle \frac{f_1(x)}{f_2(x)]}\)
Please put your MATLAB code into the textbox.