\section[Motivating the Derivative]{Motivating the Definition of the Derivative}
\subsection{Tangents}
When motivating the definition of the limit we were trying to solve the equation for the tangent to a point on a curve.  We now write the definition of the tangent of the curve at a point directly in terms of the limit where, from the following diagram, it follows that $\Delta y=f(x)-f(a)$ and $\Delta x=x-a$:

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

\definition{Let $P(a,f(a))$ be a point on the curve $y=f(x)$. The tangent line to the curve at $P$ is the line through $P$ having slope
\[m=\mylim{x}{a}\frac{f(x)-f(a)}{x-a}~,\]
assuming the limit exists.
}

\begin{example}
  \label{exam:oldslope}
  Find the equation of the tangent line to the curve $y=x^2-x$ at $P(2,2)$\,.

  \begin{solution}
    The curve is $y=f(x)$ with $f(x)=x^2-x$.  The slope of the tangent at $P(a,f(a))=(2,2)$ is:
    \begin{align*}
      m &= \lim_{x\to 2} \frac{f(x)-f(2)}{x-2}
          = \lim_{x\to2}\frac{(x^2-x)-(2^2-2)}{x-2}
          = \lim_{x\to2}\frac{x^2-x-2}{x-2}
          = \lim_{x\to 2}\frac{(x-2)(x+1)}{x-2}\\
        &= \lim_{x\to2}(x+1) = 2+1 = 3
    \end{align*}
    Using the point-slope equation of a line, $y=m(x-x_0)+y_0$, with
    $(x_0,y_0)=(2,2)$ gives the equation of the tangent line through
    $P$ to be $y= 3(x-2)+2$ in point-slope form.  Expanding gives
    the slope-intercept form $y = 3x-4$\,.
  \end{solution}

\begin{furtherquestion}
Find the equation of the tangent line to the curve $\displaystyle y=\frac{2}{x}$ at $P(2,1)$\,.
\end{furtherquestion}
\end{example}

Another equivalent (and convenient) limit for the tangent slope can be found by considering the limit as $\Delta x$ goes to $0$.  If, for brevity, we call $\Delta x$ by $h$ we have
\[h=x-a~,\]
so that $x=a+h$.  The original limit for the tangent slope becomes
$\displaystyle\boxed{m=\lim_{h\rightarrow0}\frac{f(a+h)-f(a)}{h}}~.$

\begin{example}
  Find the slope of the tangent line to the curve $y=x^2-x$ at
  $P(2,2)$ of Example~\ref{exam:oldslope}, but now using the limit $\displaystyle m=\lim_{h\to0}\frac{f(a+h)-f(a)}{h}$\,.

  \begin{solution}
    \begin{align*}
    m&=\lim_{h\to0}\frac{f(2+h)-f(2)}{h}
    =\lim_{h\to0}\frac{[(2+h)^2-(2+h)]-(2^2-2)}{h}
    =\lim_{h\to0}\frac{4+4h+h^2-2-h-2}{h}\\
    &=\lim_{h\to0}\frac{3h+h^2}{h}
    =\lim_{h\to0}\frac{h(3+h)}{h}
    =\lim_{h\to0}(3+h)=3+0=3\ \ \text{(as before)}
    \end{align*}
  \end{solution}

\begin{furtherquestions*}
\begin{enumerate}
\item Find the equation of the tangent line to the curve $y=x^3$ at
  $P(1,1)$ using the limit
  \mbox{$\displaystyle m=\lim_{h\to0}\frac{f(a+h)-f(a)}{h}$} for the tangent
  slope\,.
\item Find the slope of the tangent line to the curve $y=x^3$ at the arbitrary point $P(a,a^3)$
\end{enumerate}
\end{furtherquestions*}
\end{example}

\subsection[Velocity in 1D]{Velocity in One Spatial Dimension}

In the tangent problem the independent variable was a spatial one, $x$.  Another useful independent variable is time $t$.  If an object is moving along a straight line then its position in space is completely determined by its \textbf{displacement} $\bm s$ from some point along the line, the \textbf{origin}.  If the object is moving in time its position at any given time $t$ will be given by a \textbf{position function} $s=f(t)$.

An example of such motion is a ball thrown directly upwards which, in the absence of wind, will move in a vertical line where $s$ is the height above ground: 
\begin{center}
\parbox[t]{.6in}{\vspace{0em}{\resizebox{.6in}{!}{\includegraphics{graphics/linear_motion}}}}
\end{center}
A negative displacement would indicate the ball is positioned below ground surface.
% A second example is a toy train moving along a straight track where $s(t)$ is the displacement from some fixed point on the track.

\definition{The \textbf{average velocity} over the time interval from $t=a$ to $t=a+h$ (so $\Delta t=h$) is
\[\mbox{average velocity}=\frac{\mbox{displacement}}{\mbox{time}}=\frac{f(a+h)-f(a)}{h}\ .\]}

Letting the time interval approach zero ($h\rightarrow 0$) we arrive at the following definition:
\definition{The (instantaneous) \textbf{velocity} $v(a)$ at time $t=a$ is:
\[v(a)=\mylim{h}{0}\frac{f(a+h)-f(a)}{h}\ .\]}

Note velocity is a signed quantity.  A positive sign in our ball
example indicates the ball is moving upwards and a negative sign
indicates it would be falling.

\begin{example}
  The displacement $s$ (in metres) of a particle moving in a straight
  line is given by $s = 2t^3+t^2-5$.
  \begin{enumerate}
  \item Find the average velocity over the interval $[1,2]$.
  \item Find the (instantaneous) velocity at $t=2$ seconds.
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item For $s=f(t)=2t^3+t^2-5$ over time interval $[1,2]$ one is
      starting at time $a=1$ second with interval length $h=2-1=1$
      second.  The average velocity over time interval $[1,2]$ is
      therefore:
      \begin{align*}
        \text{average velocity} &= \frac{f(1+1)-f(1)}{h}
                                  =\frac{2(2)^3+(2)^2 - 5 - [2(1)^3+(1)^2-5]}{2-1}\\
                                &=\frac{16+4-5-2-1+5}{1} = 17\,\frac{\text{m}}{\text{s}}
      \end{align*}
    \item The (instantaneous) velocity at $t=2$ seconds is
      \begin{align*}
        v(2) & = \lim_{h\to 0} \frac{f(2+h)-f(2)}{h}
               = \lim_{h\to 0}\frac{2(2+h)^3+(2+h)^2-5-[2(2^3)+2^2-5]}{h}\\
             & = \lim_{h\to 0}\frac{2(8+12h+6h^2+h^3)+(4+4h+h^2)-5-15}{h}\\
             &  = \lim_{h\to 0}\frac{16+24h+12h^2+2h^3+4+4h+h^2-20}{h}\\
             & = \lim_{h\to 0}\frac{2h^3+13h^2+28h}{h}
               = \lim_{h\to 0}(2h^2+13h+28) = 28\,\frac{\text{m}}{\text{s}}
               \end{align*}
    \end{enumerate}
  \end{solution*}

\begin{furtherquestion}
The displacement $s$ (in metres) of a particle moving in a straight line is given by $s=t^2-4t+5$ where $t$ is measured in seconds.
\begin{enumerate}
\item Find the average velocity over the interval $[3,4]$.
\item Find the (instantaneous) velocity at $t=4$ seconds.
\end{enumerate}
\end{furtherquestion}
\end{example}

\textbook{\clearpage}

\subsection{Other Rates of Change}

The previous examples involving relative change in coordinate variables or in position with respect to time can be further generalized. If $x$ changes from $x_1$ to $x_2$ then the change in $x$, called the \textbf{increment in $\bm{x}$}, is denoted by:
\[\Delta x=x_2-x_1\ .\]
If $y=f(x)$ then the corresponding \textbf{increment in $\bm{y}$} is
\[\Delta y=f(x_2)-f(x_1)\ .\]
As with the the specific example of velocity, the \textbf{average rate of change of $\bm{y}$ with respect to $\bm{x}$} is
\[\frac{\Delta y}{\Delta x}=\frac{f(x_2)-f(x_1)}{x_2-x_1}=\frac{f(x_1+\Delta x)-f(x_1)}{\Delta x}\]
Taking the limit as $x_2\rightarrow x_1$, or equivalently $\Delta x\rightarrow 0$, one defines the \textbf{rate of change of $\bm{y}$ with respect to $\bm{x}$} as
\[\mylim{\Delta x}{0}\frac{\Delta y}{\Delta x}=\mylim{x_2}{x_1}\frac{f(x_2)-f(x_1)}{x_2-x_1}=\mylim{\Delta x}{0}\frac{f(x_1+\Delta x)-f(x_1)}{\Delta x}\]
This general definition shows there are many rates of change depending upon the choice of independent and dependent variable, velocity being only one.

\begin{example}
Recalling that the area of a circle in terms of its radius is $A=\pi r^2$,
\begin{enumerate}
\item Find the average rate of change of the area of a circle with
  respect to its radius $r$ as $r$ changes from $2$ cm to $2.5$ cm.
\item Find the instantaneous rate of change of the area with respect
  to the radius of the circle when $r=2$ cm.
\end{enumerate}

\begin{solution*}
  \begin{enumerate}
  \item Over the interval $[2\,\text{cm},2.5\,\text{cm}]$ one finds\\[.5em]
    \parbox{9em}{\centering Avg. Rate of Change\\ with respect to $r$}
    $\displaystyle=\frac{\Delta A}{\Delta r}=\frac{A(r_2)-A(r_1)}{r_2-r_1}
    =\frac{\pi(2.5)^2-\pi(2)^2}{2.5-2}=\frac{\pi(6.25-4)}{0.5}=4.5\pi\,\frac{\text{cm}^2}{\text{cm}}$
  \item The instantaneous rate of change of area with respect to radius when $r=2$ cm is:\\[.5em]
    $\begin{aligned}[t] \lim_{\Delta r\to 0}\frac{A(r+\Delta r)-A(r)}{\Delta r}
      &=\lim_{\Delta r\to 0}\frac{A(2+\Delta r)-A(2)}{\Delta r}
      =\lim_{\Delta r\to 0}\frac{\pi(2+\Delta r)^2-\pi(2)^2}{\Delta r}\\
      &=\lim_{\Delta r\to 0}\frac{\pi(4+4\Delta r+\Delta r^2)-4\pi}{\Delta r}
      =\lim_{\Delta r\to 0}\frac{\pi\Delta r(4+\Delta r)}{\Delta r}\\
      &=\lim_{\Delta r\to 0}\pi(4+\Delta r)=\pi(4+0)=4\pi\,\frac{\text{cm}^2}{\text{cm}}
    \end{aligned}$
  \end{enumerate}
\end{solution*}

\begin{furtherquestion}
  A spherical cell has approximate volume of $V=\frac{4}{3}\pi r^3$ which increases as it grows.
  \begin{enumerate}
    \item Find the average rate of change of the volume of the cell with respect to its radius $r$ as $r$ changes from $5\,\mu\mbox{m}$ to $7\,\mu\mbox{m}$\,.
    \item Find the rate of change of volume with respect to radius $r$ when $r=5\ \mu\mbox{m}$\,. 
    \end{enumerate}
    (Note 1 micrometre ($\mu\mbox{m}$) equals $1\times 10^{-6}\mbox{m}$.)
    \end{furtherquestion}
\end{example}

\begin{exercise}
\inputandlabel{DIFFERENTIATION/average-and-instantaneous-rate-of-change}
\end{exercise}

\section{The Derivative}

The preceding examples of the tangent slope, velocity, and more generally rate of change illustrate the value in defining (and calculating) the following limit of a function $f(x)$.

