\section{Antiderivatives}
\label{sec:antiderivatives}

We know how to take a derivative of a function.  If we reverse the
procedure and ask which function when differentiated results in a
given function we are finding an \textbf{antiderivative}.

\definition{If $F'(x)=f(x)$ for all $x$ in an interval $I$ then the
  function $F$ is called an \textbf{antiderivative} of $f$ on $I$.}

\begin{example}
\begin{enumerate}
\item $\displaystyle F(x)=\frac{1}{3}x^3$ is an antiderivative of $f(x)=x^2$ because $\displaystyle F'(x)=\frac{d}{dx}\frac{1}{3}x^3=x^2=f(x)$~.
\item $\displaystyle F(x)=\frac{1}{3}x^3+10$ is also an antiderivative of $f(x)=x^2$ because $\displaystyle\frac{d}{dx}\left(\frac{1}{3}x^3+10\right)=x^2$~.
\item$\displaystyle F(x)=\frac{1}{4}x^4+2x$ is an antiderivative of $f(x)=x^3+2$ since $\displaystyle F'(x)=x^3+2$~.
\end{enumerate}
\end{example}

The first two questions of the last example illustrate the following theorem: 
\theorem{\label{thm:antiderivatives}Let $C$ be an arbitrary constant.  If $F$ is an antiderivative of $f$ on an interval $I$ then $F(x)+C$ is also an antiderivative of $f$ on $I$.  Moreover, all antiderivatives of $f$ on $I$ have this form.}

That $F(x)+C$ is also an antiderivative given $F(x)$ an antiderivative is due to  $\displaystyle \frac{d}{dx}C=0$\,.  Proof that all antiderivatives can be written $F(x)+C$ follows from Theorem~\ref{thm:mvtcorb}\,.  As such the general antiderivative of a function $f$ is a family of curves $F(x)+C$\,.

Consideration of our derivative formulae results in the following table of antiderivatives (up to the additive constant $C$).  Differentiate each answer on the right to confirm the result.

\hfil$\displaystyle\begin{array}{c|l}
\mbox{Function} & \mbox{Antiderivative} \\ \hline
x^n & \frac{1}{n+1}x^{n+1}\ \rule{0em}{1.2em}\mbox{where}\ n\neq -1\\
\cos x & \sin x \\
\sin x & -\cos x \\
\sec^2 x & \tan x \\
\sec x\tan x & \sec x \\
cf(x) & cF(x) \\
f(x)\pm g(x) & F(x)\pm G(x)
\end{array}$\hfil

For the last two general formulae we are assuming $F$ and $G$ are
antiderivatives of $f$ and $g$ respectively and that $c$ is an
arbitrary constant.  These last two general formulae show that finding
an antiderivative is a linear operation.  When finding antiderivatives
of a sum of terms we can focus on each term separately and pull any
constant multipliers out front.

\begin{example}
  Find the antiderivative of the given functions.
  \begin{enumerate}
    \begin{multicols}{2}
  \item $\displaystyle f(x) = x^3 + 5x^2 + 6 $
  \item $\displaystyle g(t) = \frac{\sqrt{t} + 5t}{2\sqrt{t}}$
  \item $\displaystyle f(\theta) = 2\sin{\theta} + \sec{\theta}\tan{\theta}$
    \end{multicols}
  \end{enumerate}

\textbook{\clearpage}
  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t]
        f(x) &= x^3 + 5x^2 + 6= x^3 + 5x^2 + 6x^0  \\
        F(x) &= \frac{1}{3+1}x^{(3+1)} + 5\left(\frac{1}{2+1}\right)x^{(2+1)}
        + 6\left(\frac{1}{0+1}\right)x^{(0+1)} + C
        = \frac{1}{4}x^4 + \frac{5}{3}x^3 + 6x + C
      \end{aligned}$
    \item $\begin{aligned}[t]
        g(t) &= \frac{\sqrt{t} + 5t}{2\sqrt{t}}
        = \frac{\sqrt{t}}{2\sqrt{t}} +\frac{5t}{2\sqrt{t}}
        = \frac{1}{2} + \frac{5}{2}t^\frac{1}{2} \\
        G(t) &= \frac{1}{2}t + \frac{5}{2}\cdot\frac{1}{\frac{3}{2}}t^{\frac{3}{2}}+ C
        = \frac{1}{2}t + \frac{5}{2}\cdot\frac{2}{3}t^{\frac{3}{2}}+ C
        = \frac{1}{2}t + \frac{5}{3}t^\frac{3}{2} + C
      \end{aligned}$
    \item $\begin{aligned}[t]
        f(\theta) &= 2\sin{\theta} + \sec{\theta}\tan{\theta}\\
        F(\theta) &= -2\cos{\theta} + \sec{\theta} + C
      \end{aligned}$
    \end{enumerate}
    The reader is encouraged to check each antiderivative by
    differentiating it to see that one arrives at the original
    function.
  \end{solution*}

\begin{furtherquestions}
Find the antiderivatives of:
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle f(x)=x^3+2\cos x$
\item $\displaystyle f(x)=\sin x+\tan x\sec x$
\item $\displaystyle f(x)=\left(\sqrt{x}+x\right)^2$
\item $\displaystyle f(x)=\frac{2-3\sin x}{\cos^2x}$
\item $\displaystyle f(x)=\frac{(x-1)^2}{x^4}$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

Note that a function $f$ is an antiderivative of its own derivative
$f'$.  Similarly, since $f''$ is the derivative of $f'$, $f'$ is an
antiderivative of $f''$.

\begin{example}
  Find all functions $f$ such that $f'(\theta)=(\sec\theta+\tan\theta)^2$\,.

\begin{solution}
  If the derivative of $f(\theta)$ is $f'(\theta)$ then it follows
  that $f$ is just the antiderivative of $f'(\theta)$.  Before
  antidifferentiating we expand $f'$ and use an identity as shown.
  \begin{align*}
    f'(\theta)&=(\sec\theta+\tan\theta)^2=(\sec\theta+\tan\theta)(\sec\theta+\tan\theta)\\
    &=\sec^2\!\theta+2\sec\theta\tan\theta+\tan^2\theta\hspace{4em}
    \Leftarrow\text{Use identity $\tan^2\!\theta=\sec^2\!\theta-1$}\\
    &=\sec^2\!\theta+2\sec\theta\tan\theta+(\sec^2\theta-1)\\
    &=2\sec^2\!\theta+2\sec\theta\tan\theta-1\\
\implies f(\theta)&=2\tan\theta+2\sec\theta-\theta+C
  \end{align*}
\end{solution}

\begin{furtherquestion}
Find all functions $g$ such that $\displaystyle g'(x)=4\sin x-3x^5+6\sqrt[4]{x}$~.
\end{furtherquestion}
\end{example}

\begin{example}
If $g'(x)=x^3-4$ and $g(2)=3$, find $g(x)$\,.

\begin{solution}
Since $g'(x)=x^3-4$ is the derivative of $g(x)$, it follows that $g(x)$ is
the antiderivative of $x^3-4$\,:
\begin{align*}
  g(x)&=\frac{1}{4}x^4-4x+C
\end{align*}
At this point the answer is a family of functions, one for each value of $C$.  However the extra information $g(2)=3$ allows us to determine a value of $C$ and hence a specific function:
\begin{align*}
  3&=g(2)=\frac{1}{4}(2)^4-4(2)+C=4-8+C\\
\implies 3&=-4+C\implies C=7
\end{align*}
Therefore $\displaystyle g(x)=\frac{1}{4}x^4-4x+7$\,.
\end{solution}

\begin{furtherquestion}
If $\displaystyle f''(x)=2+\frac{4}{x^3}$, $f(1)=0$, and $f(2)=3$, find $f(x)$\,.
\end{furtherquestion}
\end{example}

\begin{example}
  An object falling in gravity at the surface of the Earth undergoes
  constant vertical acceleration given by $a(t)=-g$ where
  $g=9.8\,\frac{\text{m}}{\text{s}^2}$ is constant.  If the initial
  velocity at time $t=0$ is $v_0$ and the initial height at that time
  is $y_0$, find $y(t)$, the height of the object as a function of time.

  \begin{solution}
    Since acceleration $a(t)$ is the derivative of velocity $v(t)$, we have that $v(t)$ is the antiderivative of~$a(t)$.  Then
    \begin{align*}
      a(t)&=-g=-g(1)=-gt^0\\
      \implies v(t)&=-g\frac{1}{0+1}t^{(0+1)}+C\\
          &=-gt+C
    \end{align*}
    We can find the constant $C$ since we know $v(0)=v_0$:
    \begin{align*}
      v_0&=v(0)=(-g)(0)+C=0+C\implies C=v_0\\
      \implies v(t)&=-gt+v_0
    \end{align*}
    Next since velocity $v(t)$ is the derivative of position $y(t)$ it
    follows that $y(t)$ is the antiderivative of~$v(t)$:
    \begin{align*}
      v(t)&=-gt+v_0=-gt^1+v_0t^0\\
      \implies y(t)&=-g\left(\frac{1}{2}\right)t^2+v_0\frac{1}{1}t^1+D\\
          &=-\frac{g}{2}t^2+v_0t+D
    \end{align*}
    The second constant $D$ can be determined by using that $y(0)=y_0$\,:
    \begin{align*}
      y_0&=y(0)=-\frac{g}{2}(0)^2+(v_0)(0)+D=0+0+D \implies D=y_0\\
      \implies y(t)&=-\frac{g}{2}t^2+v_0t+y_0
    \end{align*}
  \end{solution}

\begin{furtherquestion}
An object with mass $2$~kg moving in a straight line feels a force (in Newtons) given by \mbox{$F(t)=12t+16$~N\,.}  If its initial displacement is $s(0)=3$~m and its initial velocity is $v(0)=-2$~m/s, find its position function~$s(t)$\,. (Note that according to Newton's 2\textsuperscript{nd} Law of Motion $F=ma$.)
\end{furtherquestion}
\end{example}

It will be shown that antidifferentiation is intimately connected with the calculus concept of integration to which we presently turn.

\begin{exercise}
\input{INTEGRATION/antiderivatives}
\end{exercise}

\section{Series}
\definition{A \textbf{sequence} is an ordered list of numbers (called \textbf{terms}).}
\begin{example}
\begin{itemize}
\item $\displaystyle 1, 4, 9, 16, 25, \ldots, 100$
\item $\displaystyle \frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \frac{1}{16},\ldots$
\end{itemize}
\end{example}
As the examples show a sequence may have a finite or infinite number of terms.

A similar concept to a sequence is a series.

\definition{A \textbf{series} is a \textbf{sum} of terms in a sequence.}
\begin{example}
\begin{itemize}
\item $\displaystyle 1 + 4 + 9 + 16 + 25 + \ldots + 100$~~~~(a finite series)
\item $\displaystyle \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \ldots$~~~~(an infinite series)
\end{itemize}
\end{example}

\subsection*{Sigma Notation}
When a pattern exists in the terms of a series it can be abbreviated by writing the term as a function of an index.
\begin{example}
In our first series one notices:
\[1^2+2^2+3^2+4^2+\ldots+10^2=\sum_{i=1}^{10}i^2\]
\end{example}
Here the symbol $\sum$ is \emph{sigma}, the Greek capital S, representing a sum.  The $i$ is the index, related to the position in the series. The limits of 1 and 10 indicate the set  of values $i$ ranges over ($1,2,\ldots, 10$).  Just as the $x$ when writing $f(x)$ is arbitrary ($f(u)=u^2$ is the same function as $f(x)=x^2$), we could have written the series as:
\[\sum_{j=1}^{10}j^2\]

\textbook{\clearpage}
In general we have the following:
\definition{Let $a_m$, $a_{m+1}$, \ldots, $a_n$ be a sequence of real numbers (so $m$, $n$ are integers with $m\le n$) then
\[\sum_{i=m}^{n}a_i=a_m+a_{m+1}+\ldots+a_{n-1}+a_n\]
is the \textbf{sigma notation} for the series.  Here $i$ is called the \textbf{index of the summation}. Often we can write the term $a_i$ as a function of the index, $a_i=f(i)$\,.
}
\begin{example}
  Write the following in sigma notation.
  \begin{enumerate}
  \item $\displaystyle \frac{1}{3}+\frac{2}{4}+\frac{3}{5}+\frac{4}{6}+\ldots+\frac{98}{100}$
  \item $\displaystyle 1+\frac{1}{8}+\frac{1}{27}+\frac{1}{64}+\frac{1}{125}+\ldots$
  \item $\displaystyle \frac{1}{9}+\frac{1}{27}+\frac{1}{81}+\ldots+\frac{1}{3^n}$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\begin{aligned}[t]
        &\frac{1}{3}+\frac{2}{4}+\frac{3}{5}+\frac{4}{6}+\ldots+\frac{98}{100}
        =\frac{1}{1+2}+\frac{2}{2+2}+\frac{3}{3+2}+\frac{4}{4+2}+\ldots+\frac{i}{i+2}+\ldots+\frac{98}{98+2}\\
        &=\sum_{i=1}^{98}\frac{i}{i+2}
      \end{aligned}$
      Sigma notation for a series is not unique.  This series can also be written $\displaystyle\sum_{i=3}^{100}\frac{i-2}{i}$\,.
    \item $\displaystyle 1+\frac{1}{8}+\frac{1}{27}+\frac{1}{64}+\frac{1}{125}+\ldots
        =\frac{1}{1^3}+\frac{1}{2^3}+\frac{1}{3^3}+\frac{1}{4^3}+\frac{1}{5^3}+\ldots+\frac{1}{i^3}+\ldots
        =\sum_{i=1}^\infty\frac{1}{i^3}$
    \item $\displaystyle \frac{1}{9}+\frac{1}{27}+\frac{1}{81}+\ldots+\frac{1}{3^n}=\frac{1}{3^2}+\frac{1}{3^3}+\frac{1}{3^4}+\ldots+\frac{1}{3^i}+\ldots+\frac{1}{3^n}=\sum_{i=2}^n\frac{1}{3^i}$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Write the following in sigma notation:
\begin{enumerate}
\item $\displaystyle \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \ldots + \frac{1}{256}$
\item $\displaystyle \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} + \ldots $
\item $\displaystyle 2^3+3^3+\ldots+n^3$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
Often the goal is to evaluate the sum of a series.
\begin{example}
  Evaluate the sums of the following series.
  \begin{enumerate}
    \begin{multicols}{2}
    \item $\displaystyle \sum_{k=0}^4 \frac{1}{2^k}$
    \item $\displaystyle \sum_{i=0}^4 \frac{i^2-i}{i+1}$
    \end{multicols}
  \end{enumerate}
  
