In the examples below, we will apply the use of derivatives for common tasks related to the shapes of functions. These examples use function notation for derivatives, though the
diff() command may also be used.
Example 12.1 . Finding the Equation of a Tangent Line.
In this example, we will find the equation of the tangent line to the function
\(f(x)=6\sqrt{x} - 2x\) at
\(x=4\text{.}\) We start by assigning the function a name and determining its derivative.
> f(x) := 6*sqrt(x) - 2*x;
\begin{equation*}
\displaystyle f\, := \,x\mapsto 6\,\sqrt {x}-2\,x
\end{equation*}
\begin{equation*}
\displaystyle \frac{3}{\sqrt{x}}-2
\end{equation*}
The
\(y\) -coordinate of
\(f(x)\) at
\(x=4\) can be evaluated using simple function notation.
\begin{equation*}
\displaystyle 4
\end{equation*}
Meanwhile, the slope of the tangent is the derivative of
\(f(x)\text{,}\) evaluated at
\(x=4\text{.}\) Oddly enough, this value is easily simplified, but seems to require an additional
simplify(%) command.
Aside Sometimes Maple output can be easily simplified, using
simplify(%). Alternatively, an
evalf(%) command would produce a decimal output.
\begin{equation*}
\displaystyle \frac{3}{4}\, \sqrt{4}-2
\end{equation*}
\begin{equation*}
\displaystyle -\frac{1}{2}
\end{equation*}
The general equation of the tangent line to a differentiable function \(f(x)\) at \(x=a\) is
\begin{equation*}
L(x) = f'(a) (x-a) + f(a)\text{.}
\end{equation*}
Applying this equation with
\(a=4\text{,}\) we obtain an equation of the tangent line. It can be useful to assign a name to this tangent line so that it may easily be plotted along with the original function. When calculating and plotting several tangent lines, make sure to name each one differently.
> line := f'(4)*(x-4) + f(4);
\begin{equation*}
\displaystyle line\, := \, \left( \frac{3}{4}\, \sqrt{4}-2 \right) \left( x-4 \right) +4
\end{equation*}
This equation can be expanded into a standard
\(y=mx+b\) form.
Aside You can also try looking into the
collect() command for collecting powers of
\(x\) in an expression.
\begin{equation*}
\displaystyle -\frac{1}{2}x+6
\end{equation*}
Notice that the line is only defined as an expression and is not in function notation. We can now plot the function and the line.
Aside It is a good idea to specify plot colours, especially if plotting more than one tangent line on the same axes.
> plot( [f(x),line], x=-1..10);
Example 12.2 . The Closed Interval Method for Min/Max Problems.
In this example, we will find the absolute minimum and maximum values of
\begin{equation*}
\displaystyle f(x) = \frac {-x^4+5x^3+20}{\sqrt{x^2+1}}
\end{equation*}
on the interval \([-1,5]\text{.}\) It is best to define the function and plot it first to get an idea of where the critical numbers are located.
> f(x) := (20 + 5*x^3 - x^4)/sqrt(x^2 + 1);
\begin{equation*}
\displaystyle f\, := \,x\mapsto {\frac {-{x}^{4}+5\,{x}^{3}+20}{\sqrt {{x}^{2}+1}}}
\end{equation*}
> plot(f(x), x=-1.5..5.5);
By factoring the derivative, we can see that
\(x=0\) is a critical number.
\begin{equation*}
\displaystyle -{\frac {x \left( 3\,{x}^{4}-10\,{x}^{3}+4\,{x}^{2}-15\,x+20 \right) }{ \left( {x}^{2}+1 \right) ^{3/2}}}
\end{equation*}
\begin{equation*}
\displaystyle CN\mathit{1}\, := \,0
\end{equation*}
We can use the
fsolve() command over smaller intervals to find the remaining critical numbers.
> CN2:=fsolve(f'(x)=0, x=1..2);
\begin{equation*}
\displaystyle CN\mathit{2}\, := \, 1.078091128
\end{equation*}
> CN3:=fsolve(f'(x)=0, x=3..4);
\begin{equation*}
\displaystyle CN\mathit{3}\, := \, 3.201521345
\end{equation*}
To apply the closed interval method, we must evaluate the function at all critical numbers in the interval
Aside If a closed interval was not specified, we could use the second derivative test to find local minima and maxima.
> f''(CN1);
f''(CN2);
f''(CN3);
\begin{equation*}
\displaystyle -20
\end{equation*}
\begin{equation*}
\displaystyle 8.886020129
\end{equation*}
\begin{equation*}
\displaystyle - 8.221546325
\end{equation*}
Since
\(f(x)\) is concave down at
CN1 and
CN3, we have found two local maxima. Since
\(f(x)\) is concave up at
CN2, we have found one local minimum.
> f(CN1); f(CN2); f(CN3);
\begin{equation*}
\displaystyle 20
\end{equation*}
\begin{equation*}
\displaystyle 16.94310958
\end{equation*}
\begin{equation*}
\displaystyle 23.55848432
\end{equation*}
as well as the two endpoints.
> evalf( f(-1) ); evalf( f(5) );
\begin{equation*}
\displaystyle 9.899494934
\end{equation*}
\begin{equation*}
\displaystyle 3.922322703
\end{equation*}
Comparing these values, we see that
\(x=3.201521345\) gives an absolute maximum of
\(23.55848432\) and that
\(x=5\) gives an absolute minimum of
\(3.922322703\) on the interval
\([-1,5]\text{.}\)