\section{Maximum and Minimum Values}
In practical applications we are often interested in how large or small a function can become.  The following definitions make this concept precise.
\definition{
A function $f(x)$ has an \textbf{\absolute maximum} (or
  \textbf{\otherabsolute maximum}) at~$c$ if \mbox{$f(c)\ge f(x)$} for all $x$ in the
  domain $D$. The number $f(c)$ is called the \textbf{(\absolute) maximum value}
  of $f$ on~$D$.}

\definition{A function $f(x)$ has an \textbf{\absolute minimum} (or
  \textbf{\otherabsolute minimum}) at~$c$ if $f(c)\le f(x)$ for all $x$ in the
  domain $D$. The number $f(c)$ is called the \textbf{(\absolute) minimum value}
  of $f$ on~$D$.
}

\definition{
A function $f(x)$ has a \textbf{\relative maximum} (or
  \textbf{\otherrelative maximum}) at $c$ if $f(c)\ge f(x)$ over some open interval $(a,b)$ containing $c$.
The number $f(c)$ is called a \textbf{\relative{}} or \textbf{\otherrelative maximum} value of $f$.}
\definition{A function $f(x)$ has a \textbf{\relative minimum} (or
  \textbf{\otherrelative minimum}) at $c$ if $f(c)\le f(x)$ over some open interval $(a,b)$ containing $c$.
The number $f(c)$ is called a \textbf{\relative{}} or \textbf{\otherrelative minimum} value of $f$.
}

\begin{itemize}
\item \textbf{Note:} The \absolute maximum and \absolute minimum
values of $f$ are called the \textbf{extreme values} of $f$.  Similarly we define the \textbf{\relative{}} or \textbf{\otherrelative extreme values} to be the \relative maximum and minimum values.
\end{itemize}

\begin{example}
For the graphically defined function:
\begin{center}
\resizebox{5.5in}{!}{%
\includegraphics{graphics/derivative_applications1}%
}
\end{center}
Find the (\absolute) extreme values and \relative extreme values as well as their locations.\\[1em]
\rotatebox[origin=c]{180}{\parbox{\textwidth}{\small Answer: \Absolute maximum of $6$ at $x=5$, \Absolute minimum of $1$ at $x=2$ and $x=8$\\ \Relative maximum of $4$ at $x=0$ and of $6$ at $x=5$, \Relative minimum of $1$ at $x=2$\,.}
}
\end{example}

We note that a function need not have any extreme values, \absolute or \relative.  The function $y=x^3$ is such a function.
\begin{center}
\resizebox{4cm}{!}{%
\includegraphics{graphics/derivative_applications2}%
}
\end{center}

The following theorem gives sufficient conditions for absolute extrema to exist.
\theorem{Suppose $f$ is continuous on the closed interval $[a,b]$.  Then $f$ has an \absolute maximum and an \absolute minimum on $[a,b]$.  (i.e. There exist numbers $c$ and $d$ in $[a,b]$ such that $f(c)$ is the \absolute maximum and $f(d)$ is the \absolute minimum of $f$ on $[a,b]$.)  This is known as the \textbf{Extreme Value Theorem}.}

\begin{center}
\resizebox{15cm}{!}{%
\includegraphics{graphics/derivative_applications3}%
}
\end{center}

Note:
\begin{itemize}
\item The \absolute extreme values can occur at the endpoints of the interval.
\item The assumption that the interval be closed is required.
\item The locations of the \absolute extreme values are not necessarily unique.  (There could be two or more numbers, say, on the interval where the \absolute minimum is achieved.)
\end{itemize}