\begin{solution*}
  \begin{enumerate}
  \item $\displaystyle \sum_{k=0}^4 \frac{1}{2^k} = \frac{1}{2^0} +
    \frac{1}{2^1} + \frac{1}{2^2} + \frac{1}{2^3} + \frac{1}{2^4} = 1 +
    \frac{1}{2} + \frac{1}{4} + \frac{1}{8} + \frac{1}{16} =
    \frac{16+8+4+2+1}{16} = \frac{31}{16}$
  \item $\begin{aligned}[t]
      \sum_{i=0}^4 \frac{i^2-i}{i+1} &= \frac{0^2-0}{0+1} + \frac{1^2-1}{1+1}
      + \frac{2^2-2}{2+1} + \frac{3^2-3}{3+1} + \frac{4^2-4}{4+1}
      = 0+0+\frac{2}{3}+\frac{6}{4} + \frac{12}{5}\\
      &= \frac{20+45+72}{30}
      = \frac{137}{30}
      \end{aligned}$
  \end{enumerate}
\end{solution*}

\begin{furtherquestions}
Evaluate the sums of the following series:
\begin{enumerate}
\item $\displaystyle\sum_{j=0}^52^j$
\item $\displaystyle\sum_{i=1}^3\frac{i-1}{i^2+3}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\theorem{The following series sums can be evaluated once and for all for positive integer $n$:
\begin{enumerate}
\item $\displaystyle\sum_{i=1}^n 1=n$
\item $\displaystyle\sum_{i=1}^n i=\frac{n(n+1)}{2}=\frac{n^2+n}{2}$
\item $\displaystyle\sum_{i=1}^n i^2=\frac{n(n+1)(2n+1)}{6}=\frac{2n^3+3n^2+n}{6}$
\item $\displaystyle\sum_{i=1}^n i^3=\left[\frac{n(n+1)}{2}\right]^2=\frac{n^4+2n^3+n^2}{4}$
\item $\displaystyle\sum_{i=1}^n i^4=\frac{n(n+1)(2n+1)(3n^2+3n-1)}{30}=\frac{6n^5+15n^4+10n^3-n}{30}$
\end{enumerate}
}

\textbook{\clearpage}
For general sums we have the following theorem:
\theorem{If $c$ is any constant (i.e. independent of $i$) and $\displaystyle\sum_{i=m}^n a_i$ and $\displaystyle\sum_{i=m}^n b_i$ are arbitrary sums (with the same range of indices) then
\begin{enumerate}
\item $\displaystyle \sum_{i=m}^n ca_i=c\sum_{i=m}^n a_i$
\item $\displaystyle \sum_{i=m}^n \left(a_i\pm b_i\right)= \sum_{i=m}^n a_i\pm\sum_{i=m}^n b_i$
\end{enumerate}
}
The theorem shows summation is a linear process like differentiation and antidifferentiation. 

\begin{example}
The following useful result is a consequence of the previous theorems:
\[\sum_{i=1}^nc=nc~,\]
since  $\displaystyle \sum_{i=1}^nc=\sum_{i=1}^nc\cdot 1=c\sum_{i=1}^n 1=cn$~.
\end{example}

More complicated series can be evaluated using the previous results.
\begin{example}
  Evaluate the sum of the series $\displaystyle \sum_{i=1}^n \frac{i^3+3i}{n^4}$
  using the previous theorems.
  
  \begin{solution}
    With respect to the sum the factor of $\frac{1}{n^4}$ is a
    constant; it does not depend on the summation index~$i$ and so it can
    be pulled out of the sum.\\[1em]
    $\begin{aligned}[t] \sum_{i=1}^n \frac{i^3+3i}{n^4}
      &=\frac{1}{n^4}\sum_{i=1}^n \left[i^3+3i\right] =
      \frac{1}{n^4}\left[\sum_{i=1}^n i^3 + 3\sum_{i=1}^n i\right]
      = \frac{1}{n^4}\left[\left(\frac{n(n+1)}{2}\right)^2 + 3\frac{n(n+1)}{2}\right]\\
      &= \frac{1}{n^4}\left[\frac{n^2(n+1)^2}{4} +
        \frac{3}{2}(n)(n+1)\right] = \frac{1}{4}\frac{(n+1)^2}{n^2} +
      \frac{3}{2}\frac{(n+1)}{n^3}
      \end{aligned}$
  \end{solution}

\begin{furtherquestions}
Evaluate the following sums using the previous theorems.
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle \sum_{i=1}^{n}(3+2i)^2$
\item $\displaystyle \sum_{i=1}^{n}\frac{1}{n}\left[\left(\frac{i}{n}\right)^3+2\right]$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
Sometimes we will want to take the limit of a series as $n\rightarrow\infty$.  Though technically $n$ is only allowed to take integer values, we evaluate the limit in the same way we do when $x\rightarrow\infty$ for a real variable getting arbitrarily large.

\begin{example}
  Evaluate the limit
  $\displaystyle\lim_{n\to\infty} \sum_{i=1}^n \frac{1}{n}\left[\left(\frac{i}{n}\right)^2 + \frac{3i}{n} + 5\right]$\,.

  \begin{solution}
    $\begin{aligned}[t]
      \lim_{n\to\infty} \sum_{i=1}^n \frac{1}{n}\left[\left(\frac{i}{n}\right)^2
        +\frac{3i}{n} + 5\right]
      &= \lim_{n\to\infty} \sum_{i=1}^n\frac{1}{n}\left(\frac{i^2}{n^2}
        + \frac{3i}{n} + 5\right)
      = \lim_{n\to\infty} \sum_{i=1}^n\left(\frac{i^2}{n^3}
        + \frac{3i}{n^2} + \frac{5}{n}\right)\\      
      &= \lim_{n\to\infty}\left[ \frac{1}{n^3}\sum_{i=1}^ni^2
        + \frac{3}{n^2}\sum_{i=1}^ni
        + \frac{5}{n}\sum_{i=1}^n(1)\right]\\
      &= \lim_{n\to\infty}\left[\frac{1}{n^3}\cdot \frac{2n^3+3n^2+n}{6}
        + \frac{3}{n^2}\cdot\frac{n^2+n}{2} + \frac{5}{n}\cdot n\right]\\
      &=\lim_{n\to\infty}\left[\frac{1}{6}\cdot\frac{2+\frac{3}{n}+\frac{1}{n^2}}{1}
        +\frac{3}{2}\cdot\frac{1+\frac{1}{n}}{1} + 5\right]\\
      &= \frac{1}{6}(2+0+0) + \frac{3}{2}(1+0) + 5
      = \frac{1}{3}+\frac{3}{2} + 5
      = \frac{2+9+30}{6}
      = \frac{41}{6}
      \end{aligned}$    
  \end{solution}

\begin{furtherquestions}
Evaluate the following limits:
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle \mylim{n}{\infty}\sum_{i=1}^{n}\frac{1}{n}\left[\left(\frac{i}{n}\right)^3+2\right]$
\item $\displaystyle \mylim{n}{\infty}\sum_{i=1}^{n}\frac{1}{n}\left(\frac{i}{n}\right)^4$
\item $\displaystyle \mylim{n}{\infty}\sum_{i=1}^{n}\frac{1}{n}\left(1+\frac{2}{n}i+\frac{3}{n^2}i^2\right)$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}
Note in the above limits we cannot simply write $\displaystyle \sum_{i=1}^\infty$ because the index upper limit $n$ actually appears in the terms themselves!

\begin{exercise}
\input{INTEGRATION/series}
\end{exercise}

\section{Area Under a Curve}

We know how to find the areas of simple shapes like the rectangle and triangle shown below:

\begin{center}
\parbox[t]{4.6in}{\vspace{0em}{\resizebox{3.6in}{!}{\includegraphics{graphics/basic_areas}}}}
\end{center}

More complicated polygons with straight edges could be subdivided into triangles to find their areas.

An area bounded by a smooth curve can be resolved using a limiting approach. Consider the general problem of finding the area $S$ of the region that lies under the curve $y=f(x)$ between $x=a$ and $x=b$.  By \emph{under the curve} we mean the area between the curve and the $x$-axis.  The situation is illustrated in the following diagram:
\begin{center}
\includegraphics{graphics/integration1}%
\end{center}

We are going to approximate the area $S$ with the sum of the areas of $n$ thin rectangles.  Letting the number of rectangles increase without bound ($n\rightarrow\infty$) will give us an exact result.  For a concrete example consider finding the area under the curve $y=x^3$ from $x=0$ to $x=1$ shown below.

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

Consider dividing the interval $[0,1]$ into 4 equal subintervals each of length $\Delta x=1/4$.  The rectangles have bases that are these subintervals and their heights have been chosen to have the values of the function at the \textbf{right endpoints} of the subintervals.  Diagrammatically they are as follows:

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

Let $S_4$ be the sum of the areas of the rectangles. Then an approximation of the desired area is
\[S_4=A_1+A_2+A_3+A_4=\frac{1}{4}\left(\frac{1}{4}\right)^3
+\frac{1}{4}\left(\frac{2}{4}\right)^3
+\frac{1}{4}\left(\frac{3}{4}\right)^3
+\frac{1}{4}\left(\frac{4}{4}\right)^3=\left(\frac{1}{4}\right)\left(\frac{100}{64}\right)=\frac{25}{64}\approx0.3906\,.
\]

Clearly, from the diagram, this will be an overestimate of the area $S$.  If we had, instead used left endpoints for the heights we would have underestimated $S$:

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

\textbook{\clearpage}
To get a more precise estimate divide $[0,1]$ into 8 subintervals of length $\Delta x=1/8$ and let $S_8$ be the sum of their areas, once again using the function evaluated at the right endpoints for the rectangle height:

\begin{center}
\includegraphics{graphics/integration5}%
\end{center}
The area estimate of $S$ is
\begin{eqnarray*}
S_8 & = & A_1+A_2+\ldots+A_8 \\
& = & \frac{1}{8}\left[
\left(\frac{1}{8}\right)^3+
\left(\frac{2}{8}\right)^3+
\left(\frac{3}{8}\right)^3+
\left(\frac{4}{8}\right)^3+
\left(\frac{5}{8}\right)^3+
\left(\frac{6}{8}\right)^3+
\left(\frac{7}{8}\right)^3+
\left(\frac{8}{8}\right)^3\right]\\
& = & \left(\frac{1}{8}\right)\left(\frac{1296}{4096}\right)=\frac{81}{256}\approx0.3164
\end{eqnarray*}
Once again this will be an overestimate of $S$ but we expect, based on the graph, that it has less error.

Let us find $S_n$ for any number of intervals $n$.  Divide the interval $[0,1]$ into $n$ equal subintervals of length $\Delta x=1/n$.  That is $[0,1/n]$, $[1/n,2/n]$,\ldots,$[\frac{n-1}{n},1]$. Then
\begin{eqnarray*}
S_n & = & A_1+A_2+\ldots+A_n \\
& = & \frac{1}{n}\left[\left(\frac{1}{n}\right)^3+\left(\frac{2}{n}\right)^3+\ldots+\left(\frac{n}{n}\right)^3\right] \\
& = & \left(\frac{1}{n}\right)\left(\frac{1}{n^3}\right)\left[1^3+2^3+\ldots+n^3\right] \\
& = & \frac{1}{n^4}\sum_{i=1}^{n}i^3 \\
& = & \frac{1}{n^4}\frac{n^4+2n^3+n^2}{4} \\
& = & \frac{n^2+2n+1}{4n^2}
\end{eqnarray*}
As a check note that if $n=4$ we get $S_4=0.3906$ and for $n=8$, $S_8=0.3164$\,.

\textbook{\clearpage}
Now for a larger number of intervals we expect $S_n$ to be a better estimate of $S$.  If we choose $n=16$ intervals for instance we have:
\begin{center}
\includegraphics{graphics/integration6}%
\raisebox{100pt}{$\displaystyle\Rightarrow\ S_{16}=\frac{289}{1024}=0.2822$}
\end{center}

So let us let the number of intervals go to infinity ($n\rightarrow\infty$):
\[\mylim{n}{\infty}S_n=\mylim{n}{\infty}\frac{n^2+2n+1}{4n^2}=\frac{1}{4}=0.25\]
As $n$ increases, then $S_n$ becomes a better and better approximation of the area under the curve.  Therefore:
\[\mbox{Area}=S=\mylim{n}{\infty}S_n=\frac{1}{4}\]

In general we want to evaluate the area $A$ under the curve $y=f(x)$, $f(x)\ge0$ from $x=a$ to $b$.  To do so, divide $[a,b]$ into $n$ subintervals of equal width $\Delta x=\frac{b-a}{n}$. Label the endpoints $x_0=a$, $x_1$, $x_2$, \ldots, $x_{n-1}$, $x_n=b$.  Let $x_i^*$ be any point on the subinterval $[x_{i-1},x_i]$.  The area $A$ of the region is the sum of the $n$ rectangles as $n\rightarrow\infty$ ($\Delta x\rightarrow 0$):
\[A=\mylim{n}{\infty}\sum_{i=1}^nf(x_i^*)\,\Delta x\ .\]
Since for a given $n$ the $\Delta x$ is constant, it may be pulled outside of the sum and we get:
\[A=\mylim{n}{\infty}\frac{b-a}{n}\sum_{i=1}^nf(x_i^*)\ .\]


The formula can be made more precise by specifying the position of $x_i^*$ within the interval:
\begin{description}
\item[right endpoint:] If $x_i^*$ is the right endpoint of the interval $[x_{i-1},x_i]$, then $\displaystyle x_i^*=a+i\frac{b-a}{n}$ and the area is given by
\[A=\mylim{n}{\infty}\frac{b-a}{n}\sum_{i=1}^nf\left(a+i\frac{b-a}{n}\right)\]
\item[midpoint:] If $x_i^*$ is the midpoint of the interval $[x_{i-1},x_i]$, then $\displaystyle x_i^*=a+\left(i-\frac{1}{2}\right)\frac{b-a}{n}$ and the area is given by
\[A=\mylim{n}{\infty}\frac{b-a}{n}\sum_{i=1}^nf\left(a+\left(i-\frac{1}{2}\right)\frac{b-a}{n}\right)\]
\item[left endpoint:] If $x_i^*$ is the left endpoint of the interval $[x_{i-1},x_i]$, then $\displaystyle x_i^*=a+(i-1)\frac{b-a}{n}$ and the area is given by
\[A=\mylim{n}{\infty}\frac{b-a}{n}\sum_{i=1}^nf\left(a+(i-1)\frac{b-a}{n}\right)\]
\end{description}