\definition{The \textbf{derivative} of a function $f$ at a value $x=a$, denoted by $f'(a)$, is
\[f'(a)=\mylim{h}{0}\frac{f(a+h)-f(a)}{h}\]
provided the limit exists.}

As we saw when formulating the tangent to a curve an equivalent definition is
\[f'(a)=\mylim{x}{a}\frac{f(x)-f(a)}{x-a}\]


\begin{example}
  Find the derivative of $f(x) = 2 + \sqrt{2x}$ at $x=a$\,. 

  \begin{solution*}
    \begin{align*}f'(x) &= \lim_{h\to 0}\frac{f(x+h)-f(x)}{h}
      = \lim_{h\to0}\frac{\left(2+\sqrt{2(x+h)}\right)-\left(2+\sqrt{2x}\right)}{h}
      = \lim_{h\to0}\frac{2+\sqrt{2x+2h}-2-\sqrt{2x}}{h}\\
      &= \lim_{h\to0}\frac{\sqrt{2x+2h}-\sqrt{2x}}{h}\cdot\frac{\sqrt{2x+2h} +
        \sqrt{2x}}{\sqrt{2x+2h}+\sqrt{2x}}
      = \lim_{h\to0}\frac{2x+2h-2x}{h\left(\sqrt{2x+2h}+\sqrt{2x}\right)}\\
      &= \lim_{h\to0}\frac{2h}{h\left(\sqrt{2x+2h}+\sqrt{2x}\right)}
      = \lim_{h\to0}\frac{2}{\sqrt{2x+2h}+\sqrt{2x}}
      = \frac{2}{\sqrt{2x+2(0)}+\sqrt{2x}}\\
      &= \frac{2}{\sqrt{2x}+\sqrt{2x}}
      = \frac{2}{2\sqrt{2x}}
      = \frac{1}{\sqrt{2x}}\end{align*}
  \end{solution*}

\begin{furtherquestion}
Find the derivative of $\displaystyle f(x)=\frac{1}{x^2+1}$ at $x=a$.
\end{furtherquestion}
\end{example}


Note the following regarding $f'(a)$, the derivative of $f(x)$ at $x=a$,
\begin{enumerate}
\item $f'(a)$, is the \textbf{slope of the tangent} line at $P(a,f(a))$\,.

It follows that if $f'(a)$ exists then the equation of the tangent line to the curve $y=f(x)$ at the point $P(a,f(a))$ is 
\[y=f'(a)(x-a)+f(a)~.\]

\item If $s=f(t)$ is the position function of an object moving in one spatial dimension, then $f'(a)$ is the \textbf{velocity} of an object at time $t=a$\,.

\item $f'(a)$ is, in general, the \textbf{rate of change} of $y=f(x)$ with respect to $x$ when $x=a$\,.

\end{enumerate}
If we replace $a$ by $x$ in the definition of the derivative, we have the following.

\definition{For a given function $f(x)$ the \textbf{derivative function} is given by
\[f'(x)=\mylim{h}{0}\frac{f(x+h)-f(x)}{h}\]
}

In words, associated with any function $f$ there is a corresponding
function $f'(x)$ whose evaluation gives the value of the derivative of
the function $f$ at any value $x$ of interest.

\begin{example}
  If $\displaystyle f(x) = \frac{1}{x+3}+1$ find $f'(x)$ using the limit definition.

  \begin{solution*}
    \begin{align*}f'(x) &= \lim_{h\to 0} \frac{\left(\frac{1}{(x+h)+3}+1\right) - \left(\frac{1}{x+3}+1\right)}{h}
                          = \lim_{h\to0}\frac{\frac{1}{x+h+3}-\frac{1}{x+3}}{h}
                          = \lim_{h\to0}\frac{1}{h}\left(\frac{1}{x+h+3}-\frac{1}{x+3}\right)\\
                        &= \lim_{h\to0}\frac{1}{h}\cdot\frac{1(x+3)-1(x+h+3)}{(x+h+3)(x+3)}
                          = \lim_{h\to 0}\frac{-h}{h(x+h+3)(x+3)}= \lim_{h\to 0}\frac{-1}{(x+h+3)(x+3)}\\
                        &= -\frac{1}{(x+0+3)(x+3)} = -\frac{1}{(x+3)^2}
    \end{align*}
  \end{solution*}

\begin{furtherquestion}
If $\displaystyle f(x)=\sqrt{x-1}$, find $f'(x)$.
\end{furtherquestion}
\end{example}

The following diagram illustrates the meaning of the derivative function $f'(x)$
graphically.  Each $x$ value has an associated point $P$ through which there is a unique tangent with the slope given by $f'(x)$.
\begin{center}
\includegraphics{graphics/differentiation2}%
\end{center}

\textbook{\clearpage}
\subsubsection*{Derivative Notation}
In addition to $f'$ the derivative of the function $y=f(x)$ may be denoted by

\hfil $\displaystyle y'$\hfil$\displaystyle\frac{dy}{dx}$\hfil$\displaystyle\frac{df}{dx}$\hfil$\displaystyle\frac{d}{dx}f$\hfil$\displaystyle Df$\hfil$\displaystyle D_xf$\hfil

All of these are equal but have their uses in different contexts.  The notation $\frac{dy}{dx}$, introduced by Gottfried Leibniz, clearly embodies the idea of the slope $\left(\frac{\Delta y}{\Delta x}\right)$.  To write $f'(a)$ in this notation we often write $\left.\frac{dy}{dx}\right|_{x=a}$ where the right bar means ``evaluated at''. The last three notations reflect the idea of differentiation as an \textbf{operation} on a function.  So $\frac{d}{dx}$ is to be understood as an operator that acts on the function following it to differentiate it.  In this notation, using our last example, we could write:

\[\frac{d}{dx}\left(\sqrt{x-1}\,\right)=\frac{1}{2\sqrt{x-1}}\]

Notice how, in this notation, no reference must be made to a $y$ or an $f$.

\definition{If $f'(a)$ exists, then function $f$ is said to be \textbf{differentiable at} $\bm{a}$\,.}

\definition{A function $f$ is \textbf{differentiable on an interval} $\bm{(a,b)}$ if it is differentiable at every value in $(a,b)$.} 

\theorem{\label{tmpthm}If function $f(x)$ is differentiable at $x=a$ then $f$ is continuous at $x=a$ .}

Note the converse (``If $f$ is continuous at $a$ then $f$ is differentiable $a$'') is \textbf{not} true.

\begin{example}
The absolute value function $f(x)=|x|$ is not differentiable at $x=0$ despite being continuous there.
\end{example}

Since the derivative is the slope of the tangent to $y=f(x)$ several ways $f$ may fail to be differentiable at a value $x=a$ occur are:
\begin{enumerate}
\item The graph has a corner at $(a,f(a))$.
\item The graph has a discontinuity at $x=a$
\item The graph has a vertical tangent line at $(a,f(a))$. (infinite slope)
\end{enumerate}
These situations are illustrated below.  Notice in the first and last example the function is continuous at $a$.
\begin{center}
\includegraphics{graphics/differentiation3}%
\hfil
\includegraphics{graphics/differentiation4}%
\hfil
\includegraphics{graphics/differentiation5}%
\end{center}

\begin{example}
For the graphically defined function:
\begin{center}
\includegraphics[width=4.5in]{graphics/differentiation6}
\end{center}
\begin{enumerate}
\item List all values of $x$ at which $f(x)$ fails to be continuous.%\newline
\item List all values of $x$ at which $f(x)$ fails to be differentiable.%\newline
\end{enumerate}
\hfil\rotatebox[origin=c]{180}{\parbox{35em}{\small
    \begin{enumerate}\item (Answer: $x=-1$, $x=2$, $x=5$)
  \item (Answer: $x=-1$, $x=2$, $x=3$, $x=5$)
  \end{enumerate}}}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{DIFFERENTIATION/definition-of-derivative}
\input{DIFFERENTIATION/derivative-function}
\end{exercise}

\section{Differentiation Formulae}

Several theorems for the derivatives of functions will now be introduced which will allow us to find the derivative of a function without having to resort to the limit definition.

\theorem{If $f$ is a constant function, $f(x)=c$, then

\hfil $f'(x)=0$\hspace{3em} or\hspace{3em}$\displaystyle\frac{d}{dx}(c)=0$}

\begin{example}
\hfil$\displaystyle\frac{d}{dx}(5)=0$,\hfil$\displaystyle (\pi)'=0$,\hfil$\displaystyle\frac{d}{dx}(-20)=0$,\hfil$\displaystyle\left(-\frac{2}{3}\right)'=0$\hfil
\end{example}

\theorem{If $f$ is a power function, $f(x)=x^n$, where $n$ is any real number, then

\hfil $\displaystyle f'(x)=nx^{n-1}$ \hspace{3em} or\hspace{3em}$\displaystyle\frac{d}{dx}(x^n)=nx^{n-1}$\hfil}

This is known as the \textbf{Power Rule}.

Note as a particular example of the last theorem, when $n=1$ we have $f(x)=x$ and 
\[f'(x)=1x^{1-1}=x^0=1~.\]
In Leibniz notation this is easy to remember $\frac{d}{dx}x=1$ because $\frac{dx}{dx}$ should be 1!

The last theorem can be demonstrated from first principles as demonstrated in the following examples.

\begin{example}
  Use the definition of the derivative to prove the power function
  derivative $\displaystyle \frac{d}{dx}\left(x^2\right)=2x$\,.

  \begin{solution}
    If $f(x)=x^2$ then
    \begin{align*}
      f'(x)&=\lim_{h\to0}\frac{(x+h)^2-x^2}{h}=\lim_{h\to0}\frac{x^2+2xh+h^2-x^2}{h}=\lim_{h\to0}\frac{h(2x+h)}{h}\\
           &=\lim_{h\to0}(2x+h)=2x+0=2x
    \end{align*}
  \end{solution}

  \begin{furtherquestion}
    Use the definition of the derivative to prove the power function
    derivative
    $\displaystyle\frac{d}{dx}\left(\frac{1}{x}\right)=-\frac{1}{x^2}$\,.\\
    (Recall $\displaystyle\frac{1}{x}=x^{-1}$ so this is a power function.)
  \end{furtherquestion}

\end{example}

\textbook{\clearpage}
\begin{method}
Differentiation involving the Power Rule often requires rewriting an expression as a power.  Here is a summary of some relevant identities involving powers:
\begin{eqnarray*}
x^0 & = & 1\\
x^m\cdot x^n & = & x^{m+n} \\
\frac{x^m}{x^n} & = & x^{m-n} \\
\sqrt[n]{x} & = & x^{\frac{1}{n}} \\
\frac{1}{x^n} & = & x^{-n} \\
(x^m)^n & = & x^{mn} \\
(xy)^n & = & x^ny^n \\
\left(\frac{x}{y}\right)^n & = & \frac{x^n}{y^n}
\end{eqnarray*}
\end{method}

\begin{example}
  Use the Power Rule directly to find the following derivatives.
  \begin{enumerate}
  \item $\displaystyle \left(x^4\right)'$
  \item $\displaystyle \frac{d}{dt}\left(\sqrt[3]{t^2}\right)$
  \item $\displaystyle \frac{d}{dx}\left(\frac{1}{x^c}\right)$\ \ Here $c$ is a constant.
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle \left(x^4\right)'=4x^{4-1}=4x^3$
    \item $\displaystyle \frac{d}{dt}\left(\sqrt[3]{t^2}\right)=\frac{d}{dt}\left(t^2\right)^{\frac{1}{3}}
      =\frac{d}{dt}\left(t^{\frac{2}{3}}\right)=\frac{2}{3}t^{\frac{2}{3}-1}=\frac{2}{3}t^{\frac{2}{3}-\frac{3}{3}}
      =\frac{2}{3}t^{-\frac{1}{3}}=\frac{2}{3t^{\frac{1}{3}}}=\frac{2}{3\sqrt[3]{t}}$
    \item $\displaystyle \frac{d}{dx}\left(\frac{1}{x^c}\right)=\frac{d}{dx}\left(x^{-c}\right)=-cx^{-c-1}=-cx^{-(c+1)}=-\frac{c}{x^{c+1}}$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Use the Power Rule directly to find the following derivatives.
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle \frac{d}{dx}\left(x^5\right)$
\item $\displaystyle \left(\frac{1}{x^{10}}\right)'$
\item $\displaystyle \left(\sqrt[5]{x}\right)'$
\item $\displaystyle \left(\frac{1}{\sqrt{x}}\right)'$
\item $\displaystyle \frac{d}{dx}\left(x^{23}\right)$
\item $\displaystyle \frac{d}{dt}\left(t^{\pi}\right)$
\item $\displaystyle \frac{d}{dy}\left(y^{\sqrt{3}}\right)$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

\theorem{Suppose $c$ is a constant and $f'(x)$, $g'(x)$ exist at a value $x$.
\begin{enumerate}
\item If $h(x)=cf(x)$, then $h'(x)$ exists and $h'(x)=cf'(x)$.  Equivalently:

\hfil $\displaystyle (cf)'=cf'$\hspace{3em} or\hspace{3em}$\displaystyle \frac{d}{dx}\left(cf\right)=c\frac{df}{dx}$\hfil

\item If $h(x)=f(x)+g(x)$, then $h'(x)$ exists and $h'(x)=f'(x)+g'(x)$.  Equivalently:

\hfil $\displaystyle (f+g)'=f'+g'$\hspace{3em} or\hspace{3em}$\displaystyle \frac{d}{dx}\left(f+g\right)=\frac{df}{dx}+\frac{dg}{dx}$\hfil

\item If $h(x)=f(x)-g(x)$, then $h'(x)$ exists and $h'(x)=f'(x)-g'(x)$.  Equivalently:

\hfil $\displaystyle (f-g)'=f'-g'$\hspace{3em} or\hspace{3em}$\displaystyle \frac{d}{dx}\left(f-g\right)=\frac{df}{dx}-\frac{dg}{dx}$\hfil

\end{enumerate}
}
We note in the previous theorem that the functions $f$ and $g$ need not be differentiable everywhere -- the theorem applies wherever their derivatives exist.  Also it follows from the theorem that the result may be generalized to sums or differences of a finite number of terms. (i.e. $(f+g\ldots +h)'=f'+g'+\ldots+h'$, etc.)  Mathematically, the previous theorem shows that differentiation is a \textbf{linear operation}.

\begin{example}
  Use the previous theorems to evaluate the following derivatives directly.
  \begin{enumerate}
  \item $\displaystyle \frac{d}{dx}\left(4\sqrt{x}\right)$
  \item $\displaystyle g'(t)\ \text{if}\ g(t) = 4t+\frac{1}{4t}$ 
  \item $\displaystyle y'\ \text{if}\ y=m(x-x_0)+y_0$\ \
    Here $m$, $x_0$, and $y_0$ are the straight line constants.
  \end{enumerate}
  
  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle \frac{d}{dx}\left(4\sqrt{x}\right)
      =4\frac{d}{dx}\left(x^{\frac{1}{2}}\right)
      =4\left(\frac{1}{2}\right)x^{-\frac{1}{2}}=\frac{2}{\sqrt{x}}$
    \item $\displaystyle g'(t) = \left(4t^1+\frac{1}{4}\cdot\frac{1}{t}\right)'
      =4\left(t^1\right)'+\frac{1}{4}\left(t^{-1}\right)'
      =4(1)t^0+\frac{1}{4}(-1)t^{-2}=4-\frac{1}{4t^2}$
    \item $\displaystyle y'=\left[m(x-x_0)+y_0\right]'=\left[mx^1-mx_0+y_0\right]'=m(1)x^0+0+0=m(1)=m$\\[1em]
      In other words we found that the slope of the tangent line to any
      point on a line is just the slope $m$ of the line, which of course
      it is since the tangent line to any point on a straight line will just
      be the straight line itself.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Use the previous theorems to evaluate the following derivatives directly:
\begin{enumerate}
  \begin{multicols}{2}
\item $\displaystyle\frac{d}{dx}\left(3x^4\right)$
\item $\displaystyle\frac{d}{dx}\left(-5x^2\right)$
\item $\displaystyle\frac{d}{dx}\left(2x^2-3x+1\right)$
\item $\displaystyle y'$ if $\displaystyle y=\frac{3x^3-x^2+5}{x}$
\item $f'(x)$ if $\displaystyle f(x)=x^4-\frac{3}{x^2}+\sqrt[5]{x}+\frac{2\sqrt{x}}{x}$
\item $\displaystyle\frac{d}{dx}\left(\frac{x^{a^2+2}}{\pi+\ln5}+\frac{2e}{x^b}\right)$% (Note everything except $x$ here are just constants!)
  \end{multicols}
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{DIFFERENTIATION/DRpower-sums-constant-multiple}
\input{DIFFERENTIATION/rates-of-change}
\end{exercise}

\section{Product and Quotient Rules}
% The form of these rules is debatable.  We have chosen to keep the order
% of products in terms alphabetical and the order of the two terms in the
% product rule the same as the quotient rule (to facilitate memorization).
% Obviously there is some merit in keeping the derivatives always as the
% last term to prevent it being misapplied.  In favour of our notation also
% is the derivative of three factors (fgh)'=f'gh+fg'h+fgh' which naturally
% generalization from this form chosen below.
\theorem{If $h(x)=f(x)g(x)$ and $f'(x)$ and $g'(x)$ exist at a value $x$ then \mbox{$h'(x)=f'(x)g(x)+f(x)g'(x)$}~. Equivalently:

\hfil $\displaystyle (fg)'=f'g+fg'$\hspace{3em} or\hspace{3em}$\displaystyle \frac{d}{dx}\left(fg\right)=\frac{df}{dx}g+f\frac{dg}{dx}$\hfil

This is known as the \textbf{Product Rule}.}\footnote{
% Petry: I put this as a footnote because otherwise it messed up my pages and I wanted to squeeze everything into the same pages without reprinting the whole second version.
To prove the Product Rule we use our limit theorems as follows.  For clarity call $H(x)=f(x)g(x)$.
\begin{eqnarray*}
H'(x) & = & \lim_{h\rightarrow0}\frac{H(x+h)-H(x)}{h} \\
& = &  \lim_{h\rightarrow0}\frac{f(x+h)g(x+h)-f(x)g(x)}{h} \\
& = &  \lim_{h\rightarrow0}\frac{f(x+h)g(x+h)-f(x)g(x+h)+f(x)g(x+h)-f(x)g(x)}{h} \\
& = &  \lim_{h\rightarrow0}\left[\frac{f(x+h)-f(x)}{h}g(x+h)+f(x)\frac{g(x+h)-g(x)}{h}\right] \\
& = & \lim_{h\rightarrow0}\frac{f(x+h)-f(x)}{h}\cdot\lim_{h\rightarrow0}g(x+h)+\lim_{h\rightarrow0}f(x)\cdot\lim_{h\rightarrow0}\frac{g(x+h)-g(x)}{h} \\
& = & f'(x)g(x)+f(x)g'(x)
\end{eqnarray*}

Note that since $g$ is differentiable at $x$ it is continuous at $x$ and so $\displaystyle\lim_{h\rightarrow0}g(x+h)=g(x)$ follows.}

Note:
\begin{itemize}
\item The derivative of the product is \textbf{not} the product of the derivatives, $(fg)'\neq f'g'$~!
\item Memorize the product rule in words, namely
\begin{quote}
``\emph{The derivative of a product is the derivative of the  first function times the second plus the first times the derivative of the second.}''
\end{quote}
\end{itemize}

\begin{example}
  Use the Product Rule in evaluating the following:
  \begin{enumerate}
  \item If $\displaystyle f(t)=\left(\frac{1}{t}+t\right)\left(\frac{3}{t^2}+2t^3\right)$ find $\diff{f}{t}$\,.
  \item If $\displaystyle y=x^3\left(\frac{x^4+1}{\sqrt{x}}\right)$ find $y'$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t]\diff{f}{t}&=\frac{d}{dt}\left[\left(t^{-1}+t^1\right)\left(3t^{-2}+2t^3\right)\right]
        =\frac{d}{dt}\left(t^{-1}+t^1\right)\cdot\left(3t^{-2}+2t^3\right)
        +\left(t^{-1}+t^1\right)\cdot\frac{d}{dt}\left(3t^{-2}+2t^3\right) \\
        &=\left[(-1)t^{-2}+1t^0\right]\left(3t^{-2}+2t^3\right)
        +\left(t^{-1}+t^1\right)\left[3(-2)t^{-3}+2(3)t^2\right] \\
        &=\left(-t^{-2}+1\right)\left(3t^{-2}+2t^3\right)
        +\left(t^{-1}+t^1\right)\left(-6t^{-3}+6t^2\right)
      \end{aligned}$
    \item $\begin{aligned}[t] y'&=\left[x^3\left(\frac{x^4+1}{\sqrt{x}}\right)\right]'
        =\left[x^3\left(\frac{x^4}{\sqrt{x}}+\frac{1}{\sqrt{x}}\right)\right]'
        =\left[x^3\left(\frac{x^4}{x^{\frac{1}{2}}}+\frac{1}{x^{\frac{1}{2}}}\right)\right]'
        =\left[x^3\left(x^{\frac{7}{2}}+x^{-\frac{1}{2}}\right)\right]'\\
        &=(3x^2)\left(x^{\frac{7}{2}}+x^{-\frac{1}{2}}\right)+(x^3)\left(\frac{7}{2}x^{\frac{5}{2}}-\frac{1}{2}x^{-\frac{3}{2}}\right)
      \end{aligned}$
    \end{enumerate}
  \end{solution*}

\textbook{\clearpage}
\begin{furtherquestions}
Use the Product Rule to evaluate the following:
\begin{enumerate}
\item If $f(x)=x^2$, $g(x)=x^3$, and $h(x)=f(x)g(x)=x^5$, find $h'(x)$ directly and using the Product Rule.  Confirm that $h'(x)$ is not the product $f'(x)g'(x)$.
\item If $\displaystyle y=(x^2+3x+1)(x^3-2)$, find $y'$.
\item If $\displaystyle f(t)=(t^6-2t^3+t^2-3)(\sqrt{t}-2)$, find $f'(t)$.
\item Evaluate $\displaystyle\frac{d}{dz}\left[\left(\frac{1}{z^4}-2z^3+\sqrt{z}\right)\left(z^2+5\right)\right]$
\item If $\displaystyle g(z)=\left(\frac{1}{z}+\frac{2}{z^5}\right)\left(z^3-4z^2+10\right)$, find $\frac{dg}{dz}$.
\end{enumerate}
\end{furtherquestions}
\end{example}

\theorem{If $\displaystyle h(x)=\frac{f(x)}{g(x)}$ with $g(x)\neq0$ and $f'(x)$ and $g'(x)$ exist at a value $x$ then
\[h'(x)=\frac{f'(x)g(x)-f(x)g'(x)}{\left[g(x)\right]^2}~.\]
 Equivalently:

\hfil $\displaystyle \left(\frac{f}{g}\right)'=\frac{f'g-fg'}{g^2}$\hspace{3em} or\hspace{3em}$\displaystyle \frac{d}{dx}\left(\frac{f}{g}\right)=\frac{\frac{df}{dx}g-f\frac{dg}{dx}}{g^2}$\hfil

This is known as the \textbf{Quotient Rule}.}

Note:
\begin{itemize}
\item The derivative of a quotient is \textbf{not} equal to the quotient of the derivatives, $\displaystyle \left(\frac{f}{g}\right)'\neq\frac{f'}{g'}$~.
\item The quotient rule is not symmetric under interchange of $f\leftrightarrow g$ like the product rule is because $f/g\neq g/f$.  The numerator includes a minus sign (so order matters) and only the original denominator appears in the denominator of the result.
\item Memorize in words:
\begin{quote}
``\emph{The derivative of a quotient equals the the derivative of the top times the bottom minus the top times the derivative of the bottom all over the bottom squared.}''
\end{quote}
\end{itemize}

\textbook{\clearpage}
\begin{example}
  Evaluate the following derivatives using the Quotient Rule.
  \begin{enumerate}
  \item If $\displaystyle h(y)= \frac{y^2+5}{y+2}$ find $h'(y)$ 
  \item If $\displaystyle y=\frac{x^2+2x}{\sqrt[4]{x}+9}$ find $\diff{y}{x}$
  \end{enumerate}
  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t]\displaystyle h'(y) &= \frac{(y^2+5)'(y+2)-(y^2+5)(y+2)'}{(y+2)^2}
        =\frac{2y(y+2)-(y^2+5)(1)}{(y+2)^2} = \frac{2y^2+4y-y^2-5}{(y+2)^2}\\
        & = \frac{y^2+4y-5}{(y+2)^2}\end{aligned}$
    \item $\begin{aligned}[t] \diff{y}{x} &=\frac{\frac{d}{dx}\left(x^2+2x\right)\cdot\left(x^{\frac{1}{4}}+9\right)+\left(x^2+9\right)\cdot\frac{d}{dx}\left(x^{\frac{1}{4}}+9\right)}{\left(x^{\frac{1}{4}}+9\right)^2}\\
        &=\frac{\left(2x+2\right)\left(x^{\frac{1}{4}}+9\right)+\left(x^2+9\right)\left(\frac{1}{4}x^{-\frac{3}{4}}\right)}{\left(x^{\frac{1}{4}}+9\right)^2}\end{aligned}$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following derivatives using the Quotient Rule.
\begin{enumerate}
\item If $\displaystyle f(x)=\frac{x^2-3x+5}{x-1}$ find $f'(x)$\,.
\item If $\displaystyle g(t)=\frac{t^4+2t}{t^3-5t^2+5}$ find $\displaystyle\frac{dg}{dt}$\,.
\item Evaluate $\displaystyle\frac{d}{dz}\left(\frac{\sqrt{z}+1}{z^2+5}\right)$\,.
\end{enumerate}
\end{furtherquestions}
\end{example}

When differentiating products and quotients where one of the functions is a constant function it is much easier to pull the constant out front directly using our constant rule $(cf)'=cf'$\,.

\begin{example}
You do not need to use the quotient rule to evaluate the following derivative with a constant denominator:

$\displaystyle\frac{d}{dx}\left(\frac{x^2}{2}\right)=\frac{d}{dx}\left(\frac{1}{2}x^2\right)=\frac{1}{2}\frac{d}{dx}\left(x^2\right)=\frac{1}{2}(2x^1)=x$\,.

If one evaluates this using the quotient rule a zero arises due to the differentiation of the constant.
\end{example}

\textbook{\clearpage}
As with the other rules, the product and quotient rules may need to both be applied or applied repeatedly when evaluating a given derivative.

\begin{example}
  Differentiate $\displaystyle f(x)=(x^2)\left(\sqrt{x}-\frac{1}{x}\right)(3x+7)$
  
  \begin{solution}
    $\begin{aligned}[t]f'(x)&=\left[\underbrace{(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)}\underbrace{(3x+7)\rule[-.65em]{0em}{0em}}\right]'\
      \Leftarrow\ \text{Apply Product Rule on braced factors.}\\
      &=\left[(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)\right]'(3x+7)
      +\left[(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)\right](3x+7)'\\
      &=\left[(x^2)'\left(x^{\frac{1}{2}}-x^{-1}\right)+(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)'\right](3x+7)
      +\left[(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)\right](3x+7)'\\
      &=(x^2)'\left(x^{\frac{1}{2}}-x^{-1}\right)(3x+7)+(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)'(3x+7)+(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)(3x+7)'\\
      &=(2x)\left(x^{\frac{1}{2}}-x^{-1}\right)(3x+7)+(x^2)\left(\frac{1}{2}x^{-\frac{1}{2}}+x^{-2}\right)(3x+7)+(x^2)\left(x^{\frac{1}{2}}-x^{-1}\right)(3)\\
      &=2x\left(x^{\frac{1}{2}}-x^{-1}\right)(3x+7)+x^2\left(\frac{1}{2}x^{-\frac{1}{2}}+x^{-2}\right)(3x+7)+3x^2\left(x^{\frac{1}{2}}-x^{-1}\right)
    \end{aligned}$
  \end{solution}

\begin{furtherquestions}
Differentiate the following functions:
\begin{enumerate}
\item $\displaystyle f(x)=\frac{\left(\sqrt{x}+1\right)\left(x^2-3x+1\right)}{x^3+4}$
\item $\displaystyle g(x)=\left(\sqrt[3]{x}+1\right)\left(x^3+4x^2-4\right)\left(x^2+1\right)$
\end{enumerate}
\end{furtherquestions}
\end{example}
As the last example shows one can generalize the Product Rule to three (or more) terms as follows $(fgh)'=f'gh+fg'h+fgh'$, etc.

\begin{exercise}
\input{DIFFERENTIATION/DRproducts-and-quotients}
\end{exercise}

\section[Further Geometrical Applications]{Further Geometrical Applications of the Derivative}
Note the following properties of the slope of a line:
\begin{itemize}
\item The slope of \textbf{horizontal} line is \textbf{zero} ($\bm{m=0}$).
\item If two lines are \textbf{parallel} then their slopes are \textbf{equal} ($\bm{m_1=m_2}$)
\item If two lines are \textbf{perpendicular} then their slopes satisfy $\boxed{\bm{m_1\cdot m_2=-1}}$, that is they are the \textbf{negative reciprocals of each other}, $\displaystyle \left(\bm{m_2=-\frac{1}{m_1}\right})$. 
\end{itemize}

\definition{The \textbf{normal line} to a curve at point $P$ is the line through $P$ perpendicular to the tangent~line.}

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

With these definitions in mind we can solve various problems arising from geometry, keeping in mind that the derivative at $x$ gives the slope of the tangent at $P(x,f(x))$.
\begin{example}
  \begin{enumerate}
  \item Find the equation of the normal line to the curve $y=3x^2-8x+2$ at $P(1,-3)$\,.
  \item At what point does the previous curve have a horizontal tangent?
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t] y'=6x-8&\implies m_t=y'(1)=6(1)-8=-2\implies m_n=-\frac{1}{m_t}=-\frac{1}{(-2)}=\frac{1}{2}\\
        y=m(x-x_0)+y_0&\implies y=\frac{1}{2}(x-1)-3\ \ (\text{Point-Slope Form})\\
        &\implies y=\frac{1}{2}x-\frac{7}{2}\ \ (\text{Slope-Intercept Form})
      \end{aligned}$
    \item Horizontal tangent implies slope $m_t=0$\,.  Since the slope of the tangent is the derivative,\\
      $\displaystyle 0=y'=6x-8\implies 6x=8\implies x=\frac{4}{3}$\,.
      The $y$-coordinate is\\[.5em]
      $\displaystyle y=3\left(\frac{4}{3}\right)^2-8\left(\frac{4}{3}\right)+2=\frac{16-32+6}{3}=-\frac{10}{3}$,\\[.5em]
      so at the point $P(4/3,-10/3)$ the tangent line is horizontal.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions*}
\begin{enumerate}
\item Find the equation of the tangent and normal lines to the curve $y=2x^3+3x^2-2$ when $x=1$.
\item For what values of $x$ does the graph of $f(x)=2x^3-3x^2-6x+87$ have a horizontal tangent line?
\item Find a tangent line to the graph of $y=3x^2+4x-6$ that is parallel to the line $5x-2y-1=0$.
\end{enumerate}
\end{furtherquestions*}
\end{example}

\begin{exercise}
\input{DIFFERENTIATION/parallel-perpendicular-normal}
\end{exercise}

\section{General Power Rule}
\theorem{If $n$ is any real number and $f(x)$ is differentiable at $x$ then
\[\frac{d}{dx}\left[f(x)\right]^n=n\left[f(x)\right]^{n-1}f'(x)~.\]}
This is the \textbf{General Power Rule}.\footnote{For positive integer $n$ the General Power Rule follows from the generalized Product Rule since
\[\left(\left[f(x)\right]^n\right)' = [\underbrace{f(x)f(x)\cdots f(x)}_{\mbox{\tiny $n$ factors}}]'=\underbrace{f'(x)f(x)\cdots f(x) + f(x)f'(x)\cdots f(x) + \cdots + f(x)f(x)\cdots f'(x)}_{\mbox{\tiny n equal terms}} = n\left[f(x)\right]^{n-1}f'(x)~.\]
The rule is also just a special case of the Chain Rule (Section~\ref{sec:chainrule}) with the outer function taken to be $f(u)=u^n$ so that $\displaystyle\frac{d}{dx}u^n=nu^{n-1}\cdot\frac{du}{dx}$\,.}

\begin{example}
  Differentiate the following:
  \begin{enumerate}
  \item $\displaystyle F(t) = \sqrt{t^2+3t+2}$ 
  \item $\displaystyle f(x) = (2x+3)^2(x+5)$
  \item $\displaystyle y=\frac{3}{\left(\sqrt{x}+7x\right)^3}$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle F'(t)=\left[\left(t^2+3t+2\right)^{\frac{1}{2}}\right]'=\frac{1}{2}(t^2+3t+2)^{-\frac{1}{2}}(2t+3) =
      \frac{2t+3}{2\sqrt{t^2+3t+2}}$
    \item $\begin{aligned}[t] f'(x) & = \left[(2x+3)^2\right]'(x+5)+(2x+3)^2(x+5)' \ \ \Leftarrow\text{Apply Product Rule First}\\
        &= 2(2x+3)^1(2)(x+5)+(2x+3)^2(1+0) \\
        &= 4(2x+3)(x+5)+(2x+3)^2 =(2x+3)(4x+20+2x+3) =(2x+3)(6x+23)
      \end{aligned}$
    \item $\begin{aligned}[t] y' &=\left[3\left(x^{\frac{1}{2}}+7x\right)^{-3}\right]'
        =3(-3)\left(x^{\frac{1}{2}}+7x\right)^{-4}\cdot\left(\frac{1}{2}x^{-\frac{1}{2}}+7\right)
        =-\frac{9}{\left(\sqrt{x}+7x\right)^{4}}\left(\frac{1}{2\sqrt{x}}+7\right)
      \end{aligned}$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Differentiate the following:
\begin{enumerate}
\item $\displaystyle y=\left(x^2-2x+5\right)^8$
\item $\displaystyle y=\frac{2}{\sqrt{x^3-2x^2+3}}$
\item $\displaystyle f(t)=\left[\frac{1}{t}+\left(2-t\right)^5\right]^{-4}$
\item $\displaystyle g(x)=\frac{\left(x^2+3\right)^5}{\sqrt[3]{x+1}}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}% Required for proper exercise answer label.
\begin{exercise}
\input{DIFFERENTIATION/DRgeneral-power-rule}
\end{exercise}

\section[Trigonometric Derivatives]{Derivatives of Trigonometric Functions}
Using our derivative laws, the trigonometric identities, and recalling the following trigonometric limits,

\hfil $\displaystyle\mylim{\theta}{0}\sin \theta=0$ \hfil
$\displaystyle\mylim{\theta}{0}\cos \theta=1$ \hfil
$\displaystyle\mylim{\theta}{0}\frac{\sin \theta}{\theta}=1$ \hfil
$\displaystyle\mylim{\theta}{0}\frac{1-\cos \theta}{\theta}=0$\ , \hfil

the next result may be shown.

\theorem{The basic trigonometric functions have the following derivatives:
\begin{method}
\vspace{-1em}
\begin{enumerate}
\begin{multicols}{2}
\item $\displaystyle \frac{d}{dx}\left(\sin x\right)=\cos x$
\item $\displaystyle \frac{d}{dx}\left(\cos x\right)=-\sin x$
\item $\displaystyle \frac{d}{dx}\left(\tan x\right)=\sec^2 x$
\item $\displaystyle \frac{d}{dx}\left(\csc x\right)=-\csc x\cot x$
\item $\displaystyle \frac{d}{dx}\left(\sec x\right)=\sec x\tan x$
\item $\displaystyle \frac{d}{dx}\left(\cot x\right)=-\csc^2 x$
\end{multicols}
\end{enumerate}
\end{method}
}
\textbf{Proof}:
\begin{description}
\item[1.] Let $f(x)=\sin x$. Then
\begin{eqnarray*}
f'(x) & = & \mylim{h}{0}\frac{f(x+h)-f(x)}{h} \\ 
 & = & \mylim{h}{0}\frac{\sin(x+h)-\sin x}{h} \\
 & = & \mylim{h}{0}\frac{\sin x\cos h+\cos x\sin h-\sin x}{h}\\
& = & \mylim{h}{0}\left[\sin x \frac{\left(\cos h-1\right)}{h}+\cos x\frac{\sin h}{h}\right]\\
& = & (\sin x)(0)+(\cos x)(1)\\
& = & \cos x
\end{eqnarray*}
\item[3.] $\displaystyle \frac{d}{dx}\left(\tan x\right)=\frac{d}{dx}\left(\frac{\sin x}{\cos x}\right)=\frac{(\cos x)(\cos x)-(\sin x)(-\sin x)}{[\cos x]^2}=\frac{1}{\cos^2x}=\left(\frac{1}{\cos x}\right)^2=\sec^2x$
\item[5.] $\displaystyle \frac{d}{dx}\left(\sec x\right)=\frac{d}{dx}\left(\frac{1}{\cos x}\right)=\frac{d}{dx}\left(\cos x\right)^{-1}=-\left(\cos x\right)^{-2}(-\sin x)=\frac{1}{\cos x}\cdot\frac{\sin x}{\cos x}=\sec x \tan x$
\end{description}

Once the basic trigonometric derivatives are known one may use them to differentiate any function involving a trigonometric function.
\begin{example}
  Evaluate the following:
\textbook{\begin{multicols}{2}}
  \begin{enumerate}
  \item $y'$ if $\displaystyle y=x^3\sec x$
  \item $g'(\theta)$ if $\displaystyle g(\theta) = (3\csc\theta + \sin\theta)^4$ 
  \item $f'(x)$ if $\displaystyle f(x) = \frac{\cos x}{1+\tan x}$
  \item $\diff{H}{z}$ if $\displaystyle H(z) = \left(z^2 + \frac{1}{z^2}+\cot z\right)^{-4}$
  \end{enumerate}
\textbook{\end{multicols}\clearpage}

  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle y'=3x^2\sec x+x^3\sec x\tan x$
    \item $\displaystyle g'(\theta) = 4(3\csc\theta + \sin\theta)^3(-3\csc\theta\cot\theta
      + \cos\theta)$
    \item $\displaystyle f'(x) = \frac{-\sin x(1+\tan x) - \cos x\left(0+ \sec^2x\right)}{(1+\tan x)^2}
      = \frac{-\sin x - \sin x\tan x - \cos x\sec^2
        x}{(1+\tan x)^2}$
    \item $\displaystyle \diff{H}{z} = -4\left(z^2+\frac{1}{z^2}+\cot z\right)^{-5}\left(2z-\frac{2}{z^3}-\csc^2 z\right)$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following:
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle\frac{d}{dx}\left(\sin x\cos x\right)$
\item $\displaystyle \left(\frac{x^2+3}{\sin x}\right)'$
\item $\displaystyle z'$ if $\displaystyle z=\cos^2\theta+\cos\theta$
\item $\displaystyle \frac{dz}{d\theta}$ if $\displaystyle z=\tan^3\theta$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

\begin{example}
  Suppose $f(x)=\sin^3\!\left[g(x)\right]$ and $g(2)=\pi$ and $g'(2)=4$\,.  Find $f'(2)$\,. 

  \begin{solution}
    By the General Power Rule we have, since $\sin^3[g(x)]=\left(\sin[g(x)]\right)^3$\,,\\[.5em]
    $\begin{aligned}[t]
      f'(x)&=3\sin^2\!\left[g(x)\right]\cdot g'(x)\\
      \implies f'(2)&=3\sin^2\!\left[g(2)\right]\cdot g'(2)\\
      &=3\sin^2(\pi)(4)=3(-1)^2(4)=12
    \end{aligned}$
  \end{solution}

\begin{furtherquestion}
Suppose $\displaystyle f\left(\frac{\pi}{3}\right)=4$ and $\displaystyle f'\left(\frac{\pi}{3}\right)=-2$ and let $\displaystyle g(x)=f(x)\sin x$.  Find $\displaystyle g'\left(\frac{\pi}{3}\right)$.
\end{furtherquestion}
\end{example}

% The following is a little too tricky as it requires solving a trig equation
% which requires a little too much discussion at this point.  Perhaps it could
% be replaced by a problem with an easier trig equation which could be solved
% graphically.  I'll copy this to the review questions for now.
\begin{example}
  Find the tangent line to the curve $y=\sin x+2\cos x$ at the point $P(\pi/2,1)$\,.

  \begin{solution*}
    \begin{align*}
      y'=\cos x-2\sin x &\implies m=y'(\pi/2)=\cos(\pi/2)-2\sin(\pi/2)=0-2(1)=-2\\
      y=m(x-x_0)+y_0 &\implies y=-2(x-\pi/2)+1\ \ (\text{Point-Slope Form})\\
      &\implies y=-2x+(\pi+1)\ \ (\text{Slope-Intercept Form})
    \end{align*}
  \end{solution*}

\begin{furtherquestion}
Find the ($x$-coordinates of the) points on the curve $\displaystyle y=\frac{\cos x}{2+\sin x}$ at which the tangent is horizontal.
\end{furtherquestion}
\end{example}

\begin{exercise}
\input{DIFFERENTIATION/DRtrigonometric-functions}
\end{exercise}

\section{\label{sec:chainrule}The Chain Rule}

Suppose
\[\displaystyle h(x)=\sqrt{3x^2+2x+1} \]
  Since $h(x)=\left(3x^2+2x+1\right)^{\frac{1}{2}}$ the derivative could be found using the General Power Rule.  Notice $h(x)$ can be written as a composition of two functions. Let
\[y=f(u)=\sqrt{u}\]
and
\[u=g(x)=3x^2+2x+1\]
then
\[y=h(x)=f\left(g(x)\right)\]
The following rule generalizes the General Power Rule to the case where the external function in the composition (written $f$ here) is an arbitrary differentiable function of $u$, not just $f(u)=u^n$.

\theorem{If the derivatives $g'(x)$ and $f'\left(g(x)\right)$ both
  exist, and $\displaystyle h(x)=f\circ g(x)=f\left(g(x)\right)$ is the composite function then
\[h'(x)=f'\left(g(x)\right)\cdot g'(x)~.\]
Equivalently, if $y=f(u)$ and $u=g(x)$ are both differentiable then this result may also be stated
\[\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}\,,\]
where $\diff{y}{u}$ is evaluated at $g(x)$\,. This is known as the \textbf{Chain Rule}.}

\begin{example}
  Solve the following using the Chain Rule where possible to find the derivatives:
  \begin{multicols}{2}
  \begin{enumerate}
  \item If $\displaystyle y=\cot\left(x^3+5x\right)$ find $y'$\,.
  \item If $\displaystyle y=u^2+2u$ and $u=\sqrt{x}+1$\,:
    \begin{enumerate}
    \item Find $y(x)$\,.
    \item Find $\diff{y}{x}$\,.
    \end{enumerate}
  \item If $\displaystyle M(x) = [\sin x + x^2 + 5]^\frac{3}{4}$ find $M'(x)$ and $M'(0)$\,.
  \item If $\displaystyle g(\theta) = \sqrt{\sin \left(\theta^2+4\right)}$ find $\diff{g}{\theta}$\,.
  \item If $\displaystyle f(x) = \tan^8\!\left(\sqrt{x^3+1}\,\right)$ find $f'(x)$\,.
  \end{enumerate}
  \end{multicols}
  
  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle y'=\left[\cot\left(x^3+5x\right)\right]'
      =\sec^2\!\left(x^3+5x\right)\cdot\left(x^3+5x\right)'
      =\sec^2\!\left(x^3+5x\right)\left(3x^2+5\right)$
      
    \item Since $\displaystyle y=u^2+3u$ and $u=2\sqrt{x}+1$\,,
      \begin{enumerate}
      \item $y(x)=\left(2\sqrt{x}+1\right)^2+3\left(\sqrt{x}+1\right)$
      \item $\diff{y}{x}=\diff{y}{u}\cdot\diff{u}{x}=(2u+3)\left[(2)\left(\frac{1}{2}\right)x^{-\frac{1}{2}}+0\right]
        =\left[2\left(2\sqrt{x}+1\right)+3\right]x^{-\frac{1}{2}}$
      \end{enumerate}
    \item $\displaystyle M'(x) = \frac{3}{4}[\sin x + x^2+5]^{-\frac{1}{4}}(\cos x + 2x)$~~~~
      $\displaystyle M'(0)=\frac{3}{4}[0+0+5]^{-\frac{1}{4}}(1+0)=\frac{3}{4\sqrt[4]{5}}$
    \item In this example we have a composition of three functions and
      must apply the Chain Rule twice.  We show the differentiation at
      each step but once the pattern is observed one can arrive at the
      final line in a single step.
      
      $\begin{aligned}[t]\diff{g}{\theta} &= \frac{d}{d\theta}\left\{\left[\sin\left(\theta^2+4\right)\right]^{\frac{1}{2}}\right\}\\
        &=\frac{1}{2}[\sin\left(\theta^2+4\right)]^{-\frac{1}{2}}\frac{d}{d\theta}\left[\sin\left(\theta^2+4\right)\right]\\
        &=\frac{1}{2}[\sin\left(\theta^2+4\right)]^{-\frac{1}{2}}\cos\left(\theta^2+4\right)\frac{d}{d\theta}\left(\theta^2+4\right)\\
        &= \frac{1}{2}[\sin(\theta^2+4)]^{-\frac{1}{2}}\cos
        (\theta^2+4)(2\theta)=\frac{\theta\cos(\theta^2+4)}{\sqrt{\sin(\theta^2+4)}}\end{aligned}$
    \item $\begin{aligned}[t] f'(x) &= \left[\tan^8\!\left(\sqrt{x^3+1}\,\right)\right]^{'}=8\tan^7\!\left(\sqrt{x^3+1}\,\right)\sec^2\left(\sqrt{x^3+1}\right)\frac{1}{2}\left(x^3+1\right)^{-\frac{1}{2}}(3x^2)\\
        &=\frac{12x^2\tan^7\!\left(\sqrt{x^3+1}\,\right)\sec^2\!\left(\sqrt{x^3+1}\,\right)}{\sqrt{x^3+1}}\end{aligned}$
    \end{enumerate}
  \end{solution*}
  

\begin{furtherquestions}
Solve the following using the \textbf{Chain Rule} where possible to find the derivatives:
\begin{multicols}{2}
\begin{enumerate}
\item If $\displaystyle h(x)=\sqrt{3x^2+2x+1}$ find $h'(x)$~.
\item If $\displaystyle y=u^3+u^2+1$ and $u=(2x^2-1)$,
\begin{enumerate}
\item Find $y(x)$.
\item Find the derivative $\displaystyle\frac{dy}{dx}$~.
\item Find $\displaystyle\left.\frac{dy}{dx}\right|_{x=2}$~.
\end{enumerate}
\item If $\displaystyle y=u^4+3u^2-3$ and $\displaystyle u=\sqrt{x}-1$, find $\displaystyle\frac{dy}{dx}$~.
\item If $h(x)=\cot\left(3x^2+5\right)$ find $h'(x)$~.
\item If $\displaystyle y=5\sqrt[3]{1+\sqrt{t}}$ find $y'$~.
\item If $z=\tan\sqrt{1+x^3}$ find $\displaystyle\frac{dz}{dx}$~.
\item Evaluate $\displaystyle\frac{d}{d\theta}\left(\cos^3\!\theta+\cos\theta^3\right)$~.
\item Evaluate $\displaystyle \left(\sqrt[3]{\frac{x^2+1}{x^3+5x}}\right)'$~.
\item If $\displaystyle y=\frac{1}{\sin\left(x-\sin x\right)}$, find $y'$~.
\item If $h(z)=\left(z^2-4z+5\right)^4\cdot\sec\left(3z\right)$, find $h'(z)$~.
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{DIFFERENTIATION/DRchain-rule}
\end{exercise}

\section{Implicit Differentiation}
When we define $y$ by placing $y$ on one side of the equation and $f(x)$ on the other we say $y$ is $\textbf{explicitly defined}$.
\begin{example}
Explicit:\hfil$\displaystyle y=\sqrt{x^3+1}$\hfil$\displaystyle y=x\cos x$\hfil
\end{example}
On the other hand $y$ may be defined $\textbf{implicitly}$ through any
equation involving $x$ and $y$ with $y$ not-isolated on one side or
the other:
\begin{example}
Implicit:\hfil$\displaystyle y^2-x^3=1$\hfil$x^2+y^2+2xy=10$
\end{example}

In the implicit case the curve is defined by finding points $(x,y)$ that
satisfy the equation.  In the first implicit example the point $(2,3)$ is
on the curve defined by the equation because $3^2-2^3=1$.
Sometimes one may \emph{solve the equation for y} to rewrite an
implicitly defined $y$ as an explicitly defined one, but this is often
not possible.  An explicitly defined equation will always be a
function, whereas a curve defined implicitly will often only be a
relation.  For instance in our first implicit example the point
$(2,-3)$ also lies on the curve so $y$ cannot be described by a
function.  If we tried to solve it for $y$ we would get our first
explicit example, but notice now, since the square root function is
always the positive root, only half of the implicitly defined curve is
present.  ($y=-\sqrt{x^3+1}$ would be a function describing the lower part of the implicit relation.)  The situation is depicted below.
\begin{center}
\hfil
\includegraphics{graphics/differentiation8}%
\hfil
\includegraphics{graphics/differentiation9}%
\hfil~~~
\end{center}

\textbook{\clearpage}
Suppose we wanted the tangent slope at $(2,-3)$ for our implicitly defined example.  An elegant method to find the derivative at this point is to use \textbf{implicit differentiation} which involves the following steps:
\begin{method}
\textbf{Implicit Differentiation}
\begin{enumerate}
\item Differentiate both sides of the equation with respect to $x$.
\item Solve the resulting equation for $y'$.
\end{enumerate}
Differentiating any expression involving only $x$ follows the usual rules.  When differentiating $y$ with respect to $x$ we just get $\frac{d}{dx}y=\frac{dy}{dx}=y'$.  When differentiating a function of $y$ with respect to $x$ the Chain Rule is required:
\[\frac{d}{dx}f(y)=\frac{df}{dy}\cdot\frac{dy}{dx}=f'(y)\cdot y'\]
In other words, differentiate the function of $y$ as you would $x$ but remember to multiply it by $y'$.
\end{method}

The following examples illustrate the procedure.
\begin{example}
  \label{exam:implicit}
  Use implicit differentiation to find $y'$ of the following functions:
  \begin{enumerate}
  \item \label{itm:implicit1} $\displaystyle x^3+y^4=9$
  \item $\displaystyle y^2 + \tan x = 5$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item  Differentiate both sides of equation with respect to $x$\,:
      \begin{align*}
        \frac{d}{dx}\left(x^3+y^4\right)&=\frac{d}{dx}(9)\\
        3x^2+4y^3y' &= 0
      \end{align*}
      Solve for $y'$:
      \begin{align*}
        y' &= -\frac{3x^2}{4y^3}
      \end{align*}
    \item Differentiate both sides with respect to $x$\,:
      \begin{align*}
        \frac{d}{dx}\left(y^2 + \tan x\right) &= \frac{d}{dx}(5)\\
        2yy' + \sec^2\!x &= 0
      \end{align*}
      Solve for $y'$:
      \begin{align*}
        2yy' &= -\sec^2\!x\\
        y' &= -\frac{\sec^2\!x}{2y}
      \end{align*}
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Find $y'$ if
\begin{enumerate}
\item $\displaystyle y^3=3xy-x^3$
\item $\displaystyle x^2y^2+xy=6x+5y$
\item $\displaystyle \cos x +\sin y=xy$
\item $\displaystyle \sin(x+y)=\cos x$
\item $\displaystyle \cos(xy)-\tan x+x^5y=\sin y$
\end{enumerate}
\end{furtherquestions}
\end{example}
 
When differentiating implicitly the derivative is usually a function of both the $x$ \emph{and} $y$-coordinates.

\begin{example}
  Find the equation of the tangent line to the curve $x^3+y^4=9$ at $P(2,-1)$\,.

  \begin{solution}
    The slope $m$ of the tangent line is the derivative evaluated at the point. From Problem~\ref{itm:implicit1} of Example~\ref{exam:implicit}
    the derivative is $\displaystyle y'=-\frac{3x^2}{4y^3}$.  Inserting $(x,y)=(2,-1)$ yields:\\[.5em]
    $\begin{aligned}[t]
      y'(2,-1)&=\left.-\frac{3x^2}{4y^3}\right|_{(x,y)=(2,-1)}=-\frac{3(2)^2}{4(-1)^3}=3
    \end{aligned}$\\[.5em]
    With $m=3$ and $(x_0,y_0)=(2,-1)$ in the point-slope formula $y=m(x-x_0)+y_0$ the tangent line is
    \begin{align*}
      y&=3(x-2)-1 &(\Leftarrow\ \text{Point-Slope form})\\
      y&=3x-6-1\\
      y&=3x-7 &(\Leftarrow\ \text{Slope-Intercept form)}
    \end{align*}
  \end{solution}

\begin{furtherquestion}
Find the equation of the tangent line to the curve $\displaystyle y^2-x^3=1$ at $P(2,-3)$\,.
\end{furtherquestion}
\end{example}

% I removed this topic.  Although it is interesting there isn't time for it.
\begin{comment}
\section[Orthogonal Trajectories]{Graphical Application: Orthogonal Trajectories}
A single curve may be described by the equation $y=ax^3$ where $a=2$.  By selecting different values of the parameter $a$ a \textbf{family of curves} results.
 
\begin{center}
\includegraphics{graphics/differentiation10}%
\end{center}
\definition{Two curves are called \textbf{orthogonal} if at each point of their intersection their tangent lines are perpendicular ($m_1m_2=-1$).}

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

\definition{Two families of curves are \textbf{orthogonal trajectories} of each other if every curve in one family is orthogonal to every curve in the other.}

\begin{example}
Show that the families of curves $y=ax^3$ and $x^2+3y^2=b$ are orthogonal trajectories of each other.
\end{example}

\begin{center}
\includegraphics{graphics/differentiation12}%
\end{center}
\end{comment}

\textbook{\clearpage}
\begin{exercise}
\input{DIFFERENTIATION/DRimplicit-differentiation}
\end{exercise}

The following exercise requires use of all the differentiation rules we have introduced.

\begin{exercise}
\input{DIFFERENTIATION/differentiation-all-methods}
\end{exercise}

\section{Higher Derivatives}
\textbook{\vspace{-.3em}}
Consider the function $y=f(x)$ with first derivative $f'(x)$.  The latter is itself a function, and if we differentiate the derivative we get the \textbf{second derivative}, $\bm{f''(x)}$:
\[f''(x)=\frac{d}{dx}\left(f'(x)\right)\]
Other notation for the second derivative is:

\hfil $\displaystyle y''$
\hfil $\displaystyle \frac{d^2y}{dx^2}$
\hfil $\displaystyle \frac{d^2f}{dx^2}$
\hfil $\displaystyle \frac{d^2}{dx^2} f$
\hfil $\displaystyle D^2f$
\hfil $\displaystyle D^2_x f$\hfil

Putting the $2$ in the numerator before the $y$ allows us to write the second derivative operator $\displaystyle \frac{d^2}{dx^2}$ separately from the function following it upon which it acts.\footnote{The notation also keeps the units straight.  For instance, for acceleration, as we will see, which is the second derivative of spatial position (a distance) with respect to time, $a=\frac{d^2\!s}{dt^2}$, only the time unit is squared, not the distance to give dimensions of acceleration of m/(sec$^2$).  The squaring of the denominator unit (and not the numerator which remains as is) is reflected correctly in the second derivative notation.}  

Similarly we can differentiate again to get the third derivative of a function, $f'''(x)$, also denoted:

\hfil $\displaystyle y'''$
\hfil $\displaystyle \frac{d^3y}{dx^3}$
\hfil $\displaystyle \frac{d^3f}{dx^3}$
\hfil $\displaystyle \frac{d^3}{dx^3} f$
\hfil $\displaystyle D^3f$
\hfil $\displaystyle D^3_x f$\hfil

\begin{example}
  Find the requested derivatives for each of the following functions.

  \begin{enumerate}
  \item If $\displaystyle f(x) = 4x^3+5x^2+6x-10$, find $f'(x), f''(x), f'''(x)$\,.
  \item If $\displaystyle g(t) = \sqrt{t^2 + \frac{1}{t}} = \sqrt{t^2+t^{-1}}$, find $g''(1)$\,.
  \item If $\displaystyle y = \sec x + \cos x$, find $y''$\,.
  \item If $\displaystyle g(t) = \frac{t^3+1}{t+4}$, find $\diff[2]{g}{t}$\,.
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t]
        f'(x) &= 12x^2+10x+6\,,
        &f''(x) &= 24x+10\,,
        &f'''(x) &= 24
      \end{aligned}$
      \item $\begin{aligned}[t]
          g'(t) &= \left(\sqrt{t^2+\frac{1}{t}}\right)'=\left[\left(t^2+t^{-1}\right)^{\frac{1}{2}}\right]'\\
          &=\frac{1}{2}\left(t^2+t^{-1}\right)^{-\frac{1}{2}}\left(2t-t^{-2}\right) \\
          g''(t) &=-\frac{1}{4}(t^2+t^{-1})^{-\frac{3}{2}}(2t-t^{-2})(2t-t^{-2})
          + \frac{1}{2}(t^2+t^{-1})^{-\frac{1}{2}} (2+2t^{-3}) \\
          &=-\frac{1}{4}\left(t^2+t^{-1}\right)^{-\frac{3}{2}}\left(2t-\frac{1}{t^2}\right)^2
          +\left(t^2+t^{-1}\right)^{-\frac{1}{2}}\left(1+\frac{1}{t^3}\right)\\
          g''(1)&=-\frac{1}{4}\left(1^2+1^{-1}\right)^{-\frac{3}{2}}\left(2(1)-\frac{1}{1^2}\right)^2
          +\left(1^2+1^{-1}\right)^{-\frac{1}{2}}\left(1+\frac{1}{1^3}\right)\\
          &=-\frac{1}{2^2}2^{-\frac{3}{2}}(1^2)+2^{-\frac{1}{2}}(2^1)=2^{-\frac{7}{2}}+2^{\frac{1}{2}}
        \end{aligned}$
        \textbook{\clearpage}
        \item $\begin{aligned}[t]
            y' &= \sec x\tan x - \sin x \\
            y''&= (\sec x\tan x)(\tan x)+(\sec x)(\sec^2\!x)-\cos x \\
            &=\sec x\tan^2\!x + \sec^3\!x - \cos x
          \end{aligned}$
        \item $\begin{aligned}[t]
            \diff{g}{t} &= \frac{3t^2(t+4) - (t^3+1)(1)}{(t+4)^2} \\
            &=\frac{3t^3+12t^2-t^3-1}{(t+4)^2} = \frac{2t^3+12t^2-1}{(t+4)^2} \\
            \diff[2]{g}{t}&= \frac{(6t^2+24t)(t+4)^2-(2t^3+12t^2-1)2(t+4)}{(t+4)^4}
            =\frac{(6t^2+24t)(t+4) - 2(2t^3+12t^2-1)}{(t+4)^3}\\
            &= \frac{6t^3+24t^2+24t^2+ 96t - 4t^3 - 24t^2 + 2}{(t+4)^3}
            = \frac{2t^3 + 24t^2+96t + 2}{(t+4)^3}
            \end{aligned}$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Find the requested derivatives.
\begin{enumerate}
\item If $y=3x^4-5x^3+10x$, find $y'$, $y''$, and $y'''$~.
\item If $y=\sqrt{t^2+12t}$, find $\displaystyle\frac{dy}{dt}$ and $\displaystyle\frac{d^2y}{dt^2}$~.
\item If $f(x)=x^3+\tan x$, find $f'(x)$ and $f''(x)$~.
\item Find $\displaystyle\frac{d^2}{dx^2}\left(\frac{x^2}{x+1}\right)$~.
\end{enumerate}
\end{furtherquestions}
\end{example}
\textbook{\vspace{-.3em}}

It is also possible to use implicit differentiation to find higher derivatives.  First find the first derivative, $y'$, as usual.  Then differentiate both sides of that function to find $y''$.  One can replace any $y'$'s which show in the $y''$ formula by your expression for $y'$ thereby writing $y''$ entirely in terms of $x$ and $y$ only.

\begin{example}
  Use implicit differentiation to determine $y''$ of the functions from Example~\ref{exam:implicit}\,:
  \begin{enumerate}
  \item $\displaystyle x^3+y^4=9$
  \item $\displaystyle y^2 + \tan x = 5$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item  From the earlier example it was found that
      \begin{align*}
        y' &= -\frac{3x^2}{4y^3}\,.
      \end{align*}
      Differentiate both sides of this equation with respect to $x$\,:
      \begin{align*}
        y'' &= -\frac{3}{4}\cdot\frac{2xy^3-3x^23y^2y'}{16y^6}
      \end{align*}
      Substitute expression for $y'$ above to get $y''$ in terms of $x$ and $y$ alone:
      \begin{align*}
        y'' &= -\frac{3}{4}\cdot\frac{2xy^3-9x^2y^2\left(-\frac{3x^2}{4y^3}\right)}{16y^6}
              = -\frac{3}{4}\cdot\frac{2xy^3-9x^2y^2\left(-\frac{3x^2}{4y^3}\right)}{16y^6}\cdot\frac{4y^3}{4y^3}\\
            &= -\frac{3}{4}\cdot\frac{8xy^6+27x^4y^2}{64y^9} = -\frac{3}{4}\cdot\frac{y^2\left(8xy^4+27x^4\right)}{64y^9} \\
            &= -\frac{3}{4}\cdot\frac{8xy^4+27x^4}{64y^7}
      \end{align*}
    \item From the earlier example it was found that
            \begin{align*}
              y' &= -\frac{\sec^2\!x}{2y}\,.
            \end{align*}
            Differentiate both sides with respect to $x$\,:
            \begin{align*}
              y'' &= -\frac{(2\sec x\sec x\tan x)(2y)-(\sec^2\!x)(2y')}{4y^2} = -\frac{2y\sec^2\!x\tan x-y'\sec^2\!x}{2y^2}\\
                  &= -\frac{2y\sec^2\!x\tan x-\left(-\frac{\sec^2\!x}{2y}\right)\sec^2\!x}{2y^2}\cdot\frac{2y}{2y}\\
                  &= -\frac{4y^2\sec^2\!x\tan x+\sec^4\!x}{4y^3}
            \end{align*}
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Use implicit differentiation to find $y''$ for the following:
\begin{enumerate}
\item $\displaystyle x^2+y^2=9$
\item $\displaystyle \sin x=xy$
\end{enumerate}
\end{furtherquestions}
\end{example}
\textbook{\vspace{-.3em}}

In general upon differentiating $y=f(x)$ $n$ times one gets the $n\textsuperscript{th}$ derivative, $f^{(n)}(x)$,  which may also be written:

\hfil $\displaystyle y^{(n)}$
\hfil $\displaystyle \frac{d^ny}{dx^n}$
\hfil $\displaystyle \frac{d^nf}{dx^n}$
\hfil $\displaystyle \frac{d^n}{dx^n} f$
\hfil $\displaystyle D^nf$
\hfil $\displaystyle D^n_x f$\hfil

\begin{example}
  Find $f^{{11}}(x)$ if $f(x)=\sin(2x)$\~.

  \begin{solution}
    Differentiating repeatedly we have:
    \begin{align*}
      f^{(0)}(x)&=\hspace{2ex}\sin(2x)\cdot 2^0\\
      f^{(1)}(x)&=\hspace{2ex}\cos(2x)\cdot 2^1\\
      f^{(2)}(x)&=-\sin(2x)\cdot 2^2\\
      f^{(3)}(x)&=-\cos(2x)\cdot 2^3\\
      f^{(4)}(x)&=\hspace{2ex}\sin(2x)\cdot 2^4
    \end{align*}
    The pattern of sine and cosine repeates every four iterations.
    Since we want $f^{(11)}(x)$ dividing $11$ by~$4$ gives a remainder
    of $3$ so our first factor will be $-\cos(2x)$, the same as
    $f^{(3)}(x)$\,.  We must multiply this by $2$ raised to the power
    of the derivative and so:
    \begin{align*}
      f^{(11)}(x)=-2^{11}\cos(2x)
    \end{align*}
    \end{solution}
  
\begin{furtherquestion}
  Find $f^{(20)}(x)$ if $\displaystyle f(x)=\frac{1}{x^5}$~.
\end{furtherquestion}
\end{example}

\begin{exercise}
\input{DIFFERENTIATION/higher-derivatives}
\end{exercise}


\section[Acceleration]{Acceleration in One Spatial Dimension}

Recall that the average velocity over the time interval from $t=a$ to $t=a+h$ for motion in one dimension is
\[\mbox{average velocity}=\frac{f(a+h)-f(a)}{h}\ .\]
while the (instantaneous) velocity at time $t=a$ is
 \[v(a)=\mylim{h}{0}\frac{f(a+h)-f(a)}{h}\ ,\]
where here displacement in one spatial dimension was given by the position function of the particle, $s=f(t)$.  In other words velocity at a given time $t$ is just the derivative of displacement:
\[v(t)=\left.\frac{ds}{dt}\right|_t=f'(t)\]
The \textbf{acceleration} of a particle is just the second derivative of the displacement or the derivative therefore of the velocity:
\[a(t)=v'(t)=f''(t)\]
\begin{example}
  The position function of a particle moving along a line is given by
  $\displaystyle s = f(t) = t^3 + 3t^2 - 9t + 9$ where $t$ is the time in
  seconds and $s$ is the displacement in metres.
  \begin{enumerate}
  \item Find the velocity and acceleration at time $t$\,.
  \item What are the velocity and acceleration of the particle after $1$~second
    and after $2$~seconds?
  \item When is the particle at rest?
  \item When is the particle moving in the positive direction?
  \end{enumerate}
  
  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle v(t) = f'(t) = 3t^2 + 6t - 9 \, , \, a(t) = v'(t)= 6t+6$
    \item $\begin{aligned}[t]
        v(1) & = 3(1)^2+6(1)-9 = 0\,\frac{\text{m}}{\text{s}} &a(1) &= 6(1)+6 = 12\,\frac{\text{m}}{\text{s}^2} \\[.5em]
        v(2) &= 3(2^2)+6(2)-9 = 15\,\frac{\text{m}}{\text{s}} &a(2) &= 6(2)+6 = 18\,\frac{\text{m}}{\text{s}^2}
      \end{aligned}$
    \item At rest (instantaneously) means the velocity must be zero:\\[.5em]
      $\displaystyle v(t) = 0 \implies 3t^2+6t-9 = 0 \implies t^2+2t-3 = 0
      \implies (t+3)(t-1)=0$\\[.5em]
      So $t= -3$ seconds or $t= 1$ second.
      If the particle only started moving at $t=0$ seconds (so the position function $s=f(t)$ is only valid for $t\ge0$)
      then $t=1$ second is the only solution.
    \item The particle is moving in the positive direction when the velocity is positive ($v(t)>0$).
      $\begin{aligned} t^2+2t-3 > 0 
        &\implies (t+3)(t-1) > 0
        \implies \begin{cases} t+3>0\ &\text{and}\ t-1 >0 \\ &\text{or} \\ t+3<0\ &\text{and}\ t-1 <0 \end{cases}\\
        &\implies \begin{cases} t>-3\ &\text{and}\ t>1 \\ &\text{or} \\ t<-3\ &\text{and}\ t<1 \end{cases}
        \implies \begin{cases} t>1\,\text{sec} \\ ~~\text{or} \\ t<-3\,\text{sec} \end{cases}\end{aligned}$\\[.5em]
      Once again we reject $t<-3$ seconds if the position function is only valid for $t\ge 0$\,.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions*}
\begin{enumerate}
\item The position function of a particle moving along a line is given by $s=f(t)=t^3-9t^2+24t$ where $t$ is the time in seconds and $s$ is the displacement in metres.
\begin{enumerate}
\item Find the velocity and the acceleration at time $t$.
\item What are the velocity and acceleration of the particle
\begin{enumerate}
\item After 1 second?
\item After 3 seconds?
\end{enumerate}
\item When is the particle (instantaneously) at rest?
\item When is the particle moving in the positive direction?
\end{enumerate}

\item If a ball is thrown vertically upward with an initial velocity of $25$~m/sec then its height, due to gravity, after $t$ seconds is approximately $s=25t-5t^2$~.
\begin{enumerate}
\item What is the maximum height reached by the ball?

\item What is the velocity of the ball when it is 30~m above the ground
\begin{enumerate}
\item On its way up?
\item On its way down?
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{furtherquestions*}
\end{example}

\section{Related Rates}

If a spherical balloon is being blown up both its radius and its volume are
changing in time.  That is there are two rates $\frac{dr}{dt}$ and
$\frac{dV}{dt}$ of interest.  These two rates are related to each
other, i.e. they are not independent.  In a related rates problem a
formula is found relating the rates of interest and it is used to
solve for an unknown rate under given conditions.

The following steps are typically followed in a related rates problem:
\begin{method}
\textbf{Steps for Solving a Related Rates Problem}
\begin{enumerate}
\item \textbf{Identify rates, Draw Diagram:} Identify the given and unknown rates of the problem, labelling the variables and their time derivatives appropriately.   Often a diagram illustrating the variables is helpful at this step.  Note the rates of the problem will involve time in their units.
\item\label{itm:relatedrate} \textbf{Determine Variable Equation:} Find an equation relating the variables involved in the rates of the problem.  If other variables appear in the equation find a constraint to write them in terms of the rate variables and thereby remove them.
\item \textbf{Differentiate:} Differentiate both sides of the equation with respect to time $t$ to get the related rates equation.  Since the variables are assumed to be functions of time, the \textbf{Chain Rule must be used}.
\item \textbf{Solve Unknown Rate:} Use the given rate information and other given information in the related rates equation to solve for the unknown rate.  Sometimes the equation in Step \ref*{itm:relatedrate} (or others) must be used to solve for one of the unknown values needed in the related rates equation.
\end{enumerate}
\end{method}

\begin{example}\label{example:relatedrates}
  Solve the following related rates problems:
  \begin{enumerate}
  \item A child is filling a spherical water balloon from the tap at a
    rate of $\frac{1}{8}\frac{\text{L}}{\text{s}}$. At what rate is
    the radius of the balloon changing when the diameter $D$ is
    $10$~cm? Hint: Recall $1$\,L=$1000\,\text{cm}^3$\,.
    
    \begin{solution*}
      \plainoverlay at (8.0cm,0cm) {\includegraphics[width=2.3cm]{graphics/balloon_sphere}};
      \begin{enumerate}[label=(\roman*)]
      \item Identify Rates:
        \begin{itemize}
        \item Given: $\diff{V}{t}=\frac{1}{8}\frac{\text{L}}{\text{s}}
          =\frac{1}{8}\frac{\text{L}}{\text{s}}\cdot\frac{1000\,\text{cm}^3}{1\,\text{L}}
          =125\,\frac{\text{cm}^3}{\text{s}}$
        \item Unknown: Find $\diff{r}{t}$ when $\displaystyle r=\frac{D}{2}=\frac{10\,\text{cm}}{2}=5$\,cm.
        \end{itemize}
        $\implies$ Related variables are $V$ and $r$, both of which are functions of time.
      \item Variable Equation:\\[.5em]
        Equation for volume of a sphere, $\displaystyle V=\frac{4}{3}\pi r^3$, relates $V$ to $r$.
      \item Differentiate:\\
        Differentiating both sides of the equation with respect to time gives:\\[.5em]
        $\diff{V}{t} = \frac{4}{3} \pi (3)r^2\diff{r}{t} = 4\pi r^2\diff{r}{t}$\\[.5em]
        Note the use of the Chain Rule since $V=V(t)$ and $r=r(t)$.
      \item Solve Unknown Rate:\\[.5em]
        $\diff{r}{t} =\frac{1}{4\pi r^2}\diff{V}{t}
        \implies\diff*{r}{t}{r=5\,\text{cm}}
        = \frac{1}{4\pi(5\,\text{cm})^2}\left(125\,\frac{\text{cm}^3}{\text{s}}\right)
        = \frac{5}{4\pi}\,\frac{\text{cm}}{\text{s}}$
      \end{enumerate}
    \end{solution*}
    
  \item Suppose the child in the previous problem is now filling
    cylindrical balloons of fixed diameter $D=10$\,cm.  How quickly is
    the length of the balloon changing if it is being filled at a rate
    of~$\frac{1}{8}\frac{\text{L}}{\text{s}}$\,?
    
    \begin{solution*}
      \plainoverlay at (8.0cm,-1.7cm) {\includegraphics[width=2.8cm]{graphics/balloon_cylinder}};
      \begin{enumerate}[label=(\roman*)]
      \item Rates: Given $\diff{V}{t}=125\,\frac{\text{cm}^3}{\text{s}}$, find $\diff{l}{t}$\,.
        (Related variables are volume $V$ and length $l$\,.)
      \item Equation: Volume of a right circular cylinder is area of base times height.\\[.5em]
        $\displaystyle V=\pi r^2l=\pi\left(\frac{D}{2}\right)^2l\implies V=\frac{\pi D^2l}{4}$
      \item Differentiate: $\diff{V}{t} = \frac{d}{dt}\left[\left(\frac{\pi D^2}{4}\right)l\right]
        =\frac{\pi D^2}{4}\diff{l}{t}$\\[.5em]
        Note in this problem the diameter $D$ is a constant so
        $\pi D^2/4$ is constant and can be pulled in front of the
        derivative.
      \item Solve: $\diff{l}{t} =\frac{4}{\pi D^2}\diff{V}{t}
        \implies\diff{l}{t}
        = \frac{4}{\pi(10\,\text{cm})^2}\left(125\,\frac{\text{cm}^3}{\text{s}}\right)
        = \frac{5}{\pi}\,\frac{\text{cm}}{\text{s}}$\\[.5em]
        Here the rate of change of length $l$ is constant while the
        balloon is filling, unlike the spherical balloon case where
        $\diff{r}{t}$ depends upon the radius.
      \end{enumerate}
    \end{solution*}
    
  \item As an insect crawls across a piece of graph paper it follows a
    path described by the curve $y = 3x^2 + x + 1$\,. If the insect's
    $x$-coordinate is changing at a rate of
    $3~\frac{\text{units}}{\text{s}}$ when its $y$-coordinate is
    $5\,$units, how fast is its $y$-coordinate changing at that
    moment?  The graph paper's origin~$(0,0)$ is at the lower
    left corner of the paper.
    
    \begin{solution*}
      \plainoverlay at (8cm,.7cm) {\includegraphics[width=3.1cm]{graphics/insect}};
      \begin{enumerate}[label=(\roman*)]
      \item Rates: $\displaystyle \diff{x}{t} = 3\,\frac{\text{units}}{\text{s}}$, find $\diff{y}{t}$ when  $y=5$\,units.
      \item Equation: $y = 3x^2 + x + 1$
      \item Differentiate: $\diff{y}{t} = 6x\diff{x}{t}+ \diff{x}{t}$
      \item \parbox[t]{20em}{Solve: Looking a our related rates equation we need to know $x$.
        We know that $y=5$\,units, so use our variable equation to solve for $x$\,:}\\[.5em]
        $\begin{aligned}[t]
          y&=5=3x^2+x+1\implies 0=3x^2+x-4\\
          &\implies x=\frac{-1\pm\sqrt{1^2-4(3)(-4)}}{2(3)}=\frac{-1\pm\sqrt{49}}{6}=\frac{-1\pm 7}{6}\\
          &\implies x=1\ \text{or}\ x=-\frac{4}{3}\ (\text{reject})
        \end{aligned}$\\[1em]
        Hence our solution is\\[1em]
        $\begin{aligned}[t]
          \diff*{y}{t}{x=1} &= 6(1)(3)+3
          = 18 + 3 = 21\,\frac{\text{units}}{\text{s}}
        \end{aligned}$        
      \end{enumerate}
    \end{solution*}

\textbook{\newpage}%LaTeX puts in a blank page if I use \clearpage here?  
  \item Sarah starts at a point $P$ and runs west at a rate of
    $4\frac{\text{m}}{\text{s}}$.  After two minutes, Anna starts at $P$ and runs south at a rate of $6\frac{\text{m}}{\text{s}}$. At
    what rate is the distance between them changing 2 minutes after
    Anna starts?

    \begin{solution*}
      \plainoverlay at (6cm,-2cm) {\includegraphics[width=3cm]{graphics/runners}};
      \begin{enumerate}[label=(\roman*)]
      \item Rates: Let $x$ be Sarah's distance from $P$ and $y$ be
        Anna's distance from $P$ and $z$ the distance between Sarah and
        Anna.\\[.5em]  Given
        $\displaystyle \diff{x}{t} = 4\,\frac{\text{m}}{\text{s}}$ and 
        $\diff{y}{t} = 6\,\frac{\text{m}}{\text{s}}$, find $\diff{z}{t}$
        at $2$\,minutes after Sarah starts.
      \item Equation: $\displaystyle z^2 = x^2+y^2$
      \item Differentiate: $2z\diff{z}{t} = 2x\diff{x}{t} + 2y\diff{y}{t}$
      \item Solve:
        $\diff{z}{t} = \frac{1}{z}\left(x\diff{x}{t} + y\diff{y}{t}\right)$
        
        We need values for $x$, $y$, and $z$. Since $dx/dt$ and
        $dy/dt$ are constant the distances are just these speeds
        times time.  Sarah runs for $4\, \text{min}=240\,\text{s}$ and Anna runs for $2\, \text{min}=120\,\text{s}$ and therefore:\\[1em]
        $\left.\begin{aligned} x&=\left(4\frac{\text{m}}{\text{s}}\right)(240\,\text{s})=960\,\text{m} \\
          y&=\left(6\frac{\text{m}}{\text{s}}\right)(120\,\text{s})=720\,\text{m}
          \end{aligned}\right\}\implies z=\sqrt{x^2+y^2}=\sqrt{(960\,\text{m})^2 + (720\,\text{m})^2} = 1200\,\text{m}$ 

        $\implies\diff{z}{t}=\frac{1}{1200\,\text{m}}
        \left[(960\,\text{m})\left(4\,\frac{\text{m}}{\text{s}}\right)
          +(720\,\text{m})\left(6\,\frac{\text{m}}{\text{s}}\right)\right]
        = 6.8\,\frac{\text{m}}{\text{s}}$
    \end{enumerate}
  \end{solution*}
\end{enumerate}

\begin{furtherquestions*}
\begin{enumerate}
\item A ladder $5$~metres long with one end against a vertical wall
  and one end on the ground begins to slide. If the bottom of the
  ladder is sliding away from the wall horizontally at a rate of
  $0.5$~m/sec, what is the vertical velocity of the top of the ladder
  when the bottom of the ladder is $3$~m from the wall?

\item At 2~p.m. Albert is $100$~km due west of Beth. If Albert is
  cycling directly south at $35$~km/h while Beth is cycling directly
  north at $25$~km/h, how fast is the distance between the cyclists
  changing at 6~p.m.\,?

\item A stone is thrown into a shallow pool of water creating a circular
  ripple.  If the radius of the ripple increases at a constant $2$~m/sec, at
  what rate is the area enclosed by the ripple increasing at the end
  of 6~seconds?

\item After a hot air balloon is launched it rises vertically at a
  constant speed of $2$~m/s. When the balloon is at an altitude of
  $7$~m a member of the launch crew drives away on a moped down a
  straight road at a speed of $5$~m/s. How fast is the distance
  between the driver and the balloon changing 4 seconds later?

\item A two-metre tall man walks toward a lamppost that is 5~metres in
  height.  If the man is walking at a speed of $1.8$~m/s, how fast is
  the length of his shadow changing when he is 3~metres from the
  lamppost?

\item A model in a fashion show walks down the straight runway at a
  speed of 0.75~m/s. A person in the audience located 12~metres from the
  runway keeps a camera focused on the model. At what rate is the
  camera rotating when the model is 5~metres from the point on the
  runway closest to the person?

\item\label{itm:greatpyramid} The Great Pyramid of Khufu at Giza is a
  square pyramid with approximate base side length of $B=230$~m and
  height $H=150$~m.  If it took approximately 20~years to build, one
  can use the formula for the volume of a pyramid to estimate the rate
  of change of volume with time (assumed constant) to be about
  360~m$^3$/day.  Before it was finished the construction was a
  frustum of a pyramid (i.e. a pyramid missing its top) of height $h$,
  base side length $B$, and top side length $b$.  How fast was the
  height changing when the structure was 100~m high? Use that the
  volume of a frustum of a pyramid is given by
  $V=\frac{1}{3}h(A_1+A_2+\sqrt{A_1A_2})$ where $A_1$ and $A_2$ are
  the areas of its square base and top respectively.  (Hint: Use
  constants $B$ and $H$ until the end of your
  calculation.)\footnotemark
\end{enumerate}
\end{furtherquestions*}
\end{example}
\footnotetext{To check the answer is of the correct order of magnitude note that the average rate of change with height over the time of construction is
\[\frac{\Delta h}{\Delta t}=\frac{150~\mbox{m}}{(20~\mbox{years})(365.25~\mbox{days/year})}=\frac{150~\mbox{m}}{7305~\mbox{days}}=0.02~\mbox{m/day}\]
Should the answer to the actual problem be higher or lower than this value?  Also note that this problem naively assumes that lifting blocks to the top of the pyramid required the same time as placing those on the bottom.  In fact it is believed long ramps of earth were created to place higher blocks.  This has not been factored into these calculations.}

\begin{exercise}
\input{DIFFERENTIATION/related-rates}
\end{exercise}

\section{Differentials}
Let $y=f(x)$ be a curve in the $xy$-plane and let $P\left(x,f(x)\right)$ and $Q\left(x+\Delta x,f(x+\Delta x)\right)$ be points on the curve.

For the given \textbf{increment in $\bm{x}$}, $\Delta x$, the \textbf{increment in $\bm{y}$} is
\[\Delta y=f(x+\Delta x)-f(x)\,.\]

We define the \textbf{differential of $\bm{y}$} to be:
\[dy=f'(x)dx\ .\]
Here $dy$ is considered a single variable which is a function of both $x$ and the differential $dx$.  The definition is motivated by the fact that, in Leibniz notation, $f'(x)=\frac{dy}{dx}$~.

Letting $dx=\Delta x$ one has that:
\begin{itemize}
\item $\Delta y$ is the change in the height of the curve $y=f(x)$
\item $dy$ is the change in the height of the tangent line to the curve $y=f(x)$ at $P(x,f(x))$.
\end{itemize}

Diagrammatically we have:
\begin{center}
\includegraphics{graphics/differentiation13}%
\end{center}

As $dx=\Delta x\rightarrow 0$ then
\begin{eqnarray*}
\Delta y & \approx & dy \\
f(x+\Delta x)-f(x) & \approx & f'(x)\Delta x 
\end{eqnarray*}
The approximation, as clear from the diagram, is only valid for small $\Delta x$.

\begin{example}
    Compare $\Delta y$ and $dy$ if $y=x^3+3x^2+1$ and $x$ changes from 2.0 to
    2.01

    \begin{solution*}
      \begin{align*}
        \Delta y &= f(2.01)-f(2) = \left[(2.01)^3+3(2.01)^2+1\right]-[2^3+3(2)^2+1] = 21.240901-21 = 0.240901 \\
        dy &= f'(x)dx = (3x^2+6x)dx \implies dy = f'(2)(0.01) = [3(2)^2+6(2)](0.01) = 24(0.01)=0.24
      \end{align*}

    \end{solution*}

\begin{furtherquestion}
Compare $\Delta y$ and $dy$ if $y=f(x)=x^4+x+2$ and $x$ changes from 1.0 to 1.01~.
\end{furtherquestion}
\end{example}

The differential approximation $\Delta y\approx dy$ is particularly useful for approximating the absolute error $\Delta y$ of a quantity that depends on a variable $x$ with known error $\Delta x$.  This is because, by assumption, the error $\Delta x$ is typically small, which is when the differential approximation is valid.
\begin{example}
    A circular puddle has radius $20.0\pm 0.5$\,cm.  What is its area? (Include its absolute error.)

    \begin{solution}
      The puddle radius is $r\pm\Delta r=20.0\pm 0.5$\,cm and its area is $A=\pi r^2$\,.\\[.5em]
      $\begin{aligned}
        A&=\pi r^2=\pi(20\,\text{cm})^2=400\pi\,\text{cm}^2 \\
        dA&=A'(x)\,dx=2\pi r\,dr \\
        \Delta A&\approx dA=2\pi(20.0\,\text{cm})(0.5\,\text{cm})=20\pi\,\text{cm}^2
      \end{aligned}$\\[.5em]
      Therefore $A\pm\Delta A=400\pi\pm20\pi\,\text{cm}^2\approx 1256\pm63\,\text{cm}^2$.
    \end{solution}

\begin{furtherquestion}
  A square rug is measured to have a side length of $3.00\pm0.02$ metres.  What is the area of the rug?
  % (Include its absolute error.)
\end{furtherquestion}
\end{example}

From the differential approximation of $\Delta y$ it follows that
\[f(x+\Delta x) \approx  f(x)+f'(x)\Delta x~.\]

\begin{example}
    Use differentials to find an approximation to $\sqrt{1.01}$\,.

    \begin{solution}
      We desire $1.01=x+\Delta x$ for some value of $x$ close to $1.01$
      and at which one can easily evaluate $f$ and its derivative.
      Therefore choose $x=1$ and so $\Delta x=1.01-x=0.01$\,.
      \begin{align*}
        f(x)&=\sqrt{x} \implies  f(1)=\sqrt{1}=1 \\
        f'(x) &= \frac{1}{2}x^{-\frac{1}{2}}= \frac{1}{2\sqrt{x}} \implies f'(1) = \frac{1}{2\sqrt{1}} = \frac{1}{2}\\
        f(x+\Delta x)&\approx f(x)+f'(x)\Delta x\\
        f(1.01)&=f(1+0.01)\approx f(1)+f'(1)(0.01)=1 + \frac{1}{2}(0.01)=1.005%\end{aligned}$
      \end{align*}
      Thus $\sqrt{1.01}\approx 1.005$ which can be compared with the actual value $1.004987$\,.
    \end{solution}

\begin{furtherquestion}
Use differentials to find an approximation to $\displaystyle\sqrt[3]{1.02}$~.
\end{furtherquestion}
\end{example}

For $P(a,f(a))$ we have, replacing $x$ in our previous formula with $a$:
\[f(a+\Delta x) \approx  f(a)+f'(a)\Delta x~.\]
The function at a value $x$ near $a$ will be well-approximated by the tangent at $P$ evaluated at $x$.  Setting $x=a+\Delta x$ in our last formula (so $\Delta x=x-a$) gives:
\[f(x) \approx  f(a)+f'(a)(x-a)~.\]
The right hand side of this equation is just the expression for the tangent line.  This is the \textbf{linear} or \textbf{tangent line approximation} of $f$ at $a$.  The tangent function,
\[L(x)=f(a)+f'(a)(x-a)~,\]
is called the \textbf{linearization} of $f$ at $a$.

\begin{example}
    Find the linear approximation (linearization) $L(x)$ of the function $f(x) = x^3 + 2x^2 - x - 3$ at $a=4$ and use it to
    approximate $f(3.98)$\,.

    \begin{solution*}
      \begin{align*}
        f(x) & = x^3 + 2x^2 - x - 3 \implies f(4) = 4^3 + 2(4)^2 - 4 - 3 = 64+32-7 = 89\\
        f'(x) & = 3x^2 + 4x - 1 \implies f'(4) = 3(4)^2 + 4(4)-1 = 48+16-1 = 63\\
        L(x) & = f(a) + f'(a)(x-a)\\
        L(x) &= 89 + 63(x-4)
      \end{align*}
      
      Since $f(x)\approx L(x)$ for $x$ near $a=4$ we have
      \begin{align*}
      f(3.98) &\approx L(3.98)=89 +63(3.98-4) = 89+63(-0.02) = 87.74
      \end{align*}
      which can be compared with the actual value of $f(3.98)=(3.98)^3 + 2(3.98)^2 - 3.98 - 3=87.745592$\,.
    \end{solution*}

\begin{furtherquestions*}
\begin{enumerate}
\item Find the linear approximation (linearization) $L(x)$ of the function $g(x)=\sqrt[3]{1+x}$ at $a=0$ and use it to approximate $g(-0.05)$.
\item Find the linearization $L(x)$ of the function $\displaystyle f(x)=\frac{1}{\sqrt{2+x}}$ near $a=0$~.
\end{enumerate}
\end{furtherquestions*}
\end{example}

A better approximation to $f(x)$ near $a$ is the \textbf{quadratic approximation} given by:
\[f(x)\approx f(a)+f'(a)(x-a)+\frac{1}{2}f''(a)(x-a)^2\]

\begin{example}
    Find the quadratic approximation of $f(x) = \sqrt{x^2+5}$ at $a=2$.

    \begin{solution*}
      \begin{align*}
        f(x) &= \sqrt{x^2+5} \implies f(2) = \sqrt{4+5} = 3 \\
        f'(x) &= \frac{1}{2}(x^2+5)^{-\frac{1}{2}}(2x) = \frac{x}{\sqrt{x^2+5}} \implies f'(2) = \frac{x}{\sqrt{2^2+5}}=\frac{2}{3}\\ 
        f''(x) &= \left[x\left(x^2+5\right)^{-\frac{1}{2}}\right]'= (x^2+5)^{-\frac{1}{2}} - \frac{1}{2}x(x^2+5)^{-\frac{3}{2}}(2x)
                 = \frac{1}{\sqrt{x^2+5}} - \frac{x^2}{(x^2+5)^{\frac{3}{2}}} \\
             & \implies f''(2) = \frac{1}{\sqrt{2^2+5}}-\frac{4}{(2^2+5)^{\frac{3}{2}}}
               =\frac{1}{3}-\frac{4}{\left[\left(3^2\right)\right]^{\frac{3}{2}}}=\frac{1}{3} - \frac{4}{27} = \frac{9-4}{27} = \frac{5}{27}
      \end{align*}
      Therefore $f(x) \approx 3 + \frac{2}{3}(x-2) + \frac{5}{54}(x-2)^2$ for $x$ near $a=2$\,.
    \end{solution*}

\begin{furtherquestion}
Find the quadratic approximation of $f(x)=\sqrt[3]{x}$ near $a=8$~.
\end{furtherquestion}
\end{example}

%\textbook{\clearpage}% Needed to get answer reference on correct page.
\begin{exercise}
\input{DIFFERENTIATION/differentials}
\end{exercise}

\begin{reviewexercise}
\input{DIFFERENTIATION/differentiation-review}
\end{reviewexercise}
%
% TODO: Chain Rule example with "Find y(x)" is a bit misleading
% Perhaps make it y(x) defined to be y(u(x))?
%
% TODO: Move related rates to derivative applications?
%
% TODO: In related rates maybe mention that only numbers should appear in
% diagrams if they are constant.
%
% TODO: Add a related rates problem as follows.  A hemispherical rain storage
% basin of radius 30m has V=V(D) where D is the depth.  a)If it is collecting
% water from an area of ... square metres whiat is the change dV/dt if
% rain is fall at 1mm/hour.  b) If the basin is 2m deep, how quickly is the depth
% D changing in time.  (Needs formula from Calculus II for V(D).)
% 
% TODO: Add a related rates problem where the rate of change is given as
% proportional to surface area (like dissolving cube).  It doesn't follow
% the usual steps (as the rate is given) but it is interesting.
%
% TODO: Maybe worth commenting that if f'=0 function increasing or decreasing
% is undetermined.
%
% TODO: Add appendix with formulae for basic shapes. Also mention that
% their areas goe as the square and volumes (for 3D) go as the cube.
% Give reason as being built of squares and cubes.
%
% TODO: I started using esdiff package for derivatives.  Either change
% all of them to this or revert.

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