\theorem{If a function $f$ has a \relative extremum (maximum or minimum) at $c$ and if $f'(c)$ exists, then $f'(c)=0$.  This is known as \textbf{Fermat's Theorem}.}

\begin{center}
\resizebox{6.7cm}{!}{%
\includegraphics{graphics/derivative_applications4}%
}
\end{center}

Notes:
\begin{itemize}
\item The converse is not true: $f'(c)=0$ does not imply a \relative extremum occurs at $c$.  $f(x)=x^3$ has no \relative extrema yet $f'(0)=0$.
\item A \relative extremum can occur at a number where the derivative $f'$ does not exist.  So $f(x)=|x|$ has a \relative minimum at $x=0$ but $f'(0)$ does not exist as is clear from the following graph of the function.
\end{itemize}

\begin{center}
\includegraphics{graphics/derivative_applications5}%
\end{center}

\definition{If $c$ is a number in the domain $D$ of function $f$ such that the derivative vanishes ($f'(c)=0$) or does not exist, then $c$ is a \textbf{critical number} of $f$.}

\begin{example}

Find the critical numbers of the following functions.
\begin{enumerate}
\item $\displaystyle f(t) = t^3 + t^2 - 5t + 2$
\item $\displaystyle g(x) = x^2\sqrt[3]{x+1}$
\item $\displaystyle s(t) = \frac{t^3}{3t+2}$
\item $\displaystyle g(\theta) = \cos{2\theta} + 2\sin{\theta}$
\item $\displaystyle f(x) = (2x+1)\sqrt{x^2-4}$
\end{enumerate}

\begin{solution*}

\begin{enumerate}
\item $\begin{aligned}[t]
    f(t) &= t^3 + t^2 - 5t + 2\ \ \text{(a polynomial)}\ \implies D = (-\infty , \infty) \\
  f'(t) &= 3t^2 + 2t - 5 \\[-1em]
  f'(t) &= 0 \implies 3t^2 + 2t - 5 = 0
  \implies t = \frac{-2\pm \sqrt{4-4(3)(-5)}}{6} = \frac{-2\pm 8}{6}
  \implies \begin{cases}t&=1 \\ t&= -\frac{10}{6} = -\frac{5}{3} \end{cases}
\end{aligned}$\\
  Therefore the critical numbers are $t=1$ and $t= -\frac{5}{3}$\,.

\item $\begin{aligned}[t]
    g(x) &= x^2\sqrt[3]{x+1}\ \ \text{(odd integer root)}\
    \implies\ D = (-\infty, \infty) \\
    g'(x) &= 2x\sqrt[3]{x+1} + x^2\cdot \frac{1}{3}(x+1)^{-\frac{2}{3}} 
    = 2x\sqrt[3]{x+1} + \frac{x^2}{3(x+1)^{\frac{2}{3}}} \\
    &= 2x\sqrt[3]{x+1}\cdot\frac{3(x+1)^{\frac{2}{3}}}{3(x+1)^{\frac{2}{3}}} + \frac{x^2}{3(x+1)^{\frac{2}{3}}}
    = \frac{6x(x+1) + x^2}{3(x+1)^{\frac{2}{3}}} = \frac{7x^2 + 6x}{3(x+1)^{\frac{2}{3}}}\end{aligned}$\\
  $g'(x)$ is not defined when $x = -1$\,.\\
  $g'(x) = 0 \implies 7x^2 + 6x = 0 \implies x(7x+6) = 0 \implies \begin{cases}x = 0 \\ x = -\frac{6}{7} \end{cases}$\\[.5em]
  Therefore the critical numbers are $\displaystyle x=0 \, , \, x=-1 \, , \, \text{and}\, x = -\frac{6}{7}$\,.


\item $\begin{aligned}[t]
    s(t) &= \frac{t^3}{3t+2} \ \ \text{(a rational function)}\ 
    3t+2=0\implies t=-\frac{2}{3}\implies D = \mathset{R} - \{-\frac{2}{3}\} \\ 
    s'(t) &= \frac{3t^2(3t+2) - t^3(3)}{(3t+2)^2} = \frac{9t^3+6t^2-3t^3}{(3t+2)^2} = \frac{6t^3+6t^2}{(3t+2)^2}
  \end{aligned}$\\[.5em]
  $s'(t)$ is not defined when $t=-\frac{2}{3}$ but this is not in $D$ and hence not a critical number.\\
  $s'(t) =0 \implies 6t^3+6t^2=0 \implies 6t^2(t+1) = 0 \implies \begin{cases}t&=0 \\ t&=-1\end{cases}$\\
  Critical numbers:  $t=0 \, , \, t=-1$

\item $\begin{aligned}[t]
    g(\theta) &= \cos{2\theta} + 2\sin{\theta} \ \ \text{(trigonometric functions defined everywhere)}\implies D = \mathset{R} \\
    g'(\theta) &= -2\sin{2\theta} + 2\cos{\theta} \\
    g'(\theta) &= 0 \implies -2\sin{2\theta} + 2\cos{\theta} = 0 \implies -4\sin{\theta}\cos{\theta} + 2\cos{\theta} = 0\\
    &\implies 2\cos{\theta}(-2\sin{\theta} + 1) = 0 \\
    &\implies \begin{cases}~~~~~\cos{\theta} = 0 &\implies \theta = \frac{\pi}{2}+n\pi \\ -2\sin{\theta} + 1 = 0 &\implies \sin{\theta} = \frac{1}{2} \implies \begin{cases}\theta &= \frac{\pi}{6} + 2n\pi \\ \theta &= \frac{5\pi}{6} + 2n\pi \end{cases} \end{cases}\end{aligned}$\\
  \hspace*{2.5em}(See Appendix~\ref{ap:solvingtrigequations} on solving trigonometric equations.)\\[.5em]
  Critical numbers:\\
  $\left\{\frac{\pi}{2}+n\pi\, |\, n\ \text{an integer}\right\}\cup\left\{\frac{\pi}{6} + 2n\pi\,|\,n\ \text{an integer}\right\}\cup\left\{\frac{5\pi}{6} + 2n\pi\,|\,n\ \text{an integer}\right\}$
    
  \item $\begin{aligned}[t]
      f(x) &= (2x+1)\sqrt{x^2-4}\\
      x^2-4\ge0 &\implies (x-2)(x+2)\ge 0\implies \begin{cases} x-2 \ge 0 \ &\text{and}\ x+2\ge 0 \\ &~\text{or} \\ x-2 \le 0 \ & \text{and}\ x+2\le 0 \end{cases}\\
      &\implies \begin{cases} x\ge 2 \ &\text{and}\ x\ge -2 \\ &~\text{or} \\ x\le 2 \ & \text{and}\ x\le -2 \end{cases}
      \implies \begin{cases} x\ge 2 \\ ~~\text{or} \\ x\le -2 \end{cases} \implies D = (-\infty , -2] \cup [2, \infty) \end{aligned}$\\ %Added a break here to make new page possible.
    $\begin{aligned}[t]
      f'(x) &= 2\sqrt{x^2-4} + (2x+1)\frac{1}{2}(x^2-4)^{-\frac{1}{2}}(2x) = 2\sqrt{x^2-4} + \frac{x(2x+1)}{\sqrt{x^2-4}} \\
      &= \frac{2(x^2-4) + x(2x+1)}{\sqrt{x^2-4}} = \frac{4x^2+x-8}{\sqrt{x^2-4}}\end{aligned}$\\[.5em]
    $f'(x)$ is not defined when $x = 2$ or $x=-2$ (and these both are in the domain $D$)\,.\\[.5em]
    $\displaystyle f'(x) = 0 \implies 4x^2+x-8=0 \implies x = \frac{-1\pm \sqrt{1-(4)(4)(-8)}}{8} = \frac{-1\pm \sqrt{129}}{8}$\\
    Critical numbers: $\displaystyle x=2 \, , \, x = -2 \, , \, x = \frac{-1\pm\sqrt{129}}{8}$

\end{enumerate}

\end{solution*}


\begin{furtherquestions}
Find the critical numbers of the following functions:
\begin{enumerate}
\begin{multicols}{2}
\item $\displaystyle f(x)=x^3-2x^2$
\item $\displaystyle g(t)=t(t-2)^2$
\item $\displaystyle f(x)=\sqrt[3]{x}(4-x)$
\item $\displaystyle g(t)=\frac{t^2+5}{t-2}$
\item$\displaystyle f(\theta)=\cos(2\theta)+\theta$
\item$\displaystyle h(z)=\sqrt{z}\left(z^2+2\right)$
\item$\displaystyle g(t)=4\sin^3t+3\sqrt{2}\cos^2t$
\end{multicols}
\end{enumerate}
\end{furtherquestions}
\end{example}

The next theorem narrows down the values where \relative extrema can potentially occur.
\theorem{If $f$ has a \relative extremum (minimum or maximum) at $c$, then $c$ is a critical number of~$f$.}

Knowing that an \absolute extrema of a continuous function $f$ on
$[a,b]$ will either occur in $(a,b)$ at a \relative extrema or at an
endpoint, we can now construct a method to find the \absolute maximum
and minimum values of a continuous function $f$ on a closed interval
$[a,b]$.
\begin{method}
\textbf{Method for Finding \Absolute Extrema of continuous $\bm f$ on $\bm{[a,b]}$}
\begin{enumerate}
\item Find all critical numbers in $(a,b)$\,.
\item Evaluate $f$ at the critical numbers.
\item Evaluate $f(a)$ and $f(b)$\,.
\item The largest of the values from 2. and 3. is the \absolute maximum value and the smallest of these values is the \absolute minimum value.
\end{enumerate}
\end{method}

\begin{example}

Find the \absolute maximum and minimum of the following functions on the given closed interval.  Also indicate at what value(s) of $x$ they are located.

\begin{enumerate}
  \begin{multicols}{2}
\item $\displaystyle f(x) = 2-x^{\frac{5}{3}} \  \text{on} \  [-1,8]$
\item $\displaystyle g(t) = t^4 - 4t^2 + 1 \  \text{on} \  [-1,2]$
\item $\displaystyle f(\theta) = \sin{2\theta} + \cos{2\theta} \  \text{on} \  \left[0 , \frac{\pi}{2}\right]$
  \end{multicols}
\end{enumerate}

\textbook{\newpage}
\begin{solution*}
\begin{enumerate}
\item $\begin{aligned}[t]
    f(x) &= 2-x^{\frac{5}{3}} \, ; \, [-1,8] \\
    &\hspace{-2em}\text{Find critical number(s):}\\    
    f'(x) &= -\frac{5}{3}x^{\frac{2}{3}} \\
    f'(x)&=0 \implies -\frac{5}{3}x^{\frac{2}{3}} = 0 \implies x^{\frac{2}{3}} = 0 \implies x=0\ \text{(critical number)}\\
    &\hspace{-2em}\text{Evaluate function at critical numbers in $[-1,8]$ and interval endpoints:}\\    
    f(-1) &= 2 - (-1)^{\frac{5}{3}} = 2 - (-1)^5 = 2+1 = 3\\
    f(0) &= 2-0 = 2 \\
    f(8) &= 2-(8)^{\frac{5}{3}} = 2-(2)^5 = 2-32 = -30
  \end{aligned}$\\[.5em]
  \Absolute minimum is $-30$ located at $x=8$\,.\\
  \Absolute maximum is $3$ located at $x=-1$\,.\\
  Note a compact way to write this is to say the \absolute minimum is
  $f(8)=-30$ and the \absolute maximum is $f(-1)=3$\, thereby
  identifying the value of the absolute extrema and its location at
  the same time.

\item $\begin{aligned}[t]
    g(t) &= t^4 - 4t^2 + 1 \, ; \, [-1,2] \\
    g'(t) &= 4t^3-8t \\[-1em]
    g'(t) &= 0 \implies 4t^3-8t = 0 \implies 4t(t^2-2)=0 \implies \begin{cases}t&=0\\
      t&=\pm\sqrt{2}\end{cases} \\
    &\hspace{-2em}\text{Note that while}\ t=0,\ t=-\sqrt{2},\ \text{and}\ t=\sqrt{2}\ \text{are all critical numbers of}\ g(t),\\
    -\sqrt{2}&\approx-1.41\ \text{does not lie in}\ [-1,2]\ \text{and is not considered.}\\
    g(-1) &= (-1)^4 - 4(-1)^2 + 1 = 1-4+1=-2 \\
    g(0) &= 0-0+1 = 1 \\
    g\textstyle{\left(\sqrt{2}\right)} &= \textstyle{\left(\sqrt{2}\right)}^4 - 4\textstyle{\left(\sqrt{2}\right)}^2 + 1 = 4-8+1 = 5-8 = -3\\
    g(2) &= 2^4 - 4(2)^2 + 1 = 16-16+1 = 1
  \end{aligned}$\\[.5em]
  \Absolute minimum is $g\left(\sqrt{2}\right) = -3$\,. \\
  \Absolute maximum is $g(0)=g(2)=1$\,. (i.e. located at both $x=0$ and $x=2$)

\item $\begin{aligned}[t]
    f(\theta) &= \sin{2\theta} + \cos{2\theta} \, ; \, \left[0 , \frac{\pi}{2}\right] \\
    f'(\theta) &= 2\cos{2\theta} - 2\sin{2\theta} \\
    f'(\theta) &= 0 \implies 2\cos{2\theta} - 2\sin{2\theta} = 0 \implies \sin{2\theta} = \cos{2\theta} \implies \frac{\sin{2\theta}}{\cos{2\theta}}=\tan{2\theta} = 1\\
    & \implies 2\theta = \frac{\pi}{4}+2n\pi\ \text{or}\ 2\theta=\frac{5\pi}{4}+2n\pi\implies \theta = \frac{\pi}{8}+n\pi\ \text{or}\ \theta=\frac{5\pi}{8}+n\pi\\
    &\implies \theta = \frac{\pi}{8}\ \ (\text{only critical number in interval})\\
    &\hspace{.5em}(\text{See Appendix~\ref{ap:solvingtrigequations} on solving trigonometric equations.})\\[.5em]
    f(0) &= \sin{0} + \cos{0} = 0 +1 = 1 \\
    f(\textstyle{\frac{\pi}{8}}) &= \sin{\textstyle{\frac{\pi}{4}}} + \cos{\textstyle{\frac{\pi}{4}}} = \frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2} = \frac{2\sqrt{2}}{2}=\sqrt{2}\approx 1.41\\
    f(\textstyle{\frac{\pi}{2}}) &= \sin{\pi} + \cos{\pi} = 0 -1 = -1
  \end{aligned}$\\[.5em]
    \Absolute minimum is $f(\frac{\pi}{2}) = -1$ \\
    \Absolute maximum is $f(\frac{\pi}{8}) = \sqrt{2}$
\end{enumerate}
The student is encouraged is to plot the graphs of these functions using computer software or otherwise to confirm these results.
\end{solution*}

\begin{furtherquestions}
Find the \absolute maximum and minimum of the following functions on the given closed intervals:
\begin{enumerate}
\begin{multicols}{2}
\item $\displaystyle f(x)=4x^3-15x^2+12x+7$ on $[0,3]$
\item $\displaystyle f(x)=(x^2-4)^2$ on $[-3,1]$
\item $\displaystyle f(x)=1-x^{\frac{2}{3}}$ on $[-1,8]$
\end{multicols}
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/local-and-global-extreme-values}
\textbook{\vspace{-1em}}
\end{exercise}


\section[Mean Value Theorem]{The Mean Value and Other Derivative Theorems}

We now consider several theorems whose results are used in proving deeper calculus theorems.

\theorem{Let $f$ be a continuous function on $[a,b]$ that is differentiable on $(a,b)$.  If $f(a)=f(b)$ then there exists a number $c$ in $(a,b)$ such that $f'(c)=0$.  (i.e. The tangent line at the point $(c,f(c))$ is horizontal.)  This is known as \textbf{Rolle's Theorem}.}

The situation is illustrated below.
\begin{center}
\includegraphics{graphics/derivative_applications6}%
\end{center}

Notes:
\begin{itemize}
\item For the trivial case where $f(x)$ is a constant function we can take any $c$ in $(a,b)$ to prove the theorem.
\item The proof of the theorem for the non-trivial case hinges on the observation that if $f(a)=f(b)$ then at least one \absolute extremum (which exists by the Extreme Value Theorem) must occur at $c$ within $(a,b)$ and hence be a \emph{\relative} extremum which by Fermat's Theorem has $f'(c)=0$.
\item There may be more than one $c$ with $f'(c)=0$ as illustrated in the diagram.
\end{itemize}

\begin{example}
  Verify that Rolle's Theorem applies for $f(x)=x^3+x^2-2x+3$ on the
  interval $[-2,1]$.  Next find a value $c$ it predicts must exist.

\begin{solution}
  Rolle's Theorem requirements:
  \begin{itemize}
  \item $f(x)=x^3+x^2-2x+3$ is a polynomial and hence continuous on
    closed interval $[-2,1]$\,.
  \item $f'(x)=3x^2+2x-2$ so $f(x)$ is therefore differentiable on
    the open interval $(-2,1)$\,.
  \item $\begin{aligned}[t]
      f(-2)&=(-2)^3+(-2)^2-2(-2)+3=-8+4+4+3=3\ \text{and}\\
      f(1)&=(1)^3+2^2-2(1)+3=3\\
      &\implies f(-2)=f(1)
    \end{aligned}$
  \end{itemize}
  Then by Rolle's Theorem there exists a number $c$ in $(-2,1)$ such that
  $f'(c)=0$\,.  We can find $c$ by solving for it directly:\\
  $\begin{aligned}[t]
    0&=f'(c)=3c^2+2c-2\implies c=\frac{-2\pm\sqrt{(2)^2-4(3)(-2)}}{(2)(3)}=\frac{-2\pm\sqrt{28}}{6}=\frac{-2\pm\sqrt{4}\sqrt{7}}{6}\\
    c&=\frac{-1\pm\sqrt{7}}{3}=\begin{cases}\frac{-1+\sqrt{7}}{3}\approx0.55\\\frac{-1-\sqrt{7}}{3}\approx-1.22\end{cases}
  \end{aligned}$\\[.5em]
  Therefore $c=\frac{-1\pm\sqrt{7}}{3}$, both of which lie in
  $(-2,1)$, thereby confirming the prediction of Rolle's Theorem.
\end{solution}

\begin{furtherquestion}
Verify that Rolle's Theorem applies for $f(x)=x\sqrt{x+6}+1$ on the interval $[-6,0]$.  Next find a $c$ it predicts must exist.
\end{furtherquestion}
\end{example}

\begin{example}
  Show that the equation $1-x^3-2x=0$ has exactly one real root
  (solution) on $[-1,1]$\,.

\begin{solution}
  Defining $f(x)=1-x^3-2x$ we have that $f$ is continuous on $[-1,1]$
  and $f(-1)=1-(-1)+2=4$ and $f(1)=1-1-2=-2$.  Since $f$ changes sign
  on the interval it follows by the Intermediate Value Theorem that
  there exists at least one $c$ in $(-1,1)$ such that
  $0=f(c)=1-c^3-2c$.  Thus we have at least one solution $c$ on
  $(-1,1)$.

  To prove that there is \emph{exactly} one solution we can use
  \textbf{proof by contradiction}.  We will assume there is more than
  one solution and show this leads to a logical inconsistency.  If
  there are two or more solutions in $(-1,1)$ let $a$ and $b$ be any
  two such distinct solutions.  Then $f(a)=f(b)=0$.  But $f$ is
  continuous on $[a,b]$ and $f'(x)=-3x^2-2$ shows $f$ is
  differentiable on $(a,b)$.  Then by Rolle's Theorem there is a c in
  $(a,b)$ with $f'(c)=0$.  However $f'(x)=-(3x^2+2)$ is strictly less
  than zero as $3x^2\ge0$ and $2>0$.  This shows $f'(c)<0$, a
  contradiction.  Therefore our assumption of there being more than
  one solution in $(-1,1)$ led to a contradiction and hence there is
  exactly one solution in $(-1,1)$\,.  Since $f$ at the endpoints $-1$
  and $1$ is non-zero these $x$ values are not solutions so there is
  exactly one solution on $[-1,1]$\,.
\end{solution}

\begin{furtherquestion}
Show that the equation $1+2x+x^3+4x^5=0$ has exactly one real root (solution) on $[-1,0]$.
\end{furtherquestion}
\end{example}

Rolle's Theorem is used to prove the more general Mean Value Theorem to which we now turn.

%\textbook{\clearpage}
\theorem{Let $f$ be a continuous function on $[a,b]$ that is differentiable on $(a,b)$.  Then there exists a number $c$ in $(a,b)$ such that
\[f'(c)=\frac{f(b)-f(a)}{b-a}\ .\]
This is known as the \textbf{Mean Value Theorem}.}

Geometrically the Mean Value Theorem states that the slope of the secant line between the endpoints of the curve $A(a,f(a))$ and $B(b,f(b))$,
\[m=\frac{f(b)-f(a)}{b-a}\ ,\]
 is equal to the slope of the tangent line, $f'(c)$, at at least one point $C(c,f(c))$ along the curve (not an endpoint).

\begin{center}
\resizebox{7cm}{!}{%
\includegraphics{graphics/derivative_applications7}%
}
\end{center}

If we consider one dimensional motion then the Mean Value Theorem states that the average velocity for the trip over the time interval $[a,b]$ will equal the (instantaneous) velocity at at least one time $c$ in $(a,b)$ during the trip.

To prove the Mean Value Theorem one shows that the new function $g(x)$ defined to be the difference between $f(x)$ and the secant line between $(a,f(a))$ and $(b,f(b))$, i.e.
\[g(x)=f(x)-\left[\frac{f(b)-f(a)}{b-a}(x-a)+f(a)\right]\ ,\]
satisfies Rolle's Theorem.  The $c$ guaranteed for $g(x)$ by the latter can be shown to be the $c$ required for $f(x)$ for the Mean Value Theorem.  Also note that Rolle's Theorem itself follows immediately from the Mean Value Theorem for if $f(b)=f(a)$ then $f'(c)=0$ in the Mean Value Theorem.

\begin{example}
  Verify that Mean Value Theorem applies for
  $\displaystyle f(x)=\frac{x+3}{x+1}$ on the interval $[1,3]$.
  Next find a value~$c$ it predicts must exist.

\begin{solution}
Mean Value Theorem requirements:
\begin{itemize}
\item $f(x)=\frac{x+3}{x+1}$ is a rational function and hence
  continuous on its domain $D=\mathset{R}-\{-1\}$ and hence $f$ is
  continuous on the closed interval $[1,3]$\,.
\item $f'(x)=\frac{(1)(x+1)-(x+3)(1)}{(x+1)^2}=-\frac{2}{(x+1)^2}$ so
  $f$ is therefore differentiable on the open interval $(1,3)$\,.
\end{itemize}
Then\\
\hspace*{4em}$\begin{aligned}
    f(a)&=f(1)=\frac{1+3}{1+1}=\frac{4}{2}=2\\
    f(b)&=f(3)=\frac{3+3}{3+1}=\frac{6}{4}=\frac{3}{2}\\
  \end{aligned}$
    $\displaystyle\implies \frac{f(b)-f(a)}{b-a}=\frac{2-(3/2)}{3-1}=-\frac{1}{2}\cdot\frac{1}{2}=-\frac{1}{4}$\\[.5em]
    so by the Mean Value Theorem there exists a number $c$ in $(1,3)$ such that $f'(c)=-\frac{1}{4}$\,.
\textbook{\clearpage}
    We can find $c$ by solving for it directly:\\[.5em]
$\begin{aligned}[t]
  -\frac{1}{4}&=f'(c)=-\frac{2}{(c+1)^2}\implies (c+1)^2=8
  \implies c+1=\pm\sqrt{8}=\pm\sqrt{4}\sqrt{2}=\pm2\sqrt{2}\\
  &\implies c=\pm2\sqrt{2}-1
  =\begin{cases}~~2\sqrt{2}-1\approx1.83\\-2\sqrt{2}-1\approx-3.83\ (\text{reject})\end{cases}
\end{aligned}$\\[.5em]
Therefore $c=\sqrt{2}-1$ lies in $(1,3)$ with $f'(c)=-1/4$ thereby
confirming the MVT prediction.
\end{solution}

\begin{furtherquestions}
Verify that the Mean Value Theorem applies for the following functions on the given closed intervals and find a value of $c$ it predicts must exist.
\begin{enumerate}
\item $\displaystyle f(x)=2x^3+x^2-x-1$ on $[0,2]$
\item $\displaystyle f(x)=x-3x^{\frac{1}{3}}$ on $[0,8]$
\end{enumerate}
\end{furtherquestions}
\end{example}

Two corollaries of the Mean Value Theorem are the following:
\theorem{Suppose $f'(x)=0$ for all $x$ in $(a,b)$, then $f$ is constant on the interval.}
\theorem{\label{thm:mvtcorb}Suppose $f'(x)=g'(x)$ for all $x$ in $(a,b)$, then $f(x)=g(x)+C$ for some constant $C$.}

The former corollary results by applying the M.V.T. to the interval
$[x_1,x_2]$ generated by any two values $x_1$ and $x_2$ in $(a,b)$.
Since the resulting $c$ has $f'(c)=0$ by assumption, this implies
$f(x_2)-f(x_1)$ must vanish.  (i.e. $f(x_2)=f(x_1)$.) Since $x_1$ and
$x_2$ are arbitrarily chosen it follows that all values of $f(x)$ must
equal each other and hence some constant $C$.

The second corollary follows from the first by applying it to the
function $h(x)=f(x)-g(x)$ whose derivative $h'(x)=f'(x)-g'(x)$ will
identically vanish.  Graphically it means that if two functions have
the same derivative they differ at most by a vertical shift.

\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/rolles-theorem-and-the-mean-value-theorem}
\end{exercise}

\section{Increasing and Decreasing}

We now consider how the knowledge of the properties a function and its
derivatives can help us in understanding the behaviour of its graph,
in particular finding where the function is \emph{interesting}.  This
analysis will allow us to sketch a function with limited functional
evaluation being necessary.

We first consider what it means for a function to be increasing or
decreasing.  The following definitions make the intuitive idea of
increase and decrease clear:

\definition{A function $f(x)$ is \textbf{increasing} on an interval $I$ if its
  graph continuously rises as $x$ goes from left to right through the
  interval.  (i.e.  if $x_1$ and $x_2$ are in the interval
  and $x_1<x_2$, then $f(x_1)<f(x_2)$.)}
\definition{A function $f(x)$ is \textbf{decreasing} on an interval $I$ if its
  graph continuously falls as $x$ goes from left to right through the
  interval.  (i.e. if $x_1$ and $x_2$ are in the interval
  and $x_1<x_2$, then $f(x_1)>f(x_2)$ .)}

\begin{center}
\hfil
\raisebox{3.22cm}{%
\resizebox{5cm}{!}{%
\includegraphics{graphics/derivative_applications8}%
}%
}
\hfil
\resizebox{5cm}{!}{%
\includegraphics{graphics/derivative_applications9}%
}
\hfil
\end{center}

\begin{example}
From the diagrams, $y=x^2$ decreases on $(-\infty,0]$ and increases on $[0,\infty)$ while $y=x^3$ increases on the interval $(-\infty,\infty)$.
\end{example}

\textbook{\clearpage}
Where a differentiable function increases or decreases can be determined by the \textbf{first derivative} of a function since whether a function increases or decreases is related to its tangent slope.

\begin{center}
\includegraphics[width=4cm]{graphics/derivative_applications10}%
\end{center}

\begin{method}
\textbf{Test for Increasing/Decreasing}\footnotemark
\newline
Suppose $f$ is differentiable on $(a,b)$\,.
\begin{enumerate}
\item If $f'(x)>0$ for all $x$ in $(a,b)$\,, then $f$ is increasing on
  $(a,b)$\,.
\item If $f'(x)<0$ for all $x$ in $(a,b)$\,, then $f$ is decreasing on
  $(a,b)$\,.
\end{enumerate}
\end{method}
\footnotetext{To prove this result assume $f'>0$ on $(a,b)$ and let $x_1$ and $x_2$ be arbitrary points in $(a,b)$ with $x_1<x_2$.  Since $f$ is differentiable on $(a,b)$ it is continuous on $[x_1,x_2]$ and differentiable on $(x_1,x_2)$.  By the Mean Value Theorem there exists $c$ in $(x_1,x_2)$ with $f'(c)=[f(x_2)-f(x_1)]/(x_2-x_1)$.  But $c$ lies in $(a,b)$ so $f'(c)=[f(x_2)-f(x_1)]/(x_2-x_1)$ is positive.  Since $x_2-x_1>0$ it follows that $f(x_2)-f(x_1)>0$ or $f(x_2)>f(x_1)$.  Since $x_1$ and $x_2$ were arbitrarily chosen, $f$ is increasing on $(a,b)$.  A similar argument shows that if $f'<0$ on the interval the function is decreasing there.}

\begin{example}
One may verify for the above examples that $\frac{d}{dx}x^2=2x$ is negative when $x<0$ ($y=x^2$ decreasing on $(-\infty,0)$) and positive when $x>0$ ($y=x^2$ increasing on $(0,\infty)$).  On the other hand $\frac{d}{dx}x^3=3x^2$ is positive for $x\neq0$ so by the test $y=x^3$ is increasing on $(-\infty,0)\cup(0,\infty)$.  For an interval containing $x=0$ where the derivative is zero the function is increasing by using the definition and so $x^3$ is increasing on $(-\infty,\infty)$.
\end{example}

Critical numbers usually separate intervals of increase or decrease.\footnote{Though not always, consider $y=\tan^2x$ at $x=\pi/2$.}  Analysis of whether a function is increasing or decreasing on each side of a critical number allows us to determine whether a critical number is a relative extremum and if so, of which kind (maximum or minimum).

\begin{method}
\textbf{First Derivative Test for a \Relative Extremum}\newline
Let $I=(a,b)$ be an interval containing critical number $c$ of function $f$ and further let $f$ be continuous on $I$ and differentiable on $I$ (except perhaps at $c$).  Let $L=(a,c)$ and $R=(c,b)$ be the subintervals to the left and right of $c$\,.
\begin{enumerate}
\item If $f'$ is positive on $L$ and negative on $R$, then $f$ has
  a \relative maximum at $c$\,.
\item If $f'$ is negative on $L$ and positive on $R$, then $f$ has a
  \relative minimum at $c$\,.
\item If $f'$ has the same sign on $L$ and $R$ (either both positive or negative), then $f$ has no \relative extremum at $c$\,.
\end{enumerate}
\end{method}

\begin{example}
The function $y=x^2$ has a single critical number of $c=0$ where the derivative vanishes.  Since the function decreases to the left of $0$ and increases to the right of it, a relative minimum occurs at $x=0$ which is readily verified from the graph of the function.  $y=x^3$ also has a critical number of $c=0$ but in this case the function is increasing on the intervals to the left and right of it so there is no \relative extremum at $0$.
\end{example}

\begin{example}
  Find the open intervals upon which the following functions are
  increasing or decreasing. Also find any relative minima and maxima
  and their locations.
  \begin{enumerate}
  \item $\displaystyle g(t) = \frac{t^2 + t + 2}{t^2+3}$
  \item $\displaystyle f(x) = \sqrt{x}(2x-3)$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t] g(t) &= \frac{t^2 + t + 2}{t^2+3} \ , \ \ 
        t^2+3 > 0 \implies D = \mathset{R} \\
        g'(t) &= \frac{(2t+1)(t^2+3)-(t^2+t+2)(2t)}{(t^2+3)^2}
        = \frac{2t^3+6t+t^2+3-2t^3-2t^2-4t}{(t^2+3)^2}
        = \frac{-t^2+2t+3}{(t^2+3)^2} \\
        &= -\frac{t^2-2t-3}{(t^2+3)^2} = -\frac{(t-3)(t+1)}{(t^2+3)^2} \\
        g'(t) &= 0 \implies (t-3)(t+1)=0 \implies \begin{cases}t&=3 \\
          t&=-1 \end{cases}
      \end{aligned}$
      Due to the continuity of $g'$, the critical numbers $t=-1$ and
      $t=3$ partition the real axis into intervals over which the
      function either increases or decreases.  This may be determined
      by analyzing the sign of $g'$ on the intervals. (See
      Appendix~\ref{ap:inequalities}\,.)  \vspace{-1em}
      \begin{center}
        $\begin{array}{ccc} \\
           \text{Interval} & g'(t)=-\frac{(t-3)(t+1)}{(t^2+3)^2} & g\\[.5em]\toprule
           x<-1 & -\frac{(-)(-)}{(+)^2}=(-) & \text{decreasing}\\[.5em]
           -1<x<3 & -\frac{(-)(+)}{(+)^2}=(+) & \text{increasing}\\[.5em]
           3<x & -\frac{(-)(-)}{(+)^2}=(-) & \text{decreasing}\\ %\bottomrule
      \end{array}$
      \end{center}
      Therefore $g(t)$ is increasing on $(-1,3)$ and decreasing on
      $(-\infty, -1)\cup(3,\infty)$.\\
      Since one goes from decreasing to increasing at $x=-1$ and from
      increasing to decreasing at $x=3$ we have, by the First
      Derivative Test, that $x=-1$ is the location of a \relative
      minimum and $x=3$ is the location of a \relative maximum.
      \begin{align*}
        g(-1)&=\frac{(-1)^2+(-1)+2}{(-1)^2+3}=\frac{2}{4}=\frac{1}{2}\\
        g(3)&=\frac{3^2+3+2}{3^2+3}=\frac{14}{12}=\frac{7}{6}
      \end{align*}
      Thus $g(-1) = \frac{1}{2}$ is a relative
      minimum and $g(3) = \frac{7}{6}$ is a \relative maximum.