\begin{example}
  \begin{enumerate}
  \item Find the area under the curve $y=f(x)=3x^2+5x-1$ from $a = 1$
    to $b = 3$.  Take $x_i$ to be at the right endpoint of the
    $i$\textsuperscript{th} interval.
    
    \begin{solution*}
      \begin{align*}
        A &= \lim_{n\to\infty}\frac{b-a}{n} \sum_{i=1}^n f\left(a+ i\frac{b-a}{n}\right)
            = \lim_{n\to\infty} \frac{3-1}{n} \sum_{i=1}^n f\left(1+\frac{3-1}{n}i\right)\\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n f\left(1+\frac{2}{n}i\right)
            = \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n \left[3\left(1+\frac{2}{n}i\right)^2 + 5\left(1+\frac{2}{n}i\right) - 1\right]\\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n\left[3+\frac{12}{n}i + \frac{12}{n^2}i^2 + 5 + \frac{10}{n}i - 1\right] \\
          &= \lim_{n\to\infty} \frac{2}{n}\sum_{i=1}^n \left[7+\frac{22}{n}i + \frac{12}{n^2}i^2\right]
            = \lim_{n\to\infty} \frac{2}{n}\left[7n + \frac{22}{n}\cdot\frac{n^2+n}{2} + \frac{12}{n^2}\cdot\frac{2n^3+3n^2+n}{6}\right] \\
          &= \lim_{n\to\infty} \left[14 + 22\frac{n^2+n}{n^2} + 4\frac{2n^3+3n^2+n}{n^3}\right]
            = \lim_{n\to\infty} \left[14 + 22\left(1+\frac{1}{n}\right) + 4\left(2+\frac{3}{n}+\frac{1}{n^2}\right)\right]\\
          &= 14+22+8
            = 44
      \end{align*}
    \end{solution*}
    
  \item Find the area under the curve $y=x^3+5$ from $a = 1$ to $b = 3$. Take
    $x_i^*$ to be at the left endpoint of the $i$\textsuperscript{th} interval.
  
    \begin{solution*}
      \begin{align*}
        A &= \lim_{n\to\infty}\frac{b-a}{n}\sum_{i=1}^n f\left(a+(i-1)\frac{b-a}{n}\right)
            = \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n f\left(1+\frac{2}{n}(i-1)\right)\\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n \left[\left(1+\frac{2}{n}(i-1)\right)^3+5\right]\ \ \Leftarrow (x+y)^3=x^3+3x^2y+3xy^2+y^3\\
          &= \lim_{n\to\infty} \frac{2}{n}\sum_{i=1}^n \left[1+\frac{6}{n}(i-1) + \frac{12}{n^2}(i-1)^2 + \frac{8}{n^3}(i-1)^3 + 5\right] \\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n \left[6+\frac{6}{n}i - \frac{6}{n} + \frac{12}{n^2}(i^2-2i+1)+ \frac{8}{n^3}(i^3-3i^2+3i-1)\right] \\
          &= \lim_{n\to\infty} \frac{2}{n}\left[6n+\frac{6}{n}\cdot\frac{n^2+n}{2} - \frac{6}{n}n + \frac{12}{n^2}\cdot\frac{2n^3+3n^2+n}{6} - \frac{24}{n^2}\cdot\frac{n^2+n}{2} + \frac{12}{n^2}n\right. \\
          &\hspace{5em}+ \left.\frac{8}{n^3}\cdot\frac{n^4+2n^3+n^2}{4} - \frac{24}{n^3}\cdot\frac{2n^3+3n^2+n}{6} + \frac{24}{n^3}\cdot\frac{n^2+n}{2} - \frac{8}{n^3}n\right] \\
          &= 2[6+3-0+2(2)-0+0+2(1)-0+0-0] \\
          &= 2[9+4+2] \\
          &= 30
      \end{align*}
    \end{solution*}
  \end{enumerate}

\textbook{\clearpage}
\begin{furtherquestions*}
\begin{enumerate}
\item Find the area under the curve $y=x^2+2$ from $a=1$ to $b=4$.  Take $x_i^*$ to be the right endpoint of the $i^{\mbox{\tiny th}}$ interval.

\item Find the area under the curve $y=x^2+3x-2$ from $a=1$ to $b=4$.  Take $x_i^*$ to be the left endpoint of the $i^{\mbox{\tiny th}}$ interval.
\end{enumerate}
\end{furtherquestions*}
\end{example}

We are assuming that there is no difference in the results of these area formulae, despite the evaluation at different $x_i^*$. It remains to consider what properties the function must have for this to be true.

\textbook{\addtoanswerkey{\clearpage}}
\begin{exercise}
\input{INTEGRATION/area-under-a-curve}
\end{exercise}

\section{The Definite Integral}
Our consideration of the evaluation of the area under a curve leads us to define the definite integral.

\definition{Let $f$ be a function defined on the interval $[a,b]$.  Divide $[a,b]$ into $n$ equal subintervals of width $\Delta x=\frac{b-a}{n}$ with endpoints $x_0=a$, $x_1$, $x_2$, \ldots, $x_{n-1}$, $x_n=b$.  Let $x_i^*$ denote any point in the $i^{\mbox{\tiny th}}$ interval $[x_{i-1},x_i]$.  The \textbf{definite integral of $\bm{f}$ from $\bm{a}$ to $\bm{b}$} is:
\[\int_a^bf(x)\,dx=\mylim{n}{\infty}\sum_{i=1}^n f(x_i^*)\Delta x\]
if the limit exists and is independent of the choice of the $x_i^*$.  If the limit exists, then $f$ is said to be \textbf{integrable} on the interval $[a,b]$.}

We introduce the following terminology for the parts of the definite integral:
\begin{itemize}
\item $\displaystyle\int$ is the \textbf{integral sign}.  It is a script \emph{S} suggesting summation.
\item $f(x)$ is the \textbf{integrand}.
\item $x$ is the \textbf{variable of integration}.\footnote{The choice of integration variable, just as the choice of summation index, is arbitrary, i.e.
\[\int_a^b f(x)\,dx=\int_a^b f(y)\,dy=\int_a^b f(t)\,dt~.\]}
\item $dx$ is the \textbf{differential}.
\item $b$ is the \textbf{upper limit of integration}.
\item $a$ is the \textbf{lower limit of integration}.
\item The series $\displaystyle \sum_{i=1}^n f(x_i^*)\Delta x$ is a \textbf{Riemann sum}.
\end{itemize}

If $f(x)\ge 0$ for all $x$ in $[a,b]$, then $\int_a^b f(x)\,dx$ is the \textbf{area under the curve} $\bm{y=f(x)}$ and above the $x$-axis from $\bm{x=a}$ to $\bm{x=b}$ as we have already seen. For arbitrary $f$, the geometrical meaning of $\int_a^b f(x)\,dx$ is the \textbf{net signed area} between the curve and the $x$-axis on interval $[a,b]$ with areas above the $x$-axis (where $f(x)>0$) counted positively and areas below the $x$-axis (where $f(x)<0$) counted negatively.
\begin{center}
\includegraphics{graphics/integration7}%
\end{center}

The definite integral, representing a physical area, is therefore just a number.\footnote{Assuming there are no variables in the limits of integration or non-integration variables in the integrand.}

If the upper limit $b$ is less than the lower limit $a$ we can define, assuming $f$ is integrable on $[b,a]$, that
\[\int_a^b f(x)\,dx=-\int_b^a f(x)\,dx\,.\]
This definition is consistent with the Riemann sum in the original definition since if $b<a$ there, $\Delta x$ would be negative.  In practice, it is important to remember that if one exchanges limits one must introduce a minus sign.

The following theorem gives a sufficient condition for a function $f$ to be integrable on interval $[a,b]$.

\theorem{If $f$ is continuous on $[a,b]$ then $\int_a^b f(x)\,dx$ exists.}

In fact the weaker condition that $f$ be \textbf{piecewise continuous} on $[a,b]$ is sufficient.\footnote{Piecewise continuous means function $f$  is continuous everywhere except at a finite number of removable or jump discontinuities. Vertical asymptotes (infinite discontinuities) are not allowed.}

The next theorem lists several general properties of the definite integral.  While they may be rigorously proven by considering Riemann sums, consideration of their graphical meaning in terms of areas makes them intuitively reasonable.
\theorem{Let $f$ and $g$ be integrable functions on the given intervals of integration and $a$, $b$, $c$, $m$ and $M$ constants, then the following are true for definite integrals:
\begin{method}
\vspace{-1em}
\begin{enumerate}
\item $\displaystyle \int_a^a f(x)\,dx=0$
\item $\displaystyle \int_a^b c\,dx=c(b-a)$
\item $\displaystyle \int_a^b\left[f(x)\pm g(x)\right]\,dx=\int_a^bf(x)\,dx\pm\int_a^bg(x)\,dx$
\item $\displaystyle \int_a^bc f(x)\,dx=c\int_a^bf(x)\,dx$
\item $\displaystyle \int_a^b f(x)\,dx=\int_a^c f(x)\,dx+\int_c^b f(x)\,dx$
\item If $f(x)\ge0$ for all $x$ in $[a,b]$ then $\displaystyle \int_a^b f(x)\,dx\ge0$~.
\item If $f(x)\ge g(x)$ for all $x$ in $[a,b]$ then $\displaystyle \int_a^b f(x)\,dx\ge\int_a^bg(x)\,dx$~.
\item If $m\le f(x)\le M$ for all $x$ in $[a,b]$ then $\displaystyle m(b-a)\le\int_a^b f(x)\,dx\le M(b-a)$~.
\item $\displaystyle \left|\int_a^bf(x)\,dx\right|\le\int_a^b\left|f(x)\right|\,dx$
\end{enumerate}
\end{method}
}

\begin{example}
  Evaluate or simplify the following:
  \begin{enumerate}
  \item $\displaystyle\int_{-1}^1\sqrt{1-x^2}\,dx$\\[.5em]
    
    \begin{solution}
      The integrand of $\displaystyle\int_{-1}^1\sqrt{1-x^2}\,dx$
      is $y=f(x)=\sqrt{1-x^2}$.  Squaring both sides yields
      \begin{align*}
        y^2&=1-x^2\implies x^2+y^2=1
      \end{align*}
      and we recognize a circle of radius $r=1$.  Since our
      $y=\sqrt{1-x^2}$ (and so positive) and our limits are from $-1$ to
      $1$, the plot is the upper semicircle centred on the origin:
      \begin{center}
        \includegraphics[width=3cm]{graphics/integration13}
      \end{center}
      The definite integral is the signed area between the function and
      the $x$-axis between the limits $-1$ and $1$\,.  The area is a
      semicircle of radius $r=1$.  Since our area lies above the
      $x$-axis it is counted positively.  Therefore
      \begin{align*}
        \int_{-1}^1\sqrt{1-x^2}\,dx&=+\frac{1}{2}\pi(1)^2=\frac{\pi}{2}
      \end{align*}
    \end{solution}
  \item $\displaystyle\int_\pi^{3\pi}\!x \sin x\,dx$\ \  if\ \  $\displaystyle\int_\pi^{4\pi}\!x \sin x\,dx=-5\pi$ and $\displaystyle\int_{4\pi}^{3\pi}\!x \sin x\,dx=7\pi$\\[.5em]
    
    \begin{solution}
      $\begin{aligned}[t]
        \int_\pi^{3\pi}\!x \sin x\,dx
        &=\displaystyle\underbrace{\int_\pi^{3\pi}\!x \sin x\,dx+\int_{3\pi}^{4\pi}\!x \sin x\,dx}-\underbrace{\int_{3\pi}^{4\pi}\!x \sin x\,dx}\\
        &=\hspace{3em}\int_\pi^{4\pi}\!x \sin x\,dx\hspace{1.7em}-\hspace{1.7em}\left[-\int_{4\pi}^{3\pi}\!x \sin x\,dx\right]\\
        &=\int_\pi^{4\pi}\!x \sin x\,dx+\int_{4\pi}^{3\pi}\!x \sin x\,dx\\
        &=-5\pi+7\pi=2\pi
      \end{aligned}$
    \end{solution}
  \end{enumerate}

\begin{furtherquestions}
Evaluate or simplify the following:
\begin{enumerate}
  \begin{multicols}{2}
\item $\displaystyle \int_{-1}^2 x\,dx$
\item $\displaystyle \int_9^4\sqrt{t}\,dt$\ \ if\ \ $\displaystyle \int_4^9\sqrt{x}\,dx=\frac{38}{3}$~.
\item $\displaystyle\int_3^4 f(x)\,dx+\int_1^3 f(x)\,dx+\int_4^1 f(x)\,dx$
\item $\displaystyle\int_1^3 f(x)\,dx+\int_3^6 f(x)\,dx+\int_6^{12} f(x)\,dx$
  \end{multicols}
\end{enumerate}
\end{furtherquestions}
\end{example}

If a function is integrable we are free to choose the points of evaluation, $x_i^*$, when evaluating the Riemann sum to be the right endpoints of the intervals.

\theorem{If $f$ is integrable on $[a,b]$ then
\[\int_a^b f(x)\,dx=\mylim{n}{\infty}\frac{b-a}{n}\sum_{i=1}^n f\left(a+i\frac{b-a}{n}\right)\]}

Similar theorems can be given for the left endpoint and midpoint choices of $x_i^*$ as previously discussed.

\begin{example}
  Evaluate the following definite integrals using a Riemann sum with the
  function evaluated at the right endpoints of the interval.
  \begin{enumerate}
    \begin{multicols}{2}
  \item $\displaystyle\int_0^2 (x^3+2x+1) dx$
  \item $\displaystyle\int_2^4 (2x^2+3x+2) dx$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
      \begin{enumerate}
      \item $\begin{aligned}[t]
          \int_0^2 (x^3+2x+1) dx &= \lim_{n\to\infty} \frac{2-0}{n} \sum_{i=1}^n f\left(0+i\frac{2-0}{n}\right)
          = \lim_{n\to\infty} \frac{2}{n}\sum_{i=1}^n f\left(\frac{2i}{n}\right)\\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{i=1}^n \left[\frac{8i^3}{n^3} + 2\frac{2i}{n} + 1\right] \\
          &= \lim_{n\to\infty} \frac{2}{n}\left[\frac{8}{n^3}\frac{n^4+2n^3+n^2}{4} + \frac{4}{n}\frac{n^2+n}{2} + n\right] \\
          &= 2[2(1)+2(1)+1]= 10
        \end{aligned}$
      \item $\begin{aligned}[t]
          \int_2^4 (2x^2+3x+2) dx &= \lim_{n\to\infty} \frac{4-2}{n} \sum_{n=1}^\infty f\left(2+i\frac{4-2}{n}\right)
          = \lim_{n\to\infty} \frac{2}{n} \sum_{n=1}^{\infty} f\left(2+\frac{2i}{n}\right) \\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{n=1}^\infty \left[2\left(2+\frac{2i}{n}\right)^2 + 3\left(2+\frac{2i}{n}\right) + 2\right] \\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{n=1}^\infty \left[2\left(4+\frac{8i}{n}+\frac{4i^2}{n^2}\right) + 3\left(2+\frac{2i}{n}\right) + 2\right] \\
          &= \lim_{n\to\infty} \frac{2}{n} \sum_{n=1}^\infty \left[8+\frac{16}{n}i + \frac{8i^2}{n^2} + 6 + \frac{6i}{n} + 2\right] \\
          &= \lim_{n\to\infty} \frac{2}{n}\sum_{n=1}^\infty\left[16+\frac{22}{n}i + \frac{8}{n^2}i^2\right] \\
          &= \lim_{n\to\infty} \frac{2}{n}\left[16n + \frac{22}{n}\cdot\frac{n^2+n}{2} + \frac{8}{n^2}\cdot\frac{2n^3+3n^2+n}{6}\right] \\
          &= 2\left[16+11(1)+\frac{4}{3}(2)\right]
          = 2\left[16+11+\frac{8}{3}\right]
          = 2\left[27+\frac{8}{3}\right]
          = \frac{178}{3}
        \end{aligned}$  
      \end{enumerate}
  \end{solution*}

