\section{Limits and Continuity}
In this section, we work with functions of $f(x,y)$ of two variables (aka {\it bivariate} functions).  Our goal is to introduce the definitions of \textbf{limits} and \textbf{continuity} for these functions. For functions on $\rr^n$ with $n\geq 3$, the definitions and concepts are the same, you just need to add the extra variables. Working with functions of two variables allows us to investigate new multivariable phenomena while also keeping the notation as simple as possible.


\begin{definition}\label{21-def-limits}
 If $L$ is some real number and $(a,b)$ is a point in $\mathbb{R}^2$, we say that $f$ has the limit $L$ at $(a,b)$ and write
$$
\lim_{(x,y) \rightarrow (a,b)} f(x,y) = L,
$$
if
\begin{itemize}
\item every neighbourhood of $(a,b)$ contains points of $\mathcal{D}(f)$ different from $(a,b)$,

\medskip


\item for every $\epsilon > 0$ there is a $\delta>0$ (which may depend upon $\epsilon$) such that if $(x,y) \in \mathcal{D}(f)$ and $0< \sqrt{(x - a)^2 + (y - b)^2} < \delta$, then $|f(x,y) - L| < \epsilon$.
\end{itemize}
\end{definition}

The first condition says that $(x,y)$ can approach $(a,b)$ while still remaining in the domain of $f$. The second condition says that, as $(x,y)$ approaches $(a,b)$ while remaining in the domain of $f$ (the first condition ensures that this can happen), the values of $f(x,y)$ always approach $L$.

\smallskip

Some short remarks on limits of bivariate functions:
\begin{enumerate}
\item The point $(a,b)$ in the definition of the limit need \textbf{not} be in $\mathcal{D}(f)$.
\medskip

\item Even if $(a,b)$ is in the domain of $f$, we do not require that $f(a,b) = L$ in the definition of a limit---more on this shortly.
\medskip

\item If the function $f$ has a limit $L$ at the point $(a,b)$, then this limit is unique. For the limit to exist, the values of $f(x,y)$ have to approach \textbf{the same} value $L$ regardless of how we approach $(a,b)$.

\medskip

\item Arithmetic and functional operations (addition, multiplication, division, composition of functions, and so on) on limits of functions of two variables work the same way as for functions of one variable. See your textbook for more information. 
\end{enumerate}

Having defined limits, we can introduce continuity for functions of two real variables.

\begin{definition}
We say that $f(x,y)$ is \textbf{continuous} at $(a,b)$ in $\mathbb{R}^2$ if
\begin{itemize}
\item the point $(a,b)$ is in $\mathcal{D}(f)$;

\smallskip


\item our function satisfies $\lim_{(x,y) \rightarrow (a,b)} f(x,y) = f(a,b)$
\end{itemize}

\smallskip
If $f$ is continuous at each point $(a,b)$ in its domain, we say that $f$ is a \textbf{continuous function}.

\end{definition}

Many common functions of two variables are continuous on their domains. Examples include polynomials, exponential functions, rational and trigonometric functions (on their domains of definition). Compositions of continuous functions are also continuous, so that we can use the common functions just mentioned to construct more complicated continuous functions. 

\begin{example}
Consider the following functions:
\begin{enumerate}
\item The function $f(x,y) = x^3 y^2 - \frac{1}{x}$ is well-defined for all $(x,y)$ in $\mathbb{R}^2$ with $x \neq 0$. Moreover, you can verify that $f(x,y)$ is continuous at all points in its domain.

\medskip

\item The function $f(x,y) = e^{x^2 + 4 y^2}$ is well-defined and continuous at all points $(x,y)$ in $\mathbb{R}^2$.

\medskip

\item The function
$$
f(x,y) =
\begin{cases}
\frac{1}{x^2 + y^2}&\hbox{ if }(x,y) \neq 0 \\
0&\hbox{ if } (x,y) = 0
\end{cases}
$$
is well-defined for all points $(x,y)$ in $\mathbb{R}^2$. However,  $f(x,y)$ is not continuous at $(a,b) = (0,0)$---in fact, $f(x,y)$ approaches infinity as $(x,y) \rightarrow (0,0)$, so there is no value $L$ that could satisfy the condition in Definition 1.1.