\textbook{\clearpage}
\item $\begin{aligned}[t] f(x) &= \sqrt{x}(2x-3) \ , \ x\ge0 \implies D = [0,\infty) \\
    f'(x) &= \frac{1}{2}x^{-\frac{1}{2}}(2x-3) + \sqrt{x}(2)
= \frac{1}{2\sqrt{x}}(2x-3) + 2\sqrt{x}\cdot\frac{2\sqrt{x}}{2\sqrt{x}}
= \frac{2x-3+4x}{2\sqrt{x}} = \frac{6x-3}{2\sqrt{x}} \\
 f'(x) &\text{ is not defined when } x=0\,. \\
 f'(x) &= 0 \implies 6x-3=0 \implies x = \frac{3}{6} \implies x=\frac{1}{2}
\end{aligned}$\\[.5em]
critical numbers partition the domain as follows:
      \vspace{-1em}
      \begin{center}
        $\begin{array}{ccc} \\
           \text{Interval} & f'(x)= \frac{6(x-\frac{1}{2})}{2\sqrt{x}} & f\\[.5em]\toprule
           0<x<\frac{1}{2} & \frac{(+)(-)}{(+)(+)}=(-) & \text{decreasing}\\[.5em]
           \frac{1}{2}<x<3 & \frac{(+)(+)}{(+)(+)}=(+) & \text{increasing}\\
      \end{array}$
      \end{center}

      Function $f$ is increasing on $(\frac{1}{2},\infty)$ and
      decreasing on $(0,\frac{1}{2})$\,.\\ The critical number $x=0$ is
      not contained within an open interval within $D$ and so is not a
      \relative extrema.  Since $f$ goes from decreasing to increasing
      at $x=1/2$ the First Derivative Test shows that value is the
      location of a \relative minimum.\\[.5em]      
      $f(\frac{1}{2})=\sqrt{(\frac{1}{2})}\left[2(\frac{1}{2})-3\right]
      =\frac{1}{\sqrt{2}}(-2)
      =-\frac{1}{\sqrt{2}}(\sqrt{2})^2=-\sqrt{2}$\\[.5em]
      Thus $f(\frac{1}{2}) = -\sqrt{2}$ is a \relative minimum.  There
      are no relative maxima.
\end{enumerate}
\end{solution*}

\begin{furtherquestion}
Find the open intervals upon which the function
\[f(x)=\frac{x^2-2x+1}{x}\]
is increasing or decreasing. Also find any relative minima and maxima
and their locations.
\end{furtherquestion}
\end{example}

Appendix~\ref{ap:inequalities} reviewing inequalities may be helpful in determining when $f'$ is positive and negative.

\textbook{\clearpage}
\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/first-derivative-test}
\end{exercise}

\section{Concavity}

Like increasing and decreasing, concavity is a property of intervals on a graph.