\textbook{\vspace{-.5em}}
\begin{furtherquestions}
Evaluate the following definite integrals using a Riemann sum with the function evaluated at the right endpoints of the intervals:
\begin{enumerate}
  \begin{multicols}{2}
\item $\displaystyle\int_0^3\left(x^3-5x\right)\,dx$
\item $\displaystyle\int_1^5\left(2+3x-x^2\right)\,dx$
  \end{multicols}
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{INTEGRATION/the-definite-integral}
\textbook{\vspace{-.95em}}
\end{exercise}

\section[Fundamental Theorem of Calculus]{The Fundamental Theorem of Calculus}

The \textbf{Fundamental Theorem of Calculus (FTC)} shows integration and differentiation are inverse processes of each other.  We will present two forms of the theorem, one involving derivatives and one antiderivatives.  The latter, as we will see, is particularly useful.

\theorem{\textbf{The Fundamental Theorem of Calculus (Derivative Form)}:

If $f$ is continuous on interval $[a,b]$, then the function $g(x)$ defined for all $x$ in $[a,b]$ by
\[g(x)=\int_a^xf(t)\,dt\ ,\]
is continuous on $[a,b]$ and differentiable on $(a,b)$ with\footnote{In fact, $g(x)$ is differentiable on $[a,b]$ (i.e. including the endpoints) if we admit right and left-handed derivatives at those points.  That is, we use the usual derivative formula with $\lim h\rightarrow 0^+$ and $\lim h\rightarrow 0^-$ at the endpoints.}
\[g'(x)=f(x)\ ,\]
or, equivalently,
\[\frac{d}{dx}\int_a^xf(t)\,dt=f(x)\ .\]
}

That the result of the theorem is plausible can be seen in the following diagram:
\begin{center}
\includegraphics{graphics/integration8}%
\end{center}
The function $\displaystyle g(x)=\int_a^xf(t)\,dt$ associates with each value $x$ the area under the curve $y=f(x)$ from the fixed number $a$ up to $x$. To find the derivative of the function we must evaluate:
\[g'(x)=\mylim{\Delta x}{0}\frac{g(x+\Delta x)-g(x)}{\Delta x}\]
In the diagram $g(x)$ is the dark grey area, while $g(x+\Delta x)$ is all of that area plus the light grey shaded area.  Therefore the difference $g(x+\Delta x)-g(x)$ is simply the light grey shaded area itself.  Now for finite $\Delta x$ this light grey area is not a rectangle since the left side has height $f(x)$ while the right side has height $f(x+\Delta x)$ and the top side is the curve $y=f(x)$ over $[x,x+\Delta x]$.  However, due to the continuity of $f$, we have $\mylim{\Delta x}{0}f(x+\Delta x)=f(x)$, in other words the light grey area becomes increasingly like a rectangle of width $\Delta x$ and height $f(x)$ as $\Delta x\rightarrow 0$.  Thus
\[g(x+\Delta x)-g(x)\approx f(x)\Delta x~,\]
and hence
\[\frac{g(x+\Delta x)-g(x)}{\Delta x}\approx f(x)~.\] 
and in the limit we have
\[g'(x)=\mylim{\Delta x}{0}\frac{g(x+\Delta x)-g(x)}{\Delta x}=f(x)\]
exactly.  A rigorous proof of the theorem can be made using the Extreme Value Theorem, inequalities of the definite integral, and the Squeeze Theorem.

\begin{example}
  Use the derivative form of the Fundamental Theorem of Calculus to
  find the derivatives of the following functions:
  \begin{enumerate}
  \item $\displaystyle f(x) = \int_0^x (t^2+3t+10)^{\frac{1}{3}}\,dt$
  \item $\displaystyle g(x) = \int_0^{x^2} \frac{t^2+1}{t^4+5}\,dt$
  \item $\displaystyle H(x) = \int_{\sqrt{x}}^{x^2} \sqrt{t^4+6}\,dt$
  \end{enumerate}

\begin{solution*}
  \begin{enumerate}
  \item $\begin{aligned}[t]
      f(x)&= \int_0^x \underbrace{(t^2+3t+10)^{\frac{1}{3}}}_{g(t)}\,dt \\
      f'(x) &= g(x) =(x^2+3x+10)^\frac{1}{3}
    \end{aligned}$\\[.5em]
    So if the lower limit is constant and the upper limit is just the
    variable then the theorem requires simply its substitution into the
    integrand.
  \item $\displaystyle g(x) = \int_0^{x^2} \frac{t^2+1}{t^4+5}\,dt$\\[1em]

    In this case the upper limit is not simply the variable but a
    function of the variable.  This can be evaluated by recognizing
    that $g(x)$ is a composition of functions, $g(x)=F(G(x))$, where
    $F(u)= \int_0^{u} \frac{t^2+1}{t^4+5}\,dt$ and $u=G(x)=x^2$.  Then
    by the Chain Rule $g'(x)=F'(u(x))G'(x)$.  Using the FTC one has
    $F'(u)=\frac{u^2+1}{u^4+5}\implies
    F'(u(x))=\frac{(x^2)^2+1}{(x^2)^4+5}=\frac{x^4+1}{x^8+5}$. Also
    $G'(x)=(x^2)'=2x$.  Multiplying these gives:\\[1em]

    $\begin{aligned}[t] g'(x) &=\frac{d}{dx}\int_0^{x^2}
      \frac{t^2+1}{t^4+5}\,dt
      =\frac{(x^2)^2+1}{(x^2)^4+5}\cdot(2x)=\frac{x^4+1}{x^8+5}\cdot
      (2x)=\frac{2x^5+2x}{x^8+5}
    \end{aligned}$\\[1em]
  
    This may seem complicated but the pattern is simple.  Substitute
    the upper limit into the integrand as before, but now also
    multiply by the derivative of the upper limit.

\textbook{\clearpage}
  \item $\displaystyle H(x) = \int_{\sqrt{x}}^{x^2} \sqrt{t^4+6}\,dt$\\[1em]
    In this case the lower limit is also a function of the variable.
    We use our basic properties of integrals to rewrite $H(x)$ into
    the sum of two integrals to which the FTC may be applied.\\[1em]
    $\begin{aligned}[t]
      H(x) &= \int_{\sqrt{x}}^{x^2} \sqrt{t^4+6}\,dt
      = \int_{\sqrt{x}}^0\sqrt{t^4+6}\,dt + \int_0^{x^2} \sqrt{t^4+6}\,dt\\
      &= -\int_0^{\sqrt{x}}\sqrt{t^4+6}\,dt + \int_0^{x^2}\sqrt{t^4+6}\,dt\\
      \implies H'(x)&= -\sqrt{(\sqrt{x})^4+6}\cdot\left(\frac{1}{2}x^{-\frac{1}{2}}\right) + \sqrt{(x^2)^4+6}\cdot(2x)\\
        &=-\frac{1}{2\sqrt{x}}\sqrt{x^2+6} + 2x\sqrt{x^8+6}
      \end{aligned}$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Use the derivative form of the Fundamental Theorem of Calculus to find the derivatives of the following functions:
\begin{enumerate}
\item $\displaystyle g(x)=\int_{-1}^x\sqrt{t^3+1}\,dt$
\item $\displaystyle g(x)=\int_x^4\left(2+\sqrt{u}\right)^8\,du$
\item $\displaystyle h(x)=\int_{1}^{\sqrt{x}}\frac{s^2}{s^2+1}\,ds$
\item $\displaystyle g(x)=\int_{2}^{x^2+x}\sqrt{1+t^3}\,dt$
\item $\displaystyle g(x)=\int_0^{\sin x}\cos\theta\,d\theta$
\item $\displaystyle \mathrm{Si}(2x)$ where $\mathrm{Si}(x)$ is the \emph{sine integral} function $\displaystyle \mathrm{Si}(x)=\int_0^x\frac{\sin t}{t}\,dt$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{INTEGRATION/fundamental-theorem-of-calculus-derivative-form}
\end{exercise}

\textbook{\clearpage}
We next turn to the second form of the Fundamental Theorem of Calculus which gives a simple mechanism to evaluate many definite integrals.
% Since this is just Antiderivative Form of the theorem we decrement the result.
\addtocounter{mytheorem}{-1}
\theorem{\textbf{The Fundamental Theorem of Calculus (Antiderivative Form)}:

If $f$ is continuous on $[a,b]$ and $F$ is any antiderivative of $f$ (so $F'=f$) then
\[\boxed{\int_a^bf(x)\, dx=F(b)-F(a)}~.\]
}

Note we define the shorthand $\displaystyle \left. F(x)\right|_a^b$ to be the right hand side of the equality,  $\displaystyle \left. F(x)\right|_a^b=F(b)-F(a)$.  Unlike the integral sign, the bar is placed on the right.

Proof of the Antiderivative Form of the FTC follows from the fact that the deriative form of the FTC shows that $g(x)=\int_a^x f(t)dt$ is an antiderivative of $f(x)$, since $g'(x)=f(x)$.  By  Theorem~\ref{thm:antiderivatives}, any other antiderivative $F(x)$ of $f(x)$ differs by at most a constant from $g$, $F(x)=g(x)+C$.  Hence
\[F(b)-F(a)=[g(b)+C]-[g(a)+C]=g(b)-g(a)=\int_a^bf(t)\,dt-\underbrace{\int_a^af(t)\,dt}_{=0}=\int_a^bf(t)\,dt\ .\]

\begin{example}
  Use the antiderivative form of the FTC to evaluate the following definite
  integrals:

  \begin{enumerate}
    \begin{multicols}{3}
  \item $\displaystyle \int_0^2 (4x^3+3)\,dx$
  \item $\displaystyle \int_1^4 \frac{(x+1)^2}{\sqrt{x}}\,dx$
  \item $\displaystyle\int_{-1}^2 \frac{1}{(x+1)^2}\,dx$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle\int_0^2 (4x^3+3)\,dx = \left[(4)\left(\frac{1}{4}\right) x^4+3x \right|_0^2= \left[ x^4+3x \right|_0^2
      = [2^4+3(2)] - [0 + 0] = 16+6=22$
    \item $\begin{aligned}[t]
        \int_1^4 \frac{(x+1)^2}{\sqrt{x}}\,dx
        &= \int_1^4 \frac{x^2+2x+1}{\sqrt{x}}\,dx 
        = \int_1^4 \left(\frac{x^2}{\sqrt{x}}+\frac{2x}{\sqrt{x}}+\frac{1}{\sqrt{x}}\right)dx \\
        &= \int_1^4(x^{\frac{3}{2}} + 2x^{\frac{1}{2}} + x^{-\frac{1}{2}})\,dx
        =\left[\frac{x^{\frac{5}{2}}}{\frac{5}{2}}
          +2\frac{x^{\frac{3}{2}}}{\frac{3}{2}}
          +\frac{x^{\frac{1}{2}}}{\frac{1}{2}}\right|_1^4\\
        &=\left[\frac{2}{5}x^{\frac{5}{2}}
          +\frac{4}{3}x^{\frac{3}{2}}
          +2x^{\frac{1}{2}}\right|_1^4
        = \left[\frac{2}{5}(4)^\frac{5}{2} + \frac{4}{3}(4)^\frac{3}{2}
          +2(4)^\frac{1}{2}\right] - \left[\frac{2}{5} + \frac{4}{3} + 2\right]\\
        &= \left[\frac{2}{5}(2)^5 + \frac{4}{3}(2)^3
          +2(2)\right] - \left[\frac{2}{5} + \frac{4}{3} + 2\right] \\
        &=\frac{64}{5}+\frac{32}{3}+ 4 -\frac{2}{5}-\frac{4}{3}-2
        =\frac{62}{5} + \frac{28}{3} +2
        = \frac{186+140+30}{15}
        =\frac{356}{15}
      \end{aligned}$      
    \item $\displaystyle\int_{-1}^2 \frac{1}{(x+1)^2}\,dx$\ \ \ 

      The FTC cannot be applied since $\displaystyle\frac{1}{(x+1)^2}$ is not
      continuous at $x=-1$.\\
      The integral does not in fact exist.
    \end{enumerate}
  \end{solution*}

\textbook{\clearpage}
\begin{furtherquestions}
Use the antiderivative form of the FTC to evaluate the following definite integrals:
\begin{enumerate}
\item $\displaystyle\int_1^2 x^{-2}\,dx$
\item $\displaystyle\int_0^1\left(y^9-2y^5+3y\right)\,dy$
\item $\displaystyle\int_0^{\frac{\pi}{2}}\left(\cos\theta+2\sin\theta\right)\,d\theta$
\item $\displaystyle\int_1^4\frac{\left(\sqrt{x}+2\right)^2}{\sqrt{x}}\,dx$
\item $\displaystyle\int_0^1\frac{1}{x^3}\,dx$
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{INTEGRATION/fundamental-theorem-of-calculus-antiderivative-form}
\end{exercise}

\textbook{\clearpage}
\subsection*{Indefinite Integrals}
Because of the connection between the evaluation of definite integrals with integrand $f$ and the antiderivative of $f$ we define the \textbf{indefinite integral} as follows:
\definition{If $F(x)$ is an antiderivative of $f$, so $F'(x)=f(x)$, then the \textbf{indefinite integral} of $f(x)$ is
\[\int f(x)\,dx=F(x)+C\]
}
The advantage of this notation for the antiderivative (rather than, say $F(x)$) is that $\int f(x)\,dx$ clearly indicates the function $f$ being antidifferentiated, just as $\frac{df}{dx}$ indicates the function differentiated.  Note, however, the difference between the definite and indefinite integrals.  The definite integral $\int_a^b f(x)\,dx$ is a number while the indefinite integral $\int f(x)\,dx$ is a function.\footnote{Indeed, due to the presence of the constant $C$, a family of functions.}

For indefinite integrals we say, for example, that $\frac{1}{n+1}x^{n+1}+C$ is the \textbf{(indefinite) integral} of $x^n$ where $x^n$ is the \textbf{integrand}.  The \textbf{process} of finding the integral is called \textbf{integration}.

Using our notation for indefinite integrals and our knowledge of derivatives gives the following.
\begin{method}
\vspace{-.5em}
\begin{center}
\textbf{\Large Table of Indefinite Integrals}
\end{center}
\begin{enumerate}
\item $\displaystyle\int x^n\,dx=\frac{1}{n+1}x^{n+1}+C\ \ \ \ (n\neq-1)$
\item $\displaystyle\int \cos x\,dx=\sin x+C$
\item $\displaystyle\int \sin x\,dx=-\cos x+C$
\item $\displaystyle\int \sec^2x\,dx=\tan x+C$
\item $\displaystyle\int \sec x\tan x\,dx=\sec x+C$
\item $\displaystyle\int \csc^2x \,dx=-\cot x+C$
\item $\displaystyle\int \csc x\cot x\,dx=-\csc x+C$
\item $\displaystyle\int c f(x)\,dx=c\int f(x)\,dx$
\item $\displaystyle\int \left[f(x)\pm g(x)\right]\,dx=\int f(x)\,dx\pm \int g(x)\,dx$
\end{enumerate}
\end{method}
In the last two integration formulae $f(x)$ and $g(x)$ are functions while $c$ is a constant.  

\begin{example}
  Evaluate the following integrals:
  \begin{enumerate}
    \begin{multicols}{3}
    \item $\displaystyle\int (x^2+1)^2\,dx$
    \item $\displaystyle\int\left(\sqrt{t} + \frac{1}{\sqrt{t}}\right)\!dt$
    \item $\displaystyle\int (3\cos{\theta} + 5\sec^2\!\theta)\,d\theta$
    \end{multicols}
  \end{enumerate}
  
  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle\int (x^2+1)^2\,dx = \int (x^4+2x^2+1)\,dx
      = \frac{1}{5}x^5 + \frac{2}{3}x^3+x+C$
    \item $\displaystyle\int\left(\sqrt{t} + \frac{1}{\sqrt{t}}\right)\!dt
      = \int(t^{\frac{1}{2}} + t^{-\frac{1}{2}})\,dt
      = \frac{2}{3}t^{\frac{3}{2}} + 2t^{\frac{1}{2}} + C$
    \item $\displaystyle\int (3\cos{\theta} + 5\sec^2\!\theta)\,d\theta
      = 3\sin{\theta} + 5\tan{\theta} + C$
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following integrals:
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle\int\sqrt{x}\left(x^2-\frac{1}{x}\right)\,dx$
\item $\displaystyle\int\left(\sqrt{x}+3x\right)^2\,dx$
\item $\displaystyle\int\frac{\left(2x^3+3\right)^2}{x^2}\,dx$
\item $\displaystyle\int\left(3\cos t-2\sin t+\sec t\tan t\right)\,dt$
\item $\displaystyle\int\left(\sqrt[3]{y}+\frac{1}{\sqrt[3]{y}}\right)\,dy$
\item $\displaystyle\int\frac{(x+1)^3}{x^5}\,dx$
\item $\displaystyle\int_1^4\left(\sqrt{3x}+5x+1\right)\,dx$
\item $\displaystyle\int_0^{\frac{\pi}{4}}\left(2\cos x-3\sin x+\sec^2x\right)\,dx$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}
The last two integrals in the example, definite integrals, illustrate that these just require the further step, after finding the antiderivative, of finding the difference of its evaluation at the endpoints.

\begin{exercise}
\input{INTEGRATION/indefinite-integrals}
\textbook{\vspace{-1em}}
\end{exercise}

\section{Integration by Substitution}

Consider the indefinite integral
\[\int x^2\sqrt{1+x^3}\, dx~.\]
Finding an antiderivative is possible if we recall the Chain Rule for differentiating compositions of functions:
\[\frac{d}{dx} f(g(x))=f'(g(x))\cdot g'(x)~.\]
In this example consider $\left(1+x^3\right)^{\frac{3}{2}}$ which can be thought of as $f(g(x))$ where $f(u)=u^{\frac{3}{2}}$ and \mbox{$u=g(x)=1+x^3$}.  The Chain Rule gives:
\[\frac{d}{dx} \left(1+x^3\right)^{\frac{3}{2}}=\frac{3}{2}\left(1+x^3\right)^{\frac{1}{2}}\cdot\frac{d}{dx}\left(1+x^3\right)=\frac{3}{2}\sqrt{1+x^3}\cdot\left(0+3x^2\right)=\frac{9}{2}x^2\sqrt{1+x^3}~.\]
This is almost the integrand.  Recalling that $(cf(x))'=cf'(x)$ we can get rid of the $9/2$ by multiplying the original function by $2/9$:
\[\frac{d}{dx}\left[ \frac{2}{9}\left(1+x^3\right)^{\frac{3}{2}}\right]=\frac{2}{9}\cdot\frac{9}{2}x^2\sqrt{1+x^3}=x^2\sqrt{1+x^3}~,\]
and therefore,
\[\int x^2\sqrt{1+x^3}\, dx = \frac{2}{9}\left(1+x^3\right)^{\frac{3}{2}}+C~.\]

This example is not very practical because the initial step of considering the derivative of $\left(1+x^3\right)^{\frac{3}{2}}$ came out of nowhere.  However it does suggest that the Chain Rule should underlie some useful integration method.  It does.  In practice we focus on transforming the original integral in $x$ into an integral in terms of a new variable $u$ where $u=g(x)$ is the inner function of a composite function found in the integrand.  We have the following:

\theorem{\textbf{Substitution Rule (Indefinite Integrals):} Suppose $u=g(x)$ is a differentiable function whose range of values is an interval $I$ upon which a further function $f$ is continuous, then
\[\int f(g(x))g'(x)\,dx=\int f(u)\,du\ .\]
where the right hand integral is to be evaluated at $u=g(x)$ after integration.
}

Note that the $du$ appearing on the right side is the differential:
\[du=g'(x)dx\]
which, recall, can be remembered by thinking $\frac{du}{dx}=g'(x)$ and multiplying both sides by $dx$.

\begin{method}
To integrate using the Substitution Rule for an indefinite integral follow these steps:
\begin{enumerate}
\item Selection a substitution $u$ that appears to simplify the integrand.  Try to select $u$ so that its derivative is a factor in the integrand.
\item Express the integrand entirely in terms of $u$ and $du$ eliminating the original variable and its differential.
\item Evaluate the new $u$ integral if possible.
\item Express the antiderivative found in the last step (a function of u) in terms of the the original variable.
\end{enumerate}
\end{method}

Consider the original integral again:
\[\int x^2\sqrt{1+x^3}\, dx\]
Let us apply the Substitution Rule steps to solve this integral:
\begin{enumerate}
\item Looking at the integrand a useful substitution looks like
\[u=1+x^3\]
since this turns $\sqrt{1+x^3}$ into $\sqrt{u}$.  Differentiating $u$ we get:
\[\frac{du}{dx}=0+3x^2=3x^2\ .\]
Up to the constant $3$ this is a factor in the integrand.  Our $du$ is:
\[du=3x^2\,dx\]
\item The original integral becomes, in terms of $u$ and $du$:
\[\int x^2\sqrt{1+x^3}\, dx=\int \sqrt{1+x^3}(x^2\, dx)=\int \sqrt{u}\,\frac{du}{3}\]
Here we used, from our differential formula that $x^2\,dx=\frac{du}{3}$.
\item Integrating we get:
\[\int \sqrt{u}\,\frac{du}{3}=\frac{1}{3}\int u^{\frac{1}{2}}\,du=\frac{1}{3}\frac{1}{\frac{3}{2}}u^{\frac{3}{2}}+C=\frac{1}{3}\cdot\frac{2}{3}u^{\frac{3}{2}}+C=\frac{2}{9}u^{\frac{3}{2}}+C\]
\item Replacing $u$ with $1+x^3$ gives the final result:
\[\int x^2\sqrt{1+x^3}\, dx=\frac{2}{9}\left(1+x^3\right)^{\frac{3}{2}}+C\]
Note this last step is required as the antiderivative of a function of $x$ must itself be a function of~$x$.
\end{enumerate}

\begin{example}
  Evaluate the indefinite integrals:
  \begin{enumerate}
    \begin{multicols}{2}
    \item \label{itm:indefinite1} $\displaystyle\int x(3x^2+5)^3\,dx$
    \item \label{itm:indefinite2} $\displaystyle\int \sqrt{6+x}\,dx$
    \item $\displaystyle\int\left[x(3x^2+5)^3+\sqrt{6+x}+x^3\right]dx$
    \item $\displaystyle\int \sin{2x}\sqrt[4]{\cos{2x}}\,dx$
    \item $\displaystyle\int \frac{t^3-2t+4}{t^3}\,dt$
    \item $\displaystyle\int \frac{\cos{x}}{(1+3\sin{x})^3}\,dx$
    \item $\displaystyle\int x^3\sqrt{2x^2+5}\,dx$
    \item $\displaystyle\int \frac{1-x}{(2-6x+3x^2)^4}\,dx$
    \item $\displaystyle\int \frac{(\tan\theta+2)^2\sec^2\!\theta}{\tan^4\!\theta}\,d\theta$
    \item $\displaystyle\int x(2+x^3)^2\,dx$
    \end{multicols}
    \end{enumerate}

    \textbook{\newpage}
  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle \int x(3x^2+5)^3\,dx
      =\int (3x^2+5)^3x\,dx
      = \int u^3\frac{1}{6}\,du
      = \frac{1}{6}\cdot\frac{u^4}{4} + C = \frac{1}{24}(3x^2+5)^4 + C$\\[.5em]
      \hspace*{10em}$\boxed{\begin{aligned}
          u &= 3x^2+5 \\
          \textstyle\frac{du}{dx} &= 6x \\
          du &= 6x\,dx \implies \textstyle \frac{1}{6}du
          = x\,dx
        \end{aligned}}$
      
    \item $\displaystyle \int \sqrt{6+x}\,dx
      =\int u^\frac{1}{2}\,du = \frac{2}{3} u^\frac{3}{2} + C
      =\frac{2}{3}(6+x)^\frac{3}{2} + C$\\[.5em]
      \hspace*{4em}$\boxed{\begin{aligned}
          u &=6+x \\
          \textstyle\frac{du}{dx} &= 1 \\
          du &= dx \\
        \end{aligned}}$
      
    \item $\begin{aligned}[t]\int\left[x(3x^2+5)^3+\sqrt{6+x}+x^3\right]dx
        &=\int x(3x^2+5)^3\,dx~~~~+~~ \int \sqrt{6+x}\,dx ~~~\,+~\int x^3\,dx\\
        &=\left(\begin{array}{c}\text{sub }u=3x^2+5\\
            \text{as in Question~\ref{itm:indefinite1}}\end{array}\right)
        \left(\begin{array}{c}\text{sub }w=6+2\\
                \text{as in Question~\ref{itm:indefinite2}}\end{array}\right)
        \left(\begin{array}{c}\text{no sub}\\
                \text{at all}\end{array}\right)\\
        &=\frac{1}{24}(3x^2+5)^4+\frac{2}{3}(6+x)^\frac{3}{2}+\frac{1}{4}x^4+C
      \end{aligned}$\\[.5em]
      Remember that when integrating we can integrate term by term.
      One may need a substitution for only one term or potentially
      different substitutions on different terms. Treat each term as
      its own integration problem.

    \item $\displaystyle  \int \sin{2x}\sqrt[4]{\cos{2x}}\,dx
      = -\frac{1}{2}\int \sqrt[4]{u}\,du
      = -\frac{1}{2}\int u^\frac{1}{4}\,du
      = -\frac{1}{2}\cdot\frac{4}{5} u^\frac{5}{4} + C
      = -\frac{2}{5}(\cos{2x})^\frac{5}{4} + C$\\[.5em]      
      \hspace*{1em}$\boxed{\begin{aligned}
          u & = \cos{2x} \\
          \textstyle \frac{du}{dx} & = (-\sin{2x})(2)=-2\sin{2x} \\
          du & = -2\sin{2x}\,dx
          \implies -\frac{1}{2}du = \sin{2x}\,dx
        \end{aligned}}$
      
    \item $\begin{aligned}[t]
        \int \frac{t^3-2t+4}{t^3}\,dt
        &= \int \left[1-\frac{2}{t^2}+\frac{4}{t^3}\right]dt
        = \int [1-2t^{-2} + 4t^{-3}]\,dt
        = t - 2\frac{t^{-1}}{-1} + 4\frac{t^{-2}}{-2} + C\\
        &= t + \frac{2}{t} - \frac{2}{t^2} + C
      \end{aligned}$\\[.5em]
      (Not every integral is solved using a substitution!)
      
    \item $\begin{aligned}[t]
        \int\frac{\cos{x}}{(1+3\sin{x})^3}\,dx
        = \int\frac{1}{(1+u)^3}\frac{1}{3}\,du
        = \frac{1}{3}\int\frac{1}{(1+u)^3}\,du
        \end{aligned}$\\[.5em]
        \hspace*{1.5em}$\boxed{\begin{aligned}
            u &= 3\sin{x} \\
            du &= 3\cos{x}\,dx \implies \frac{1}{3}\,du = \cos{x}\,dx \\
        \end{aligned}}$\\[.5em]
      We can try a further substitution at this point.\\[1em]
      $\begin{aligned}[t]
        \hspace{8em}\ldots \frac{1}{3}\int\frac{1}{(1+u)^3}\,du
        &= \frac{1}{3}\int \frac{1}{w^3}\,dw
        =\frac{1}{3}\int w^{-3}\,dw
        = \frac{1}{3}\cdot\frac{w^{-2}}{-2} + C\\
        &=-\frac{1}{6w^2} + C
        = -\frac{1}{6(1+u)^2} + C
        = -\frac{1}{6(1+3\sin{x})^2} + C
        \end{aligned}$\\[-5em]
      \hspace*{1.5em}$\boxed{\begin{aligned}
          w &= 1+u \\
          dw &= du
        \end{aligned}}$\\[2em]
      So with repeated substitutions in indefinite integrals one has
      to back replace the variable more than once.  In this example
      the reader may show that a more efficient (single) substitution
      would have been $u=1+3\sin x$ from the beginning.
    \item $\begin{aligned}[t] \int x^3\sqrt{2x^2+5}\,dx
        = \int x^2\sqrt{2x^2+5}(x\,dx)
        &= \int \frac{1}{2}(u-5)\sqrt{u}\frac{1}{4}\,du
        = \frac{1}{8}\int (u^{\frac{3}{2}} - 5u^\frac{1}{2})\,du\\
        &= \frac{1}{8}\left[\frac{2}{5}u^{\frac{5}{2}} - 5\frac{2}{3}u^\frac{3}{2}\right] + C\\
        &= \frac{1}{20}(2x^2+5)^\frac{5}{2} - \frac{5}{12}(2x^2+5)^\frac{3}{2} + C
      \end{aligned}$\\[-4.5em]
      \hspace*{2em}$\boxed{\begin{aligned} u = 2x^2 + 5 \implies x^2 =
          \frac{1}{2}(u-5) \\
          du = 4x\,dx \implies \frac{1}{4}\,du = x\,dx \\
        \end{aligned}}$\\[.5em]
      This example illustrates that one does not always need to have
      the differential visibly present when doing a substitution.
      Since one can, with a substitution $u(x)$, solve for $x(u)$ one
      can use the latter expression to remove the remaining $x$'s in
      the integrand in terms of $u$.  Usually one ends up with a more
      complicated integral to solve, but in some cases, such as this,
      the integral becomes doable.
      
    \item $\begin{aligned}[t]  \int \frac{1-x}{(2-6x+3x^2)^4}\,dx
      =\int \frac{1}{u^4}\cdot\frac{-1}{6}\,du
      = -\frac{1}{6}\int u^{-4}\,du
      &=-\frac{1}{6}\cdot\frac{u^{-3}}{-3} + C
      =\frac{1}{18}u^{-3}+ C\\
      &= \frac{1}{18(2-6x+3x^2)^3} + C
    \end{aligned}$\\[-2em]
      \hspace*{1em}$\boxed{\begin{aligned}
          u&=2-6x+3x^2 \\
          du&= (-6+6x)\,dx
          \implies -\frac{1}{6}\,du = (1-x)\,dx \\
        \end{aligned}}$

    \item $\begin{aligned}[t]\int \frac{(\tan\theta+2)^2\sec^2\!\theta}{\tan^4\!\theta}\,d\theta
        &=\int \frac{(u+2)^2}{u^4}\,du
        = \int \frac{u^2+4u+4}{u^4}\,du
        = \int \left(\frac{1}{u^2} + \frac{4}{u^3} + \frac{4}{u^4}\right)\,du\\
        &= \int (u^{-2} + 4u^{-3}+ 4u^{-4})\,du
        = \frac{u^{-1}}{-1} + 4\frac{u^{-2}}{-2} + 4\frac{u^{-3}}{-3} + C\\
        &= -\frac{1}{u} - \frac{2}{u^2} - \frac{4}{3u^3} + C
        =-\frac{1}{\tan\theta} - \frac{2}{\tan^2\!\theta} - \frac{4}{3\tan^3\!\theta} + C\\
        &=-\cot\theta - 2\cot^2\!\theta - \frac{4}{3}\cot^3\!\theta + C\\
      \end{aligned}$\\[-6.5em]
      \hspace*{1.5em}$\boxed{\begin{aligned}
          u&=\tan \theta \\
          du&= \sec^2\!\theta\,d\theta\\
        \end{aligned}}$\\[3em]

    \item
      $\displaystyle\int x(2+x^3)^2\,dx = \int x(4+4x^3+x^6)\,dx =
      \int (4x+4x^4 + x^7)\,dx
      = 2x^2 + \frac{4}{5} x^5 + \frac{x^8}{8} + C$\\[1em]
      One may have been tempted to try the substitution $u=2+x^3$ so
      $du=3x^2\,dx$.  However the integrand only has $x\,dx$ outside
      of the square.  When doing a successful substitution all
      instances of the original variable must be replaced.  One can
      replace the remaining $x$'s in this case by solving $u=2+x^3$
      for $x$ to get $x=\sqrt[3]{u-2}$, in which case the integral can
      be rewritten as
      $\int x(2+x^3)^2\,dx = \int \frac{1}{x}(2+x^3)^2x^2\,dx
      =\int\!\frac{u^2}{\sqrt[3]{u-2}}\left(\frac{1}{3}\right)du$\,.  This new integral,
      however, is no easier to integrate than the original.
    \end{enumerate}
  \end{solution*}

\textbook{\newpage}
\begin{furtherquestions}
Evaluate the indefinite integrals:
\begin{multicols}{3}
\begin{enumerate}
\item $\displaystyle\int \frac{5x^4+3}{\left(x^5+3x+2\right)^3}\,dx$
\item $\displaystyle\int \frac{x^2-1}{\left(x^3-3x+7\right)^2}\,dx$
\item $\displaystyle\int \tan^2x\, \sec^2x\,dx$
\item $\displaystyle\int x\cos\left(x^2+3\right)\,dx$
\item $\displaystyle\int \frac{\cos x}{\left(1+\sin x\right)^{\frac{5}{2}}}\,dx$
\item $\displaystyle\int \frac{\left(x^3+3x\right)^2}{x^2}\,dx$
\item $\displaystyle\int x^3\sqrt{1+x^2}\,dx$
\item $\displaystyle\int \frac{\sec^2\sqrt{x}}{\sqrt{x}}\,dx$
\item $\displaystyle\int x^5\left(2+3x^2\right)^{\frac{3}{2}}\,dx$
\item $\displaystyle\int \sin^2x\,dx$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

\subsection*{Substitution Rule with Definite Integrals}
When the substitution method is required for definite integrals the obvious method is to use the substitution to find the antiderivative and then evaluate at the endpoints and subtract as usual.
\begin{example}
Evaluate the definite integral $\displaystyle\int_0^2 x^2\sqrt{1+x^3}\, dx$.

Here we recognize the indefinite integral from before.  We solved this using the substitution $u=1+x^3$ to find the required antiderivative $\frac{2}{9}\left(1+x^3\right)^{\frac{3}{2}}+C$ so the definite integral is just:
\[\int_0^2 x^2\sqrt{1+x^3}\, dx=\ldots=\left.\frac{2}{9}\left(1+x^3\right)^{\frac{3}{2}}\right|_0^2=\frac{2}{9}\left[(1+2^3)^{\frac{3}{2}}-(1+0^3)^{\frac{3}{2}}\right]=\frac{2}{9}\left[27-1\right]=\frac{52}{9}\]
Notice here the constant $\frac{2}{9}$ which was a factor of both the upper and lower limit was pulled out to simplify evaluation.
\end{example}

A quicker way to solve the definite integral when doing a substitution is to skip the last step of converting the antiderivative in terms of $u$ back to the original variable.  Instead you can convert the limits of the original variable into new limits of the variable $u$.

\begin{example}
Evaluate the definite integral $\displaystyle\int_0^2 x^2\sqrt{1+x^3}\, dx$ by changing the limits of the integral upon substitution.

As before we have the substitution $u=1+x^3$ so $du=3x^2\, dx$.  Now $x$ ranges from lower limit 0 to upper limit 2.  The new limits of $u$ are:
\begin{description}
\item[upper limit:] $x=2$ $\Rightarrow$ $u=1+2^3=9$
\item[lower limit:] $x=0$ $\Rightarrow$ $u=1+0^3=1$
\end{description}

The integral becomes:
\[\int_0^2 x^2\sqrt{1+x^3}\, dx=\frac{1}{3}\int_1^9u^{\frac{1}{2}}\,du=\frac{1}{3}\left[\frac{1}{\frac{3}{2}}u^{\frac{3}{2}}\right|_1^9=\frac{2}{9}\left(9^{\frac{3}{2}}-1^{\frac{3}{2}}\right)=\frac{2}{9}\left[27-1\right]=\frac{52}{9}\]
\end{example}

Not only is changing the limits to limits in $u$ usually faster it is also cleaner.  For instance it would be wrong to write $\int_0^2 x^2\sqrt{1+x^3}\, dx=\frac{1}{3}\int_0^2u^{\frac{1}{2}}\,du$, even if you ultimately plan on converting $u$ back to $x$ to find the antiderivative.  The $u$ is just a dummy variable so $\frac{1}{3}\int_0^2u^{\frac{1}{2}}\,du$ can be evaluated to equal $2^{\frac{5}{2}}/9$ which is not the answer to the definite integral in question.

Also note that when you change the limits to limits in $u$ it can occur that the upper limit in $u$ may now be lower in value than the lower limit.  There is nothing wrong with this.  The upper limit in $u$ must correspond to the upper limit of original variable, and similarly for the lower limit.

The whole discussion may be summarized in the following theorem.
\theorem{\textbf{Substitution Rule (Definite Integrals):} Suppose
  $u=g(x)$ is a differentiable function whose derivative $g'$ is
  continuous on $[a,b]$ and a further function $f$ is continuous on
  the range of $u=g(x)$ (evaluated on $[a,b]$), then
\[\int_a^b f(g(x))g'(x)\,dx=\int_{g(a)}^{g(b)} f(u)\,du\ .\]
}
\begin{example}
  Find the definite integrals:
  \begin{enumerate}
    \begin{multicols}{3}
    \item $\displaystyle\int_0^1 (y^2+1)^4 y\, dy$
    \item $\displaystyle\int_0^{\pi/4}\!3\sin(2x-\pi/2)\,dx$
    \item $\displaystyle\int_{0.3}^{0.5}\left(x+4\tan x\sec^2\!x\right)dx$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item $\displaystyle \int_0^1 (y^2+1)^4 y\,dy
      = \int_1^2 u^4\frac{1}{2}\,du
      = \left[\frac{1}{2}\cdot\frac{u^5}{5} \right|_{u=1}^{u=2}
      = \frac{1}{10}\left[u^5\rule{0em}{.95em}\right|_{u=1}^{u=2}
      =\frac{1}{10}[2^5-1^5] = \frac{1}{10}[32-1] = \frac{31}{10}$\\[.5em]
      \hspace*{1em}$\boxed{\begin{aligned}
          u & = y^2+1 \\
          du & =2y\, dy \implies \frac{1}{2}du = y\, dy \\
          \text{upper limit: }&y=1 \implies u=1^2+1=2\\
          \text{lower limit: }&y=0 \implies u=0^2+1=1
        \end{aligned}}$

    \item $\begin{aligned}[t]
        \int_0^{\pi/4}\!3\sin(2x-\pi/2)\,dx
        = \int_{-\pi/2}^0 3\sin u \left(\frac{1}{2}\right)du
        = \frac{3}{2}\int_{-\pi/2}^0 \sin u\,du
        &= \frac{3}{2}\left[-\cos u\rule{0em}{.9em}\right|_{-\pi/2}^0
        = -\frac{3}{2}\left[\cos u\rule{0em}{.9em}\right|_{-\pi/2}^0\\
        &= -\frac{3}{2}\left[\cos 0-\cos(-\pi/2)\right]\\
        &=-\frac{3}{2}[1-0]\\
        &=-\frac{3}{2}
      \end{aligned}$\\[-6.5em]
      \hspace*{4em}$\boxed{\begin{aligned}
          u & \textstyle = 2x-\frac{\pi}{2} \\
          du & =\textstyle 2\, dx \implies \frac{1}{2}du = dx \\
          \text{upper limit: }&\textstyle x=\frac{\pi}{4} \implies u=2\left(\frac{\pi}{4}\right)-\frac{\pi}{2}=0\\
          \text{lower limit: }&\textstyle x=0 \implies u=2(0)-\frac{\pi}{2}=-\frac{\pi}{2}
        \end{aligned}}$\\[.5em]

    Note that as the previous examples illustrate, when doing substitutions with
    definite integrals, if you change the limits then you never substitute
    back to the original variable.
  \item To integrate $\displaystyle\int_{0.3}^{0.5}\left(x+4\tan x\sec^2\!x\right)dx$ one must integrate term by term, i.e.\\[.5em]
    $\displaystyle\int_{0.3}^{0.5}\left(x+4\tan x\sec^2\!x\right)dx
    =\int_{0.3}^{0.5}x\,dx+\int_{0.3}^{0.5}\tan x\sec^2\!x\,dx$\\[.5em]
    No substitution is required on the first term and $u=\tan\,x$ is
    required on the second.  One can do this as above but changing
    limits only when evaluating the second integral.  Alternatively,
    if one wishes to evaluate an expression only with the initial
    limits one can just work out the antiderivative (indefinite
    integral) of the second term on the side and then use this result
    as follows:\\[.5em]
    \hspace*{-1.75em}$\begin{aligned}\int_{0.3}^{0.5}\left(x+4\tan x\sec^2\!x\right)dx
      =\left[\frac{1}{2}x^2+2\tan^2\!x\right|_{0.3}^{0.5}
      &=\left[\frac{(0.5)^2}{2}+2[\tan(0.5)]^2\right]-\left[\frac{(0.3)^2}{2}+2[\tan(0.3)]^2\right]\\
      &=0.72189282-0.23637783=0.48551499
    \end{aligned}$\\[-1em]    
    $\boxed{\begin{aligned}
        \int 4\tan x\sec^2\!x\,dx
        &=4\int u\,du=2u^2+C\\
        &=2\tan^2\!x+C\\[2.5em]
      \end{aligned}}$\\[-3.9em]
    \hspace*{.6em}$\boxed{\begin{aligned}
        u &=\tan x\\
        du&=\sec^2\!x\,dx
        \end{aligned}}$
    \end{enumerate}
    What one \textbf{cannot} do is write
    $\int_{0.3}^{0.5}\left(x+4\tan
      x\sec^2\!x\right)dx=\int_{0.3}^{0.5}\left(x+4u\right)dx$ which
    is just wrong.  If you do not change your limits then work out the
    indefinite integrals on the side of the calculation.
  \end{solution*}

\begin{furtherquestions}
Find the definite integrals:
\begin{enumerate}
\begin{multicols}{2}
\item $\displaystyle\int_0^1 \left(1+x\right)^5\,dx$
\item $\displaystyle\int_1^4 \frac{\left(\sqrt{x}+1\right)^4}{\sqrt{x}}\,dx$
\item $\displaystyle\int_0^{\frac{\pi}{3}}\sin 3\theta\,d\theta$
\item $\displaystyle\int_2^{10}\frac{3}{\sqrt{5x-1}}\,dx$
\item $\displaystyle\int_1^4\sqrt{5-x}\,dx$
\end{multicols}
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\textbook{\addtoanswerkey{\clearpage}}
\begin{exercise}
\input{INTEGRATION/the-substitution-rule}
\end{exercise}

\section{Symmetry and Definite Integrals}
\theorem{The following is true for symmetric functions integrable on $[-a,a]$\,:
\begin{itemize}
\item If $f(x)$ is \textbf{even} then $\displaystyle\int_{-a}^af(x)\,dx=2\int_0^af(x)\,dx$.
\item If $f(x)$ is \textbf{odd} then $\displaystyle\int_{-a}^af(x)\,dx=0$.
\end{itemize}
}
The last theorem is obvious from consideration of the definite integral as a sum of areas for in the even case the areas on each side of the $y$-axis will be equal.  In the odd case the areas are also equal in magnitude but will contribute oppositely in sign to the overall integral (since $f(-x)=-f(x)$).  Alternatively one may prove the theorem directly by writing
\[\int_{-a}^af(x)\,dx=\int_{-a}^0f(x)\,dx+\int_0^af(x)\,dx~,\]
and doing a change of variables of $u=-x$ on the $\int_{-a}^0$ integral.

\begin{example}
  Integrate the following:
  \begin{enumerate}
    \begin{multicols}{3}
    \item $\displaystyle\int_{-2}^2 (x^4+3x^2+2)\,dx$
    \item $\displaystyle\int_{-2}^2 (x^3+4x)\,dx$
    \item $\displaystyle\int_{-5}^5 \frac{x^5+4x^3+\sin x}{x^2}\,dx$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
  \begin{enumerate}
  \item If $f(x)=x^4+3x^2+2$ then
    $f(-x)=(-x)^4+3(-x)^2+2=x^4+3x^2+2=f(x)$ implies that $f(x)$ is an
    even function.  Since the limits are $-a=-2$ to $a=2$ one has\\[.5em]
    $\begin{aligned}[t]
      \int_{-2}^2 (x^4+3x^2+2)\,dx 
      &=2\int_0^2 (x^4+3x^2+2)\,dx = 2\left[\frac{x^5}{5} + x^3+2x\right|_0^2\\
      &= 2\left(\left[\frac{32}{5} + 8+4\right]-\left[0+0+0\right]\right)
      = 2\left[\frac{32}{5} + 12\right]
      = 2\left(\frac{32+60}{5}\right)
      = \frac{184}{5}
      \end{aligned}$

    \item If $f(x)=x^3+4x$ then
      $f(-x)=(-x)^3+4(-x)=-x^3-4x=-(x^3+4x)=-f(x)$ implies that $f(x)$
      is an odd function.  Since the limits are $-a=-2$ to $a=2$ one
      has\\[.5em]
      $\displaystyle\int_{-2}^2 (x^3+4x)\,dx = 0$

    \item If $\displaystyle f(x)=\frac{x^5+4x^3+\sin x}{x^2}$ then
      \begin{align*}
        f(-x)&=\frac{(-x)^5+4(-x)^3+\sin(-x)}{(-x)^2}\ \ \Leftarrow\text{Recall sine is an odd function}\\
             &=\frac{-x^5+-4x^3-\sin(x)}{x^2}
             =-\frac{x^5+4x^3+\sin x}{x^2}=-f(x)
      \end{align*}
      Thus $f(x)$ is an odd function.  Since the limits are $-a=-5$ to $a=5$ one
      has\\[.5em]
      $\displaystyle\int_{-5}^5 \frac{x^5+4x^3+\sin x}{x^2}\,dx=0$
    \end{enumerate}
    Note that a critical aspect of applying symmetry in this manner is
    that the limits be $-a$ and~$a$\,.
  \end{solution*}

\begin{furtherquestions}
Integrate the following:
\begin{enumerate}
\item $\displaystyle \int_{-2}^{2} (x^2+3)\,dx$
\item $\displaystyle \int_{-\pi/2}^{\pi/2} \left(\sin x +\sin 2x\right)\,dx$
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{INTEGRATION/integration-all-methods}
\textbook{\vspace{-.1em}}
\end{exercise}

\section{Areas Between Curves}

We have already calculated an area between curves.  Namely, when $y=f(x)\ge0$ on $[a,b]$ then
\[A=\int_a^b f(x)\,dx\]
is the area below the curve $y=f(x)$ and above the $x$-axis.  But since the $y$-axis is just the curve $y=0$, the above integral is also the area between the curve $y=f(x)$ and the curve $y=0$.  If the lower curve is $y=g(x)$ instead of $y=0$ we get the following result:

\theorem{If $y=f(x)$ and $y=g(x)$ are integrable on the $x$-interval $[a,b]$ with $f(x)\ge g(x)$ on the interval then the \textbf{area between the curves} $y=f(x)$ and $y=g(x)$ and the lines $x=a$ and $x=b$ is 
\[A=\int_a^b \left[f(x)-g(x)\right]\,dx~.\]
}

The situation is illustrated in the following diagram:
\begin{center}
\includegraphics{graphics/integration9}%
\end{center}

A simple way to remember the theorem is the differential notation.  We are finding the sum $A=\int dA$ of the infinitesimal rectangle areas each of area $dA$ where
\[dA=\underbrace{\left[f(x)-g(x)\right]}_{\mbox{\tiny height}}\cdot\underbrace{\rule[-.25em]{0em}{1em}dx}_{\mbox{\tiny width}}~.\]
Since $f(x)\ge g(x)$ the height of the infinitesimal rectangular area,
$f(x)-g(x)$, is positive, even if one (or both) of the curves lies below the $x$-axis.  Since $a<b$ for an interval $[a,b]$ the width $dx$ is also positive, thereby ensuring a positive area element $dA$.

Another useful way to remember the result is that the area between the curves $y=f(x)$ and $y=g(x)$ is just the area under the curve $y=f(x)$ minus the area under the curve $y=g(x)$.  This is verified by using the properties of the definite integral to get:
\[A=\int_a^b \left[f(x)-g(x)\right]\,dx=\int_a^b f(x)\,dx-\int_a^b g(x)\,dx\]
This interpretation gives the proper area even when one or both of the curves lie below the $y$-axis.  (Think about it!)

\begin{example}
  Find the area of the region bounded by $y=x^2+2$ and $y=4-x^2$\,.
  
  \begin{solution}
    First solve to find the $x$-coordinates of the points of intersection:\\[.5em]
    $x^2+2 = 4-x^2\implies2x^2=2 \implies x^2=1 \implies x=\pm 1$\\[.5em]
    So our integration interval is $[a,b]=[-1,1]$\,.  The $y$-coordinates of
    the endpoints are:
    \begin{align*}
      y(-1)&=(-1)^2+2=4-(-1)^2=3 \\
      y(1)&=(1)^2+2=4-(1)^2=3
    \end{align*}
    To find which function is higher on the interval we can evaluate
    them at a point it contains, say $x=0$.  Then $0^2+2=2$ and
    $4-0^2=4$ show that $f(x)=4-x^2$ is the upper function and
    $g(x)=x^2+2$ is the lower function on the interval.

    A sketch of the region is as follows:
    \begin{center}
      \includegraphics[width=6cm]{graphics/integration14}
    \end{center}

    The area between the curves is:
    \begin{align*}
      A&=\int_a^b[f(x)-g(x)]\,dx=\int_{-1}^1[(4-x^2)-(x^2+2)]
      = \int_{-1}^1(2-2x^2)\,dx \ \ \ (\text{Even integrand!}) \\
      &= 2\int_0^1(2-2x^2)\,dx = 2\left[2x-\frac{2}{3}x^3\right|_0^1
      = 2\left[\left(2-\frac{2}{3}\right) - \left(0-0\right)\right] = 2\frac{6-2}{3} = \frac{8}{3}
    \end{align*}
  \end{solution}

\begin{furtherquestion}
Find the area of the region bounded by $y=2x+4$ and $y=x^2+2x+3$ between $x=0$ and $x=\frac{1}{2}$\,.
\end{furtherquestion}
\end{example}

\textbook{\clearpage}
Sometimes one is asked to find the area between two curves $y=h_1(x)$
and $y=h_2(x)$ with no endpoints $a$, $b$ given.  In that case the
curves in question must intersect at least twice to form one (or more)
regions bounded by the two curves.  The problem is illustrated below.
\begin{center}
\includegraphics{graphics/integration10}%
\end{center}
Here the two curves intersect at three points with $x$-coordinates $x_0$, $x_1$, and $x_2$.  The total area between the curves $A=A_1+A_2$ where the light grey area $A_1$ is over $[x_0,x_1]$ and has $h_1(x)\ge h_2(x)$, while the dark grey area $A_2$ is over $[x_1,x_2]$ and has $h_2(x)\ge h_1(x)$. In general proceed as follows.

\begin{method}
\vspace{-1em}
\begin{enumerate}
\item Find the $x$-coordinates of the intersection points of the two
  curves.  These will determine where each bounded subregion begins and
  ends.  Since an intersection point must lie on both curves this
  requires that $h_1(x)=y=h_2(x)$.  In other words we must solve:
\[h_1(x)=h_2(x)\]
for $x$ to get the solutions $x_i$.

\item For each interval corresponding to a bounded subregion one must
  determine which curve is higher than the other, i.e. which is $f(x)$
  and which $g(x)$ in the area formula.  This can be achieved by a
  sketch of the curve or consideration of the values of $h_1(x)$ and
  $h_2(x)$ of a test point $x$ in the interval.  If two or more
  regions are bounded by the curves then $h_1(x)$ and $h_2(x)$ will
  typically alternate being the higher curve.
\item Calculate the area of each subregion using the area formula and add
  them together.  (If any subregion area results in a negative
  value you have misidentified the higher curve.)
\end{enumerate}
\end{method}

\begin{example}
  \begin{furtherquestions}
Find the area of the region bounded by the following curves:
\begin{enumerate}
\item $y=2x+4$ and $y=x^2+2x+3$ 
\item $y=x^2$ and $y=18-x^2$
\item $y=x^2$ and $y=(x-2)^2$ from $x=0$ to $x=3$
\end{enumerate}
\end{furtherquestions}
\end{example}

Sometimes the region for which one wants an area is better described by functions $x=f(y)$ and $x=g(y)$ denoting the right and left boundaries of the region respectively.  One then has the result:

\theorem{If $x=f(y)$ and $x=g(y)$ are integrable on the $y$-interval $[c,d]$ with $f(y)\ge g(y)$ on the interval then the \textbf{area between the curves} $x=f(y)$ and $x=g(y)$ and the lines $y=c$ and $y=d$ is 
\[A=\int_c^d \left[f(y)-g(y)\right]\,dy~.\]
}
The situation is depicted below:
\begin{center}
\includegraphics{graphics/integration11}%
\end{center}

In this case the integral represents the addition of horizontal area elements $dA$ of area 
\[dA=\underbrace{\left[f(y)-g(y)\right]}_{\mbox{\tiny width}}\cdot\underbrace{\rule[-.25em]{0em}{1em}dy}_{\mbox{\tiny height}}~.\]
When only the region bounded by $x=h_1(y)$ and $x=h_2(y)$ is requested with no interval $[c,d]$ given one must solve $h_1(y)=h_2(y)$ to find the $y$-values $y_i$ which enclose the bounded regions and identify the greater curve ($x=f(y)$) and the lesser curve ($x=g(y)$) for each interval.
\begin{example}
  Find the area of the region bounded by $x=3-y^2$ and $y+x = 1$\,.

  \begin{solution}
    In this case the $y^2$ prevents us from writing $y$ as a function
    of $x$ for the first curve. It is already written as $x(y)$
    however.  Writing the second equation as a function of $y$ as well
    gives $y+x-1 \implies x=1-y$.

    Next solve for the $y$-coordinates of the points of intersection
    of the curves:\\[.5em]
    $1-y = 3-y^2 \implies y^2-y-2 = 0 \implies
    (y-2)(y+1) = 0 \implies y= 2 \ \text{or} \ y = -1$\\[.5em]
    So our integration interval is $[c,d]=[-1,2]$\,.
    The $x$-coordinates of the endpoints are:
    \begin{align*}
      x(2)&=1-2=3-2^2=-1\\
      x(-1)&=1-(-1)=3-(-1)^2=2
    \end{align*}
    To find which curve is further to the right we can evaluate our
    functions and some point in the interval, say $y=0$ to get $1-0=1$
    and $3-0^2=3$.  This shows that $f(y)=3-y^2$ is further to the
    right than $g(y)=1-y$\,.

    \textbook{\newpage}
    A sketch of the region is as follows:
    \begin{center}
      \includegraphics[width=6cm]{graphics/integration15}
    \end{center}

    The area is:
    \begin{align*}
      A & = \int_c^d[f(y)-g(y)]\,dy
          =\int_{-1}^2\left[(3-y^2)-(1-y)\right]\,dy
          = \int_{-1}^2(2+y-y^2)\,dy
          =\left[2y + \frac{1}{2}y^2 - \frac{1}{3}y^3\right|_{-1}^2\\
        &= \left[4+2-\frac{8}{3}\right]
          -\left[-2+\frac{1}{2}+\frac{1}{3}\right]
          = 6 - \frac{8}{3}+ 2 - \frac{1}{2} -\frac{1}{3} = 8-3-\frac{1}{2}
          = 5-\frac{1}{2} = \frac{9}{2}
    \end{align*}
  \end{solution}

\begin{furtherquestions}
Find the area of the region bounded by the following curves:
\begin{multicols}{2}
\begin{enumerate}
\item $y^2=2x+10$ and $y=x+1$
\item $2y^2=x+4$ and $x=y^2$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}
If given a choice of doing a vertical or horizontal area analysis of a bounded region one should consider:
\begin{itemize}
\item Whether the enclosing curves can be written as \textbf{functions} of $x$ or $y$.
\item Whether the area is comprised of any horizontal or vertical lines.
\item Whether the area would require piecewise defined functions along either direction.
\end{itemize}

\begin{example}
  \begin{furtherquestions}
Find the area of the region bounded by the following curves:
\begin{enumerate}
\item $x^2+y=1$ and $x-y=1$
\item $y^2=4+x$ and $y^2+x=2$
\item $y=x+6$, $y=x^3$, and $2y+x=0$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{INTEGRATION/area-between-curves}
\end{exercise}

\section{Net Change}
If a variable $y$ is a function $f$ of $x$, then as $x$ changes from $x_1$ to $x_2$, and so undergoes a change $\Delta x=x_2-x_1$, there is a corresponding change in $y$ of $\Delta y=y_2-y_1=f(x_2)-f(x_1)$.  Assuming $f$ has continuous first derivative $f'$ on $[x_1,x_2]$ it follows by the Fundamental Theorem of Calculus that the net change in $y$ is
\[\Delta y=\int_{x_1}^{x_2}f'(x)\,dx\ .\]
In other words, if we know the derivative $\frac{dy}{dx}=f'(x)$, we can calculate the change in $y$ from its initial value $y_1$ at $x_1$ as $x$ changes to $x_2$.  In our formula, one notes that since the differential $dy$ is $dy=f'(x)\,dx$ the total change in $y$, $\Delta y$, is just the sum of infinitesimal changes in $y$, i.e. $\Delta y=\int_{y_1}^{y_2} dy$\, as one expects.

Often the independent variable $x$ is time $t$.  For instance, an object undergoing motion in one spatial dimension with velocity $v=\frac{ds}{dt}$ will have a total change in displacement $s(t)$ given by
\[\Delta s=\int_{t_1}^{t_2}\frac{ds}{dt}\,dt=\int_{t_1}^{t_2}v\,dt\]
between times $t_1$ and $t_2$.

\begin{example}
  Using ten years of data a biologist estimates that the rate at which a population of mice
  changes in a particular region oscillates with the approximate behaviour:
  \begin{align*}
    \diff{N}{t}=a\cos(2\pi t/b+c)\ \ [\text{mice/year}]
  \end{align*}
  with constants $a=4500\,\frac{\text{mice}}{\text{yr}}$, $b=2.6$\,yr\,
  and $c=0.4$\,.  Here $t=0$~yr is the time at which measurement began.
  \begin{enumerate}[label=(\alph*)]
  \item What is the expected change of the mouse population from $t=0$ to $t=15$~years?
  \item If the initial population was $N_0=14000$~mice, what is the expected population at $t=15$~years?
  \end{enumerate}
  \begin{solution*}
    \begin{enumerate}
      \item We will retain the literal constants $a$, $b$, and $c$ to make the calculation cleaner.\\[.5em]
        $\begin{aligned}[t]
          \hspace{2em}\Delta N=\int_0^{15}\diff{N}{t}\,dt
          =a\int_0^{15}\cos(2\pi t/b+c)\,dt
          &=a\int_c^{\frac{30\pi}{b}+c}(\cos u)\cdot\left(\frac{b}{2\pi}\right)du\\
          &=\frac{ab}{2\pi}\left[\sin u\rule{0em}{1em}\right|_c^{\frac{30\pi}{b}+c}\\
          &=\frac{ab}{2\pi}\left[\sin\left(\frac{30\pi}{b}+c\right)-\sin c\right]\\
          &=\frac{(4500)(2.6)}{2\pi}\left[\sin\left(\frac{30\pi}{2.6}+0.4\right)-\sin(0.4)\right]\\
          &=-2340\ \text{mice}
        \end{aligned}$\\[-9em]
        \hspace*{0em}$\boxed{\begin{aligned}
            u & \textstyle = 2\pi t/b+c=\frac{2\pi}{b}t+c\\
            du & =\textstyle \frac{2\pi}{b}\, dt \implies \frac{b}{2\pi}du = dt \\
            \text{upper limit: }&\textstyle t=15 \implies u= 2\pi(15)/b+c\\
            &\hspace{6em}=30\pi/b+c\\
            \text{lower limit: }&\textstyle t=0 \implies u=2\pi(0)/b+c=c
          \end{aligned}}$\\[.5em]
        \begin{comment}
          % The following version retains units.  While useful it perhaps
          % adds unnecessary confusion (and space - it doesn't quite fit).
        $\begin{aligned}[t]
          \hspace{2em}\Delta N=\int_{0\,\text{yr}}^{15\,\text{yr}}\diff{N}{t}\,dt
          =a\int_{0\,\text{yr}}^{15\,\text{yr}}\cos(2\pi t/b+c)\,dt
          &=a\int_c^{\frac{(30\,\text{yr})\pi}{b}+c}(\cos u)\cdot\left(\frac{b}{2\pi}\right)du\\
          &=\frac{ab}{2\pi}\left[\sin u\rule{0em}{1em}\right|_c^{\frac{(30\,\text{yr})\pi}{b}+c}\\
          &=\frac{ab}{2\pi}\left[\sin\left(\frac{(30\,\text{yr})\pi}{b}+c\right)-\sin c\right]\\
          &=\frac{(4500\,\frac{\text{mice}}{\text{yr}})(2.6\,\text{yr})}{2\pi}
          \left[\sin\left(\frac{(30\,\text{yr})\pi}{2.6\,\text{yr}}+0.4\right)-\sin(0.4)\right]\\
          &=-2340\ \text{mice}
        \end{aligned}$\\[-9em]
        \hspace*{0em}$\boxed{\begin{aligned}
            u & \textstyle = 2\pi t/b+c=\frac{2\pi}{b}t+c\\
            du & =\textstyle \frac{2\pi}{b}\, dt \implies \frac{b}{2\pi}du = dt \\
            \text{upper limit: }&\textstyle t=15\,\text{yr} \implies u= 2\pi(15\,\text{yr})/b+c\\
            &\hspace{6em}=(30\,\text{yr})\pi/b+c\\
            \text{lower limit: }&\textstyle t=0\,\text{yr} \implies u=2\pi(0\,\text{yr})/b+c=c
          \end{aligned}}$\\[.5em]
      \end{comment}
    \item The population at $t=15$ years is just the initial population plus the change:
      \begin{align*}
        N=N_0+\Delta N=14000+(-2340)=11660\,\text{mice}
      \end{align*}
    \end{enumerate}
  \end{solution*}

  \textbook{\clearpage}
  \begin{furtherquestions*}
    \begin{enumerate}
    \item A ball thrown vertically upward has velocity given by
      $v(t)=-10t+18$ in m/s.  What is the total change in displacement
      of the ball between $t=1$ and $t=2$ seconds?

    \item Over the first 20~years of its existence a factory had a
      production rate of units given by
      \[\frac{dU}{dt}=1000+150t\ [\mbox{units}/\mbox{year}]\,.\]
      How many units did the factory produce in its first $20$~years?

    \item In the Further Question~\ref{itm:greatpyramid} of
      Example~\ref{example:relatedrates}
      (page~\pageref*{itm:greatpyramid}), the rate of change of height
      of the pyramid frustum with time was
      \[\frac{dh}{dt}=\frac{1}{B^2\left(1-\frac{h}{H}\right)^2}R~,\]
      where $B=230$~m was the length of the base of the pyramid,
      $H=150$~m was its final height, and $R=360$~m$^3$/day was the
      constant rate of change of volume with time.  The rate of change
      of time with respect to height is the reciprocal:
      \[\frac{dt}{dh}=\frac{B^2}{R}\left(1-\frac{h}{H}\right)^2~.\]
      How long did it take to build the top third of the pyramid?
      (i.e. from 2/3 of its final height to its final
      height.)\footnotemark
    \end{enumerate}
  \end{furtherquestions*}
\end{example}
\footnotetext{Note you can check your answer directly by working out the volume of the top third of the pyramid and dividing by~$R$\,.}

\begin{exercise}
\input{INTEGRATION/distances-and-net-change}
\end{exercise}

\section{Differential Equations}
We are accustomed to solving equations like $x^3-4x=0$ to find those values of $x$ that make the equation true (i.e. the solutions, here $x=-2$, $x=0$, and $x=2$.).  We now consider equations where the unknown is not a value $x$, but rather a function $y=f(x)$.

\definition{An equation which contains an unknown function and at least one of its derivatives is called at \textbf{differential equation}.}
\begin{example}
$\displaystyle y''+\sin(xy)+2=\frac{1}{x}$ is a differential equation involving unknown function $y=f(x)$.
\end{example}

\definition{The highest order derivative that occurs in a differential equation is called the \textbf{order} of the differential equation.}
\begin{example}
The order of the following differential equations is as follows:
\begin{enumerate}
\item $y'+3xy=\sin x$\ \ ($1^{\mbox{\tiny st}}$ order)
\item $\displaystyle\frac{d^2y}{dx^2}+3\frac{dy}{dx}+5y=\cos x$\ \ ($2^{\mbox{\tiny nd}}$ order)
\item $xy'+3y\sin x=x^2+5$\ \ ($1^{\mbox{\tiny st}}$ order)
\end{enumerate}
\end{example}

\definition{If a function $y=f(x)$ and its derivatives  when substituted into a differential equation satisfies that equation then $f(x)$ is called a \textbf{solution} of the differential equation.}

\begin{example}
  \label{exam:differentialeq}
  Show that the given function is a solution of the given differential equation.
  \begin{enumerate}
  \item $\displaystyle y=\frac{c}{x}+x$ in $\displaystyle y'=2-\frac{y}{x}$
  \item $\displaystyle y=\tan x$ in $y''=2yy'$
  \end{enumerate}
  
  \begin{solution*}
    \begin{enumerate}
    \item \label{itm:differentialeq1}
      $\displaystyle y=\frac{c}{x}+x=cx^{-1}+x\implies y'=-cx^{-2}+1=-\frac{c}{x^2}+1$\\[.5em]
      Substitution into the differential equation gives:
      \begin{align*}
        y'&\overset{?}{=}2-\frac{y}{x}\\
        -\frac{c}{x^2}+1&\overset{?}{=}2-\frac{1}{x}\left(\frac{c}{x}+x\right)\\
        -\frac{c}{x^2}+1&\overset{?}{=}2-\frac{c}{x^2}-1\\
        -\frac{c}{x^2}+1&=-\frac{c}{x^2}+1
      \end{align*}
    \item $\displaystyle y=\tan x\implies y'=\sec^2\!x\implies y''=2(\sec x)(\sec x\tan x)=2\sec^2\!x\tan x$\\[.5em]
      Substitution into the differential equation gives:
      \begin{align*}
        y''&\overset{?}{=}2yy'\\
        2\sec^2\!x\tan x&\overset{?}{=}2(\tan x)(\sec^2\!x)\\
        2\sec^2\!x\tan x&=2\sec^2\!x\tan x
      \end{align*}
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
\label{ex:desolution} Show that the given function is a solution of the given differential equation.
\begin{enumerate}
\item $\displaystyle y=2x^2+cx$\, in\, $\displaystyle xy'-y=2x^2$
\item $\displaystyle y=x\sin x$\, in\, $\displaystyle y''+y-2\cos x=0$
\end{enumerate}
\end{furtherquestions}
\end{example}

The first solution in Example~\ref*{ex:desolution}, containing a constant, is called a \textbf{general solution} to the differential equation.\footnote{Other solutions called \textbf{singular solutions} may also arise for certain differential equations.} It can be shown that $n$ different constants are required for a general solution to a differential equation of order $n$.  Choosing different values for the constant(s) in a general solution generates a family of solutions to the differential equation.  Assigning specific values to the constants in a general solution yields a \textbf{particular solution} to the differential equation.  The second solution in Example~\ref*{ex:desolution} is a particular solution to that differential equation.  The next graph shows particular solutions generated by using the constants $c=1/10$, $c=1$, and $c=3$ respectively in the general solution of the first problem in Example~\ref*{ex:desolution}.  
\begin{center}
\resizebox{5cm}{!}{%
\includegraphics{graphics/integration12}%
}
\end{center}

Physical problems often require finding a function that is not only a solution to a differential equation but also satisfies \textbf{initial conditions} at some value of the independent variable.  For example one may require the function satisfy the constraint $y(t_0)=y_0$ for given constants $t_0$ and $y_0$.  Here the terminology \emph{initial} arises from problems for which the independent variable is time.  An \textbf{initial value problem} is one for which one seeks a solution to a differential equation that satisfies a given set of initial conditions.  The initial conditions of the problem determine the constants of the general solution to the differential equation.  The resulting particular solution is the physical solution to the problem.  Higher order differential equations require more initial conditions, which may involve either the function or its derivatives having specified values at time $t_0$.

\begin{example}
  Find the value of $c$ that makes $\displaystyle y=\frac{c}{x}+x$ as solution to the initial value problem $\displaystyle y'=2-\frac{y}{x}$, $y(1)=3$\,.

  \begin{solution}
    In Question~\ref{itm:differentialeq1} of Example~\ref{exam:differentialeq} it was shown that $\displaystyle y=\frac{c}{x}+x$ is a solution of  
    $\displaystyle y'=2-\frac{y}{x}$.  Set $y(1)=3$ to find $c$\,:
    \begin{align*}
      3=y(1)=\frac{c}{(1)}+1\implies 3-1=c\implies c=2
    \end{align*}
    Hence $\displaystyle y=\frac{2}{x}+x$ is a solution to the initial value problem.
  \end{solution}

\begin{furtherquestions*}
\begin{enumerate}
\item Find the value of $c$ that makes $y=2x^2+cx$ a solution to the initial value problem $xy'-y=2x^2$, $y(1)=5$~.
\item For the initial value problem $y'+y\tan t=\sec t$, $y(0)=2$, show that $y=\sin t+C\cos t$ is a general solution to the differential equation and find the value $C$ that makes it satisfy the initial condition.
\end{enumerate}
\end{furtherquestions*}
\end{example}

As the previous example shows, solving an initial value problem given a general solution to the differential equation amounts to solving one (or more) equations for the unknown constant(s).  An equation is generated using each of the initial conditions substituted into the general solution, or potentially its derivatives.  So the central problem becomes how to find the general solution to a given differential equation.  Books and courses are devoted to that problem.  However there is a class of such differential equations we can solve at this point, namely those of the form
\[y^{(n)}=g(x)\ ,\]
where $y^{(n)}$ is the $n^{\scriptstyle th}$ derivative of $y$ with respect to $x$ and $g(x)$ is a function of $x$.  When $n=1$ we have
\[y'=g(x)\ .\]
In Section~\ref{sec:antiderivatives} we have already seen that the solution to such a problem is just the \emph{antiderivative} of $g(x)$.  Since the indefinite integral is just the antiderivative, it follows that the solution of
\[y'=g(x)\]
is just
\[y=\int\! g(x)\,dx+C\,.\]
Here the constant of integration has been written explicitly.  It is this constant that make the indefinite integral the general solution to the differential equation.  The constant $C$ will be determined by the given initial condition in an initial value problem.

For the higher order differential equation
\[y^{(n)}=g(x)\]
one can, in principle, integrate $n$ times with respect to $x$.  Each such integration will introduce a new constant of integration so that our general solution $y(x)$ will contain $n$ constants as expected for this order $n$ differential equation.  These, in turn, must be determined by $n$ initial conditions to find the physical solution to the initial value problem. 

\begin{example}
  Solve the following differential equations and initial value problems.
  \begin{enumerate}
  \item $\displaystyle y''=\frac{1}{\sqrt{x}}$
  \item $\displaystyle y'\tan x=\sin x\ ,\ y(\pi/2)=4$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item Since the second derivative of $y$ is isolated and $y$
      itself does not appear on the right hand side we just need to
      integrate twice:\\[.5em]
      $\begin{aligned}[t] y''=\frac{1}{\sqrt{x}}=x^{-\frac{1}{2}}\implies y'
        &=\int x^{-\frac{1}{2}}\,dx=\frac{x^{\frac{1}{2}}}{\frac{1}{2}}+C=2x^{\frac{1}{2}}+C\\
        \implies y&=\int\left(2x^{\frac{1}{2}}+C\right)dx=2\frac{x^{\frac{3}{2}}}{\frac{3}{2}}+Cx+D\\
        \implies y&=\frac{4}{3}x^{\frac{3}{2}}+Cx+D
      \end{aligned}$
    \item First solve the differential equation by isolating $y'$ and integrating:\\[.5em]
      $y'\tan x=\sin x\implies y'=\frac{\sin x}{\tan x}=\frac{\sin x}{\frac{\sin x}{\cos x}}
      \implies y'=\cos x\implies y=\int \cos x\,dx \implies y=\sin x+C$\\[.5em]
      Next find $C$ by using the initial value $y(\pi/2)=4$\,:\\[.5em]
      $\displaystyle 4=y(\pi/2)=\sin(\pi/2)+C=1+C\implies C=4-1=3$\\[.5em]
      Thus $y=\sin x+3$ is a solution to the initial value problem.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Solve the following differential equations and initial value problems.
\begin{enumerate}
\item $\displaystyle \frac{dy}{dx}=\sin^2\!x\cos x$
\item $\displaystyle y''=x^2+\cos x$
\item $\displaystyle \sqrt{1-x^2}+\frac{x}{y'}=0$, $y(0)=3$
\item $\displaystyle \frac{d^2 y}{dt^2}=-9.8~\mbox{m/s}^2$, $y(0)=3$~m, $\displaystyle\left.\frac{dy}{dt}\right|_{t=0}=2$~m/s
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{INTEGRATION/differential-equations}
\end{exercise}

\clearpage
\textbook{\addtoanswerkey{\clearpage}}
\begin{reviewexercise}
\input{INTEGRATION/integration-review}
\end{reviewexercise}
%
% TODO
%
% Give more insight into summation formulas for powers of i?  Make this
% an exercise or appendix.
%
% Should we discuss "sum" of a series and a series being summable with
% a reference to infinite series?  This goes beyond the scope of the
% course.  One could add a footnote.
%
% Add computer problem to Exercise 5-3 asking to calculate the area of
% an arbitrary (convex) polygon with vertices (x_i,y_i) by subdividing it
% into triangles, working out the side lengths using the distance formula and
% finally using Heron's formula to work out the triangle area.
%
% In problems involving the derivative form of the FTC add something where
% a special function like erf(x) is part of a larger function to which
% other derivative rules need to be applied.
%
% Add illustration for the symmetry of definite integrals.
%
% Add comment that the many methods of solving differential equations
% in keeping with the many methods of solving regular equations.
%
% Add Graphs to Theorem 5-5 illustrating their meaning.
%
% Should I introduce notation for converting limits from one variable to
% another?  i.e. like x|_a^b \rightarrow u_c^d ?
%
% 

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