\medskip

\item But if we just use $f(x,y)=\frac{1}{x^2 + y^2}$ on its natural domain of definition (which is $\mathcal{D}=\rr^2\setminus\{(0,0)\}$), then $f$ is continuous on $\mathcal{D}$.
\end{enumerate}
\end{example}



\subsection{Evaluating limits using the Squeeze Theorem}

The following \textit{Squeeze Theorem} should look familiar from single-variable calculus. It continues to be true for functions of two variables.

\begin{theorem}
Suppose $f,g,h$ are functions of two variables, defined on some common neighbourhood $N$ of $(a,b)$ except possibly at $(a,b)$. Further, suppose that
\begin{itemize}
\item there is some real number $L$ such that
$$
\lim_{(x,y) \rightarrow (a,b)} f(x,y) = \lim_{(x,y) \rightarrow (a,b)} h(x,y) = L,
$$
\item the function $g(x,y)$ lies between $f(x,y)$ and $h(x,y)$ for all $(x,y)\in N$ except possibly at $(a,b)$.

\end{itemize}

\smallskip

Then, $\lim_{(x,y) \rightarrow (a,b)} g(x,y) = L$.
\end{theorem}

Note that the second bullet point is a little bit vague, in that we do not specify whether 
$f(x,y) \leq g(x,y) \leq h(x,y)$ or $h(x,y) \leq g(x,y) \leq f(x,y)$. Either would work, and it could in fact happen that the first inequality holds for some points $(x,y)\in N$ and the second one holds for others. This is the case in Example \ref{22-sinexample} below. 

The theorem could also be modified to allow cases where the domain of $f$ does not contain an entire neighbourhood of $(a,b)$. For example, if $g(x,y)$ is only defined for $(x,y)$ with $x> 0$ and we want to find its limit at $(0,0)$, it's enough to find $f$ and $h$ so that $f,g,h$ satisfy the assumptions of the Squeeze Theorem for $x>0$ only. 





\begin{example}\label{22-sinexample}
Let us decide whether $f(x,y) = x \sin(\frac{1}{y})$, defined for $(x,y)$ with $y \neq 0$, has a limit as $(x,y) \rightarrow (0,0)$.
\end{example}



\smallskip
The trick is to recall that
$$
-1 \leq \sin \left(\frac{1}{y}\right) \leq 1, \textrm{ for every } y \neq 0.
$$
This means that $f(x,y)$ always lies between $x$ and $-x$, 
regardless of the value of $y$ in $\mathbb{R} \setminus \{0\}$. Specifically, we have
\begin{align*}
-x \leq f(x,y) \leq x  & \textrm{ for } x\geq 0,\\
x \leq f(x,y) \leq -x  & \textrm{ for } x< 0.
\end{align*}
Since
$$
\lim_{(x,y) \rightarrow (0,0)} (-x) = \lim_{(x,y) \rightarrow (0,0)} x = 0,
$$
the Squeeze Theorem gives $\lim_{(x,y) \rightarrow (0,0)} f(x,y) = 0.$

\subsection{Evaluating limits using the  $\epsilon- \delta$ definition of a limit (Definition 1.1)}

\begin{example}
Let us prove using the $\epsilon- \delta$ definition of a limit that
$$
\lim_{(x,y) \rightarrow (0,0)} (x^2 + y^2) = 0.
$$
\end{example}

\smallskip

Let $\epsilon > 0$.  We need to find a $\delta = \delta (\epsilon) > 0$ such that
$$
0 < \sqrt{x^2 + y^2} < \delta \Longrightarrow |x^2 + y^2| < \epsilon.
$$
Here, the notation $\delta = \delta (\epsilon)$ means that $\delta$ is allowed to depend (as a function) upon the given $\epsilon > 0$.

So, choose $\delta = \sqrt{\epsilon}$.  Then $\delta > 0$ and
$$
0 < \sqrt{x^2 + y^2} < \delta = \sqrt{\epsilon} \ \Rightarrow \ x^2 + y^2 < \epsilon.
$$
Hence, by definition, $\lim_{(x,y) \rightarrow (0,0)} (x^2 + y^2) = 0$.