\definition{The graph of function $f(x)$ is \textbf{concave upward} on $(a,b)$ if $f'$ is an increasing function on $(a,b)$\,.  Graphically, the curve $y=f(x)$ lies above all its tangent lines on $(a,b)$\,.}

\definition{The graph of function $f(x)$ is \textbf{concave downward} on $(a,b)$ if $f'$ is a decreasing function on $(a,b)$\,.  Graphically the curve $y=f(x)$ lies below all its tangent lines on $(a,b)$\,.}

\begin{center}
\includegraphics{graphics/derivative_applications11}%
\end{center}

\begin{example}
For $y=x^3$ the graph is concave upward on $(0,\infty)$ because the curve lies above the tangent lines at any point on the interval.  Alternatively one sees that as we move from left to right on the interval the tangent slopes are increasing.  Similarly $y=x^3$ is concave down on $(-\infty,0)$ as the curve lies below the tangent line at any point in the interval.  Alternatively the tangent slopes are decreasing as one moves from left to right through the interval.
\end{example}

An easy way to remember concavity is to note that if the interval looks like part of the mouth of a happy face, {\Large\smiley}, then it is concave upward.  If it is part of the mouth of a sad face, {\Large\frownie}, then it is concave downward.

\textbook{\clearpage}
Since the second derivative $f''(x)$ tells us whether the derivative (and hence tangent slope) is increasing or decreasing we can determine the concavity on an interval using it as follows.

\begin{method}
\textbf{Test for Determining Concavity}\newline
Suppose function $f$ is twice differentiable on an interval $(a,b)$\,.
\begin{enumerate}
\item If $f''(x)>0$ for all $x$ in $(a,b)$, then the graph of $f$ is concave
  upward on $(a,b)$\,.
\item If $f''(x)<0$ for all $x$ in $(a,b)$, then the graph of $f$ is concave
  downward on $(a,b)$\,.
\end{enumerate}
\end{method}

To remember this note that $f''$ is positive when the function is concave upward (\raisebox{-.2em}{\Large\smiley}) and negative when the function is concave downward (\raisebox{-.2em}{\Large\frownie}). 

\begin{example}
For $y=f(x)=x^3$ we have $f''(x)=6x$ which is positive for $x>0$ and negative for $x<0$ which indicates the curve is concave upward and concave downward on those intervals as was already observed.
\end{example}

Just as intervals of increasing and decreasing are often punctuated by locations of \relative maxima and minima, regions of concavity for a graph are often broken up by inflection points:

\definition{An \textbf{inflection point} is a point $P$ on the graph of a
  function at which the function is continuous and the graph changes
  from concave upward to concave downward or vice versa.}

Due to the concavity test, possible inflection points are located at
numbers $c$ in the domain of $f$ where $f''(c)=0$ or $f''(c)$ does not
exist.

Note that an inflection point is a point $P$ and is therefore reported as $(c,f(c))$.

\begin{example}
For our function $y=x^3$ the point $(0,0)$ is an inflection point as the function is continuous there and the concavity changes.
\end{example}

\begin{example}
For the following graphically defined function find intervals where the function is increasing, decreasing, concave upward, and downward.  Identify any inflection points.

\begin{center}
\resizebox{3in}{!}{%
\includegraphics{graphics/derivative_applications12}%
}
\rotatebox[origin=t]{180}{\parbox{21em}{\small Answer: Increasing: $(-\infty,0)\cup(2,5)$\\
    Decreasing: $(0,2)\cup(5,8)$\\ CC Upward: $(-\infty,-2)\cup(1,3.5)\cup(6.5,8)$\\
    CC Downward: $(-2,1)\cup(3.5,6.5)$\\
    Inf. Points: $(-2,3)$, $(1,2.5)$, $(3.5,3.5)$, $(6.5,3.5)$}}

\end{center}
\end{example}

\begin{example}
  Find the open intervals upon which the function
  $\displaystyle f(x) = x^3 - 12x^2$ is concave upward or concave
  downward.  Also find any inflection points.
  
  \begin{solution}
    $\begin{aligned}[t] f(x) &= x^3 - 12x^2 \, , \,
      f\ \text{a polynomial}\ \implies D = (-\infty , \infty) \\
      f'(x) &= 3x^2 - 24x \\
      f''(x)&=6x-24=6(x-4) \\
      f''(x) &= 0 \implies 6(x-4) = 0 \implies x= 4
    \end{aligned}$\\[.5em]
    Since $f''(x)$ is continuous, the value $x=4$ partitions the real
    axis into intervals that are either concave upward or downward.
    The concavity may be determined by analyzing the sign of $f''(x)$\,:
    \vspace{-1em}
    \begin{center}
      $\begin{array}{ccc} \\
         \text{Interval} & f''(x)=6(x-4) & f\\[.5em]\toprule
         x<4 & (+)(-)=(-) & \text{concave downward}\\[.5em]
         4<x & (+)(+)=(+) & \text{concave upward}
       \end{array}$
     \end{center}
     Therefore $f(x)$ is concave downward on $(-\infty, 4)$ and
     $f(x)$ is concave upward on $(4,\infty)$\,.  Since concavity
     changes sign at $x=4$, and that value lies in the domain of $f$,
     we have that
     $x=4$ is the $x$-component of an inflection point.\\[.5em]
     $y=f(x)=4^3-12(4)^2=-128$\\[.5em]
     Thus $(4,-128)$ is an inflection point of function $f$.
   \end{solution}

   \begin{furtherquestion}
     Find the open intervals upon which the function
     $\displaystyle f(x) = x^4 - x^3$ is concave upward or concave
     downward.  Also find any inflection points.
\end{furtherquestion}
\end{example}

\begin{example}
   \label{exam:incdeccc}
  Find the intercepts, maxima and minima, intervals of increase and
  decrease, intervals of concave upward and downward, and inflection
  points of the following functions. Then sketch their graphs.
  \begin{enumerate}
  \item $f(x) = 3x^5 - 10x^3$
  \item $f(x) = x - 2\sin{x}\ \text{on}\ [0,2\pi]$
  \end{enumerate}
  
  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t] f(x) &= 3x^5 - 10x^3= x^3(3x^2-10)\\
        & f\ \text{a polynomial}\ \implies D=\mathset{R}\\
        & y\text{-intercept: }f(0) =0-0=0 \implies y=0\\[-1em]
        & x\text{-intercept(s): }f(x)= 0 \implies x^3(3x^2-10)=0
        \implies \begin{cases}
          x&=0\\
          x&=\pm\sqrt{\frac{10}{3}}
        \end{cases} \\
        f'(x) &= 15x^4 - 30x^2=15x^2(x^2-2)\\[-1em]
        &\text{critical numbers: } f'(x) = 0 \implies 15x^2(x^2-2) = 0
        \implies \begin{cases}
          x&=0 \\
          x&=\pm\sqrt{2}
        \end{cases} \\
        f''(x) &= 60x^3 - 60x = 60x(x^2-1)\\[-1em]
        &\text{potential concavity change: }
        f''(x) = 0 \implies 60x(x^2-1)=0
        \implies \begin{cases}
          x&=0 \\
          x&=\pm 1
        \end{cases}
      \end{aligned}$\\
      To analyze the intervals of increase/decrease and
      concavity we can partition the real axis by the critical numbers
      and the values where $f''(x)=0$.  Since both the first and
      second derivatives are continuous, each such sub-interval will
      either increase or decrease and be either concave upward or
      downward.
      \vspace{-1em}
      \begin{center}
        $\begin{array}{cccl} \\
        & f'(x)= & f''(x)= & \\
           \text{Interval} & 15x^2[x-(-\sqrt{2})](x-\sqrt{2}) & 60x[x-(-1)](x-1)& \hspace{3em}f\\[.5em]\toprule
           x<-\sqrt{2} & (+)(-)^2(-)(-)=(+) & (+)(-)(-)(-)=(-) & \text{inc, concave down}\\[.5em]
           -\sqrt{2}<x<-1 & (+)(-)^2(+)(-)=(-) & (+)(-)(-)(-)=(-) & \text{dec, concave down}\\[.5em]
           -1<x<0 & (+)(-)^2(+)(-)=(-) & (+)(-)(+)(-)=(+) & \text{dec, concave up}\\[.5em]
           0<x<1 & (+)(+)^2(+)(-)=(-) & (+)(+)(+)(-)=(-) & \text{dec, concave down}\\[.5em]
           1<x<\sqrt{2} & (+)(+)^2(+)(-)=(-) & (+)(+)(+)(+)=(+) & \text{dec, concave up}\\[.5em]
           \sqrt{2}<x & (+)(+)^2(+)(+)=(+) & (+)(+)(+)(+)=(+) & \text{inc, concave up}\\[.5em]
         \end{array}$
      \end{center}
      Evaluate $f$ at useful $x$ values:\\[.5em]
      $\begin{aligned}[t]
        f\textstyle{\left(-\sqrt{2}\right)}&=3\textstyle{\left(-\sqrt{2}\right)}^5-10\textstyle{\left(-\sqrt{2}\right)}^3=-12\sqrt{2}+20\sqrt{2}=8\sqrt{2}\\
        f(-1)&=3(-1)^5-10(-1)^3=-3+10=7\\
        f(1)&=3(1)^5-10(1)^3=3-10=-7\\
        f\textstyle{\left(\sqrt{2}\right)}&=3\textstyle{\left(\sqrt{2}\right)}^5-10\textstyle{\left(\sqrt{2}\right)}^3=12\sqrt{2}-20\sqrt{2}=-8\sqrt{2}
      \end{aligned}$\\[.5em]
      \plainoverlay at (10cm,3.1cm) {\includegraphics[width=5.5cm]{graphics/derivative_applications16}};
      
      \parbox{.6\textwidth}{The function $f$ is increasing on
      $(-\infty,-\sqrt{2})\cup(\sqrt{2},\infty)$ and decreasing on
      $(-\sqrt{2},\sqrt{2})$\,. Analysis of critical numbers
      using the First Derivative Test shows:}
      \begin{itemize}
      \item $f\textstyle{\left(-\sqrt{2}\right)}=8\sqrt{2}$ is a \relative maximum.
      \item $f\textstyle{\left(\sqrt{2}\right)}=-8\sqrt{2}$ is a \relative minimum.
      \end{itemize}
      
      The function $f$ is concave upward on $(-1,0)\cup(1,\infty)$ and
      concave downward on $(-\infty,-1)\cup(0,1)$\,.  Analysis of
      locations where $f''(x)=0$ shows that points $(-1,7)$, $(0,0)$,
      and $(1,-7)$ are all inflection points.
      
      Plotting intercepts, relative extrema, inflection points and then
      connecting these dots using the information on
      increasing/decreasing and concavity makes a sketch of the graph
      straightforward.
      
    \item $\begin{aligned}[t]
        f(x) &= x-2\sin x \ \text{on}\ [0,2\pi] \\ 
        & f\ \text{a polynomial}(D=\mathset{R})+\text{sine}(D=\mathset{R})\
        \implies\ f\ \text{defined on entire interval}\implies D=[0,2\pi]\\
        & y\text{-intercept: }f(0) =0-2\sin{0}=0-0=0 \implies y=0\\[0em]
        & x\text{-intercept(s): }f(x)= 0 \implies x-2\sin x=0
        \implies \begin{cases}
          x=0\ (\text{by inspection})\\
          x=1.895494267\approx 1.9
        \end{cases} \\
        &(\text{The second solution must be found numerically,
          for example, by the Bisection Method.}\\
        &\text{~A root exists by the Intermediate Value Theorem as
          $f(0.1)\approx-0.1<0$ and $f(2\pi)=2\pi>0$\,.})\\
        f'(x) &= 1-2\cos x\\
        &\text{critical numbers: }
        f'(x) = 0 \implies 1 - 2\cos x = 0
        \implies\cos x = \frac{1}{2} \implies x = \frac{\pi}{3}+2n\pi\ \text{or}\ x = \frac{5\pi}{3} +2n\pi \\
        &\hspace{10.7em}\implies x = \frac{\pi}{3}\ \text{or}\ x = \frac{5\pi}{3} \ \text{in } [0,2\pi]\\[-.5em]
        f''(x) &= 2\sin x \\
        &\text{potential concavity change: }f''(x) = 0 \implies \sin x = 0 \implies x=n\pi\\
        &\hspace{16.7em}\implies x=0\ \text{or}\ x = \pi\ \text{or}\ x = 2\pi\
        \text{in}\ [0,2\pi]
      \end{aligned}$ To evaluate the sign of $f'$ and $f''$ it is of
      value to use test points in the intervals.  (See
      Appendix~\ref{ap:inequalities}.)  One can choose arbitrary values
        in the interval and use a calculator or judiciously choose
        angles when possible for which the trigonometric values may be derived.
        \vspace{-1em}
      \begin{center}
        $\begin{array}{ccccl} \\
        & & f'(x)= & f''(x)= & \\
           \text{Interval} & \text{Test Value} & 1-2\cos x& 2\sin x& \hspace{6em}f\\[.5em]\toprule
           0<x<\frac{\pi}{3} & \frac{\pi}{4} & 1-\sqrt{2}=(-) & \sqrt{2}=(+) & \text{decreasing, concave upward}\\[.5em]
           \frac{\pi}{3}<x<\pi & \frac{\pi}{2} & 1=(+) & 2=(+) & \text{increasing, concave upward}\\[.5em]
           \pi<x<\frac{5\pi}{3} & \frac{5\pi}{4} & 1+\sqrt{2}=(+) & -\sqrt{2}=(-) & \text{increasing, concave downward}\\[.5em]
           \frac{5\pi}{3}<x<2\pi & 6  & \approx-.92=(-) & \approx-.56=(-) & \text{decreasing, concave downward}
         \end{array}$
      \end{center}
      Evaluate $f$ at useful $x$ values:\\[.5em]
      $\begin{aligned}[t]
        f\left(\frac{\pi}{3}\right)
        &=\frac{\pi}{3}-2\sin\!\left(\frac{\pi}{3}\right)
        =\frac{\pi}{3}-2\left(\frac{\sqrt{3}}{2}\right)=\frac{\pi}{3}-\sqrt{3}\\
        f(\pi)&=\pi-2\sin\pi=\pi+0=\pi\\
        f\left(\frac{5\pi}{3}\right)
        &=\frac{5\pi}{3}-2\sin\!\left(\frac{5\pi}{3}\right)
        =\frac{5\pi}{3}+2\sin\!\left(\frac{\pi}{3}\right)=\frac{5\pi}{3}+\sqrt{3}
      \end{aligned}$\\[.5em]
      \plainoverlay at (9.5cm,3.3cm) {\includegraphics[width=4.8cm]{graphics/derivative_applications17}};
      
      \parbox{.6\textwidth}{The function $f$ is increasing on
      $(\pi/3,5\pi/3)$ and decreasing on
      $(0,\pi/3)\cup(5\pi/3,2\pi)$\,. Analysis of critical numbers
      using the First Derivative Test shows:}
      \begin{itemize}
      \item $f\left(\frac{\pi}{3}\right)=\frac{\pi}{3}-\sqrt{3}$ is a
        \relative minimum.
      \item $f\left(\frac{5\pi}{3}\right)=\frac{5\pi}{3}+\sqrt{3}$ is
        a \relative maximum.
      \end{itemize}
      
      The function $f$ is concave upward on $(0,\pi)$ and concave
      downward on $(\pi,2\pi)$\,.  Analysis of locations where
      $f''(x)=0$ shows that the point $(\pi,\pi)$ is an inflection
      point. A sketch is shown.  Values involving $\pi$ and $\sqrt{3}$
      need to be evaluated or estimated to get the relative point positions
      correct in the sketch.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Find the intercepts, \relative maxima and minima, intervals of increase and decrease, intervals of concave upward and downward, and inflection points of the following functions.  Then sketch their graphs.
\begin{enumerate}
\item $\displaystyle f(x)=x^4-6x^2$
\item $\displaystyle f(x)=x-3x^{\frac{1}{3}}$
\item $\displaystyle f(x)=y=3\sin x-\sin^3x$ on $[0,2\pi]$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{example}
  Sketch the graph of a continuous function on $\mathset{R}$
  satisfying all of the following:
  \begin{itemize}
    \begin{multicols}{2}
  \item $f(0)=1$
  \item $f'(2)=f'(5)=0$
  \item $f'(x)>0$ if $0<x<2$ or $x>5$
  \item $f'(x)<0$ if $2<x<5$
  \item $f''(x)>0$ if $0<x<1$ or $x>4$
  \item $f''(x)<0$ if $1<x<4$
  \item $f(-x)=f(x)$
    \end{multicols}
  \end{itemize}
  
  \begin{solution}
    We see that $x=2$ and $x=5$ are critical numbers.  Summarizing the
    information for $f'$ and $f''$ on a table gives:
    \vspace{-2em}
    \begin{center}
      $\begin{array}{cccl} \\
         \text{Interval} & f'(x) & f''(x) & \hspace{3em}f\\[.5em]\toprule
         0<x<1 & (+) & (+)  & \text{increasing, concave up}\\[.5em]
         1<x<2 & (+) & (-)  & \text{increasing, concave down}\\[.5em]
         2<x<4 & (-) & (-)  & \text{decreasing, concave down}\\[.5em]
         4<x<5 & (-) & (+)  & \text{decreasing, concave up}\\[.5em]
         5<x & (+) & (+) & \text{increasing, concave up}\\[.5em]
       \end{array}$
     \end{center}
     \vspace{-1em}
     By the First Derivative Test, $x=2$ will be the location of a
     \relative maximum and $x=5$ will be the location of a \relative
     minimum.  Since $f$ is continuous, $x=1$ and $x=4$ will be the
     $x$-coordinates of points of inflection.  Since $f(0)=1$, we have
     a $y$-intercept of $y=1$.  Start there and sketch to the right on
     the graph using the above information.  For the graph for $x<0$
     note that $f(-x)=f(x)$ implies that $f$ is an even function.  As
     such once the function is drawn for $x\ge0$ this only needs to be
     reflected across the $y$-axis to generate the graph of $f$ for
     $x<0$\,.  One possible graph that meets all of these criteria is
     as follows:
     \vspace{-1em}
     \begin{center}
       \includegraphics[width=6cm]{graphics/derivative_applications23}
     \end{center}
  \end{solution}

\begin{furtherquestion}
Sketch the graph of a function satisfying all of the following:
\begin{itemize}
\begin{multicols}{2}
\item $f(0)=0$
\item $f'(1)=f'(3)=f'(5)=0$
\item $f'(x)>0$ if $0<x<1$ or $3<x<5$
\item $f'(x)<0$ if $1<x<3$ or $x>5$
\item $f''(x)>0$ if $2<x<4$
\item $f''(x)<0$ if $0<x<2$ or $x>4$
\item $f(-x)=-f(x)$
\end{multicols}
\end{itemize}
\end{furtherquestion}
\end{example}

The second derivative can also be used to evaluate whether critical numbers are the locations of relative extrema and, if so, whether they are maxima or minima:

\begin{method}
\textbf{Second Derivative Test for a \Relative Extremum}\newline
Suppose $f''$ is continuous on an open interval that contains $c$ and
that $f'(c)=0$.
\begin{enumerate}
\item If $f''(c)<0$, then $f$ has a \relative maximum at $c$ .
\item If $f''(c)>0$, then $f$ has a \relative minimum at $c$ .
\item If $f''(c)=0$, then the test is inconclusive.
\end{enumerate}
\end{method}

This result follows from the fact that a negative second derivative at
$c$ means the graph of the function is concave downward
(\raisebox{-.2em}{\Large\frownie}) at that value (and hence will have
a relative maximum), while a positive second derivative means the
graph of the function is concave upward
(\raisebox{-.2em}{\Large\smiley}) at that value (and hence will have a
relative minimum).

\begin{example}
\begin{itemize}
\item $y=x^2$ has $f'(0)=0$ and $f''(0)=2$.  Since $f''(0)$ is greater than zero the function is concave upward at $x=0$ and hence has a relative minimum at that critical number.
\item $y=x^3$ has $f'(0)=0$.  However $f''(0)=0$ as well so the Second Derivative Test is inconclusive.  We need to use a different test (First Derivative Test) to determine that no extrema occurs at~0.
\item $y=x^4$ has $f'(0)=0$ and $f''(0)=0$ so the Second Derivative Test is also inconclusive here. However in this case the First Derivative Test confirms a \relative minimum occurs at 0.
\end{itemize}
\end{example}

\begin{example}
  Find the relative maxima and minima (and their locations) of the
  questions in Example~\ref{exam:incdeccc}\,:
  \begin{enumerate}
  \item $f(x) = 3x^5 - 10x^3$
  \item $f(x) = x - 2\sin{x}\ \text{on}\ [0,2\pi]$
  \end{enumerate}
  Use the Second Derivative Test where possible.

  \begin{solution*}
    \begin{enumerate}
    \item From Example~\ref{exam:incdeccc} we found:\\[.5em]
      $\begin{aligned}[t] f(x) &= 3x^5 - 10x^3= x^3(3x^2-10)\\
        f'(x) &= 15x^4 - 30x^2=15x^2(x^2-2)\implies \text{critical numbers: } x=0,\ \pm\sqrt{2}\\
        f''(x) &= 60x^3 - 60x = 60x(x^2-1)
      \end{aligned}$\\[.5em]
      Evaluating the second derivative at the critical numbers yields:\\[.5em]
      $\begin{aligned}[t]
        f''\textstyle{\left(-\sqrt{2}\right)}&=60\textstyle{\left(-\sqrt{2}\right)}\left[\textstyle{\left(-\sqrt{2}\right)}^2-1\right]=-60\sqrt{2}<0\ \ \ {\Large\frownie} \\
        &\implies x=-\sqrt{2}\ \text{is the location of a \relative maximum.}
      \end{aligned}$
      \textbook{\clearpage}
      $\begin{aligned}
        f''(0)&=60(0)\left[(0)^2-1\right]=0\\
        &\implies \text{Second Derivative Test is inconclusive.}\\
        &\implies \text{Apply First Derivative Test as before to conclude no extrema at $x=0$\,.}\\
        f''\textstyle{\left(\sqrt{2}\right)}&=60\textstyle{\left(\sqrt{2}\right)}\left[\textstyle{\left(\sqrt{2}\right)}^2-1\right]=60\sqrt{2}>0\ \ \ {\Large\smiley} \\
        &\implies x=\sqrt{2}\ \text{is the location of a \relative minimum.}
      \end{aligned}$

      As before evaluate $f$ at these locations to conclude
      $f\textstyle{\left(-\sqrt{2}\right)}=8\sqrt{2}$ is a \relative
      maximum and $f\textstyle{\left(\sqrt{2}\right)}=-8\sqrt{2}$ is a
      \relative minimum.


    \item From Example~\ref{exam:incdeccc} we found:\\[.5em]
    $\begin{aligned}[t]
        f(x) &= x-2\sin x \ \text{on}\ [0,2\pi] \\ 
        f'(x) &= 1-2\cos x \implies \text{critical numbers: }
        x = \frac{\pi}{3}\ \text{or}\ x = \frac{5\pi}{3}\\
        f''(x) &= 2\sin x
      \end{aligned}$\\[.5em]
      Evaluating the second derivative at the critical numbers yields:\\[.5em]
      $\begin{aligned}[t]
        f''\textstyle{\left(\frac{\pi}{3}\right)}&=2\sin\!\textstyle{\left(\frac{\pi}{3}\right)}=2\textstyle{\left(\frac{\sqrt{3}}{2}\right)}=\sqrt{3}>0\ \ \ {\Large\smiley} \\
        &\implies x=\frac{\pi}{3}\ \text{is the location of a \relative minimum.}\\
        f''\textstyle{\left(\frac{5\pi}{3}\right)}&=2\sin\!\textstyle{\left(\frac{5\pi}{3}\right)}=-2\sin\!\textstyle{\left(\frac{\pi}{3}\right)}=
-2\textstyle{\left(\frac{\sqrt{3}}{2}\right)}=-\sqrt{3}<0\ \ \ {\Large\frownie} \\
        &\implies x=\frac{5\pi}{3}\ \text{is the location of a \relative maximum.}
      \end{aligned}$

      As before evaluate $f$ at these locations to conclude
      $f\left(\frac{\pi}{3}\right)=\frac{\pi}{3}-\sqrt{3}$ is a \relative
      minimum and $f\left(\frac{5\pi}{3}\right)=\frac{5\pi}{3}+\sqrt{3}$ is a
      \relative maximum.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Find the \relative maxima and minima (and their locations) of
\begin{enumerate}
\item $\displaystyle f(x)=x^3-2x^2+x$
\item $\displaystyle B(x)=3x^{\frac{2}{3}}-x$
\end{enumerate}
Use the Second Derivative Test where possible.
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/inflection-points}
% The next set of problems has some negative \vspace
\input{DERIVATIVE_APPLICATIONS/second-derivative-test}
% The next set of problems has some negative \vspace
\input{DERIVATIVE_APPLICATIONS/curve-sketching-I} 

