\section{Tangent to a Curve}
Most are familiar with a tangent line to a circle at a point $P$.  It is the line that just clips the circle at only that point:
\begin{center}
\includegraphics{graphics/limits1}%
\end{center}
We can similarly imagine a tangent line to an arbitrary curve at a point $P$:
\begin{center}
\includegraphics{graphics/limits2}%
\end{center}

\textbook{\clearpage}
If we place the curve in a Cartesian Coordinate system we can
represent it by the function \mbox{$y=f(x)=x^3$} and the point of interest by its coordinates $P(1,1)$:
\begin{center}
\includegraphics{graphics/limits3}%
\end{center}

We can define our tangent line as follows:
\definition{A \textbf{tangent line} to a curve $y=f(x)$ at a point $P(x_0,y_0)$ is a (straight) line that touches the curve at $P$ which, if extended, does not cross the curve at that point.}

Now that we have coordinates we can ask what the tangent line at $P(1,1)$ actually is, by which we mean ``What is the tangent line written as a function?''.  The equation of any line in two dimensions can be written:
\[\boxed{y=mx+b}\ \ \ \ \Leftarrow\ \mbox{Slope-Intercept Form}\]
where the constant $m=\frac{\Delta y}{\Delta x}$ is the \textbf{slope} which is a measure of the direction the line is going, while $b$ is the \textbf{$\bm y$-intercept} which indicates where to start the line on the $y$-axis. Another convenient recipe for determining the equation of the line is to use the slope $m$ as before but also an arbitrary point $(x_0,y_0)$ on the line as the starting point (no longer $(0,b)$):
\[\boxed{y=m(x-x_0)+y_0}\ \ \ \ \Leftarrow\ \mbox{Point-Slope Form}\]
 
In our case we know our tangent line goes through the point $(1,1)$ so this is $(x_0,y_0)$.  It remains to find the slope, call it $m_t$, for our tangent at $P$.  We can approximate the slope of the tangent by taking a point $Q$ near $P$ and finding the slope of the line (the \textbf{secant}) between $Q$ and $P$.  If we let the $x$-coordinate of $Q$ be $x$, a value close to $1$, then the point $Q$ is $Q(x,f(x))=Q(x,x^3)$.   
\begin{center}
\includegraphics{graphics/limits4}%
\end{center}
Then the slope of the secant line $PQ$ is:
\[m_{\s PQ}=\frac{\Delta y}{\Delta x}=\frac{1-x^3}{1-x}\]
Since knowing the $x$-coordinate completely determines $Q$ and consequently the slope, we see that $m_{\s PQ}$ is really just a function of $x$:
\[m(x)=\frac{1-x^3}{1-x}\]
So, for instance, at the point $Q(1/2,1/8)$ which corresponds to $x=1/2$ the slope of the secant would be:
\[m_{\s PQ}=m\left(\frac{1}{2}\right)=\frac{1-\left(\frac{1}{2}\right)^3}{1-\frac{1}{2}}=\frac{\frac{7}{8}}{\frac{1}{2}}=\frac{7}{4}\]
Now we don't want the slope of any of these secants through $P$, we want the slope of the tangent $m_t$, so let's just plug in $x=1$ to get it:
\[m_t=m(1)=\frac{1-1^3}{1-1}=\frac{0}{0}\]
The slope function $m(x)$ is not defined at $x=1$!  However if we take $x$ values slightly smaller than $1$ (so $Q$ gets very close to $P$ from the left as in the diagram) or $x$ values slightly larger than $1$ (so $Q$ gets very close to $P$ from the right) we have the following answers for the slope of those secants:

\hfil\begin{tabular}{D{.}{.}{-1}D{.}{.}{-1}} \\ %\toprule
\multicolumn{2}{c}{Approaching 1 From the Left}\\ \midrule
\multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$m_{\s PQ}=m(x)$} \\ \midrule
0.5& 1.75 \\
0.9& 2.71  \\
0.99 & 2.9701  \\
0.999 & 2.997001 \\
0.9999 & 2.99970001 \\ %\bottomrule
\end{tabular}
\hfil
\begin{tabular}{D{.}{.}{-1}D{.}{.}{-1}} \\ %\toprule
\multicolumn{2}{c}{Approaching 1 From the Right}\\ \midrule
\multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$m_{\s PQ}=m(x)$} \\ \midrule
1.5 & 4.75 \\
1.1 & 3.31 \\
1.01 & 3.0301 \\
1.001 & 3.003001 \\
1.0001 & 3.00030001 \\ %\bottomrule
\end{tabular}
\hfil

The results show that the closer $x$ is to 1 (equivalently point $Q$ is to $P$), the closer $m_{\s PQ}$ is to 3.  This suggests the slope of the tangent line at $P$ should be $m_t=3$.  However, as shown above, this is not the value of the function $m(x)$ at $x=1$ as that value is undefined.  We need a new concept.  We say the slope of the tangent line is the \textbf{limit} of the slopes of the secant lines and we write
\[m_t=\lim_{\s Q\rightarrow P}m_{\s PQ}~.\]
Written in terms of the function $m(x)$,
\[m_t=\lim_{x\rightarrow 1}m(x)=\lim_{x\rightarrow 1}\frac{1-x^3}{1-x}=3~.\]
We can now use the point-slope formula with $(x_0,y_0)=(1,1)$ and $m_t=3$ to get the equation of the tangent line at $P$ to be
\[y=3(x-1)+1\ .\]
Multiplying this out gives the slope-intercept form of the tangent, namely
\[y=3x-2\ .\]


\begin{example}
  Consider the curve described by the function $\displaystyle y=f(x) =
  \frac{x-4}{x^2+1}$\,.
  \begin{enumerate}[label=(\alph*)]
  \item Show that the points $(0,-4)$ and $\left(2,-\frac{2}{5}\right)$ lie on the curve.
  \item Determine the slope of the secant line passing through the points
    $(0,-4)$ and $\left(2,-\frac{2}{5}\right)$\,.
  \item\label{itm:limits_tangentc} Let $Q$ be the arbitrary point $(x,\frac{x-4}{x^2+1})$ on the curve.
    Find the slope of the secant line passing through $Q$ and $(0,-4)$\,.
  \item Use your answer in $\ref*{itm:limits_tangentc}$ to determine the slope of the tangent line to the curve at the point $(0,-4)$\,. Evaluate the resulting limit numerically.
  \end{enumerate}
  \begin{solution*}
    \begin{enumerate}[label=(\alph*)]
    \item A point lies on a curve $y=f(x)$ if it satisfies the equation.\\[.3em]
      $\displaystyle (0,-4)\,:\ \ y=f(0) = \frac{0-4}{0+1} = -4$~~~~~~~~~~~
      $\left(2,-\frac{2}{5}\right)$\,:\ \ $\displaystyle y=f(2) = \frac{2-4}{2^2+1} =-\frac{2}{5}$\\[.3em]
    So the points $(0,-4)$ and $\left(2,-\frac{2}{5}\right)$ lie on the curve.
    \item \label{itm:limits_tangentansb}slope of secant between $(0,-4)$ and $Q=\left(2,-\frac{2}{5}\right)$: $\displaystyle m= \frac{-\frac{2}{5} - (-4)}{2-0} =
      \frac{-\frac{2}{5}+4}{2} = \frac{\frac{18}{5}}{2} = \frac{9}{5}$
    \item \label{itm:limits_tangentansc} slope of secant between $(0,-4)$ and $Q=(x,f(x))$:\\[.5em]
      $\displaystyle m= \frac{\frac{x-4}{x^2+1}-(-4)}{x-0} =
      \frac{\frac{x-4}{x^2+1}+4\left(\frac{x^2+1}{x^2+1}\right)}{x} = \frac{x-4+4x^2+4}{x(x^2+1)} = 
      \frac{x(1+4x)}{x(x^2+1)} = \frac{1+4x}{x^2+1} \ \left(\text{if } x\neq 0\right)$
      Note $m$ itself is a function of $x$, $m=m(x)$, since it depends on the arbitrary $x$ coordinate of~$Q$.
    \item The slope $m(x)$ of the arbitrary secant between $(0,-4)$ and $Q(x,f(x))$ is not defined at $x=0$.  We can evaluate points $Q$ close to $(0,-4)$ by choosing values of $x$ close to $0$ to the left and right of that value.
      
\hfil\begin{tabular}{D{.}{.}{-1}D{.}{.}{-1}} \\ %\toprule
\multicolumn{2}{c}{Approaching 0 From the Left}\\ \midrule
\multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$m_{\s PQ}=m(x)$} \\ \midrule
-0.5 & -0.8 \\
-0.1 & 0.594059405941 \\
-0.01 & 0.959904009599 \\
-0.001 & 0.995999004001 \\
-0.0005 & 0.9979997505 \\
-0.0001 & 0.999599990004 \\ %\bottomrule
\end{tabular}
\hfil
\begin{tabular}{D{.}{.}{-1}D{.}{.}{-1}} \\ %\toprule
\multicolumn{2}{c}{Approaching 0 From the Right}\\ \midrule
\multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$m_{\s PQ}=m(x)$} \\ \midrule
0.5 & 2.4 \\
0.1 & 1.38613861386 \\
0.01 & 1.0398960104 \\
0.001 & 1.003998996 \\
0.0005 & 1.0019997495 \\
0.0001 & 1.00039999 \\ %\bottomrule
\end{tabular}
\hfil

The secant slopes approach the value $1$, the slope of the tangent $m_t$.  We write
\begin{align*}
  m_t=\lim_{x\to0}m(x)=\lim_{x\to 0}\frac{1+4x}{x^2+1} = 1
\end{align*}

One can check the answer graphically.  Since the secant and tangent
lines go through $(0,-4)$ we have immediately that that the
$y$-intercept $b$ of both lines is $b=-4$.  Using our slopes from
\ref*{itm:limits_tangentansb} and \ref*{itm:limits_tangentansb} the
equation of the secant between $(0,-4)$ and
$\left(2,-\frac{2}{5}\right)$ is $y=\frac{9}{5}x-4$ while the equation
of the tangent at $(0,-4)$ is $y=1x-4$.  A graph of the original curve
and these lines is:
\begin{center}
  \resizebox{.4\textwidth}{!}{%
    \includegraphics{graphics/limits_tangent}%
    }