\subsection{Functions that do not have limits}
We now discuss some functions which do not have limits at certain points $(a,b)$ in $\mathbb{R}^2$.

\begin{example}
Consider the function
$$
f(x,y) = \frac{x^2 - y^2}{x^2 + y^2},
$$
defined so long as $(x,y) \neq (0,0)$.  We encountered the level curves of this function in Section 2.1.

We claim that $f(x,y)$ does \textbf{not} have a limit as $(x,y) \rightarrow (0,0)$, for the reason that the limits along different paths approaching $(0,0)$ are different. Let us illustrate.
If $(x, 0)$ and $(0,y)$ are points on the $x$ and $y$ axis respectively, then
$$
f(x,0) = \frac{x^2}{x^2} = 1, \quad \quad \quad f(0,y) = \frac{-y^2}{y^2} = -1.
$$
So, evaluating the limit $(x,y) \rightarrow (0,0)$ along the $x$- and $y$-axes produces distinct values.
We could also revisit the level curves found in Section 2.1 to see that, for any value of $c$ in $[-1,1]$, there is at least one line $L$ such that $f(x,y)$ approaches $c$ as $(x,y)$ approach $(0,0)$ along $L$! This multitude of limits from different directions means that the limit in the sense of Definition \ref{21-def-limits} does not exist.







\end{example}



\medskip


\begin{example}
The function
$$
f(x,y) = \frac{x^4 - y^2}{x^4 + y^2},
$$
defined for $ (x,y) \neq (0,0)$,
does not have a limit as $(x,y) \rightarrow (0,0)$.
As an exercise, prove this using a similar argument along the $x$- and $y$-axes.

\end{example}
\medskip


\begin{example}
Let us modify the function from the last example. Consider the limit as $(x,y)\to (0,0)$ of the function
$$
g(x,y) =
\begin{cases}
\frac{x^4 - y^2}{x^4 + y^2}&\hbox{ if }  y \neq 0, \\
-1 &\hbox{ if } y = 0.
\end{cases}
$$
Then, $g(x,0) = g(0,y) = -1$ for any $x,y$ in $\mathbb{R}$ (check this!).  Even more, if we set $y = ax$ for some non-zero number $a$--so that $(x,y) = (x, ax)$--we see that for $x\neq 0$,
$$
g(x,ax) = \frac{x^4 - a^2 x^2}{x^4 + a^2 x^2} = \frac{x^2 - a^2}{x^2 + a^2},
$$
so that $g(x,ax) \rightarrow -1$ as $x \rightarrow 0$.  Geometrically: this means that along linear paths $\{(x,ax) : \ x \in\rr \}$ through the origin, $g$ approaches $-1$ as $x \rightarrow 0$. It might look like the bivariate limit should be $-1$.


Yet, in spite of this, the limit $\lim_{(x,y) \rightarrow (0,0)} g(x,y)$ fails to exist.  To see this, evaluate the limit along the parabolic curve $y = x^2$.  Then, for $x \neq 0$,
$$
g (x,x^2) = \frac{x^4 - (x^2)^2}{x^4 + (x^2)^2} = \frac{0}{2 x^4} = 0.
$$
In particular, $g(x,x^2) \rightarrow 0$ as $x \rightarrow 0$! Therefore the bivariate limit does not exist.
Again, we could also find other parabolas that produce different value of the limit along path. To see how this is possible, we recommend revisiting the level curves in the last example in Section 2.1. 


\end{example}

In conclusion: for a limit of $f(x,y)$ to exist at $(a,b)$, its value must be the same \textbf{for all possible paths} to $(a,b)$ across the domain of $f$! This means:

\begin{itemize}
\item If you are proving that a limit \textbf{does not} exist, it's enough to indicate two different paths of approach to $(a,b)$ with different limits along those paths.

\medskip
\item It could also happen that the limit along a single path does not exist. In that case, we can see that the double limit does not exist just by considering that single path.


\medskip

\item If you are proving that a limit \textbf{exists}, it's never enough to consider just limits along paths. There are infinitely many possible paths of approach, and moreover, there are infinitely many \textit{types of} paths that one could take. There is no way to check all of them. You have to use ``affirmative'' methods such as the rules for limits, the Squeeze Theorem, or the $\epsilon-\delta$ definition.