\end{exercise}


\section{Limits at Infinity and Horizontal Asymptotes}
We have seen how $y$-values of $y=f(x)$ may approach infinity at a vertical asymptote.  We now consider the behaviour of a function as $x$ approaches infinity.

\begin{center}
\includegraphics{graphics/derivative_applications13}%
\end{center}

\definition{If the values of $f(x)$ can be made arbitrarily close to the value $L$ as $x$ is made sufficiently large then we write:\footnote{A rigorous definition of this limit can be made as follows.  Suppose function $f$ is defined on some interval $(a,\infty)$. Then $\displaystyle \mylim{x}{\infty}f(x)=L$ if and only if for any $\epsilon>0$ there exists $c\in(a,\infty)$ such that $|f(x)-L|<\epsilon$ whenever $x>c$\,.  A similar definition $\mylim{x}{-\infty}f(x)=L$ may also be formulated.}
\[\mylim{x}{\infty}f(x)=L~.\]
}

\definition{If the values of $f(x)$ can be made arbitrarily close to the value $L$ as $x$ is made sufficiently large negatively then we write:
\[\mylim{x}{-\infty}f(x)=L~.\]}

\begin{example}
For the above graphically defined example one has:
\[\mylim{x}{\infty}f(x)=-1\]
and
\[\mylim{x}{-\infty}f(x)=3\]
\end{example}

\textbook{\clearpage}
The following theorem, in conjunction with our other limit theorems, allows us to evaluate many limits as $x\rightarrow\infty$ or $-\infty$.

\theorem{Let $r>0$ be a rational number.  Then
\begin{itemize}
\item $\displaystyle \mylim{x}{\infty}\frac{1}{x^r}=0$
\item $\displaystyle \mylim{x}{-\infty}\frac{1}{x^r}=0$
\end{itemize}
In the second case ($x\rightarrow-\infty$), $r$ must be such that
$x^r$ is defined.\footnote{We note in passing that the theorem is also valid for $0<r<1$, not just $r\ge1$. So, for instance, $\displaystyle\lim_{x\to\infty}\frac{1}{x^{1/2}}=\lim_{x\to\infty}\frac{1}{\sqrt{x}}=0$ despite the fact that for large $x$, $\sqrt{x}<x$.  The point is that $\sqrt{x}$ increases without bound as $x$ does so the limit vanishes.}}

When one tries to evaluate limits where the magnitude of $x$
approaches infinity, direct substitution of ``$x=\infty$'' may lead to
the indeterminate form $\displaystyle\frac{\infty}{\infty}$. As a
general strategy one divides the numerator and denominator in an
expression by the highest power term found in either to evaluate the limit.

\begin{example}
  Evaluate the given limits.
  \begin{enumerate}
    \begin{multicols}{2}
    \item $\displaystyle \lim_{x\to\infty}\frac{2x^3+4x-1}{3x^3-5x^2+2}$
    \item $\displaystyle \lim_{x\to\infty}\frac{4x^3+5}{x^2+1}$
    \item $\displaystyle \lim_{x\to\infty}\frac{5x^4+3x+2}{6x^5+2x^3+1}$
    \item $\displaystyle \lim_{x\to -\infty}\left(\sqrt{x^2+3x}+x\right)$
    \end{multicols}
  \end{enumerate}

\begin{solution*}
  \begin{enumerate}
  \item $\displaystyle \lim_{x\to\infty}\frac{2x^3+4x-1}{3x^3-5x^2+2}
    =\lim_{x\to\infty}\frac{x^2\left(2+\frac{4}{x^2}-\frac{1}{x^3}\right)}{x^2\left(3-\frac{5}{x}+\frac{2}{x^3}\right)}
    =\lim_{x\to\infty}\frac{x^2}{x^2}\cdot\frac{2+\frac{4}{x^2}-\frac{1}{x^3}}{3-\frac{5}{x}+\frac{2}{x^3}}
    =\lim_{x\to\infty}1\cdot\frac{2+0-0}{3-0+0}
    = \frac{2}{3}$
    \item $\displaystyle \lim_{x\to\infty}\frac{4x^3+5}{x^2+1}
      =\lim_{x\to\infty}\frac{x^3}{x^2}\cdot\frac{4+\frac{5}{x^3}}{1+\frac{1}{x^2}}
      =\lim_{x\to\infty}x\cdot\frac{4+\frac{5}{x^3}}{1+\frac{1}{x^2}}
      =(+\infty)\frac{4+0}{1+0}= \infty$
    \item $\displaystyle \lim_{x\to\infty}\frac{5x^4+3x+2}{6x^5+2x^3+1}
      =\lim_{x\to\infty}\frac{x^4}{x^5}\cdot\frac{5 + \frac{3}{x^3}
        + \frac{2}{x^4}}{6 + \frac{2}{x^2}+\frac{1}{x^5}}
      =\lim_{x\to\infty}\frac{1}{x}\cdot\frac{5 + \frac{3}{x^3}
        + \frac{2}{x^4}}{6 + \frac{2}{x^2}+\frac{1}{x^5}}
      = 0\cdot\frac{5+0+0}{6+0+0} = 0$
    \item Unlike the previous limits that all had the indeterminate
      form $\frac{\infty}{\infty}$ this limit has the form
      $\infty-\infty$ since the square root is always positive and the
      second term is approaching $-\infty$.  Resolving the limit may be
      accomplished by multiplying by
      $1=\frac{\text{conjugate}}{\text{conjugate}}$\,:\\[.5em]
      $\begin{aligned}[t]\lim_{x\to -\infty}\left(\sqrt{x^2+3x}+x\right)
      &=\lim_{x\to-\infty}\frac{\left(\sqrt{x^2+3x}+x\right)\left(\sqrt{x^2+3x}-x\right)}{\sqrt{x^2+3x}-x}
      = \lim_{x\to -\infty}\frac{x^2+3x-x^2}{\sqrt{x^2+3x}-x} \\
      &=\lim_{x\to -\infty}\frac{3x}{\sqrt{\left(x^2\right)\left(1+\frac{3}{x}\right)}-x}
      =\lim_{x\to -\infty}\frac{3x}{\sqrt{x^2}\sqrt{1+\frac{3}{x}}-x}\\
      &=\lim_{x\to -\infty}\frac{3x}{|x|\sqrt{1+\frac{3}{x}}-x}
      =\lim_{x\to -\infty}\frac{3x}{(-x)\sqrt{1+\frac{3}{x}}-x}\\
      &=\lim_{x\to -\infty}\frac{x}{x}\cdot\frac{3}{-\sqrt{1+\frac{3}{x}}-1}
      =1\cdot\frac{3}{-\sqrt{1+0}-1} = \frac{3}{-1-1} = -\frac{3}{2}
    \end{aligned}$\\[.5em]
    Note that critical to the correct evaluation of this limit is to
    recall that $\sqrt{x^2}=|x|$ and that $|x|=-x$ since, as
    $x\to-\infty$, $x$ is negative.

    The reader can check all of these limits by evaluating the
    function at either a large positive value of $x$ (for
    $x\to+\infty$ limit) or a large negative value of $x$ (for
    $x\to-\infty$ limit).  If this is done on a calculator it is a good
    idea to store the value in a variable when evaluating the
    function.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following:
\begin{enumerate}
\item $\displaystyle\mylim{x}{\infty}\frac{2x^2-5x+7}{7x^2+3x+2}$
\item $\displaystyle\mylim{x}{\infty}\frac{x^3-1}{x^4+1}$
\item $\displaystyle\mylim{x}{\infty}\frac{x^5+3x+5}{x^2-2x+1}$
\item $\displaystyle\mylim{x}{-\infty}\frac{x^3+5x+1}{2x^3-4x^2+3}$
\item $\displaystyle\mylim{x}{\infty}\frac{\sqrt{x^2+3}}{x+2}$
\item $\displaystyle\mylim{x}{-\infty}\frac{\sqrt{x^2+1}}{x-3}$
\item $\displaystyle\mylim{x}{\infty}\left(\sqrt{x^2+3x+1}-x\right)$
\item $\displaystyle\mylim{x}{\infty}\left(x-\sqrt{4x^2+5x-3}\right)$
\end{enumerate}
\end{furtherquestions}
\end{example}

\subsection*{Horizontal Asymptotes}
Recall that a vertical line $x=a$ is called a \textbf{vertical asymptote} of the curve $y=f(x)$ if at least one of the following statements is true:

\hfil$\displaystyle\mylim{x}{a}f(x)=\pm\infty$\hfil$\displaystyle\mylim{x}{a^+}f(x)=\pm\infty$\hfil$\displaystyle\mylim{x}{a^-}f(x)=\pm\infty$\hfil

\definition{The horizontal line $y=L$ is called a \textbf{horizontal asymptote} of the curve $y=f(x)$ if either of the following statements is true:

\hfil$\displaystyle\mylim{x}{\infty}f(x)=L$\hfil$\displaystyle\mylim{x}{-\infty}f(x)=L$\hfil}

\textbook{\clearpage}
The following function has horizontal asymptotes $y=-1$ and $y=1$.
\begin{center}
\includegraphics{graphics/derivative_applications14}%
\end{center}


\begin{example}
In the above graphically defined example the horizontal asymptotes are the lines $y=-1$ and $y=3$.
\end{example}

\begin{example}
  Find the horizontal and vertical asymptotes of the following functions.
  \begin{enumerate}
    \begin{multicols}{2}
    \item $\displaystyle f(x) = \frac{x^2-4x}{x^2-16}$
    \item $\displaystyle f(x) = \frac{\sqrt{9+x^2}}{3-x}$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle f(x) = \frac{x^2-4x}{x^2-16}$\\[.5em]
      $\begin{aligned}[t]
        &\hspace*{-6em}\text{horizontal asymptotes:}\\
        \lim_{x\to\infty} f(x) &=\lim_{x\to\infty}\frac{x^2-3x}{x^2-16}
        =\lim_{x\to\infty}\frac{1-\frac{3}{x}}{1-\frac{16}{x^2}}
        = \frac{1-0}{1-0}=1 \\
        \lim_{x\to-\infty}f(x)&=\lim_{x\to-\infty}\frac{x^2-3x}{x^2-16x}
        =\lim_{x\to-\infty}\frac{1-\frac{3}{x}}{1-\frac{16}{x^2}}
        =\frac{1-0}{1-0}=1 \\
        &\hspace*{-6em}\text{vertical asymptotes:}\\
        x^2-16 &= 0\implies (x-4)(x+4)=0 \implies x = \pm 4\\[.5em]
        \lim_{x\to 4}\frac{x^2-4x}{x^2-16}
        &= \lim_{x\to 4}\frac{x(x-4)}{(x+4)(x-4)}
        = \lim_{x\to 4}\frac{x}{x+4}
        =\frac{4}{4+4} = \frac{4}{8}=\frac{1}{2}\ \ (\text{no asymptote}) \\
        \lim_{x\to-4}\frac{x^2-4x}{x^2-16} &: \frac{(-4)^2-4(-4)}{(-4^2)+16}=\frac{16+16}{16-16}=\frac{32}{0}
      \end{aligned}$

      Therefore $f$ has horizontal asymptote $y=1$ (in both
      directions) and vertical asymptote~$x = -4$\,.  Note that near
      $x=-4$ we have:
      \begin{align*}
        \lim_{x\to-4^-}f(x)&=\lim_{x\to -4^-}\frac{x(x-4)}{(x+4)(x-4)}=\lim_{x\to-4^-}\frac{x}{x+4}=\frac{-4}{0^-}=+\infty\\
        \lim_{x\to-4^+}f(x)&=\lim_{x\to-4^+}\frac{x(x-4)}{(x+4)(x-4)}=\lim_{x\to-4^+}\frac{x}{x+4}=\frac{-4}{0^+}=-\infty
      \end{align*}
      which is useful information when graphing the function near the
      vertical asymptote.
    \item $\displaystyle f(x) = \frac{\sqrt{9+x^2}}{3-x}$ \\[.5em]
      $\begin{aligned}[t]
        &\hspace*{-6em}\text{horizontal asymptotes:}\\
        \lim_{x\to\infty}\frac{\sqrt{9+x^2}}{3-x}
        &=\lim_{x\to\infty}\frac{\sqrt{x^2}\sqrt{\frac{9}{x^2}+1}}{3-x} 
        =\lim_{x\to\infty}\frac{|x|\sqrt{\frac{9}{x^2}+1}}{3-x} 
        =\lim_{x\to\infty}\frac{x\sqrt{\frac{9}{x^2}+1}}{x\left(\frac{3}{x}-1\right)}\\ 
        &=\lim_{x\to\infty}\frac{\sqrt{\frac{9}{x^2}+1}}{\frac{3}{x}-1}
        =\frac{\sqrt{0+1}}{0-1} =\frac{1}{-1}= -1 \\
        \lim_{x\to -\infty}\frac{\sqrt{9+x^2}}{3-x}
        &=\lim_{x\to-\infty}\frac{\sqrt{x^2}\sqrt{\frac{9}{x^2}+1}}{3-x} 
        =\lim_{x\to-\infty}\frac{|x|\sqrt{\frac{9}{x^2}+1}}{3-x} 
        =\lim_{x\to-\infty}\frac{-x\sqrt{\frac{9}{x^2}+1}}{x\left(\frac{3}{x}-1\right)}\\ 
        &=\lim_{x\to -\infty}\frac{-\sqrt{\frac{9}{x^2}+1}}{\frac{3}{x}-1}
        =\frac{-\sqrt{0+1}}{0-1}=\frac{-1}{-1} = 1 \\
        &\hspace*{-6em}\text{vertical asymptotes:}\\
        \lim_{x\to 3}\frac{\sqrt{9+x^2}}{3-x} &: \frac{\sqrt{9+3^2}}{3-3}
          =\frac{\sqrt{18}}{0}
        \end{aligned}$\\[1em]
        Therefore $f$ has horizontal asymptotes $y=1$ and $y=-1$ and
        vertical asymptote $x=3$\,.\\[.3em] (Near $x=3$ one finds
        ${\displaystyle\lim_{x\to3^-}}f(x)=\frac{\sqrt{18}}{0^+}=\infty$
          and
          ${\displaystyle\lim_{x\to3^+}}f(x)=\frac{\sqrt{18}}{0^-}=-\infty$\,. )
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Find the horizontal and vertical asymptotes of the following functions.
\begin{enumerate}
\item $\displaystyle y=\frac{x+3}{x^2-9}$
\item $\displaystyle f(x)=\frac{\sqrt{4x^2+1}}{x+1}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/limits-at-infinity-and-horizontal-asymptotes}
\end{exercise}

\section{Slant Asymptotes}

A function has a \textbf{slant asymptote} if it approaches an oblique (slanted) line as $x$ approaches infinity as shown in the following graph.
\begin{center}
\resizebox{7.5cm}{!}{%
\includegraphics{graphics/derivative_applications15}%
}
\end{center}
A slant asymptote will occur if
\[\mylim{x}{\infty}\left[f(x)-(mx+b)\right]=0\ \mbox{or}\ \mylim{x}{-\infty}\left[f(x)-(mx+b)\right]=0\]
for some constants $m$, and $b$, the slope and $y$-intercept of the asymptote, respectively.  The equation of the slant asymptote is therefore:
\[y=mx+b~.\]

A rational function $f(x)=P(x)/Q(x)$ will have a slant asymptote if
the degree of the numerator $P(x)$ is one more than the denominator
$Q(x)$.  In this case use long division to find the equation of the
slant asymptote.  While a function may have a different slant
asymptote as $x\rightarrow\infty$ and $x\rightarrow-\infty$, for the
rational functions under consideration here these will be the same.
\begin{example}
Find the slant asymptote (if any) of the rational function
$\displaystyle y=f(x)=\frac{x^3+x^2+7}{2x^2-2x}$\,.

\begin{solution}
  The degree of the numerator is $3$ which is one more than the degree
  of the denominator which is $2$ so the rational function will have a
  slant asymptote.  Using \textbf{polynomial long division} one finds
  $x^3+x^2+7$ divided by $2x^2-2x$ is $\frac{1}{2}x+1$ with a remainder of
  $2x+7$.  In symbols
  \begin{align*}
    \frac{x^3+x^2+7}{2x^2-2x}&=\frac{1}{2}x+1+\frac{2x+7}{2x^2-2x}\,,
  \end{align*}
  since the remainder is yet to be divided by $2x^2-2x$.

  The slant
  asymptote is therefore the line $y=\frac{1}{2}x+1$ since\\[.5em]
  $\displaystyle\lim_{x\to\pm\infty}\left[f(x)-\left(\frac{1}{2}x+1\right)\right]
  =\lim_{x\to\pm\infty}\frac{2x+7}{2x^2-2x}
  =\lim_{x\to\pm\infty}\frac{x}{x^2}\cdot\frac{2+\frac{7}{x}}{2-\frac{2}{x}}
    =\lim_{x\to\pm\infty}\frac{1}{x}\cdot\frac{2+\frac{7}{x}}{2-\frac{2}{x}}
    =0\cdot\frac{2+0}{2-0}=0$
  \end{solution}

\begin{furtherquestions}
Find the slant asymptotes (if any) of the following:
\begin{enumerate}
\item $\displaystyle f(x)=\frac{x^3}{x^2+2}$
\item $\displaystyle y=\frac{6x^4+5}{2x^3-4}$
\item $\displaystyle y=\frac{2x^4-x^3+x-3}{x^3-2}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/slant-asymptotes}
\end{exercise}


\section{Curve Sketching}
We have now developed many tools to analyze a function that enable us to accurately sketch a curve.