\end{center}
\end{enumerate}
\end{solution*}

  Further Example:\\
  Consider the curve described by the function $y=5x^4+3x^2-10$\,. 
  \begin{enumerate}[label=(\alph*)]
  \item Show that the points $(0,-10)$ and $(1,-2)$ lie on the curve.
  \item Determine the slope of the secant line passing through the points
    $(0,-10)$ and $(1,-2)$\,.
  \item\label{itm:limits_tangent2c} Let $Q$ be the arbitrary point
    $(x,5x^4+3x^2-10)$ on the curve. Find the slope of the secant line
    passing through $Q$ and $(1,-2)$\,.
  \item Use your answer in $\ref*{itm:limits_tangent2c}$ to determine
    the slope of the tangent line to the curve at the point
    $(1,-2)$\,.  Evaluate the resulting limit numerically.
  \end{enumerate}
  \begin{comment}
  \begin{solution*}
    \begin{enumerate}[label=(\alph*)]
    \item $\displaystyle f(x) = 5x^4+3x^2-10\\f(0)=0+0-10 = -10 \\ f(1)=5(1)^4 + 3(1)^2 - 10 =
      5+3-10=-2 \\ \therefore \text{the points } (0,-10) \text{ and } (1,-2)
      \text{ lie on the curve.}$
    \item $\displaystyle\text{slope }= \frac{-2-(-10)}{1-0} = \frac{-2+10}{1} = \frac{8}{1}
      =8$
    \item $\displaystyle\text{slope }= \frac{5x^4+3x^2-10+2}{x-1} = \frac{5x^4+3x^2-8}{x-1}
        = 5x^3+5x^2+8x+8 \text{ if } x\neq 1$
      \item $\displaystyle \lim_{x\to 1}(5x^3+5x^2+8x-8) = 5(1^3)+5(1)^2+8(1)+8 = 5+5+8+8=26
        \\ \therefore \text{the slope of the tangent line is 26}$
    \end{enumerate}
  \end{solution*}
  \end{comment}
\end{example}

\textbook{\clearpage}%Needed to fix exercise label
\begin{exercise}
\input{LIMITS/secant-and-tangent-lines}
\end{exercise}

\section{Limit of a Function}

In the last section we came up with a function $m(x)$ and considered its limiting behaviour as $x\rightarrow 1$.  In general we can explore limits numerically for an arbitrary function:

\begin{example}
Investigate the limiting behaviour of the function $f(x)=x^2+1$ for $x$ near $2$:

\hfil\begin{tabular}{D{.}{.}{-1}D{.}{.}{-1}} \\ %\toprule
\multicolumn{2}{c}{Approaching 2 From the Left}\\ \midrule
\multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$f(x)$} \\ \midrule
1.5 & 3.25 \\
1.9 & 4.61 \\
1.99 & 4.9601 \\
1.999 & 4.996001 \\
1.9995 & 4.99800025 \\
1.9999 & 4.99960001
\end{tabular}
\hfil
\begin{tabular}{D{.}{.}{-1}D{.}{.}{-1}} \\ %\toprule
\multicolumn{2}{c}{Approaching 2 From the Right}\\ \midrule
\multicolumn{1}{c}{$x$} & \multicolumn{1}{c}{$f(x)$} \\ \midrule
2.5 & 7.25 \\
2.1 & 5.41 \\
2.01 & 5.0401 \\
2.001 & 5.004001 \\
2.0005 & 5.00200025 \\
2.0001 & 5.00040001
\end{tabular}\hfil

From the numerical tables we can see that when $x$ gets closer to 2 (on either side) $f(x)$ gets closer to 5.  Therefore the limit of $f(x)=x^2+1$ as $x$ approaches 2 is $5$:
\[\lim_{x\rightarrow2}(x^2+1)=5\]
\end{example}

The previous discussion leads to the following non-rigorous definition of a limit.
\definition{The \textbf{limit} of $f(x)$ as $x$ approaches $a$ is $L$
if we can make the values of $f(x)$ as close as we like to $L$ by taking $x$-values sufficiently close but not equal to $a$. In symbols we write:
\[\lim_{x\rightarrow a}f(x)=L\ .\]}

If such a limit exists then the values of $f(x)$ get closer and closer to the number $L$ as $x$ gets closer and closer to the number $a$ (from either side of $a$) but $x\neq a$.

Note that because the limit at $x=a$ only depends upon the values of the function $f(x)$ around $a$ the function at $a$ may not even be defined (i.e. $a$ may not be in the domain of the function).  This was the case of our secant slope function $m(x)$ at $x=1$.  If the function is defined it might equal the limit.  In the above numerical example we found the limit was $L=5$ at $a=2$ and in fact $f(2)=2^2+1=5$ also equals $5$.  However we could also tweak the above function to have a different value from the limit at $x=2$ by defining it to be
\[g(x)=\left\{
\begin{array}{cl}
x^2+1&\mbox{if}\ x\neq2\\
6&\mbox{if}\ x=2
\end{array}
\right.~.\]
\textbook{\clearpage}
Graphically the two functions look as follows:
\begin{center}
\hfil
\includegraphics{graphics/limits5}%
\hfil
\includegraphics{graphics/limits6}%
\hfil
\end{center}
The function values at $x=2$ differ since $f(2)=5\neq6=g(2)$, but the limit as $x\rightarrow 2$ for both functions is $L=5$,
\[\lim_{x\rightarrow2}f(x)=\lim_{x\rightarrow2}g(x)=5~,\]
 since the limits only depends upon what the functions are doing near the $x$-value $a=2$ which is identical for both functions.

\section{Rigorous Definition of the Limit}
For our course the previous definition of the limit which is intuitive is adequate.  However if we really want to prove basic theorems of limits (such as the ones we shall state without proof in the next section) we need a more precise definition.  The epsilon-delta ($\epsilon$-$\delta$) definition of the limit is such a definition.

\definition{Let function $f$ be defined on an open interval containing the number $a$, except possibly at $a$ itself. Then 
\[\lim_{x\rightarrow a}f(x)=L\ \ \ \mbox{(the limit of $f(x)$ as $x$ approaches $a$ is $L$)}\]
 if for every number $\epsilon>0$ there exists a number $\delta>0$ such that
\[|f(x)-L|<\epsilon\ \mbox{whenever}\ 0<|x-a|<\delta\ .\]
}

The following diagram illustrates that for the given $\epsilon$ (here 0.5) a value of $\delta$ can be found (here 0.15) which would be sufficient to meet the criterion for the function shown.  To prove that $\displaystyle\lim_{x\rightarrow2}f(x)=3$ we would need to show such a delta could be found for every epsilon.

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


\section{Limit Rules}
We wish to have rules for limits so we do not have to evaluate them all numerically. The following graphs of some basic functions illustrate what will be our first limit rules.
\begin{center}
\includegraphics{graphics/limits8}%
~~\raisebox{6em}{$\Rightarrow$~~$\displaystyle \boxed{\lim_{x\rightarrow a} c=c}$}
\end{center}
\begin{center}
\includegraphics{graphics/limits9}%
~~\raisebox{10em}{$\Rightarrow$~~$\displaystyle\boxed{\lim_{x\rightarrow a} x=a}$}
\end{center}
\begin{center}
\includegraphics{graphics/limits10}%
~~\raisebox{10em}{$\Rightarrow$~~$\displaystyle\boxed{\lim_{x\rightarrow a}x^n=a^n}$}
\end{center}
The validity of the former limit results, whose truth is made plausible by the graphs, can be verified with proofs using the rigorous definition of the limit.\footnote{Note that a numerical evaluation of a limit is not rigorous as one is only checking the behaviour of a handful of $x$-values around $a$ where limits require analysis of \emph{all} the values around $a$.}  These and other results involving limits are summarized in the following theorem.
\theorem{\label{thm:limitrules}Let $c$ be a constant and suppose the limits $\displaystyle\lim_{x\rightarrow a} f(x)$ and $\displaystyle\lim_{x\rightarrow a} g(x)$ exist.
Then the following limit rules hold:
\begin{method}
\vspace{-1em}
\begin{enumerate}
\item \label{itm:limitrules1} $\displaystyle \lim_{x\rightarrow a} c=c$
\item \label{itm:limitrules2}$\displaystyle \lim_{x\rightarrow a} x=a$
\item \label{itm:limitrules3}$\displaystyle \lim_{x\rightarrow a}x^n=a^n$
\item \label{itm:limitrules4}$\displaystyle \lim_{x\rightarrow a}\sqrt[n]{x}=\sqrt[n]{a}$\  (Here $n$ is a positive integer. If $n$ is even, then we require $a>0$.)
\item \label{itm:limitrules5}$\displaystyle \lim_{x\rightarrow a} [f(x)\pm g(x)]=\lim_{x\rightarrow a}f(x)\pm\lim_{x\rightarrow a}g(x)$
\item \label{itm:limitrules6}$\displaystyle \lim_{x\rightarrow a}[cf(x)]=c\lim_{x\rightarrow a}f(x)$
\item \label{itm:limitrules7}$\displaystyle \lim_{x\rightarrow a} [f(x)g(x)]=\left[\lim_{x\rightarrow a} f(x)\right]\left[\lim_{x\rightarrow a} g(x)\right]$
\item \label{itm:limitrules8}$\displaystyle \lim_{x\rightarrow a}\frac{f(x)}{g(x)}=\frac{\displaystyle\lim_{x\rightarrow a} f(x)}{\displaystyle\lim_{x\rightarrow a} g(x)}$\  (Here we require $\displaystyle\lim_{x\rightarrow a} g(x)\neq 0$)
\item \label{itm:limitrules9}$\displaystyle \lim_{x\rightarrow a} [f(x)]^n=\left[\lim_{x\rightarrow a} f(x)\right]^n$
\item \label{itm:limitrules10}$\displaystyle \lim_{x\rightarrow a}\sqrt[n]{f(x)}=\sqrt[n]{\lim_{x\rightarrow a} f(x)}$ ($n$ a positive integer. If $n$ is even, then $\displaystyle\lim_{x\rightarrow a} f(x)> 0$ is required.)
\end{enumerate}
\end{method}}

\textbook{\clearpage}
\begin{example}
  Evaluate the given limits. Consider which rules are being used at each step of the evaluation.
  \begin{enumerate}
    \begin{multicols}{2}
    \item $\displaystyle \lim_{x\to3}9-2x$
    \item $\displaystyle \lim_{x\to2}\frac{1+\sqrt{2x+3x^2}}{x}$
    \item $\displaystyle \lim_{x\to -1}\frac{x^4-1}{x^3+1}$
    \item $\displaystyle \lim_{x\to 5}\frac{x-5}{\frac{1}{x} - \frac{1}{5}}$
    \item $\displaystyle \lim_{x\to 4} \frac{x-4}{\sqrt{x}-2}$
    \item $\displaystyle \lim_{h\to 0} \frac{\sqrt{9+h}-3}{h}$
    \item $\displaystyle \lim_{t\to 0} \frac{\frac{1}{(3+t)^2} - \frac{1}{9}}{t}$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
    \newcommand{\circref}[1]{\circled{\small\ref{#1}}}
    \begin{enumerate}
      \item The particular rule from Theorem~\ref{thm:limitrules} being used at each step is shown below the equal sign.\\[.5em]
        $\displaystyle \lim_{x\to3}9-2x
        \underset{\circref{itm:limitrules5}}{=}\lim_{x\to3}9-\lim_{x\to3}2x
        \underset{\circref{itm:limitrules6}}{=}\lim_{x\to3}9-2\lim_{x\to3}x
        \underset{\circref{itm:limitrules1}\,\circref{itm:limitrules2}}{=}9-2(3)
        =3$
    \item \begin{align*}
            \lim_{x\to2}\frac{1+\sqrt{2x+3x^2}}{x}
            &\underset{\circref{itm:limitrules8}}{=}\frac{\displaystyle\lim_{x\to2}\left(1+\sqrt{2x+3x^2}\right)}{\displaystyle\lim_{x\to 2}x}
              \underset{\circref{itm:limitrules5}\,\circref{itm:limitrules2}}{=}\frac{\displaystyle\lim_{x\to2}1+\lim_{x\to2}\sqrt{2x+3x^2}}{2}\\[.5em]
            &\underset{\circref{itm:limitrules1}\,\circref{itm:limitrules2}}{=}\frac{\displaystyle 1+\sqrt{\lim_{x\to2}\left(2x+3x^2\right)}}{2}
              \underset{\circref{itm:limitrules5}\,\circref{itm:limitrules6}}{=}\frac{\displaystyle 1+\sqrt{2\lim_{x\to2}x+3\lim_{x\to2}x^2}}{2}\\[.5em]
            &\underset{\circref{itm:limitrules2}\,\circref{itm:limitrules3}}{=}\frac{\displaystyle 1+\sqrt{2(2)+3(2)^2}}{2}
            =\frac{\displaystyle 1+\sqrt{16}}{2}=\frac{5}{2}
\end{align*}

Looking at the final result of this and the previous problem suggests that the answer for many limits will be the same as just plugging the value $a$ into the function itself.  The remaining examples will show that this is often not the case. However if one can ``plug in the value'' and it results in a number, Theorem~\ref{thm:limitrules} can be systematically used to show that that number is the actual limit value.
  \item For $\displaystyle\lim_{x\to -1}\frac{x^4-1}{x^3+1}$ we can plug $x=-1$ into the function but we see we get $\frac{(-1)^4-1}{(-1)^3+1}=\frac{0}{0}$\,, so the function is undefined at $x=-1$.  However the function not being defined at $x=-1$ does not mean the limit does not exist since the limit only depends on what the function is doing \emph{near} $x=-1$ not \emph{at} that value.  To evaluate the limit we need a different strategy from the previous problems.  A little thought suggests that the reason that the numerator and denominator are vanishing at $a=-1$ is because $(x-a)=(x-(-1))=(x+1)$ is a factor of both polynomials.  Factoring confirms this and leads to the resolution of the limit:\\[1em]
    $\displaystyle \lim_{x\to -1}\frac{x^4-1}{x^3+1}
    = \lim_{x\to -1}\frac{(x^2)^2-1^2}{x^3+(1)^3}
    = \lim_{x\to -1}\frac{(x^2+1)(x^2-1)}{(x+1)(x^2-x+1)}
    = \lim_{x\to -1}\frac{(x^2+1)(x+1)(x-1)}{(x+1)(x^2-x+1)}$\\[.5em]
At this stage one can cancel the factor $(x+1)$ since near (but not at) $x=-1$ this evaluates to a non-zero number and the previous limit equals:\\[.5em]
    $\displaystyle= \lim_{x\to -1}\frac{(x^2+1)(x-1)}{x^2-x+1}
     \underset{\circref{itm:limitrules8}\,\circref{itm:limitrules7}\,\circref{itm:limitrules5}\,\circref{itm:limitrules1}\,\circref{itm:limitrules2}\,\circref{itm:limitrules3}}{=} \frac{[(-1)^2+1](-1-1)}{(-1)^2-(-1)+1} = \frac{-4}{1+1+1} = -\frac{4}{3}$
  \item Plugging in $x=5$ into $\frac{x-5}{\frac{1}{x}-\frac{1}{5}}$ yields $\frac{0}{0}$ showing the limit is indeterminate.  Simplifying the expression by combining fractions in the denominator resolves the limit:
\begin{align*}
  \lim_{x\to 5}\frac{x-5}{\frac{1}{x}-\frac{1}{5}}
    &=\lim_{x\to 5}\frac{x-5}{\left(\frac{1}{x}\right)\left(\frac{5}{5}\right) - \left(\frac{1}{5}\right)\left(\frac{x}{x}\right)}
    =\lim_{x\to 5} \frac{x-5}{\frac{5-x}{5x}}
    = \lim_{x\to 5}\frac{(x-5)(5x)}{-(x-5)}
    = \lim_{x\to 5} (-5x)\\[.5em]
    &= -5(5) = -25
\end{align*}
  \item Also indeterminate, we can resolve this limit by factoring:\\[.5em]
    $\displaystyle \lim_{x\to 4} \frac{x-4}{\sqrt{x}-2}
    =\lim_{x\to 4} \frac{(\sqrt{x})^2-2^2}{\sqrt{x}-2}
    = \lim_{x\to 4}\frac{(\sqrt{x}+2)(\sqrt{x}-2)}{\sqrt{x}-2}
    = \lim_{x\to 4} (\sqrt{x}+2) = \sqrt{4}+2 = 2+2 = 4$
  \item The following indeterminate limit can be evaluated by multiplying by $1=\frac{\text{conjugate}}{\text{conjugate}}$ where here the conjugate of $\sqrt{9+h}-3$ is $\sqrt{9+h}+3$ (i.e. change the sign between terms).
\begin{align*}
    \lim_{h\to 0} \frac{\sqrt{9+h}-3}{h}
    &= \lim_{h\to 0}\frac{\sqrt{9+h}-3}{h}\cdot \frac{\sqrt{9+h}+3}{\sqrt{9+h}+3}
    = \lim_{h\to 0}\frac{(\sqrt{9+h}-3)(\sqrt{9+h}+3)}{h(\sqrt{9+h}+3)}\\[.5em]
    &= \lim_{h\to 0}\frac{(\sqrt{9+h})^2+3\sqrt{9+h}-3\sqrt{9+h}-3^2}{h(\sqrt{9+h}+3)}
    = \lim_{h\to 0}\frac{9+h-9}{h(\sqrt{9+h}+3)}\\[.5em]
    &= \lim_{h\to 0}\frac{h}{h(\sqrt{9+h}+3)}
    = \lim_{h\to 0} \frac{1}{\sqrt{9+h}+3}
    = \frac{1}{\sqrt{9+0}+3} = \frac{1}{3+3} = \frac{1}{6}
\end{align*}
  \item This indeterminate form is also resolved by combining fractions:
    \begin{align*}\lim_{t\to 0} \frac{\frac{1}{(3+t)^2} - \frac{1}{9}}{t}
    &=\lim_{t\to 0}\frac{\frac{9-(3+t)^2}{9(3+t)^2}}{t}
    = \lim_{t\to 0}\frac{9-9-6t-t^2}{9t(3+t)^2}
    = \lim_{t\to 0}\frac{t(-6-t)}{9t(3+t)^2}
    = \lim_{t\to 0}\frac{-6-t}{9(3+t)^2}\\[.5em]
    &= \frac{-6-0}{9(3+0)^2} = \frac{-6}{(9)(9)} = -\frac{6}{81} = -\frac{2}{27}
\end{align*}
  \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following limits.  Consider which rules are being used at each step of the evaluation.
\begin{multicols}{2}
\begin{enumerate}
\item $\mylim{x}{2}\left(3x^3-2x^2+3x+1\right)$
\item $\mylim{x}{4}\sqrt{x^2-4}$
\item $\mylim{x}{-1}\frac{x^2+1}{x+4}$
\item $\mylim{x}{1}\frac{x^2-1}{x^2+1}$
\item $\mylim{x}{2}\frac{x-2}{x^2-2x}$
\item $\mylim{h}{0}\frac{(1+h)^2-1}{h}$
\item $\mylim{s}{0}\frac{\sqrt{s^2+9}-3}{s^2}$
\item $\mylim{x}{-2}\frac{x^2-x-6}{x+2}$
\item $\mylim{x}{1}\frac{\frac{1}{x}-1}{x-1}$
\item $\mylim{x}{-1}\frac{x^3+x^2-x-1}{x^3+2x^2+2x+1}$
\item $\mylim{t}{-5}\frac{t^2+5t}{\sqrt{t^2-16}-3}$
\item $\mylim{x}{1}\frac{1-x^3}{1-x}$\ \ $\Leftarrow$\ \parbox{3cm}{Recall this was our secant slope limit: $\displaystyle \mylim{x}{1}m(x)$ }
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

The previous examples illustrate the general strategy for evaluating the limit $\mylim{x}{a} f(x)$~:
\begin{itemize}
\item Evaluate $f(a)$ and see if it results in the \textbf{indeterminate form} $\bm{\frac{0}{0}}$~.  If it is not, the limit rules can often be used to show the limit really is just $f(a)$.
\item If the result is an indeterminate form, try the following:
\begin{itemize}
\item Simplify
\item Expand
\item Factor
\item Rationalize using the conjugate
\end{itemize}
\item Of course one can also check a result numerically by evaluating the function at values close to $a$.
\end{itemize}
Remember: $\frac{0}{0}$ is not an answer for a limit.  The indeterminate form indicates more work must be done to find the limit or else to show it does not exist.

The following example illustrates evaluating limits involving symbolic functions and constants.
\begin{example}
  If $\mylim{x}{a}f(x)=2$, $\mylim{x}{a}g(x)=-3$, and $\mylim{x}{a}h(x)=3$ then find:
  \begin{enumerate}
    \item $\displaystyle \lim_{x\to a}\sqrt{f(x)+h(x)}$
    \item $\displaystyle \lim_{x\to a}\frac{f(x)g(x)}{[h(x)]^2}$
    \end{enumerate}
    
    \begin{solution*}
      \begin{enumerate}
      \item $\displaystyle \lim_{x\to a}\sqrt{f(x)+h(x)}
        =\sqrt{\lim_{x\to a}[f(x)+h(x)]}
        =\sqrt{\lim_{x\to a}f(x)+\lim_{x\to a}h(x)}
        =\sqrt{2+3}=\sqrt{5}$
      \item $\displaystyle \lim_{x\to a}\frac{f(x)g(x)}{[h(x)]^2}
        =\frac{\displaystyle\lim_{x\to a}[f(x)g(x)]}{\displaystyle\lim_{x\to a}[h(x)]^2}
        =\frac{\displaystyle\left[\lim_{x\to a}f(x)\right]\left[\lim_{x\to a}g(x)\right]}{\displaystyle\left[\lim_{x\to a}h(x)\right]^2}
        =\frac{(2)(-3)}{(3)^2}
        =-\frac{2}{3}$
      \end{enumerate}
  \end{solution*}    
      

\begin{furtherquestions}
Using the same limits as above find:
\begin{enumerate}
\item $\mylim{x}{a} \frac{6f(x)-4[g(x)]^2}{g(x)-4f(x)}$
\item $\mylim{x}{a} [f(x)+h(x)]^3$
\item $\mylim{x}{a} \frac{f(x)}{g(x)+h(x)}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}%Needed for correct Answer reference.
\begin{exercise}
\input{LIMITS/calculating-limits-using-limit-laws}
\end{exercise}

\section{Trigonometric Limits}

\theorem{\label{thm:limittrig}The following trigonometric limits can be shown to exist:

\hfil$\mylim{x}{0}\frac{\sin x}{x}=1$\hfil$\mylim{x}{0}\frac{\sin ax}{x}=a$\hfil$\mylim{x}{0}\frac{1-\cos x}{x}=0$\hfil

\hfil$\mylim{x}{a}\sin x=\sin a$\hfil$\mylim{x}{a}\cos x=\cos a$\hfil

Useful examples of the last two limits are:

\hfil$\mylim{x}{0}\sin x=0$\hfil$\mylim{x}{0}\cos x=1$\hfil

\hfil$\mylim{x}{\pi/2}\sin x=1$\hfil$\mylim{x}{\pi/2}\cos x=0$\hfil

\hfil $\mylim{x}{\pi}\sin x=0$\hfil $\mylim{x}{\pi}\cos x=-1$\hfil

}
The trigonometric limits which involve a ratio may be verified numerically using a calculator (note the angles must be in radians), the remainder may be verified by consideration of the graphs of the functions.\footnote{Note that the limits $\displaystyle\lim_{x\to a}\sin x=\sin a$ and $\displaystyle\lim_{x\to a}\cos x=\cos a$ reflect, as will be seen in Section~\ref{sec:continuity}, the continuity of sine and cosine.}

These basic results, our previous limit rules, and trigonometric
identities may be used to find more complicated trigonometric limits.
\begin{example}
  Evaluate the trigonometric limits.
  \begin{enumerate}
    \item $\displaystyle \lim_{x\to 0} \frac{3-2\sin x}{2+x}$
    \item $\displaystyle \lim_{\theta\to 0} \frac{\sin(-2\theta)}{5\theta}$
    \item $\displaystyle \lim_{t\to 0} \frac{t^2-t\cos t}{4t}$
    \item $\displaystyle \lim_{\theta\to 0} \frac{4\theta\sin\theta - 5\theta^2}{3\theta^2}$
    \item $\displaystyle \lim_{x\to 0 } \frac{3\sin^{2}x}{1-\cos x}$
    \end{enumerate}
  
    \begin{solution*}
      \begin{enumerate}
      \item Combining the basic trigonometric limits
        \begin{align*} \lim_{x\to a}\sin x=\sin a~~~~~~~~~\lim_{x\to a}\cos x=\cos a\end{align*}
        from Theorem~\ref{thm:limittrig} with the general results of Theorem~\ref{thm:limitrules} to resolve this limit:\\[.5em]
$\displaystyle \lim_{x\to 0} \frac{3-2\sin x}{2+x}
= \frac{\displaystyle\lim_{x\to0}(3-2\sin x)}{\displaystyle\lim_{x\to0}(2+x)}
= \frac{\displaystyle\lim_{x\to0}3-2\lim_{x\to0}\sin x}{\displaystyle\lim_{x\to0}2+\lim_{x\to0}x}
=\frac{3-2\sin 0}{2+0} = \frac{3-0}{2} = \frac{3}{2}$\\[.5em]
Thus many limits involving trigonometric expressions will also equal the function evaluated at the limit point if the latter is defined.  (Since limits involving tangent, cotangent, secant, and cosecant can be written as quotients involving sine and cosine this is true of those as well.)
  \item The following is an indeterminate form $(\frac{0}{0})$\,.  Using $\displaystyle\lim_{x\to0}\frac{\sin ax}{x}=a$ of Theorem~\ref{thm:limittrig} with $a=-2$ we have:\\[.5em]
    $\displaystyle \lim_{\theta\to 0} \frac{\sin(-2\theta)}{5\theta} =
    \frac{1}{5}\lim_{\theta\to 0} \frac{\sin(-2\theta)}{\theta}=
    \frac{1}{5}(-2) = -\frac{2}{5}$\\[.5em]
    An alternative approach casts uses $\displaystyle\lim_{x\to 0}\frac{\sin x}{x}=1$ by making the denominator match the argument of the trigonometric function:\\[.5em] 
    $\displaystyle \lim_{\theta\to 0} \frac{\sin(-2\theta)}{5\theta}
    =\frac{1}{5}\lim_{\theta\to 0} \frac{\sin(-2\theta)}{-2\theta}(-2)
    \underset{(x=-2\theta)}{=}-\frac{2}{5}\lim_{x\to 0} \frac{\sin x}{x}
    =-\frac{2}{5}(1) = -\frac{2}{5}$
  \item This indeterminate form requires cancellation of the factor $t$:\\[.5em]
    $\displaystyle \lim_{t\to 0} \frac{t^2-t\cos t}{4t} = \lim_{t\to 0}
    \frac{t(t-\cos t)}{4t} = \lim_{t\to 0} \frac{t-\cos t}{4} = \frac{0-\cos
      0}{4} = -\frac{1}{4}$
  \item $\displaystyle \lim_{\theta\to 0} \frac{4\theta\sin\theta - 5\theta^2}{3\theta^2}
    = \lim_{\theta\to 0} \frac{\theta(4\sin\theta - 5\theta)}{3\theta^2}
    = \lim_{\theta\to 0} \left(\frac{4\sin\theta}{3\theta} -\frac{5}{3}\right)
    = \frac{4}{3}(1) - \frac{5}{3} = \frac{4}{3} - \frac{5}{3} = -\frac{1}{3}$
  \item This indeterminate form may be resolved by multiplying by $1=\frac{\text{conjugate}}{\text{conjugate}}$ where conjugate is the conjugate of the denominator.  A basic trigonometric identity is also required.

    $\begin{aligned}[t]
    \lim_{x\to 0} \frac{3\sin^{2}x}{1-\cos x}
    & =  \lim_{x\to 0}\frac{3\sin^{2}x}{1-\cos x}\cdot \frac{1+\cos x}{1+\cos x}
      = \lim_{x\to 0}\frac{3\sin^{2}x(1+\cos x)}{(1+\cos x)(1-\cos x)}\\[.5em]
    & = \lim_{x\to 0}\frac{3\sin^{2}x(1+\cos x)}{1-\cos^{2}x}
      = \lim_{x\to 0}\frac{3\sin^{2}x(1+\cos x)}{\sin^{2}x}\\[.5em]
    & = \lim_{x\to 0} 3(1+\cos x) = 3(1+\cos 0) = 3(1+1) = 6\end{aligned}$
  \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following trigonometric limits:
\begin{enumerate}
\item $\mylim{x}{0}\frac{\sin^2\!x}{x}$
\item $\mylim{x}{0}\frac{x}{1-\cos x}$
\item $\mylim{x}{0}\frac{1-\cos x}{x^2}$
\item $\mylim{x}{0}\frac{\sec x\tan x}{x}$
\item $\mylim{x}{0}\frac{\sin^2\!x}{x^\frac{4}{3}}$
\item $\mylim{x}{0}\frac{\sin 4x}{3x}$
\item $\mylim{t}{0}\frac{2t\sin t-5t^2}{t^2}$
\item $\mylim{x}{\frac{\pi}{2}}\frac{\cos^2x}{1+\cos 2x}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\begin{exercise}
\input{LIMITS/trigonometric-limits}
\end{exercise}

\section{The Squeeze Theorem}
\theorem{If $g(x)\le f(x)\le h(x)$ for all $x$ in an interval containing $a$ (with the potential exception of $x=a$) and
\[\mylim{x}{a}g(x)=\mylim{x}{a}h(x)=L\]
then
\[\mylim{x}{a}f(x)=L\]
This is known as the \textbf{squeeze theorem}.
}
\begin{example}
If $3x\le f(x)\le x^3+2$ for $0\le x\le2$, evaluate $\mylim{x}{1}f(x)$\ .

\begin{solution}
  Evaluating the limits at $a=1$ we have
  \begin{align*}
    \lim_{x\to1}3x & = 3(1) = 3 \\
    \lim_{x\to1}x^3+2 & = (1)^3+2 = 3
  \end{align*}
  Since $f(x)$ is greater than or equal to $g(x)=3x$ and less than or equal to  $h(x)=x^3+2$ by assumption and the two limits at $a=1$ are equal, it follows by the Squeeze Theorem that $\displaystyle\lim_{x\to1}f(x)=3$\,.

  The following graph shows $g(x)=3x$ and $h(x)=x^3+2$ and a hypothetical $f(x)$ which meets the criterion of being between the two functions.
\begin{center}
\includegraphics[width=3.5cm]{graphics/limits11}%
\end{center}

\end{solution}

\begin{furtherquestion}
If $\cos x\le f(x)\le \sec x$ on the interval $[-1,1]$, evaluate $\displaystyle \lim_{x\to 0}f(x)$\,.
\end{furtherquestion}
\end{example}

\section{One-sided Limits}
We can define weaker limit criteria if we restrict ourselves to approaching $a$ from either the left or the right.\footnote{More rigorous $\epsilon$-$\delta$ definitions of the left-hand and right-hand limits can easily be formulated by replacing the condition $0<|x-a|<\delta$ with $a-\delta<x<a$ and $a<x<a+\delta$ respectively in the (two-sided) limit definition.  One now also only requires that $f$ be defined to the left or right of $a$ respectively.}
\definition{The \textbf{left-hand limit} of $f(x)$ as $x$ approaches $a$ is $L$
if we can make the values of $f(x)$ as close as we like to $L$ by taking $x$-values sufficiently close to $a$ with $x$ less than $a$. In symbols we write:
\[\lim_{x\rightarrow a^{-}}f(x)=L\ .\]}
\definition{The \textbf{right-hand limit} of $f(x)$ as $x$ approaches $a$ is $L$
if we can make the values of $f(x)$ as close as we like to $L$ by taking $x$-values sufficiently close to $a$ with $x$ greater than $a$. In symbols we write:
\[\lim_{x\rightarrow a^{+}}f(x)=L\ .\]}
The following graph of a hypothetical function $f(x)$ shows the behaviour of the one-sided limits at $a=2$:
\begin{center}
\includegraphics[width=10cm]{graphics/limits12}%
\end{center}
The following important theorem relates the (two-sided) limit at $a$ to the one-sided limits at that number.
\theorem{\label{thm:onesidedlimits}$\mylim{x}{a}f(x)=L$ if and only if $\mylim{x}{a^{-}}f(x)=L$ and $\mylim{x}{a^{+}}f(x)=L$}

Note that the above theorem requires that for a limit to exist both the left and right-handed limits must exist and be equal.  It follows that in our above graph $\mylim{x}{2}f(x)$ does not exist as the one-sided limits, while they exist, are not equal.

\begin{example}
  Solve the following problems involving one-sided limits.
  \begin{enumerate}
  \item Find $\displaystyle \lim_{x\to3^{-}}f(x)$ and $\displaystyle \lim_{x\to3^{+}}f(x)$ if
  $\displaystyle f(x) = \begin{cases} 2x+3 & \text{if } x \leq 3 \\ x^2 - 4 &
    \text{if } x > 3 \end{cases}$\ . Does $\displaystyle \lim_{x\to3}f(x)$ exist?\\[.5em]

  \begin{solution}
    The function $f(x)$ is piecewise-defined.  For $x<3$ the function evaluates to $2x+3$, so the left-hand limit is\\[.5em]
    $\displaystyle \lim_{x\to3^-}f(x)=\lim_{x\to3^{-}}(2x+3) = 2(3)+3=9$\\[.5em]
    For $x>3$ the function evaluates to $x^2-3$ so the right-hand limit is\\[.5em]
    $\displaystyle\lim_{x\to3^{+}}f(x)=\lim_{x\to3^{+}}(x^2-4) = (3)^2-4 = 5$

    Since the left-hand and right-hand limits differ at $a=3$ the limit $\displaystyle\lim_{x\to3} f(x)$ does not exist by Theorem~\ref{thm:onesidedlimits}\,.

    Note that the reader may have been concerned that we appear to be evaluating our one-sided limits using the same procedures (for which we had theorems) for evaluating our two-sided limits.  How is this justified?  We can actually use Theorem~\ref{thm:onesidedlimits} in reverse.  Since we know for instance that the (two-sided) limit $\displaystyle \lim_{x\to3}(2x+3)=2(3)+3=9$ this implies by Theorem~\ref{thm:onesidedlimits} that $\displaystyle \lim_{x\to3^{-}}(2x+3)$ and $\displaystyle \lim_{x\to3^{+}}(2x+3)$ both equal $9$.  We used the former result above.
  \end{solution}

  \item Find $\displaystyle \lim_{x\to-1^{-}}f(x)$ and $\displaystyle
 \lim_{x\to-1^{+}}$ if $f(x) = \begin{cases}\frac{\sqrt{x+5}-2}{x+1} & \text{if } x>-1 \\ x^2-\frac{3}{4} & \text{if } x\leq -1\end{cases}$\ . Does $\displaystyle \lim_{x\to-1}f(x)$ exist?

   \begin{solution}
     $\displaystyle \lim_{x\to-1^{-}}f(x)
     =\lim_{x\to-1^{-}}\left(x^2-\frac{3}{4}\right)
     =(-1)^2-\frac{3}{4} = \frac{4}{4}-\frac{3}{4}=\frac{1}{4}$\\[.5em]
     $\begin{aligned}[t]
       \lim_{x\to-1^{+}}f(x) & = \lim_{x\to-1^{+}}\frac{\sqrt{x+5}-2}{x+1}
                               = \lim_{x\to-1^{+}}\frac{\sqrt{x+5}-2}{x+1}\cdot\frac{\sqrt{x+5}+2}{\sqrt{x+5}+2} \\
                             &  =\lim_{x\to-1^{+}}\frac{x+5-4}{(x+1)(\sqrt{x+5}+2)}
                               =\lim_{x\to-1^{+}}\frac{x+1}{(x+1)(\sqrt{x+5}+2)}\\
                             & =\lim_{x\to-1^{+}}\frac{1}{\sqrt{x+5}+2} = \frac{1}{\sqrt{(-1)+5}+2}
                               =\frac{1}{2+2}=\frac{1}{4}
     \end{aligned}$\\[.5em]
     Since the left-hand and right-hand limits at $a=-1$ exist and are
     equal, the limit exists at $-1$ and equals their common value,
     $\displaystyle \lim_{x\to-1}f(x) = \frac{1}{4}$\,.
   \end{solution}
 \end{enumerate}

\textbook{\clearpage}
\begin{furtherquestions}
\begin{center}
\includegraphics{graphics/limits13}%
\end{center}

\begin{enumerate}
\item For the above function evaluate $\mylim{x}{a^-}f(x)$, $\mylim{x}{a^+}f(x)$, $\mylim{x}{a}f(x)$, and $f(a)$ at $a=0$, $a=3$, and $a=5$\,.
\item Find $\mylim{x}{2^-}f(x)$ and $\mylim{x}{2^+}f(x)$ if
$\displaystyle f(x)=\left\{
\begin{array}{cc}
x^3 & \mbox{if}\ x\le2 \\
4-2x & \mbox{if}\ x>2
\end{array}
\right.$

Does $\mylim{x}{2}$ exist?

\item Suppose $\displaystyle f(x)=\left\{
\begin{array}{cc}
\frac{9}{x^2} & \mbox{if}\ x\le-3 \\
4+x & \mbox{if}\ x>-3
\end{array}
\right.$\ .

Find $\mylim{x}{-3^-}f(x)$, $\mylim{x}{-3^+}f(x)$, and $\mylim{x}{-3}f(x)$, if they exist.
\item Show that $\mylim{x}{7}\frac{|x-7|}{x-7}$ does not exist.
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\begin{exercise}
\input{LIMITS/one-sided-limits}
\end{exercise}

\section{Limits Involving Infinity}
Sometimes when limits do not exist at $x=a$ they may yet show a systematic trend to larger positive or larger negative values as one approaches $a$.  The following definitions give the notation used to indicate such trends.\footnote{The first definition (involving $+\infty$) can be made rigorous by demanding that for any $M>0$ there exist $\delta>0$ such that $f(x)>M$ whenever $0<|x-a|<\delta$.  For the second definition (involving $-\infty$) we demand that for any $N<0$ there exist $\delta>0$ such that $f(x)<N$ whenever $0<|x-a|<\delta$.}
\definition{Suppose function $f(x)$ is defined to the left and the right of the $x$-value $a$ (though perhaps not at $a$ itself).  Then
\[\mylim{x}{a}f(x)=\infty\]
if the values of $f(x)$ can be made arbitrarily large positively by taking $x$ sufficiently close (but not equal) to $a$.}

The following graph illustrates a function tending to positive infinity.
\begin{center}
\includegraphics{graphics/limits14}%
\end{center}
\definition{\label{def:positiveinfinitelimits}Suppose function $f(x)$ is defined to the left and the right of the $x$-value $a$ (though perhaps not at $a$ itself).  Then
\[\mylim{x}{a}f(x)=-\infty\]
if the values of $f(x)$ can be made arbitrarily large negatively by taking $x$ sufficiently close (but not equal) to $a$.}

The following graph illustrates a function tending to negative infinity.
\begin{center}
\includegraphics{graphics/limits15}%
\end{center}

\definition{\label{def:onesidedinfinitelimits}We analogously define the following \textbf{one-sided limits} involving infinity:

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

These various cases are illustrated below.

\begin{center}
\resizebox{.52\textwidth}{!}{%
\includegraphics{graphics/limits16}%
}

\vspace{1em}
\resizebox{.52\textwidth}{!}{%
\includegraphics{graphics/limits17}%
}

\vspace{1em}
\resizebox{.52\textwidth}{!}{%
\includegraphics{graphics/limits18}%
}
\end{center}

Note the following function \textbf{does not} approach infinity as $x$ approaches zero:
\[f(x)=A\left|\frac{1}{x}\cos\left(\frac{a}{x}\right)\right|\]
where $a$ and $A$ are positive constants.  Its graph for a choice of these constants is shown below.
\begin{center}
\includegraphics{graphics/limits19}%
\end{center}

If an arbitrary number is picked (say $3$) there must be some
interval around 0 (not including 0 itself) for which \textbf{all} the
values will be above $3$.  The fact that the function returns to zero
(despite getting very large at other points) makes it impossible to
have the limit approach infinity.

Note that if $f(x)$ approaches infinity at $x=a$ the limit \textbf{does not exist} at $x=a$.  A limit $L$ must be a number.  The notation $\infty$ indicates a trend in the function $f(x)$ toward a large magnitude at $a$, but it is not a number.

As we have seen, for limits $\mylim{x}{a}f(x)$ where $f(x)$ is made up
of algebraic manipulations of common functions like polynomials,
trigonometric functions, etc., it is of value to see what the function
$f(a)$ is to help determine the behaviour of the limit at the
value.  If $f(a)$ is actually defined our limit laws can often be used
to show that the limit is exactly that value.  If the result is
indeterminate, $0/0$, more work must be done to evaluate the limit.
If $f(a)$ is $p/0$ where $p$ is a \textbf{non-zero} constant this is
an indication the function tends to infinity at that value.  Consideration
of values of $f(x)$ for $x$ a little to the left and right of $a$
determine whether the function approaches $\infty$ or $-\infty$ and
whether the behaviour is one-sided or not.  Looking at the sign and magnitude of factors in the expression to the right and left of $a$ can also help resolve infinite trends at $a$.

\begin{example}
  Determine the following limits:
  \begin{enumerate}
    \begin{multicols}{2}
  \item $\displaystyle \lim_{x\to3^{-}} \frac{2x+3}{2x-6}$
  \item $\displaystyle \lim_{x\to4}\frac{x^2-2x-8}{x^2-3x-4}$
    \end{multicols}
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item The limit has the form $\frac{\text{non-zero}}{0}$
      suggesting the limit does not exist.  To determine an infinite
      trend one must identify the sign of the terms, in particular how the
      denominator is approaching~0\,:\\[.5em]
      $\displaystyle \lim_{x\to3^{-}} \frac{2x+3}{2x-6} =
      \frac{6+3}{6^{-}-6}= \frac{9}{\,0^{-}} = -\infty$\\[.5em]
      Here our notation $6^-$ is meant to suggest we are approaching
      $6$ from the left ($5.9$, $5.99$, etc.) which in turn implies we
      will approach $0$ from the left (here denoted $0^-$) to get
      small negative values (-0.1, -.01, etc.) when we subtract $6$
      from this.  The finite positive numerator divided by this small
      negative value will be large and positive.  Note we can check
      this limit numerically by inserting values like $2.9$, $2.99$,
      etc. into the original function to confirm the trend to large
      negative numbers.
      
    \item Inserting $4$ in the denominator gives $0$, but the numerator also
      vanishes so this is an indeterminate form $\left(\frac{0}{0}\right)$:\\[.5em]      
      $\displaystyle \lim_{x\to4}\frac{x^2-2x-8}{x^2-3x-4} = \lim_{x\to 4}
      \frac{(x-4)(x+2)}{(x-4)(x+1)} = \lim_{x\to 4}\frac{x+2}{x+1} = \frac{6}{5}$\\[.5em]   
      Note that a limit with an indeterminate form \emph{could} have
      an infinite trend as well.  Modifying the above limit with an
      extra factor of $(x-4)^2$ in the denominator yields a limit in
      an indeterminate form that trends to positive infinity:\\[.5em]
      $\displaystyle \lim_{x\to4}\frac{x^2-2x-8}{(x^2-3x-4)(x-4)^2} = \lim_{x\to 4}
      \frac{(x-4)(x+2)}{(x+1)(x-4)^3} = \lim_{x\to 4}\frac{x+2}{(x+1)(x-4)^2} = \frac{6}{(5)(0^+)}=+\infty$\\[.5em]
      Adding the square of $(x-4)$ is critical here for the two-sided
      limit to exist.  A single $(x-4)$ factor would have made the
      left-hand limit approach $-\infty$ and the right-hand limit
      approach $+\infty$, so a (two-sided) limit in that case would
      have had no trend.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Evaluate the following:
\begin{multicols}{3}
\begin{enumerate}
\item $\mylim{x}{2}\frac{1-x^2}{x^2-4x+4}$
\item $\mylim{t}{1}\frac{t^3+5t}{t^2+3t-4}$
\item $\mylim{x}{0}\frac{x^2+9x}{x^3}$
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}

\definition{If the limit as $x\rightarrow a$ of $f(x)$ tends to $\pm\infty$ from either the left or right or both, i.e.

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

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

 then the line $x=a$ is a \textbf{vertical asymptote} of the curve $y=f(x)$.
}
In the previous diagrams involving $f(x)$ approaching infinity on pages~\pageref{def:positiveinfinitelimits} and~\pageref{def:onesidedinfinitelimits} the dashed lines are the vertical asymptotes once they are extended indefinitely upwards and downwards.

Notes:
\begin{itemize}
\item Because any of the above conditions in the definition can occur
it is sufficient to show the limit is of the form $p/0$ with $p\neq 0$
to determine the location of a vertical asymptote, without evaluating
the particular way the function is approaching infinity at $a$.
\item When reporting a vertical asymptote, one writes $x=a$ because this is the relation representing a vertical line.  (The point $(a,y)$ clearly satisfies the equation for any real value $y$\,.)
\end{itemize}

\begin{example}
  Find the vertical asymptotes of the function
  $\displaystyle f(x) = \frac{x^2-9}{x^2-x-6}$\,.

  \begin{solution}
    Potential locations of a vertical asymptote occur where the denominator vanishes:\\[.5em]
    $\displaystyle x^2-x-6 = 0 \implies (x+2)(x-3)=0 \implies x=-2\ \text{or}\ x=3$
    \begin{description}
      \item[$\bm{x=-2}$:]
        $\displaystyle\lim_{x\to -2} f(x) = \lim_{x\to -2} \frac{x^2-9}{x^2-x-6}
        = \lim_{x\to -2}\frac{(x+3)(x-3)}{(x-3)(x+2)}
        = \lim_{x\to -2} \frac{x+3}{x+2}:\ \frac{-2+3}{-2+2} = \frac{1}{0}$\\[.5em]
        Therefore $x=-2$ is a vertical asymptote.  Note that while we
        could have plugged in the value $x=-2$ into the original
        expression to determine this immediately, the work to get to the final
        expression allows one to easily see
        \begin{align*}\displaystyle\lim_{x\to-2^-}f(x)=\frac{1}{(-2)^-+2}=\frac{1}{\,0^-}=-\infty~~\text{and}~~
          \lim_{x\to-2^+}f(x)=\frac{1}{(-2)^++2}=\frac{1}{\,0^+}=+\infty\,.
        \end{align*}
        This information is useful when graphing the function.  As a
        further note we did not write
        $\displaystyle\lim_{x\to-2}f(x)=\ldots=\frac{1}{0}$ as the latter is not
        mathematically meaningful.  As the differing left-hand and
        right-hand limits show their is no common infinite trend to
        the limit and we can neither write that the limit trends to
        $+\infty$ or $-\infty$\,.

      \item[$\bm{x=3}$:]
        The limit has the indeterminate form $\frac{0}{0}$.  Investigating the
        limit yields\\[.5em]
    $\displaystyle\lim_{x\to 3} \frac{x^2-9}{x^2-x-6} =
    \lim_{x\to 3} \frac{(x+3)(x-3)}{(x-3)(x+2)} = \lim_{x\to 3} \frac{x+3}{x+2}
    = \frac{6}{5}$\\[.5em]
    Therefore $x=3$ is not a vertical asymptote.
  \end{description}
  Hence $x=-2$ is the only vertical asymptote of the graph $y=f(x)$.
  Note we write $x=-2$ and not simply $-2$  because an asymptote is a
  \emph{line} and $x=-2$ is the equation representing this vertical line
  consisting of all points $(-2,y)$ which satisfy the equation.
  \end{solution}

\begin{furtherquestions}
Find the vertical asymptotes of the following functions:
\begin{enumerate}
\item $\displaystyle y=\frac{x^2+4}{x^2-1}$
\item $\displaystyle y=\frac{x+2}{x^2+5x+6}$
\item $\displaystyle y=\frac{x^2+2x-8}{(x-2)^2}$
\end{enumerate}
\end{furtherquestions}
\end{example}

\textbook{\clearpage}
\textbook{\addtocontents{ans}{\clearpage}}
\begin{exercise}
\input{LIMITS/infinite-limits-and-vertical-asymptotes}
\end{exercise}

\section{Continuity}
\label{sec:continuity}
The idea of continuity of a function $f(x)$ at a value $x=a$ is intuitively seen in a graph of a function:

\hfil
\includegraphics[width=5.3cm]{graphics/limits20}%
\hfil
\includegraphics[width=5.3cm]{graphics/limits21}%
\hfil

It is obvious from the graph of the function that the function $f$
is continuous at $x=2$ while $g$ would not be (as it has a hole).
Similarly $g$ is not continuous at $x=1$ due to the break in the
function.  However $g$ would be continuous at a location like $x=-1$.

A rigorous definition of continuity that will match our intuitive one
requires the concept of the limit of $f$ at $a$ and links it to the
value of the function evaluated at $a$.

\definition{\label{def:continuity}A function $f(x)$ is \textbf{continuous} at $x=a$ if
\[\mylim{x}{a}f(x)=f(a)\ .\]
If $f(x)$ is not continuous at $a$ then $f$ is \textbf{discontinuous} at $a$ or $f(x)$ has a \textbf{discontinuity} at $a$.}

The above definition of continuity at $a$ requires three things:
\begin{enumerate}
\item $f(a)$ is defined. (I.e. $a$ is in the domain of $f$~.)
\item $\mylim{x}{a}f(x)$ exists.
\item $\mylim{x}{a}f(x)=f(a)$.
\end{enumerate}

With a rigorous definition of continuity we can evaluate the continuity of a function at any point.
\begin{example}
  Determine whether the function is continuous at the given value of $x$.
  \begin{enumerate}
  \item $\displaystyle f(x) = 5x + \sqrt{3x+4}$ at $x = 4$\,?

    \begin{solution}
      To determine continuity we \begin{inparaenum}[i)] \item evaluate the function, \item the limit, and then \item see if they are equal. \end{inparaenum}
      \begin{enumerate}[label=(\roman*)]
      \item $f(4) = 5(4) + \sqrt{3(4)+4} = 20+4 = 24$
      \item $\displaystyle \lim_{x\to 4} f(x) = 5(4) + \sqrt{3(4)+4} = 20 + \sqrt{16}
        = 20+4 = 24$
      \item $\displaystyle\lim_{x\to 4} f(x) = 24 =f(4)$
      \end{enumerate}
      $\displaystyle\implies f(x) \text{ is continuous at } x = 4$\,.
    \end{solution}
    
  \item $\displaystyle g(t) = \frac{t^2-25}{t+5}$ at $t = -5$\,?

    \begin{solution*}
      \begin{enumerate}[label=(\roman*)]
      \item $\displaystyle g(-5)= \frac{(-5)^2-25}{-5+5} = \frac{0}{0}$ so $g(-5)$ is not defined.
      \end{enumerate}
      $\implies g(t) \text{ is discontinuous at } x = -5$\,.

      Note the limit may well exist as $x\to-5$ but if the function is
      undefined one need not evaluate this to disprove
      continuity. This is why we choose to evaluate the function first
      as evaluating the limit is usually more work.
    \end{solution*}

  \item $\displaystyle f(x) = \frac{\cos(2x) + \sin(3x)}{x^2+1}$ at $x = 0$\,?

    \begin{solution*}
      \begin{enumerate}[label=(\roman*)]
      \item $\displaystyle f(0) = \frac{\cos(2(0)) + \sin(3(0))}{0^2+1} = \frac{1+0}{1} = 1 $
      \item $\displaystyle \lim_{x\to 0}f(x)
        = \frac{\cos(2(0)) + \sin(3(0))}{0^2+1} = \frac{1+0}{1} = 1$
      \item $\displaystyle \lim_{x\to 0} f(x) = 1 = f(0)$
    \end{enumerate}
    $\implies f(x) \text{ is continuous at } x =0$\,.
    \end{solution*}

   \item $\displaystyle f(x)
    = \begin{cases}\frac{\sqrt{x-3}-1}{x-4}\ &\text{if}\ x>4 \\ ~~x-\frac{7}{2}\ &\text{if}\ x\leq 4\end{cases}$ at $x=4$\,?

    \begin{solution*}
      \begin{enumerate}[label=(\roman*)]
      \item $\displaystyle f(4) = 4-\frac{7}{2} = \frac{1}{2}$
      \item $\displaystyle\lim_{x\to 4^{-}} f(x)
        =\lim_{x\to 4^{-}}\left(x-\frac{7}{2}\right)
        = 4 - \frac{7}{2} =\frac{8-7}{2} = \frac{1}{2}$\\[.5em]
        $\begin{aligned}[t]
          \lim_{x\to 4^{+}} f(x)
          &= \lim_{x\to4^{+}}\frac{\sqrt{x-3}-1}{x-4}
            = \lim_{x\to4^{+}}\frac{\sqrt{x-3}-1}{x-4}\cdot\frac{\sqrt{x-3}+1}{\sqrt{x-3}+1}\\
          &= \lim_{x\to 4^{+}}\frac{x-3-1}{(x-4)(\sqrt{x-3}+1)}
            = \lim_{x\to 4^{+}}\frac{x-4}{(x-4)(\sqrt{x-3}+1)}\\
          &= \lim_{x\to 4^{+}}\frac{1}{\sqrt{x-3}+1}
          = \frac{1}{\sqrt{4-3}+1} = \frac{1}{1+1} = \frac{1}{2}
        \end{aligned}$\\[.5em]
        $\displaystyle \lim_{x\to 4^{-}}f(x) =\frac{1}{2}= \lim_{x\to 4^{+}}f(x) \implies \lim_{x\to4}f(x)=\frac{1}{2}$
      \item $\displaystyle \lim_{x\to 4}f(x)=\frac{1}{2}=f(4)$
      \end{enumerate}
      $\implies f(x)$ is continuous at $x = 4$\,.
    \end{solution*}

  \item $\displaystyle g(\theta) = \begin{cases} \frac{1-\cos\theta}{\sin^2\theta}\ &\text{if}\ \theta \neq 0
      \\ ~~~2 &\text{if}\ \theta = 0\end{cases}$ at $\theta=0$\,?

      \begin{solution*}
        \begin{enumerate}[label=(\roman*)]
        \item $\displaystyle g(0) = 2$
        \item $\begin{aligned}[t]\lim_{\theta\to 0} g(\theta)
          &= \lim_{\theta\to 0}\frac{1-\cos\theta}{\sin^2\theta}
          = \lim_{\theta\to 0}\frac{1-\cos\theta}{\sin^2\theta}\cdot\frac{1+\cos\theta}{1+\cos\theta}
          = \lim_{\theta\to 0}\frac{1-\cos^2\theta}{\sin^2\theta(1+\cos\theta)}\\
          &= \lim_{\theta\to 0}\frac{\sin^2\theta}{\sin^2\theta(1+\cos\theta)}
          = \lim_{\theta\to 0}\frac{1}{1+\cos\theta} = \frac{1}{1+\cos0}
          = \frac{1}{1+1} = \frac{1}{2}
        \end{aligned}$
          \item $\displaystyle\lim_{\theta\to 0}g(\theta) =\frac{1}{2}\neq 2=g(0)$
        \end{enumerate}
        $\implies g(\theta)$ is discontinuous at $x = 0$\,.
      \end{solution*}

    \end{enumerate}

\begin{furtherquestions}
\label{ex:continuity}
Determine whether the following functions are \textbf{continuous} at the given values of $x$.
\begin{multicols}{2}
\begin{enumerate}
\item $\displaystyle f(x)=x+2$\ \  at $x=1$\,?
\item\label{itm:removable1} $\displaystyle f(x)=\frac{x^2-4}{x-2}$\ \ at $x=2$\,?
\item\label{itm:jump1} $\displaystyle f(x)=\left\{\begin{array}{cl}
(x-1)^3 & \mbox{if}\ x<0 \\
(x+1)^3 & \mbox{if}\ x\ge0
\end{array}\right.$\ \  at $x=0$\,?
\item\label{itm:removable2} $\displaystyle f(x)=\left\{\begin{array}{cl}
2x+1 & \mbox{if}\ x<1 \\
2 & \mbox{if}\ x=1 \\
x+2 & \mbox{if}\ x>1
\end{array}\right.$\ \  at $x=1$\,?
\item\label{itm:removable3} $\displaystyle f(x)=\left\{\begin{array}{cl}
\displaystyle\frac{\sin x}{x} & \mbox{if}\ x\neq 0 \\[1em]
2 & \mbox{if}\ x=0
\end{array}\right.$\ \  at $x=0$\,?
\item\label{itm:infinite1} $\displaystyle f(x)=\frac{\cos x}{x}$ at $x=0$\,?
\end{enumerate}
\end{multicols}
\end{furtherquestions}
\end{example}
Clearly not all discontinuities have the same behaviour.  A \textbf{removable discontinuity} at $a$ is one for which, if the function $f$ were redefined appropriately at $a$, would result in a continuous function at that value.  These are functions whose graphs essentially have a hole in them.  Questions~\ref*{itm:removable1}, \ref*{itm:removable2}, and \ref*{itm:removable3} in Example~\ref{ex:continuity} are of this kind.  \textbf{Jump discontinuities}, as the name suggests, occur when the function shifts from one limiting value on the left to another on the right as in Question~\ref*{itm:jump1}.  Finally an \textbf{infinite discontinuity} occurs when there is a vertical asymptote at $x=a$ such as in Question~\ref*{itm:infinite1}\,.  The latter two discontinuities cannot be removed by redefinition of the function at $a$.

\definition{At $x=a$ a function $f(x)$ is \textbf{continuous from the left} if
\[\mylim{x}{a^-}f(x)=f(a)\ ,\]
and \textbf{continuous from the right} if
\[\mylim{x}{a^+}f(x)=f(a)\ .\]}

\definition{A function $f(x)$ is \textbf{continuous on an interval} if it is continuous at every value in the interval.  (For an endpoint of a closed interval if the domain of the function does not extend beyond the endpoint one-sided continuity is sufficient.)}

\begin{example}
In our previous graphically defined functions on page~\pageref{def:continuity} we see that $f(x)$ is continuous on $[1,3]$ and any subinterval of that interval while $g(x)$ would be continuous on $(-\infty,1]$, $[-1,1]$, $(1,2)$, $(2,3]$, but not $(0,2.5)$ nor $[1,2]$.
\end{example}  

Continuity of a function on its domain can also be analyzed directly from the definition.

\textbook{\clearpage}
\begin{example}
    \begin{enumerate}
    \item Is $\displaystyle f(x) = \begin{cases}3x^2+5\ &\text{if}\ x<2 \\ 2x+1\ &\text{if}\ x\geq 2\end{cases}$ a continuous function on $(-\infty,\infty)$\,?

      \begin{solution}
        For $x<2$ and $x>2$ the function $f(x)$ evaluates to a polynomial and hence is continuous at $x$.  It remains to evaluate the continuity at $x=2$\,:
      \begin{enumerate}[label=(\roman*)]
      \item $\displaystyle f(2)=2(2)+1 = 4+1=5$
      \item $\displaystyle \lim_{x\to2^{-}} f(x)
        = \lim_{x\to2^{-}} (3x^2+5)=3(2)^2+5 = 12+5 = 17$\\[1em]
          $\displaystyle\lim_{x\to2^{+}} f(x) = \lim_{x\to2^{+}} (2x+1) = 2(2)+1 = 4+1=5$\\[1em]
          Since $\displaystyle\lim_{x\to2^{-}}f(x)=17\neq 5=\lim_{x\to2^{+}}f(x)$ the $\displaystyle\lim_{x\to2}f(x)$ does not exist.
        \end{enumerate}
        $\implies f(x) \text{ is discontinuous at }x = 2$\,.  Thus
        $f(x)$ is not continuous on the interval $(-\infty,\infty)$\,.
        
    \end{solution}
    
    \item Determine all values of $c$ such that $f(x)$ is continuous on $\mathset{R}$. \\
      $\displaystyle f(x) = \begin{cases} cx+5 & \text{ if } x\leq 3 \\ cx^2+4
        & \text{ if } x>3\end{cases}$

      \begin{solution}
        For any value of $c$ the function $f(x)$ evaluates to a
        (continuous) polynomial on the intervals $(-\infty,3)$ and
        $(3,\infty)$\,.  Continuity at $x=3$ constrains the value of
        $c$\,:
        \begin{enumerate}[label=(\roman*)]
        \item $\displaystyle f(3) = c(3)+5 = 3c+5$
        \item $\displaystyle \lim_{x\to 3^{-}}f(x)
          =\lim_{x\to 3^{-}}(cx+5) = 3c+5 \\[1em]
          \lim_{x\to 3^{+}}f(x) = \lim_{x\to 3^{+}}(cx^2+4) = 9c+4$
          
          So for $\displaystyle\lim_{x\to3}f(x)$ to exist requires the
          left-hand and right-hand limits be equal:\\[1em]
          $\displaystyle 3c+5 = 9c+4 \implies 1=6c \implies c= \frac{1}{6}$\,.
        \item With $c=\frac{1}{6}$,
          $\displaystyle\lim_{x\to3}f(x)=f(3)=\frac{33}{6}=\frac{11}{2}$
          and $f(x)$ will be continuous at $x=3$ as well.
        \end{enumerate}
      \end{solution}
      
      \item Determine all values of $c$ such that $f$ is continuous on
        $\mathset{R}$. \\ $\displaystyle f(x) = \begin{cases}c^2x+1 & \text{if }
          x<-1 \\ 5cx+5 & \text{if } x\geq -1 \end{cases}$

        \begin{solution*}
          \begin{enumerate}[label=(\roman*)]
          \item $\displaystyle f(-1) = 5c(-1) + 5 = -5c+5$
          \item $\displaystyle \lim_{x\to -1^{-}} f(x)
            =\lim_{x\to -1^{-}} (c^2x + 1) = c^2(-1)+1 = -c^2+1 \\[1em]
            \lim_{x\to -1^{+}} f(x) = \lim_{x\to -1^{+}}(5cx + 5) = 5c(-1)+5=-5c+5$

            Existence of the limit at $x=-1$ requires:\\ 
            $\displaystyle -c^2+1 = -5c+5 \implies
            0 = c^2-5c+4 \implies 0=(c-4)(c-1) \implies \begin{cases}c&=4\\ & \text {or} \\c&=1\end{cases}$
          \item With $c=4$ or $c=1$ we have
            $\displaystyle\lim_{x\to-1}f(x)=f(-1)$ and $f(x)$ will be
            continuous at $x=-1$ (as well as the rest of
            $\mathset{R}$)\,. For $c=4$ this value is $-15$ and for $c=1$ this value is $0$\,.
          \end{enumerate}
        \end{solution*}
    
      \item Find the values of $m$ and $u$ such that $f(x)$ is continuous on
        $\mathset{R}$. \\ $\displaystyle f(x) = \begin{cases} m &\text{ if }
          x\leq -2 \\ 3mx + u &\text{ if } -2<x<2 \\ ux^2 + 2 &\text{ if } x\geq
          2 \end{cases}$
        
        \begin{solution}
          For the piecewise-defined function we need to ensure
          continuity at $x=-2$ and $x=2$\,:
          \begin{enumerate}[label=(\roman*)]
          \item $\displaystyle f(-2) = m \, , \, f(2) = u(2)^2 + 2 = 4u + 2$
          \item $\displaystyle \lim_{x\to -2^{-}} f(x)
            = \lim_{x\to -2^{-}}(m) = m \\ \lim_{x\to-2^{+}} f(x) = \lim_{x\to -2^{+}}(3mx+u) = -6m+u \\[1em]
            \lim_{x\to2^{-}}f(x) = \lim_{x\to 2^{-}}(3mx+u) = 6m+u \\
            \lim_{x\to2^{+}}f(x) = \lim_{x\to 2^{+}}(ux^2+2) = 4u+2$ \\[1em]
            Limits of $f(x)$ existing at $-2$ and $2$\,:\\[1em]
            $\implies\displaystyle \begin{cases}~~~m &= -6m+u \\ &\text{and} \\
              6m+u &= 4u+2\end{cases} \implies \begin{cases}-7m+u &=0 ~\small\circled{1} \\ ~~~~~~\text{and}\\ 6m-3u &= 2 ~\circled{2} \end{cases}$\\[1em]
            One can solve this linear system by substitution:\\
            $\circled{1}\implies u=7m$ into $\displaystyle\circled{2} \implies 6m-3(7m) = 2 \implies
            6m-21m = 2\\ \implies -15m = 2 \implies m = -\frac{2}{15}\implies
            u = 7\left(-\frac{2}{15}\right) \implies u = -\frac{14}{15}$ \\
          \item With constant values $\displaystyle u=-\frac{14}{15}$ and $\displaystyle m=-\frac{2}{15}$ one has
            \begin{align*}
              \lim_{x\to-2} f(x)=f(-2)=-\frac{2}{15}~~~~~~~\lim_{x\to2} f(x)=f(2)=-\frac{26}{15}
            \end{align*}
            and $f(x)$ is continuous on $\mathset{R}$.          
          \end{enumerate}
          
        \end{solution}
\end{enumerate}

\begin{furtherquestions*}
\begin{enumerate}
\item Is  $\displaystyle f(x)=\left\{\begin{array}{ll}
x-1 & \mbox{if}\ x<3 \\
5-x & \mbox{if}\ x\ge3
\end{array}\right.$ continuous?
\item Find the value(s) of $a$ so that the given function is continuous for all $x$.

$\displaystyle f(x)=\left\{\begin{array}{ll}
a^2x^2+3x-4 & \mbox{if}\ x\le-1 \\
x+2a & \mbox{if}\ x>-1
\end{array}\right.$
\end{enumerate}
\end{furtherquestions*}
\end{example}

\newpage
To avoid resorting to the definition of continuity the following theorem can be used:

\theorem{\label{thm:continuity}The following results involving continuity are valid:
\begin{method}
\vspace{-1em}
\begin{enumerate}
\item A constant function $f(x)=c$ is continuous for all $x$.
\item For $n$ a positive integer, $f(x)=x^n$ is continuous for all $x$.
\item A polynomial is continuous for all $x$.
\item A rational function is continuous on its domain, that is it is wherever it is defined\newline (wherever the denominator does not vanish). 
\item For $n$ a positive even integer, $\sqrt[n]{x}$ is continuous for all $x$ with $x\ge0$~.
\item For $n$ a positive odd integer, $\sqrt[n]{x}$ is continuous everywhere.
\item A trigonometric function is continuous on its domain (i.e. wherever it is defined.)
\item Suppose $f$ and $g$ are continuous at $x=a$ and let $c$ be any constant, then the following functions are continuous at $a$:

\hfil$f+g$\hfil$f-g$\hfil$cf$\hfil$fg$\hfil$\displaystyle\frac{f}{g}$ (provided $g(a)\neq0$).

\item If $g$ is continuous at $a$ and $f$ is continuous at $g(a)$ then $f\circ g(x)=f(g(x))$ is continuous at~$a$.

\end{enumerate}
\end{method}
}

\begin{example}
  Determine where the following functions are continuous.
  \begin{enumerate}
  \item $\displaystyle f(x)=\frac{2x-2}{x-1}$
  \item $\displaystyle f(x)=\sqrt[3]{x+\sin x}$
  \end{enumerate}

  \begin{solution*}
    \begin{enumerate}
    \item The rational function $f(x)=\frac{2x-2}{x-1}$ is undefined
      when $x-1=0\implies x=1$\, so its domain is
      $D=\mathset{R}-\{1\}=(-\infty,1)\cup(1,\infty)$.  By
      Theorem~\ref{thm:continuity} the rational function $f(x)$ is
      continuous on this domain.
    \item The functions $x$ and $\sin x$ are defined for all
      $\mathset{R}$ and by Theorem~\ref{thm:continuity} continuous
      on this domain.  The theorem also implies their sum, $x+\sin x$,
      will also be continuous on $\mathset{R}$.  Finally the cube root
      function is continuous everywhere so $f(x)$, which is the
      composition of it and $x+\sin x$, will also be continuous on
      $\mathset{R}$\,.
    \end{enumerate}
  \end{solution*}

\begin{furtherquestions}
Determine where the following functions are continuous:
\begin{enumerate}
\item $\displaystyle f(x)=x^2-2x+1$
\item $\displaystyle f(x)=\frac{x}{x^2-x-6}$
\item $\displaystyle f(x)=\sqrt[3]{x^2-4}$
\item $\displaystyle f(x)=\sqrt[4]{x^2-4}$
\item $\displaystyle f(x)=\sqrt{\frac{x}{x-2}}$
\end{enumerate}
\end{furtherquestions}
\end{example}

We note that by the continuity theorems, most of the functions we would typically write down, excluding piecewise-defined functions, are continuous on their domains.  Thus at any point $a$ in the domain $D$ of such a function, continuity there implies $\displaystyle \lim_{x\to a}f(x)=f(a)$.  In other words, the limit can be found by evaluating the function at $x=a$, a result we previously concluded for such functions using our limit theorems.

\section{The Intermediate Value Theorem}
\theorem{Let $f(x)$ be continuous on a closed interval $[a,b]$.  If $M$ is a value strictly between $f(a)$ and $f(b)$, then there exists a number $c$ in $(a,b)$ such that $f(c)=M$. This is known as the \textbf{Intermediate Value Theorem}.}

The theorem is depicted below for a hypothetical function:
\begin{center}
\includegraphics[width=12cm]{graphics/limits22}%
\end{center}

A continuous curve on the closed interval $[a,b]$ is like a string joining the points $(a,f(a))$ and $(b,f(b))$.  So if we choose the value $M$ between $f(a)$ and $f(b)$ and extend a horizontal line across, it must, due to the continuity, cross the curve at least once.  Where it does is the point $(c,f(c))$, which, since $f(c)=M$, yields the desired value $c$.  Notice that there could be more than one value $c$ that works.  In the above graph if our value $M$ had been $0.5$ then the horizontal line would have crossed the curve 3 times, yielding three suitable values of $c$ with $f(c)=0.5$~.

\begin{example}
  For the function $f(x) = 2x^3 - 4x^2 + 5$, use the Intermediate
  Value Theorem to show that there is a real number $c$ such that $f(c) =
  -10$\,.
  
  \begin{solution}
    $\displaystyle f(x) = 2x^3 - 4x^2 + 5$ is a polynomial and
    therefore continuous on all \mathset{R} and hence on any closed
    interval $[a,b]$ it contains.  Evaluating $f$ at several values of
    $x$ gives:
    \begin{align*}
      f(0) &= 0-0+5 = 5 \\
      f(-1) &= 2(-1)^3 - 4(-1)^2 + 5 = -2-4+5=-6+5=-1\\
      f(-2) &= 2(-2)^3 - 4(-2)^2+5 = -16-16+5=-27
    \end{align*}
    One observes that $M=-10$ lies between -1 and -27 so consider
    $[a,b] = [-1,-2]$\,.  Then $f(x)$ is continuous on the closed
    interval $[-1,-2]$. Also, $f(-2) = -27 < M=-10 < f(-1)=-1$.
    Therefore, by the Intermediate Value Theorem there exists a value
    $c$ in $(-1,-2)$ such that $f(c)=M=-10$\,.
  \end{solution}

\begin{furtherquestions*}
\begin{enumerate}
\item If $f(x)=x^3+x^2+x$, prove there is a value $c$ in $(-1,2)$ with $f(c)=3$~.
\item If $g(x)=x^5-2x^3+x^2+2$ show there is a number $c$ such that $g(c)=-1$~.
\end{enumerate}
\end{furtherquestions*}
\end{example}

A corollary of the Intermediate Value Theorem is that if $f(x)$ is a continuous function on $[a,b]$ with $f(a)$ and $f(b)$ of different sign (so $f(a)<0$ and $f(b)>0$ \textbf{or} $f(a)>0$ and $f(b)<0$) then there exists at least one $c$ in $(a,b)$ with $f(c)=0$.

Now any equation (such as $2x+\sin x=0$) can always be written in the form
\[f(x)=0\]
by taking all the terms to the left-hand side and defining that to be
$f(x)$.  If we find two values $a$ and $b$ such that the function
at those values has different sign, then, assuming the function is
continuous on $[a,b]$, the intermediate value theorem corollary implies a $c$
exists in the interval with $f(c)=0$.  But then this $c$ is precisely a root
(solution) of the equation we wished to solve.

\begin{example}
  Show that the equation $x^4-2x^3+5x^2-6 = 0$ has a root (solution)
  between $1$ and $2$\,.

  \begin{solution}
    Let $f(x) = x^4-2x^3+5x^2-6$ and $[a,b] = [1,2]$. The polynomial
    $f(x)$ is continuous on the closed interval $[1,2]$\,.  The value
    $c$ will be a solution to the original equation if we can find
    $f(c)=M=0$ since then $c^2-2c^3+5c^2-6=0$.  Evaluate $f(x)$ at the endpoints:
    \begin{align*}
      f(1) &= 1^4-2(1)^3+5(1)^2-6 = 1-2+5-6 = -2\\
      f(2) &= 2^4-2(2)^3+5(2)^2-6=16-16+20-6=14
    \end{align*}
    Then $f(1)=-2 < M=0 < f(2) = 14$\,. By the IVT there exists $c$ in
    $(1,2)$ with $f(c)=0$; this $c$ is therefore a solution to the
    given equation between $1$ and $2$ as required.
  \end{solution}

\begin{furtherquestion}
Show that $x^4-x^3-1=0$ has a root between $x=-1$ and $x=0$.
\end{furtherquestion}
\end{example}

Once an interval containing a root is found one may evaluate the
function at the midpoint of the interval.  Its sign will differ from
one of the endpoints and so one can narrow the interval which contains
the root.  Repeating the process is the basis of the \textbf{bisection
  method}, a numerical method for finding solutions to arbitrary
equations.

\textbook{\clearpage}
\begin{exercise}
\input{LIMITS/continuity}
\end{exercise}

\textbook{\addtocontents{ans}{\clearpage}}
\begin{reviewexercise}
\input{LIMITS/limits-review}
\end{reviewexercise}

% TODO
% Add a question in continuity section
% Without graphing give conditions on how to identify the type of a discontinuity as
% 1) removable, 2) jump, 3) infinity
% See my file identifying_discontinuity_type.txt

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

