\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}
\begin{asy}
import graph;
size(150,0);
real f(real x) {return sqrt(10-x^2);}
pair F(real x) {return (x,f(x));}
real fneg(real x) {return -sqrt(10-x^2);}
pair Fneg(real x) {return (x,f(x));}
real g(real x) {return 3x-10;}
pair G(real x) {return (x,g(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
//xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,2)));
//yaxis("$y$",Arrow(HookHead,size=4));
//yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
draw(graph(f,-sqrt(9.9999),sqrt(9.9999),operator ..),red+2);
draw(graph(fneg,-sqrt(9.9999),sqrt(9.9999),operator ..),red+2);
draw(graph(g,2,4,operator ..),blue+2);
//xequals(-2,ymin=0,ymax=f(-2),dashed);
//yequals(f(-2),xmin=-2,xmax=-.5,dashed);
//labely(1,E);
dot((3,-1),L=Label("$P$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\end{center}
We can similarly imagine a tangent line to an arbitrary curve at a point $P$:
\begin{center}
\begin{asy}
import graph;
size(170,0);
real f(real x) {return x^3;}
pair F(real x) {return (x,f(x));}
real g(real x) {return 3x-2;}
pair G(real x) {return (x,g(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
//xaxis(xmin=-1.5,xmax=1.5,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,2)));
//yaxis("$y$",Arrow(HookHead,size=4));
//yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
draw(graph(f,-1,1.4,operator ..),red+2);
draw(graph(g,.3,1.5,operator ..),blue+2);
//xequals(-2,ymin=0,ymax=f(-2),dashed);
//yequals(f(-2),xmin=-2,xmax=-.5,dashed);
//labely(1,E);
//label("$y=x^3$",F(1.35),W);
dot((1,1),L=Label("$P$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\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}
\begin{asy}
import graph;
size(200,0);
real f(real x) {return x^3;}
pair F(real x) {return (x,f(x));}
real g(real x) {return 3x-2;}
pair G(real x) {return (x,g(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(xmin=-1.5,xmax=1.5,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,2)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
draw(graph(f,-1,1.4,operator ..),red+2);
draw(graph(g,.3,1.5,operator ..),blue+2);
//xequals(-2,ymin=0,ymax=f(-2),dashed);
//yequals(f(-2),xmin=-2,xmax=-.5,dashed);
//labely(1,E);
label("$y=x^3$",F(1.35),W);
dot((1,1),L=Label("$P(1,1)$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\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}
\begin{asy}
import graph;
size(200,0);
real f(real x) {return x^3;}
pair F(real x) {return (x,f(x));}
real g(real x) {return 3x-2;}
pair G(real x) {return (x,g(x));}
real h(real x) {return (0.67^3-1)*(x-1)/(.67-1)+1;}
pair H(real x) {return (x,g(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(xmin=-1.5,xmax=1.5,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,2)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
draw(graph(f,-1,1.4,operator ..),red+2);
//draw(graph(g,.3,1.5,operator ..),blue+2);
draw(graph(h,.3,1.5,operator ..),purple+2);
xequals(1,ymin=f(.67),ymax=1,dotted+1);
yequals(f(.67),xmin=.67,xmax=1,dotted+1);
//labely(1,E);
label("$y=x^3$",F(1.35),W);
//label("$y=m(x-1)+1$",G(1.35),E);
dot((1,1),L=Label("$P(1,1)$",align=NW),6+black);
dot(F(0.67),L=Label("$Q(x,x^3)$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
label(Label("$\Delta y$",fontsize(10)),(1,0.62),E);
label(Label("$\Delta x$",fontsize(10)),(0.83,f(.67)),S);
xequals(.67,ymin=-.045,ymax=f(.67),black+dashed);
label("$x$", (.67,-.075),S);
\end{asy}
\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{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
\begin{asy}
import graph;
size(150,0);
real f(real x) {return x^2+1;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(xmin=-2.5,xmax=2.5,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(),OmitTick()));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=7.6,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
draw(graph(f,-2.5,2.5,operator ..),red+2);
xequals(2,ymin=0,ymax=f(-2),dashed);
yequals(f(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$y=f(x)$",F(2.3),NW);
dot((2,5),3+red);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\hfil
\begin{asy}
import graph;
size(150,0);
real f(real x) {return x^2+1;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(xmin=-2.5,xmax=2.5,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(),OmitTick()));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=7.6,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
draw(graph(f,-2.5,1.95,operator ..),red+2);
draw(graph(f,-2.05,2.5,operator ..),red+2);
xequals(2,ymin=0,ymax=f(-2),dashed);
yequals(f(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$y=g(x)$",F(2.3),NW);
dot((2,6),3+black);
dot((2,6),2+red);
dot((2,5),3+black);
dot((2,5),2+white);
//dot((2,6),L=Label("$(2,6)$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\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}
\begin{asy}
import graph;
size(250,0);
real f(real x) {return x^2/2+1;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(xmin=0,xmax=3,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(3),OmitTick(3)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=4.5,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(),OmitTick()));
draw(graph(f,0.1,2.5,operator ..),red+2);
//draw(graph(f,-0.5,1.95,operator ..),red+2);
//draw(graph(f,2.05,2.5,operator ..),red+2);
xequals(2,ymin=0,ymax=f(2));
xequals(1.85,ymin=0,ymax=f(1.85),purple);
xequals(2.15,ymin=0,ymax=f(2.15),purple);
yequals(f(2),xmin=0,xmax=2);
yequals(f(1.85),xmin=0,xmax=1.85,purple);
yequals(f(2.15),xmin=0,xmax=2.15,purple);
yequals(f(2)+.5,xmin=0,xmax=2.5,blue+dashed);
yequals(f(2)-.5,xmin=0,xmax=2.5,blue+dashed);
labely("L=~~",3,W);
labely("$L+\epsilon$",3.5,W,blue);
labely("$L-\epsilon$",2.5,W,blue);
label("$y=f(x)$",F(2.5),SE);
label("$a$",(2,-.2),S);
//label("$a-\delta$",(1.85,-.2),S,purple);
//label("$a+\delta$",(2.15,-.2),S,purple);
labelx("$a-\delta$",1.7,S,purple);
labelx("$a+\delta$",2.3,S,purple);
dot((2,4),3+black);
dot((2,4),2+red);
dot((2,3),3+black);
dot((2,3),2+white);
//dot((2,6),L=Label("$(2,6)$",align=NW),6+black);
//label("$(-2,4)$",F(-2),W);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\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}
\begin{asy}
import graph;
size(150,0);
real f(real x) {return 3;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(1,3,4),OmitTick(0,4)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=4,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0,1,2),OmitTick(0,4)));
draw(graph(f,-.1,4,operator ..),red+2);
xequals(2,ymin=0,ymax=f(2),dashed);
yequals(f(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$f(x)=3$",F(1),N);
label("$\displaystyle\lim_{x\rightarrow2}3=3$",(2.2,2.4),E);
label("Constant Function",(2,4),N);
dot(F(1),4+black);
dot(F(1.5),4+black);
dot(F(1.75),4+black);
dot(F(1.9),4+black);
dot(F(2.1),4+black);
dot(F(2.25),4+black);
dot(F(2.5),4+black);
dot(F(3),4+black);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
~~\raisebox{6em}{$\Rightarrow$~~$\displaystyle \boxed{\lim_{x\rightarrow a} c=c}$}
\end{center}
\begin{center}
\begin{asy}
import graph;
size(150,0);
real f(real x) {return x;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(1,3,4),OmitTick(0,4)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=4,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0,1,3),OmitTick(0,4)));
draw(graph(f,0,4,operator ..),red+2);
xequals(2,ymin=0,ymax=f(2),dashed);
yequals(f(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$f(x)=x$",F(3.3),NW);
label("$\displaystyle\lim_{x\rightarrow2}x=2$",(2.2,1.6),E);
label("Direct Variation Function",(2,4),N);
dot(F(1),4+black);
dot(F(1.5),4+black);
dot(F(1.75),4+black);
dot(F(1.9),4+black);
dot(F(2.1),4+black);
dot(F(2.25),4+black);
dot(F(2.5),4+black);
dot(F(3),4+black);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
~~\raisebox{10em}{$\Rightarrow$~~$\displaystyle\boxed{\lim_{x\rightarrow a} x=a}$}
\end{center}
\begin{center}
\begin{asy}
import graph;
size(150,0);
real f(real x) {return x^2;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(1,3,4),OmitTick(0,4)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=5.2,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0,1,2,3,5),OmitTick(0,5)));
draw(graph(f,0,2.28,operator ..),red+2);
xequals(2,ymin=0,ymax=f(2),dashed);
yequals(f(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$f(x)=x^2$",F(2.1),NW);
label("$\displaystyle\lim_{x\rightarrow2}x^2=2^2$",(2.2,1.6),E);
label("Power Function $(n=2)$",(2,5.1),N);
//dot(F(1),4+black);
//dot(F(1.5),4+black);
dot(F(1.75),4+black);
dot(F(1.93),4+black);
dot(F(1.98),4+black);
dot(F(2.02),4+black);
dot(F(2.07),4+black);
dot(F(2.25),4+black);
//dot(F(2.5),4+black);
//dot(F(3),4+black);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
~~\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{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 $\displaystyle \lim_{x\rightarrow a} c=c$
\item $\displaystyle \lim_{x\rightarrow a} x=a$
\item $\displaystyle \lim_{x\rightarrow a}x^n=a^n$
\item $\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 $\displaystyle \lim_{x\rightarrow a} [f(x)\pm g(x)]=\lim_{x\rightarrow a}f(x)\pm\lim_{x\rightarrow a}g(x)$
\item $\displaystyle \lim_{x\rightarrow a}[cf(x)]=c\lim_{x\rightarrow a}f(x)$
\item $\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 $\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 $\displaystyle \lim_{x\rightarrow a} [f(x)]^n=\left[\lim_{x\rightarrow a} f(x)\right]^n$
\item $\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 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{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 $\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{example}

\begin{exercise}
\input{LIMITS/calculating-limits-using-limit-laws}
\end{exercise}

\section{Trigonometric Limits}

\theorem{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 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{example}

\textbook{\clearpage}
\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)$\ .
\end{example}

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}
\begin{asy}
import graph;
size(150,0);
real g(real x) {return 3x;}
pair G(real x) {return (x,g(x));}
real h(real x) {return x^3+2;}
pair H(real x) {return (x,h(x));}
real f(real x) {return 0.4*(x^3+2-3x)*sin(12*x)+(x^3+2+3x)*0.5;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(2),OmitTick(0)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(1,2,4,5,6),OmitTick(0,7)));
draw(graph(f,0,1.7,operator ..),purple+1);
draw(graph(g,0,1.7,operator ..),blue+1);
draw(graph(h,0,1.7,operator ..),red+1);
xequals(1,ymin=0,ymax=g(1),dashed);
yequals(g(1),xmin=0,xmax=1,dashed);
//labely("L=",5,W);
label("$f(x)$",F(1.6),E);
label("$g(x)=3x$",G(1.6),SE);
label("$h(x)=x^3+2$",H(1.67),W);
//label("$\displaystyle\lim_{x\rightarrow2}x=2$",(2.2,1.6),E);
//dot(F(1),4+black);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label(Label("$f(-2)$",fontsize(8)),(0,4),E);
\end{asy}
\end{center}

\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}
\begin{asy}
import graph;
size(200,0);
real f(real x) {return 1.5/2*x+1.5;}
pair F(real x) {return (x,f(x));}
real g(real x) {return 2-sqrt(x-1);}
pair G(real x) {return (x,g(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(1,3,4),OmitTick(0,4)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymax=4,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0,2),OmitTick(0,4)));
draw(graph(f,-.5,2,operator ..),red+2);
draw(graph(g,2,4,operator ..),red+2);
xequals(2,ymin=0,ymax=3.5,dashed);
yequals(f(2),xmin=0,xmax=2,dashed);
yequals(g(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$f(x)$",(-.5,1.3),N);
label("$\displaystyle\lim_{x\rightarrow2^-}f(x)=3$",(2.2,2.9),E);
label("$\displaystyle\lim_{x\rightarrow2^+}f(x)=1$",(2.2,1.2),E);
dot(F(1),4+black);
dot(F(1.5),4+black);
dot(F(1.75),4+black);
dot(F(1.9),4+black);
dot(G(2.1),4+black);
dot(G(2.25),4+black);
dot(G(2.5),4+black);
dot(G(3),4+black);
dot(F(2),4+black);
dot(F(2),3+white);
dot(G(2),4+black);
dot(G(2),3+white);
dot((2,3.7),4+black);
dot((2,3.7),3+red);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\end{center}
The following important theorem relates the (two-sided) limit at $a$ to the one-sided limits at that number.
\theorem{$\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.

\textbook{\clearpage}
\begin{example}
\begin{center}
\begin{asy}
import graph;
size(400,0);
real f(real x) {return 23/360*x^3+5/18*x^2-49/120*x+1;}
pair F(real x) {return (x,f(x));}
real g(real x) {return 3/2*abs(x-5)-1;}
pair G(real x) {return (x,g(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(),OmitTick(0,8)));
//yaxis("$y$",Arrow(HookHead,size=4));
yaxis(ymin=-1.5,ymax=5,shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,5)));
draw(graph(f,-5,3,operator ..),red+2);
draw(graph(g,3,5,operator ..),red+2);
draw(graph(g,5,8,operator ..),red+2);
//xequals(2,ymin=0,ymax=3.5,dashed);
//yequals(f(2),xmin=0,xmax=2,dashed);
//yequals(g(2),xmin=0,xmax=2,dashed);
//labely("L=",5,W);
label("$f(x)$",G(7.5),NW);
//label("$\displaystyle\lim_{x\rightarrow2^-}f(x)=3$",(2.2,2.9),E);
//label("$\displaystyle\lim_{x\rightarrow2^+}f(x)=1$",(2.2,1.2),E);
dot(F(0),4+black);
dot(F(0),3+white);
dot(F(3),4+black);
dot(F(3),3+white);
dot((3,3),4+black);
dot((3,3),3+red);
dot(G(3),4+black);
dot(G(3),3+white);
//dot((2,3.7),4+black);
//dot((2,3.7),3+red);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
//label(Label("$f(-2)$",fontsize(10)),(0,4),E);
\end{asy}
\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{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}
\begin{asy}
import graph;
size(300,0);
real f(real x) {return .5/abs(x+1);}
pair F(real x) {return (x,f(x));}
xaxis("$x$",xmax=6.4,Arrow(HookHead,size=4));
yaxis("$y$",Arrow(HookHead,size=4));
draw(graph(f,-4,-1.1,operator --),red+2);
draw(graph(f,-.9,6,operator --),red+2);
xequals(-1,ymin=0,ymax=5,dashed);
labelx("$-1$",-1,S);
label("$\displaystyle\lim_{x\rightarrow-1}f(x)=\infty$",(-1.5,2),W);
\end{asy}
\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}
\begin{asy}
import graph;
size(300,0);
real f(real x) {return -.3/abs(x-2);}
pair F(real x) {return (x,f(x));}
xaxis("$x$",xmax=6.4,Arrow(HookHead,size=4));
yaxis("$y$",ymax=2,Arrow(HookHead,size=4));
draw(graph(f,-4,1.9,operator --),red+2);
draw(graph(f,2.1,6,operator --),red+2);
xequals(2,ymin=-3,ymax=0,dashed);
labelx("$2$",2,N);
label("$\displaystyle\lim_{x\rightarrow2}f(x)=-\infty$",(3,-2),E);
\end{asy}
\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{.53\textwidth}{!}{%
\asycode{%
import graph;
size(250,0);
real f(real x) {return .5/abs(x-1)+.2sin(4*x)+.5;}
pair F(real x) {return (x,f(x));}
real g(real x) {return .5*x+2;}
pair G(real x) {return (x,g(x));}
xaxis("$x$",Arrow(HookHead,size=4));
yaxis("$y$",Arrow(HookHead,size=4));
draw(graph(f,1.1,6,operator --),red+2);
draw(graph(g,-6,0.9,operator --),red+2);
xequals(1,ymin=0,ymax=6,dashed);
labelx("$a$",1,S);
label("$\displaystyle\lim_{x\rightarrow a^+}f(x)=\infty$",(2,2),E);
dot(G(1),4+black);
dot(G(1),3+white);
}
}

\vspace{1em}
\resizebox{.53\textwidth}{!}{%
\asycode{%
import graph;
size(250,0);
real f(real x) {return -.6/(x+1)-1;}
pair F(real x) {return (x,f(x));}
real g(real x) {return -.6/(x+1)-1;}
pair G(real x) {return (x,g(x));}
xaxis("$x$",Arrow(HookHead,size=4));
yaxis("$y$",Arrow(HookHead,size=4));
draw(graph(f,-6,-1.1,operator --),red+2);
draw(graph(g,-.9,6,operator --),red+2);
xequals(-1,ymin=-7,ymax=5,dashed);
labelx("$a$",-1,SE);
label("$\displaystyle\lim_{x\rightarrow a^-}f(x)=\infty$",(-2,1),W);
label("$\displaystyle\lim_{x\rightarrow a^+}f(x)=-\infty$",(0,-3),E);
dot((-1,-2),4+black);
dot((-1,-2),3+red);
}
}

\vspace{1em}
\resizebox{.53\textwidth}{!}{%
\asycode{%
import graph;
size(250,0);
real f(real x) {return -.5/abs(x-1);}
pair F(real x) {return (x,f(x));}
real g(real x) {return .3*x*sin(x)+2;}
pair G(real x) {return (x,g(x));}
xaxis("$x$",Arrow(HookHead,size=4));
yaxis("$y$",Arrow(HookHead,size=4));
draw(graph(f,-6,0.9,operator --),red+2);
draw(graph(g,1.1,6,operator --),red+2);
xequals(1,ymin=-6,ymax=0,dashed);
labelx("$a$",1,N);
label("$\displaystyle\lim_{x\rightarrow a^-}f(x)=-\infty$",(0,-2),W);
dot(G(1),4+black);
dot(G(1),3+red);
}
}
\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}
\begin{asy}
import graph;
size(300,0);
//real f(real x) {return .5*abs(cos(8.15/x)*exp(1/abs(x)));}
real f(real x) {return .5*abs(cos(8.15/x)*(1/abs(x)));}
//real f(real x) {return cos(1/x);}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(3)));
//yaxis("$y$",Arrow(HookHead,size=4));
//yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,5)));
yaxis(shift(0,6)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0,1,2,3,4),OmitTick(0,5)));
// Note the -- below ensures a linear interpolation is done.
draw(graph(f,-3,-.6,operator --),red+2);
// Need n large below otherwise we get artifacts suggesting the function
// isn't returning to 0.
draw(graph(f,-.6,-.1,operator --,n=2000),red+2);
draw(graph(f,.1,.6,operator --,n=2000),red+2);
draw(graph(f,.6,3,operator --),red+2);
\end{asy}
\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}
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{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 relation for any real value $y$\,.)
\end{itemize}

\begin{example}
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{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
\begin{asy}
import graph;
size(200,0);
real f(real x) {return .3sin(2*x)+1.5;}
pair F(real x) {return (x,f(x));}
xaxis("$x$",xmax=3.5,Arrow(HookHead,size=4));
yaxis("$y$",ymax=2.5,Arrow(HookHead,size=4));
draw(graph(f,1,3,operator --),red+2);
//draw(graph(g,-6,0.9,operator --),red+2);
xequals(1,ymin=0,ymax=f(1),dashed);
xequals(2,ymin=0,ymax=f(2),dashed);
xequals(3,ymin=0,ymax=f(3),dashed);
labelx("$1$",1,S);
labelx("$2$",2,S);
labelx("$3$",3,S);
label("$\displaystyle f(x)$",F(2.8),NW);
dot(F(1),4+black);
dot(F(1),3+red);
dot(F(3),4+black);
dot(F(3),3+red);
\end{asy}
\hfil
\begin{asy}
import graph;
size(200,0);
real f(real x) {return 2*x^2;}
pair F(real x) {return (x,f(x));}
real g(real x) {return  x;}
pair G(real x) {return (x,g(x));}
xaxis("$x$",xmax=3.5,Arrow(HookHead,size=4));
yaxis("$y$",Arrow(HookHead,size=4));
draw(graph(f,-1.3,1,operator --),red+2);
draw(graph(g,1,3,operator --),red+2);
xequals(-1,ymin=0,ymax=f(-1),dashed);
xequals(1,ymin=0,ymax=f(1),dashed);
xequals(2,ymin=0,ymax=g(2),dashed);
xequals(3,ymin=0,ymax=g(3),dashed);
labelx("$-1$",-1,S);
labelx("$1$",1,S);
labelx("$2$",2,S);
labelx("$3$",3,S);
label("$\displaystyle g(x)$",G(2.8),NW);
dot(F(1),4+black);
dot(F(1),3+red);
dot(G(1),4+black);
dot(G(1),3+white);
dot(G(2),4+black);
dot(G(2),3+white);
dot(G(3),4+black);
dot(G(3),3+red);
\end{asy}
\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}\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{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.

\begin{example}
\vspace*{-1em}\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{example}

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

\theorem{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)=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{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}
\begin{asy}
import graph;
size(300,0);
real f(real x) {return .7*x+.6*sin(2.3*x)-.5;}
pair F(real x) {return (x,f(x));}
//xaxis("$x$",Arrow(HookHead,size=4));
// Use Step= to set tick steps.
// OmitFormat removes label, OmitTick removes tick and label.
// endlabel=false removes the last label.
// n=1 removes small ticks.
xaxis(xmax=4.5,shift(-7,-10)*Label("$x$",align=E),Arrow(HookHead,size=4),ticks=Ticks(n=1,Step=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick()));
//yaxis("$y$",Arrow(HookHead,size=4));
//yaxis(shift(-8,-7)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0,5)));
yaxis(shift(0,6)*Label("$y$",align=N),Arrow(HookHead,size=4),ticks=Ticks(n=1,Size=3,Label(fontsize(10)),OmitFormat(0),OmitTick(0)));
// Note the -- below ensures a linear interpolation is done.
draw(graph(f,.5,3.5,operator --),red+2);
xequals(.5,ymin=0,ymax=f(.5),dashed);
xequals(3.5,ymin=0,ymax=f(3.5),dashed);
xequals(2.7,ymin=0,ymax=f(2.7),dotted+blue+2);
yequals(f(.5),xmin=0,xmax=.5,dashed);
yequals(f(3.5),xmin=0,xmax=3.5,dashed);
yequals(f(2.7),xmin=0,xmax=4,dotted+blue+2);
labely("$f(a)$",f(.5),W);
labely("$f(b)$",f(3.5),W);
labely("$M$",f(2.7),W);
labelx("$a$",.5,S);
labelx("$b$",3.5,S);
labelx("$c$",2.7,S);
//label("$f(x)$",F(7.5),NW);
//label("$\displaystyle\lim_{x\rightarrow2^-}f(x)=3$",(2.2,2.9),E);
//label("$\displaystyle\lim_{x\rightarrow2^+}f(x)=1$",(2.2,1.2),E);
dot(F(2.7),5+blue);
//dot((2,5),L=Label("$(2,5)$",align=NW),6+black);
label(Label("$(c,f(c))$",blue),F(2.7),NW);
\end{asy}
\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}
\vspace{-.5em}
\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{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 $x^4-x^3-1=0$ has a root between $x=-1$ and $x=0$.
\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.

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

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