\begin{method}
\textbf{Sketching the Graph of $\bm{y=f(x)}$}
\begin{description}
\item[Domain:] Determine $D$, the set of $x$-values for which the function is defined.
\item[Intercepts:] The $y$-intercept is $y=f(0)$ while the $x$-intercepts are $x=c$ where $c$ are the solutions of $f(c)=0$.
\item[Symmetry:]  Is the function even, $f(-x)=f(x)$, odd, $f(-x)=-f(x)$, or periodic, $f(x+p)=f(x)$?
\item[Asymptotes:] Find any vertical $\left( x=a\ \mbox{where}\ \mylim{x}{a^{(\pm)}}f(x)=\pm\infty\right)$,\newline horizontal $\left( y=L\ \mbox{where}\ \mylim{x}{\pm\infty}f(x)=L\right)$,\newline or slant $\left(y=mx+b\ \mbox{where}\ \mylim{x}{\pm\infty}\left[f(x)-(mx+b)\right]=0\right)$
asymptotes.
\item[Intervals:] Partition $D$ into open intervals using locations of any vertical asymptotes, critical numbers ($c$ in $D$ where $f'(c)=0$ or does not exist), and numbers $c$ in $D$ where $f''(c)=0$ or does not exist.
\item[Increasing/Decreasing:] Use increasing/decreasing test to determine intervals of increase ($f'(x)>0$) or decrease ($f'(x)<0$).
\item[\Relative Extrema:] For any critical numbers determine \relative extrema.  Evaluate them using the First Derivative Test ($f'$ goes from negative to positive at $c$ $\Rightarrow$ \relative minimum, positive to negative $\Rightarrow$ \relative maximum, no change $\Rightarrow$ no extremum) or Second Derivative Test ($f''(c)>0$ $\Rightarrow$ \relative minimum, $f''(c)<0$ $\Rightarrow$ \relative maximum, $f''(c)=0$ $\Rightarrow$ inconclusive).  Evaluate $f(c)$ to find the value of any \relative extrema.
\item[Concavity:] Use the concavity test ($f''(x)>0$ $\Rightarrow$ concave upward, $f''(x)<0$ $\Rightarrow$ concave downward) to find intervals of concavity.
\item[Inflection Points:] Consider $x$-values $c$ where $f''(c)=0$ or does not exist but $f$ is continuous.  Inflection points $(c,f(c))$ occur where concavity changes (positive to negative or vice versa).
\item[Sketch:] Sketch the above information on a graph choosing axis limits that will include the interesting regions of the graph.
\end{description} 
\end{method}

\begin{example}
  Apply calculus techniques to identify all important features of the
  graph of each function and then sketch it.
  \begin{enumerate}
  \item $\displaystyle f(x) = \frac{x^2}{x^2-3}$
  \item $\displaystyle f(x) = x(x+1)^{\frac{3}{5}}$
  \end{enumerate}

  \textbook{\newpage}
  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t] f(x) &= \frac{x^2}{x^2-3} \\
        & \text{domain: } x^2-3=0 \implies x=\pm\sqrt{3}
        \implies D=\mathset{R}-\left\{-\sqrt{3}, \sqrt{3}\right\}\\
        & y\text{-intercept: }f(0) =\frac{0^2}{0^2-3}=0 \implies y=0\\
        & x\text{-intercept(s): }f(x)= 0 \implies x^2=0 \implies x=0 \\
        & \text{symmetry: } f(-x)=\frac{(-x)^2}{(-x)^2-3}=\frac{x^2}{x^2-3}=f(x)\implies f\ \text{is even.}\\
        & \text{horizontal asymptotes: }\\
        &\lim_{x\to\infty}\frac{x^2}{x^2-3}=\lim_{x\to\infty}\frac{1}{1-\frac{3}{x^2}}
        = \frac{1}{1-0}=1 \implies y=1\ \ 
        (\text{Similarly }\lim_{x\to-\infty}f(x)=1 \implies y=1\,.)\\
        & \text{vertical asymptotes: }\\
        &\lim_{x\to\sqrt{3}}\frac{x^2}{x^2-3}: \frac{3}{3-3}=\frac{3}{0}\implies x=\sqrt{3}\ \ \ \ \ 
        \lim_{x\to -\sqrt{3}}\frac{x^2}{x^2-3}: \frac{3}{3-3}=\frac{3}{0}\implies x=-\sqrt{3} \\
        & \text{slant asymptotes: } \text{None since the degree of the numerator and denominator are both equal to 2.}\\[.5em]
        f'(x) &= \frac{2x(x^2-3)-x^2(2x)}{(x^2-3)^2} = \frac{-6x}{(x^2-3)^2} \\
        &\text{critical numbers: } f'(x) = 0 \implies -6x = 0\implies x=0\\[.5em]
        f''(x) &= \frac{-6(x^2-3)^2 - (-6x)(2)(x^2-3)(2x)}{(x^2-3)^4} =
        \frac{-6(x^2-3)+24x^2}{(x^2-3)^3} = \frac{18x^2+18}{(x^2-3)^3} 
        = \frac{18(x^2+1)}{(x^2-3)^3} \\
        &\text{potential concavity change: }
        f''(x) = 0 \implies x^2+1=0 \implies \text{ no solution} \\
      \end{aligned}$\\
      Note that $f'(x)$ and $f''(x)$ are not defined if
      $x=\pm\sqrt{3}$, however these values are not in the domain $D$.
      As such they cannot be a location for an extrema nor an
      inflection point.  However the sign of $f'$ and $f''$ can change
      at such a discontinuity so these values also must be used when
      partitioning the real axis into intervals.  In general one must
      remember to consider vertical asymptotes in addition to critical
      values and locations where $f''(x)=0$ or is undefined when
      doing interval analysis.  \vspace{-1em}
      \begin{center}
        $\begin{array}{cccl} \\
        & f'(x)= & f''(x)= & \\
           \text{Interval} & \frac{(-6)x}{(x^2-3)^2} & \frac{18(x^2+1)}{[x-(-\sqrt{3})]^3(x-\sqrt{3})^3} & \hspace{5em}f\\[.5em]\toprule
           x<-\sqrt{3} & \frac{(-)(-)}{(+)}=(+) & \frac{(+)(+)}{(-)^3(-)^3}=(+) & \text{increasing, concave upward}\\[.5em]
           -\sqrt{3}<x<0 & \frac{(-)(-)}{(+)}=(+) & \frac{(+)(+)}{(+)^3(-)^3}=(-) & \text{increasing, concave downward}\\[.5em]
           0<x<\sqrt{3} & \frac{(-)(+)}{(+)}=(-) & \frac{(+)(+)}{(+)^3(-)^3}=(-) & \text{decreasing, concave downward}\\[.5em]
           \sqrt{3}<x & \frac{(-)(+)}{(+)}=(-) & \frac{(+)(+)}{(+)^3(+)^3}=(+) & \text{decreasing, concave upward}\\[.5em]
         \end{array}$
      \end{center}
      
      The function $f$ is increasing on
      $(-\infty,-\sqrt{3})\cup(-\sqrt{3},0)$ and decreasing on
      $(0,\sqrt{3})\cup(\sqrt{3},\infty)$\,. (Note that the vertical
      asymptotes at $x=\pm\sqrt{3}$ mean we cannot combine these
      intervals.)  Analysis of the critical number at $x=0$ using the
      First Derivative Test and the table or the Second Derivative
      Test ($f''(0)=-\frac{2}{3}<0$) shows that
      \begin{itemize}
      \item $f(0)=0$ is a \relative maximum.
      \end{itemize}
      
      The function $f$ is concave upward on
      $(-\infty,-\sqrt{3})\cup(\sqrt{3},\infty)$ and concave downward
      on $(-\sqrt{3},\sqrt{3})$\,.  There are no inflection points.
      (Concavity does change at $x=\pm\sqrt{3}$ but these are not in
      the domain.)

      A sketch of the graph is below.
      \begin{center}
        \includegraphics[width=5cm]{graphics/derivative_applications18}
      \end{center}

    \item $\begin{aligned}[t] f(x) &= x(x+1)^{\frac{3}{5}}\\
        & \text{domain: } \text{Since } (x+1)^{\frac{3}{5}}=\left[(x+1)^3\right]^{\frac{1}{5}}=\sqrt[5]{(x+1)^3}\ \text{(odd root)} \implies D=\mathset{R}\\
        & y\text{-intercept: }f(0) =0(1)^{\frac{3}{5}}=0 \implies y=0\\
        & x\text{-intercept(s): }f(x)= 0 \implies x=0 \\
        &\hspace{3.7em}\text{or }(x+1)^{\frac{3}{5}}=0 \implies \left[(x+1)^{\frac{3}{5}}\right]^{\frac{5}{3}}=0^{\frac{5}{3}}\implies x+1=0\implies x=-1 \\
        & \text{symmetry: } f(-x)=(-x)(-x+1)^{\frac{3}{5}}=(-x)(-1)^{\frac{3}{5}}(x-1)^{\frac{3}{5}}=x(x-1)^{\frac{3}{5}}\implies \text{No symmetry}\\
        & \text{horizontal asymptotes: }\text{None since:}\\
        &\lim_{x\to\infty}x(x+1)^{\frac{3}{5}}=\lim_{x\to\infty}x^1(x)^{\frac{3}{5}}\left(1+\frac{1}{x}\right)^{\frac{3}{5}}=\lim_{x\to\infty}x^{\frac{8}{5}}\left(1+\frac{1}{x}\right)^{\frac{3}{5}}=(\infty)\left(1+0\right)^{\frac{3}{5}}=\infty\\
        &\!\lim_{x\to-\infty}x(x+1)^{\frac{3}{5}}=\lim_{x\to-\infty}x^{\frac{8}{5}}\left(1+\frac{1}{x}\right)^{\frac{3}{5}}=\lim_{x\to-\infty}\left(x^{\frac{1}{5}}\right)^8\left(1+\frac{1}{x}\right)^{\frac{3}{5}}=(+\infty)\left(1+0\right)^{\frac{3}{5}}=\infty\\
        & \text{vertical asymptotes: }\text{None}\\
        & \text{slant asymptotes: } \text{None}
      \end{aligned}$
      $\begin{aligned}[t]
        f'(x) &= (x+1)^\frac{3}{5} + \frac{3}{5}x(x+1)^{-\frac{2}{5}}
        = (x+1)^\frac{3}{5}\cdot\frac{5(x+1)^\frac{2}{5}}{5(x+1)^\frac{2}{5}}
        +\frac{3x}{5(x+1)^\frac{2}{5}}
        = \frac{5(x+1)+3x}{5(x+1)^\frac{2}{5}}\\
        &= \frac{8x+5}{5(x+1)^\frac{2}{5}} \\
        &\text{critical numbers: } f'(x)\ \text{is not defined at }x=-1\\
        &\hspace{6.7em}f'(x) = 0 \implies 8x+5 = 0\implies x=-\frac{5}{8}\\[.5em]
        f''(x) &=\frac{3}{5}(x+1)^{-\frac{2}{5}} + \frac{3}{5}(x+1)^{-\frac{2}{5}}
        -\frac{6}{25}x(x+1)^{-\frac{7}{5}}
        = \frac{6}{5(x+1)^\frac{2}{5}}- \frac{6x}{25(x+1)^\frac{7}{5}}\\
        &= \frac{6}{5(x+1)^\frac{2}{5}}\cdot\frac{5(x+1)^{\frac{5}{5}}}{5(x+1)^{\frac{5}{5}}}-\frac{6x}{25(x+1)^\frac{7}{5}}
        = \frac{30(x+1)-6x}{25(x+1)^\frac{7}{5}} = \frac{24x+30}{25(x+1)^\frac{7}{5}}
        = \frac{6(4x+5)}{25(x+1)^\frac{7}{5}} \\[.5em]
        &\text{potential concavity change: }f''(x)\ \text{is not defined at }x=-1\\
        &\hspace{12.2em}f''(x) = 0 \implies 4x+5=0 \implies x=-\frac{5}{4} \\[.5em]
      \end{aligned}$\\
      When analyzing the sign of $f'(x)$ we note that
      $(x+1)^{\frac{2}{5}}=\left[(x+1)^{\frac{1}{5}}\right]^2=(\sqrt[5]{x+1}\,)^2\ge
        0$ for all $x$ and when analyzing the sign of $f''(x)$ that
        $(x+1)^{\frac{7}{5}}=(\sqrt[5]{x+1})^7$ will have the same
        sign as $x+1$ since the fifth root and the seventh power being
        odd will preserve the sign.\vspace{-1em}
%        & f'(x)= & f''(x)= & \\
      \begin{center}
        $\begin{array}{cccl} \\
           \text{Interval} & f'(x)=\frac{8\left[x-\left(-\frac{5}{8}\right)\right]}{5(x+1)^\frac{2}{5}} & f''(x)=\frac{24\left[x-\left(-\frac{5}{4}\right)\right]}{25[x-(-1)]^\frac{7}{5}\rule[-.1em]{0em}{1em}}& \hspace{5em}f\\[.7em]\toprule
           x<-\frac{5}{4} & \frac{(+)(-)}{(+)(+)}=(-) & \frac{(+)(-)}{(+)(-)}=(+) & \text{decreasing, concave upward}\\[.5em]
           -\frac{5}{4}<x<-1 & \frac{(+)(-)}{(+)(+)}=(-) & \frac{(+)(+)}{(+)(-)}=(-) & \text{decreasing, concave downward}\\[.5em]
           -1<x<-\frac{5}{8} & \frac{(+)(-)}{(+)(+)}=(-) & \frac{(+)(+)}{(+)(+)}=(+) & \text{decreasing, concave upward}\\[.5em]
           -\frac{5}{8}<x & \frac{(+)(+)}{(+)(+)}=(+) & \frac{(+)(+)}{(+)(+)}=(+) & \text{increasing, concave upward}\\[.5em]
         \end{array}$
      \end{center}
      Evaluate $f$ at useful $x$ values:\\[.5em]
      $\begin{aligned}[t]
        f\textstyle{\left(-\frac{5}{4}\right)}&=-\frac{5}{4}\left(-\frac{5}{4}+1\right)^{\frac{3}{5}}=-\frac{5}{4}\left(-\frac{1}{4}\right)^{\frac{3}{5}}=-\frac{5}{4}\cdot\frac{(-1)^{\frac{3}{5}}}{(2^2)^{\frac{3}{5}}}=-\frac{5}{(2)^2}\cdot\frac{-1}{(2)^{\frac{6}{5}}}=\frac{5}{2^{\frac{16}{5}}}\approx 0.54\\
        f(-1)&=(-1)(-1+1)^{\frac{3}{5}}=(-1)(0)^{\frac{3}{5}}=0\\
        f\textstyle{\left(-\frac{5}{8}\right)}&=-\frac{5}{8}\left(-\frac{5}{8}+1\right)^{\frac{3}{5}}=-\frac{5}{8}\left(\frac{3}{8}\right)^{\frac{3}{5}}=-\frac{5}{8}\cdot\frac{(3)^{\frac{3}{5}}}{(2^3)^{\frac{3}{5}}}=-\frac{5}{(2)^3}\cdot\frac{(3)^{\frac{3}{5}}}{(2)^{\frac{9}{5}}}=-\frac{5(3)^{\frac{3}{5}}}{2^{\frac{24}{5}}}\approx-0.35
      \end{aligned}$\\[.5em]
      
      The function $f$ is increasing on $(-\frac{5}{8},\infty)$ and decreasing
      on $(-\infty,-\frac{5}{8})$\,. Analysis of the critical numbers $x=-1$
      and $x=-\frac{5}{8}$ using the First Derivative Test and the table shows
      that
      \begin{itemize}
      \item
        $f(\textstyle{-\frac{5}{8}})=-\frac{5(3)^{\frac{3}{5}}}{2^{\frac{24}{5}}}\approx-0.35$
        is a \relative minimum.
      \end{itemize}
      
      The function $f$ is concave upward on
      $(-\infty,-\frac{5}{4})\cup(-1,\infty)$ and concave downward
      on $(-\frac{5}{4},-1)$\,.  Analysis of the concavity on both sides of those locations where $f''(x)$ vanished or was undefined ($-1$ and $-\frac{5}{4}$) shows that the following are inflection points:
      \begin{itemize}
      \item $(-1,0)$
      \item $\left(-\frac{5}{4},\frac{5}{2^{\frac{16}{5}}}\right)\approx\left(-\frac{5}{4},0.54\right)$
      \end{itemize}
      A sketch of the graph is below.
      \begin{center}
        \includegraphics[width=5cm]{graphics/derivative_applications19}
      \end{center}
    \end{enumerate}
  \end{solution*}

\begin{furtherquestion}
Sketch the graph of $\displaystyle f(x)=\frac{2x^2+2x-3}{x^2+x-2}$.
\end{furtherquestion}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/curve-sketching-II}
\end{exercise}

\section{Optimization}
A particularly useful application of calculus is optimization.  We have already seen how we can find \absolute and \relative extrema of functions.  When these functions represent physical quantities solutions of extrema problems give optimal settings of the independent variable that will result in the lowest or highest possible value of the dependent variable.

So in business one may be interested in minimizing cost or maximizing profit by setting selecting the value of a design specification in its production or determining the sale price of an item.  Environmentally one may be interested in minimizing the production of some toxic compound whose formation depends on an alterable temperature at production.  Often we are interested in minimizing distance or time.