\end{itemize}



\begin{remark}
There are other definitions of continuity that you may see in the literature, and this can lead to some nuance as to which functions are considered continuous on domains that have isolated points. For example, the topological definition of continuity is that the inverse images of all open sets are open. With this definition, a function defined only on the set of integer points $\mathcal{D}=\{(m,n)\in\zz^2:\ m,n$ are integer$\}$ would always be continuous by default, with the limit condition vacuously true because there are no limits to be considered.
\end{remark}

\begin{remark}
Some authors reserve the term ``double limit" for the limit 
$$\lim_{x\to a, y\to b} f(x,y),
$$
 as opposed to the limit $\lim_{(x,y)\to (a,b)} f(x,y)$ that we have been considering. The difference is that the first limit ``ignores" the values of $f$ along the lines $x=a$ and $y=b$, not just at $(x,y)=(a,b)$. In practice, however, the first type of limits is often used in situations when $f$ is undefined along the lines $x=a$ and $y=b$, in which case the second type of limits also ignores those two lines. For clarity, we recommend always writing out the limits using mathematical symbols and not just words.


\end{remark}



\section*{Worked Problems}

\begin{enumerate}[1.]



\item {\it 
Let 
$$f(x,y)=\left\{\begin{matrix}
\displaystyle{\frac{x^3}{x^2+y^2}}&\hbox{ if }(x,y)\neq (0,0)\\
0&\hbox{ if }(x,y)=(0,0)\\
\end{matrix}
\right.
$$
Is $f$ continuous at $(0,0)$? Prove your answer.}

\medskip
\noindent{\bf Solution 1: Using the Squeeze Theorem.}
For all
$(x,y)\neq (0,0)$, we have
$$
|f(x,y)|= \left|\frac{x^3}{x^2+y^2}\right|
= |x|\cdot  \left|\frac{x^2}{x^2+y^2}\right|\leq |x|.$$
This means that $f(x,y)$ lies between $x$ and $-x$ for all $(x,y)\neq (0,0)$.
Since $\pm x\to 0$ as $(x,y)\to (0,0)$, we also have $\lim_{(x,y)\to (0,0)} f(x,y)=0
=f(0,0)$. Therefore $f$ is continuous at $(0,0)$.

\medskip
\noindent{\bf Solution 2: Using the $\epsilon- \delta$ definition of a limit. }
Let $\epsilon > 0$. We want to find $\delta (\epsilon) > 0$ such that, if $0 < \sqrt{x^2 + y^2} < \delta$, then $\frac{|x^3|}{|x^2 + y^2|} < \epsilon$.  First, we see as in Solution 1 that
$$
\frac{|x^3|}{|x^2 + y^2|} \leq |x|, \textrm{ for all } (x,y) \neq (0,0).
$$
Now, remember that
$$
|x| = \sqrt{x^2} \leq \sqrt{x^2 + y^2}, \textrm{ for all } x,y \textrm{ real}.
$$
Hence, choosing $\delta = \epsilon$, we see that
$$
\frac{|x^3|}{|x^2 + y^2|} \leq |x| \leq \sqrt{x^2 + y^2} < \delta = \epsilon,
$$
which is what we wanted.

Note the strategy of the proof: to give an epsilon-delta proof for a complicated function $f(x,y)$, it helps to proceed at first as if you were going to use the Squeeze Theorem. If you can place $f(x,y)$ between functions $g(x,y)$ and $h(x,y)$ that are simpler but have the same limit (in this case we can use $g(x,y)= x$ and $h(x,y)=-x$), and find a $\delta$ that works for these functions, then the same $\delta$ will work for $f$.


\bigskip

\item {\it
Find, with proof, all values of $c\in\R$ such that the limit
$$\displaystyle \lim_{(x,y)\to (0,0)} \frac{cx^2+y^4  }{x^2+y^2}$$
exists.}

\medskip

If we let $x=0$ and $y\to 0$, then the limit is
$$
 \lim_{y\to 0} \frac{y^4}{y^2}=\lim_{y\to 0} y^2=0.
 $$
Hence if the limit exists, it should be 0. 
But if we let $y=0$ and $x\to 0$, we get
$$
 \lim_{x\to 0} \frac{cx^2}{x^2}= c ,
 $$
so that the limit can only exist if $c=0$. 

We now prove that if $c=0$ then the limit exists. We have
$$
\left| \frac{y^4 }{x^2+y^2}\right|
=|y|^2\,  \left|\frac{y^2 }{\sqrt{x^2+y^2}}\right|
\leq |y|^2.
$$
Since $|y|^2\to 0$ as $(x,y)\to (0,0)$, the limit exists and is equal to zero.



\bigskip
 
\item {\it 
Prove {\bf using the $\epsilon-\delta$ definition} that if $f,g$ are both defined for all $(x,y)$
in some neighbourhood of $(a,b)$, and if $\lim_{(x,y)\to (a,b)} f(x,y)=2$ and
$\lim_{(x,y)\to (a,b)} g(x,y)=3$, then $\lim_{(x,y)\to (a,b)} f(x,y) + g(x,y)=5$.}

\bigskip

Let $\epsilon>0$. 
We need to prove that there exists $\delta>0$ such that for all $x,y$ with 
$$0<\sqrt{(x-a)^2+(x-b)^2}<\delta$$
 we have
\[|f(x,y) + g(x,y) - 5|<\epsilon\ .\]

Since $\lim_{(x,y)\to (a,b)} f(x,y)=2$, there exists $\delta_1>0$ such that for all $x,y$ with $0<\sqrt{(x-a)^2+(x-b)^2}<\delta_1$ we have
\[|f(x,y)-2|<\frac\epsilon 2\ .\]
Similarly, since $\lim_{(x,y)\to (a,b)} g(x,y)=3$, there exists $\delta_2>0$ such that for all $x,y$ with $0<\sqrt{(x-a)^2+(x-b)^2}<\delta_2$ we have
\[|g(x,y)-3|<\frac\epsilon 2\ .\]

Let $\delta=\min(\delta_1,\delta_2)$. Then for all $(x,y)$ such that $0<\sqrt{(x-a)^2+(x-b)^2}<\delta$, we have both $|f(x,y)-2|<\epsilon/2$ and $|g(x,y)-3|<\epsilon/2$.
Therefore
\begin{align*}
|f(x,y) + g(x,y) - 5| &= |\big(f(x,y) - 2 \big) + \big(g(x,y) - 3\big)|\\
&\leq |f(x,y) -2| + |g(x,y) -3|\\
&< \frac{\epsilon}{2} + \frac{\epsilon}{2} = \epsilon,
\end{align*}
where the second step follows from the triangle inequality. This proves our conclusion.


\bigskip





\item {\it Let
$$
f(x,y) =
\begin{cases}
1&\hbox{ if }  x+y> 0, \\
-1 &\hbox{ if } x+y\leq 0 .
\end{cases}
$$
Prove {\bf using the $\epsilon$-$\delta$ definition} that $f(x,y)$ is not continuous at $(0,0)$.}


\medskip

Since $f(0,0)=-1$, we have to prove the following: there exists $\epsilon>0$ such that for every $\delta>0$ there exist $x,y$ with 
$$
0<\sqrt{x^2+y^2}<\delta\hbox{ and }|f(x,y)+1|>\epsilon.
$$
Let $\epsilon=1$. For any $\delta>0$, let $(x,y)=(\delta/2,0)$. Then $\sqrt{x^2+y^2}=\delta/2<\delta$ and
$|f(x,y)+1|=1+\delta/2>1$, as claimed.






\bigskip









\item {\it 
Suppose that a function $f(x,y)$ has the following form in polar coordinates:
$$f(r\cos\theta,r\sin\theta)=\begin{cases}
r\tan\theta &\hbox{ if }\theta\not\in\{\frac{\pi}{2},  \frac{3\pi}{2}\},     \\
0&\hbox{ if }\theta\in\{\frac{\pi}{2},  \frac{3\pi}{2}\}.
\end{cases}
$$
Is it true that $\lim_{(x,y)\to (0,0)} f(x,y)=0$? Prove your answer. (In this question, an $\epsilon-\delta$ proof is 
not required.)}


\medskip

It is not true. To see this, consider the trajectory where $r\tan\theta=1$, $0\leq\theta<\pi/2$. Since
$\tan\theta\to\infty$ as $\theta\to\pi/2$, we have $r\to 0$ but 
$f(r\cos\theta,r\sin\theta)=1$ along that trajectory.

\bigskip




\end{enumerate}

\section*{Practice Problems}

\begin{enumerate}[1.]
\item Evaluate the following limits, or prove that they do not exist. In this question, you {\bf do not have to} use the $\epsilon-\delta$  definition of limits.
 
 \medskip
 
 (a) $\displaystyle \lim_{(x,y)\to(0,0)} \frac{\sin(xy)}{x^2-y^2}$
 
 \medskip
 
 
 
 
 (b) $\displaystyle \lim_{(x,y)\to(0,0)} \frac{xy^5\cos(1/y)}{x^4+y^4}$

\medskip

(c) $\displaystyle \lim_{(x,y)\to (0,0)} \frac{xy^2}{x^4+y^4}$

\medskip

 
 
 (d) $\displaystyle \lim_{(x,y)\to(0,0)} \frac{x^2y^4}{x^2+y^6}$

 


\bigskip


\item
Evaluate the following limits, or prove that they do not exist. In this question, you {\bf do not have to} use the $\epsilon-\delta$  definition of limits.

\medskip

(a) $\displaystyle \lim_{(x,y)\to(0,0)}
\frac{xy}{\sqrt{x^2+y^2}}.$



\medskip
(b) 
$\displaystyle{\lim_{(x,y)\to (0,0)} \frac{(x-y)^2}{x^2+y^2}}$ 



\medskip

(c) 
$\displaystyle{\lim_{(x,y)\to (0,0)} \frac{x^3}{|x|+|y|}}$

\medskip

(d) $\displaystyle \lim_{(x,y)\to(0,0)}
\frac{x+y}{\sqrt{x^2+y^2}}.$

(e) $\displaystyle{\lim_{(x,y)\to (0,0)} \frac{\sin^2 x\sin^2 y}{x^2+y^2}}$ 



\bigskip




\item Prove using the $\epsilon-\delta$ definition that 
$\displaystyle \lim_{(x,y)\to(0,0)} \frac{x^3y^3}{(x^2+y^2)^2}=0$. (Given $\epsilon>0$, find $\delta>0$ such that...)

\bigskip

\item Prove using the $\epsilon-\delta$ definition that 
$$\displaystyle \lim_{(x,y)\to(0,0)} \frac{x^3y}{x^2+y^4}=0.$$

\bigskip

\item Give an $\epsilon-\delta$ proof that $\displaystyle \lim_{(x,y)\to (0,0)} \frac{x^2+4y^2}{|x|+|y|}=0.$ 
(Given $\epsilon>0$, find $\delta>0$... You might find it useful to consider three cases: when $x,y \neq 0$, when $x = 0$, and when $y = 0$.)


\bigskip

\item 
Prove {using the $\epsilon-\delta$ definition} that 
$\displaystyle{\lim_{(x,y)\to(0,0)} \frac{2xy^3}{x^2+y^2}=0}$. (Given $\epsilon>0$, find $\delta>0$ such that...)





\bigskip

\item
Assume that the following is true for some function
$f(x,y)$, defined for all $x$ and $y$: for every $\epsilon>0$ there is a $\delta>0$ such that
for some $(x,y)$ such that $0<\sqrt{(x-a)^2+(y-b)^2}<\delta$ 
we have $|f(x,y)-L|<\epsilon$  (make sure to read
this carefully!). Does this imply that $\lim_{(x,y)\to (a,b)}f(x,y)=L$? If yes, prove it. If not, give an example of a function
$f(x,y)$ that satisfies the above condition but does not have a limit at $(a,b)$.


\bigskip


\item 
Prove {using the $\epsilon-\delta$ definition} that  if $f(x,y)$ is a function such that 
$$
\lim_{x\to 0} f(x,0)=4, \ \ \lim_{y\to 0}f(0,y)=1,
$$
then the limit $\lim_{(x,y)\to (0,0)} f(x,y)$ does not exist. (You need to prove that the ``for every $\epsilon>0$ there exists $\delta>0$...'' statement {\bf cannot} be true for a function as above.)




\end{enumerate}