As with any word problem, the challenge with an optimization problem is to convert this into a calculus problem.  Once this is accomplished one follows the steps already discussed for finding the \absolute extremum of interest.  In summary do the following:

\begin{method}
\textbf{Optimization Problem Steps}
\begin{description}
\item[1) Identify Variables:] Identify the dependent variable to be
  maximized or minimized and the independent variable to be varied.
  (If the problem is geometrical in nature try sketching a diagram.)
  Determine the physically valid domain $D$ of the independent
  variable.
\item[2) Determine Function:] Write the dependent variable as a function of the independent variable.  (If another variable appears in the
  function, try to find a constraint involving the independent variable
  and it so that the latter may be removed from the function.\footnotemark)
\item[3) Differentiate:] Take the derivative of the dependent variable
  with respect to the independent one.
\item[4) Critical Numbers:] Find any critical numbers of the independent variable (where the derivative vanishes or does not exist).
\item[5) Evaluate Dependent Variable:] If seeking an \absolute
  maximum, check which critical numbers are \relative maxima (using
  the Second or First Derivative Test) and evaluate the dependent
  variable at those points.  Also evaluate the dependent variable at
  the endpoints of $D$.  The largest of these is the \absolute maximum
  of the dependent variable while its location is the optimal setting
  of the independent variable.  Do similarly if seeking an \absolute
  minimum.\footnotemark
\end{description}
\end{method}
\addtocounter{footnote}{-1}
\footnotetext{If no such constraint exists so that the other
    variable is actually independent, then multivariate calculus would
    be required.}
\addtocounter{footnote}{1}
\footnotetext{As a final step, note that plotting your function to confirm the location and value of the extremum is a good idea in practice.}

\begin{example}
  Solve the following optimization problems.
  \begin{enumerate}
  \item A page in a children's book is to have a total area of
    $600$~cm$^{2}$.  Its top and bottom margins are to be $3$~cm while
    its side margins are to be $2$~cm each.  What should the
    dimensions of the page be to maximize the printed area between the
    margins?

    \textbook{\newpage}
    \begin{solution*}
      \begin{enumerate}[label=(\roman*)]
      \item Identify Variables:
        \plainoverlay at (6.5cm,1.6cm) {\includegraphics[width=1.8cm]{graphics/bookpage}};
        \begin{itemize}
        \item independent: $x=$inner width ($y=$inner height)
        \item dependent: maximize printed area $A$
        \end{itemize}
        What are the allowed values of $x$?  Clearly $x$, as a length,
        must be positive.  The maximum $x$ possible occurs when the height
        $y$ vanishes:\\[.5em]
        $y=0\implies(2+x+2)(3+0+3)=600\implies x+4=100\implies x=96$\,cm\\[.5em]
        So the actual $x$ must lie in the interval $[0,96]$\,.\footnotemark
      \item Determine Function: The printed area $A=xy$\,.  We can
        eliminate the height $y$ using the constraint that the total
        area must be $600\,\text{cm}^2$ which implies (see diagram):\\[.5em]
        $\displaystyle 
          (4+x)(6+y)=600
          \implies 6+y=\frac{600}{4+x}
          \implies y=\frac{600}{4+x}-6$\\[.5em]
        Inserting this value in $A=xy$ gives A as a function of $x$ alone:
        $\displaystyle A(x)=\frac{600x}{4+x}-6x$
      \item Differentiate: $\displaystyle\diff{A}{x}
        =\frac{600(4+x)-600x(1)}{(4+x)^2}-6\implies \diff{A}{x}=\frac{2400}{(4+x)^2}-6$
      \item Critical Numbers:\\[.5em]
        $\begin{aligned}[t]
          0&=A'=\frac{2400}{(4+x)^2}-6\implies0=2400-6(4+x)^2\implies(4+x)^2=\frac{2400}{6}=400\\
          &\implies \sqrt{(4+x)^2}=\sqrt{400}\implies |4+x|=20\\
          &\implies 4+x=-20\ \text{or}\ 4+x=20\implies x=-24\,\text{cm}\ \text{or}\ x=16\,\text{cm}
        \end{aligned}$\\[.5em]
        We will reject $x=-24$\,cm as it does not lie in our interval. So $x=16$\,cm.
      \item Evaluate Dependent Variable:\\
        We know on the closed interval $[0,96]$ the function
        $A(x)=\frac{600x}{4+x}-6x$ is continuous and hence achieves
        its \absolute maximum at either a critical number or an
        endpoint.  Evaluating at these locations gives:
        \begin{align*}
          A(0)&=\frac{600(0)}{4+0}-6(0)=0\,\text{cm}^2\\
          A(16)&=\frac{600(16)}{4+16}-6(16)=480-960=384\,\text{cm}^2\\
          A(96)&=\frac{600(96)}{4+96}-6(96)=0\,\text{cm}^2\\
        \end{align*}
        That $A(0)=A(96)=0\,\text{cm}^2$ makes sense since either the
        $x$ or $y$ dimension is $0$ in these cases.  When $x=16$\,cm
        we find, using our equation for $y$ found above, that
        \begin{align*}
          y&=\frac{600}{4+16}-6=30-6=24\,\text{cm}\,.
        \end{align*}
        Hence a maximum printed area of $384\,\text{cm}^2$ occurs when
        the inner area dimensions are width of $x=16$\,cm by height
        of $y=24$\,cm.  The actual page dimensions (what the problem
        asked for) are therefore:
        \begin{align*}
          \text{page width}&=x+4=20\,\text{cm}\\
          \text{page height}&=y+6=30\,\text{cm}
        \end{align*}
        Final notes:\\
        One could have shown that $x=16$\,cm was the
        location of a \relative maximum of $A$ using the Second
        Derivative Test:\\[.5em]
        $\displaystyle A''(x)=-4800(4+x)^{-3}\implies A''(16)
        =-\frac{4800}{20^3}=-0.6<0$ ({\Large\frownie}) \\[.5em]
        A \relative maximum located at $x=16$ does not guarantee that
        it is the location of the \absolute maximum but it is a useful
        check nonetheless.  We can visualize the optimization problem
        by graphing $A(x)$ to get:
      \begin{center}
        \includegraphics[width=5cm]{graphics/derivative_applications20}
      \end{center}

      \end{enumerate}
      
    \end{solution*}

  \item Earth is located at the fixed point $(1,0)$ in a coordinate
    system superimposed on the plane of the solar system with the sun
    at the origin.  Here measurements are in Astronomical
    Units~(AU)\,.\footnotemark\, A spaceship follows a hyperbolic
    trajectory $y=\sqrt{x^2+1}$ through the plane.  At what point is
    the spaceship closest to Earth and how far away is it at that
    point?

    \begin{solution*}
      \begin{enumerate}[label=(\roman*)]
      \item Identify Variables:\\[.5em]
        \plainoverlay at (9.3cm,1.5cm) {\includegraphics[width=4cm]{graphics/derivative_applications21}};
        \begin{minipage}{9cm}
        \begin{itemize}
        \item independent: Let $x$ be the $x$-coordinate of the point
          $P$ on the hyperbola (and $y$ its $y$-coordinate).
          \item dependent: Minimize distance $d$ between $P(x,y)$ and
            $(0,1)$, the location of the Earth.  To simplify our work,
            it is actually easier to minimize the distance-squared,
            $D=d^2$.  (The location of a minimum of $D=d^2$ will also
            clearly be the location of a minimum of $d$.)
          \end{itemize}
        \end{minipage}\\
          Since the $x$-coordinate can get arbitrarily large in either
          direction, $x$ can lie anywhere in~$(-\infty,\infty)$\,.
      \item Determine Function: The distance formula between two points $(x_1,y_1)$ and $(x_2,y_2)$ by the Pythagorean Theorem is just
        \begin{align*}
          d&=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}\implies D=d^2=(x_2-x_1)^2+(y_2-y_1)^2
        \end{align*}
        So between the point $(x,y)$ of the spaceship and $(1,0)$ of Earth we have:
        \begin{align*}
          D=(x-1)^2+(y-0)^2=x^2-2x+1+y^2
        \end{align*}
        To remove the dependency of $D$ on $y$ we use the constraint that the point $(x,y)$ lies on the hyperbola ($y=\sqrt{x^2+1}$) to get
        \begin{align*}
          D(x)&=x^2-2x+1+\left(\sqrt{x^2+1}\right)^2=x^2-2x+1+x^2+1\\
          \implies D(x)&=2x^2-2x+2
        \end{align*}

      \item Differentiate: $\displaystyle \diff{D}{x}=4x-2$
      \item Critical Numbers: $\displaystyle 0=D'=4x-2\implies x=\frac{2}{4}=\frac{1}{2}$
      \item Evaluate Dependent Variable:\\[.5em]
        $D\left(\frac{1}{2}\right)
        =2\left(\frac{1}{2}\right)^2-2\left(\frac{1}{2}\right)+2
        =\frac{1-2+4}{2}=\frac{3}{2}\,\text{AU}^2$\\[.5em]
        To see this is a relative minimum, note that\\[.5em]
        $D''(x)=4\implies D''\left(\frac{1}{2}\right)=4>0\
        ({\Large\smiley})$,\\[.5em]
        so by the Second Derivative Test
        $D\left(\frac{1}{2}\right)=\frac{3}{2}\,\text{AU}^2$ is a
        \relative minimum.

        The function $D(x)$ is defined on $(-\infty,\infty)$ which is
        not a closed interval.  However we can consider the behaviour
        at the infinite ``endpoints'' by taking the limits:
        \begin{align*}
          \lim_{x\to\infty}D(x)&=\lim_{x\to\infty}(2x^2-2x+2)=\lim_{x\to\infty}2x^2\left(1-\frac{1}{x}+\frac{1}{x^2}\right)=(+\infty)(1-0+0)=\infty\\
          \lim_{x\to-\infty}D(x)&=\lim_{x\to-\infty}(2x^2-2x+2)=\lim_{x\to-\infty}2x^2\left(1-\frac{1}{x}+\frac{1}{x^2}\right)=(+\infty)(1-0+0)=\infty
        \end{align*}
        This suggests that
        $D\left(\frac{1}{2}\right)=\frac{3}{2}\,\text{AU}^2$ is an
        absolute minimum.

        Finally we also need the $y$-coordinate for the closest point
        $P$.  Using the constraint equation gives
        \begin{align*}
          y=\sqrt{\left(\frac{1}{2}\right)^2+1}=\sqrt{\frac{5}{4}}=\frac{\sqrt{5}}{\sqrt{4}}=\frac{\sqrt{5}}{2}\,\text{AU}\,.
        \end{align*}

        Thus the point of closet approach is
        $P\left(\frac{1}{2},\frac{\sqrt{5}}{2}\right)$ with a closest
        distance of (since $D=d^2$) $d=\sqrt{\frac{3}{2}}$\,AU.
      \end{enumerate}

      Further Notes:\\
      The reader is welcome to do the problem optimizing the
      distance $d(x)=\sqrt{2x^2-2x+2}$ directly.  Also note that a
      graph of $D(x)$ looks as follows:
      \begin{center}
        \includegraphics[width=6cm]{graphics/derivative_applications22}
      \end{center}
    \end{solution*}
\end{enumerate}

\textbook{\clearpage}
\begin{furtherquestions}
Solve the following optimization problems.
\begin{enumerate}
\item A farmer intends to put a rectangular garden along one side of a
  barn.  The remaining three sides of the garden will be fenced. Find
  the dimensions and area of the largest garden that can be enclosed using
  40~metres of fencing material.

\item Find the dimensions of the rectangle with fixed area $a$ having
  the smallest perimeter possible.

\item A polygonal window is composed of a rectangle topped with an
  equilateral triangle.  Find the dimensions of the window that will
  maximize the area if the perimeter of the window must be $6$~m.

\item In a certain type of cheese production the cheese is pressed
  into a cylindrical mold with a circular base and no top.  If the
  total area of the mold is to be $1600$~cm$^2$, find the radius and
  height of the mold that will maximize the volume it contains.
% Note the high pressure when pressing is why cylindrical molds are used.

\item A plastic rectangular box for transporting vegetables needs to
  be designed to have a volume of 72000~cm${}^3$.  The box is to have
  an open top.  The cost of material for the base is
  $0.25$~cents/cm${}^2$ while for the sides it is only
  $0.2$~cents/cm${}^2$.  If the length of the base is desired to be
  $1.5$ times its width, find the dimensions and cost for the least
  expensive box meeting these requirements.

\item A semicircle has a radius of $2$~cm.  What are the dimensions of
  the rectangle with largest area that can be inscribed within it?

\end{enumerate}
\end{furtherquestions}
\end{example}
\footnotetext{One Astronomical Unit equals the average distance from the
  earth to the sun, approximately 150 million kilometres.}

\begin{exercise}
\input{DERIVATIVE_APPLICATIONS/optimization-problems}
\end{exercise}

\begin{reviewexercise}
\input{DERIVATIVE_APPLICATIONS/derivative-applications-review}
\end{reviewexercise}

% TODO: Make section Increasing and Decreasing FUNCTIONS?  But relations too...
%
% TODO: Add problem where given the graph of a function, sketch f', f''
%
% TODO: Add preamble to curve sketching discussing blindly plotting a function.
% Choose an inappropriate domain and range.  Use it as a reminder about how to plot
% a function.
%
% TODO: In curve sketching add the problem I created for the 2016 fall final.
%
% TODO: Add part (b) to the cylindrical can optimization problem asking what their
% ratio for h/r is and then getting to prove it is the same for any optimized
% can of height H and radius R.  Also look at my optimization problem for a skier
% which I had on a previous midterm as well as problems I created with optimizing
% an equilateral triangle bordered by three squares.  Also my spaceship 2-D
% and 3D problem.  The 2D one I had proposed for a final exam and was worked
% out.
%
% TODO: Add a geometry appendix.  It should have info on cartesian coordinates,
% including distances between horizontal points and arbitrary points.
% Also need an appendix with perimeters and areas of planar shapes and
% surface areas and volumes of 3D shapes.  See resources directory for examples.
%
% Maybe add an optimization problem tips section where I mention
% distance formula, geometry appendix, and cost = cost/length*length, etc.
%
% Make more changes from term value to number when talking about the domain,
% like critical number.  Use term value more for value of a function, like
% maximum value.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "master"
%%% End:
