\section{Sets and Coordinates}

\subsection{Rectangular Coordinates and Euclidean Distance in $\mathbb{R}^3$.}
Every point $P$ in $\mathbb{R}^3$ can be written as $P = (x,y,z)$, where $x,y$ and $z$ are real numbers.  This corresponds to \textbf{rectangular coordinates}, as shown in the following picture.


\begin{figure}[H]\label{11fig1}
\centering\includegraphics[width= .8\textwidth]{11fig1.png}
\caption{Three points $O,P,Q$ in $\mathbb{R}^3$. }
\end{figure}


We will reserve the notation $O = (0,0,0)$ for the \textbf{origin}--that is, the point with zero for each coordinate.  In this picture, $Q = (x_0,y_0,0)$ and $P = (x_0,y_0,z_0)$. This is because $Q$ lies in the plane where $z = 0$, and $P$ is collinear with $Q$ on a line parallel to the $z$-axis.

Notice that $O,P$ and $Q$ form the vertices of a right-triangle.  In particular, the segment $OP$ connecting $O$ and $P$--corresponding to the hypotenuse of this right-triangle--has length
\begin{equation}\label{eq:Odist}
|OP| : = \sqrt{|OQ|^2 + |PQ|^2} = \sqrt{x_0^2 + y_0^2 + z_0^2}.
\end{equation}
In other words, the distance from the origin to $P$ is given by formula \eqref{eq:Odist}.  In general, we have the following notion of distance in $\mathbb{R}^3$.

\begin{definition}
Suppose that $P = (x_0, y_0, z_0)$ and $R = (x_1, y_1, z_1)$. Then, the (\textbf{Euclidean}) \textbf{distance} between $P$ and $R$ is denoted $|PR|$ and satisfies,
\begin{equation}
|PR| : = \sqrt{(x_0 - x_1)^2 + (y_0 - y_1)^2 + (z_0 - z_1)^2}
\end{equation}
\end{definition}

Make sure you are comfortable with all of this terminology in your preferred course textbook. We will make ready use of it as we proceed.

\subsection{Equations and Surfaces in $\mathbb{R}^3$} We will often use equations to represent curves and surfaces in $\mathbb{R}^3$, as follows.
\begin{enumerate}
\item{\underline{A single equation} will generally be used to describe a surface.  For example, the equation $x^2 + y^2 + z^2 = 9$ describes a sphere in $\mathbb{R}^3$, centred at the origin, with radius $r = 3$.  Equations need not involve all variables $x,y$ and/or $z$. The equation $z = 2$ describes a plane parallel to the $xy$-plane, passing through the point $(0,0,2)$. }

\item \underline{A system of two equations} will generally be used to describe a curve (the intersection of two surfaces). For example,  the system of equations
$$
\begin{cases}
x^2 + y^2 + z^2 = 9 \\[1ex]
z = 2
\end{cases}
$$
represents a circle.
All three of the above sets (sphere, plane,  intersected circle) are shown in the following figure.
\end{enumerate}

\begin{figure}[H]\label{11fig2}
\centering\includegraphics[width= .75\textwidth]{11fig2.png}
\caption{The sphere $\{(x,y,z) : x^2 + y^2 + z^2 = 9\}$ and the plane $\{(x,y,z) : z = 2\}$ intersect in a curve (the dark-green circle).}
\end{figure}

\textbf{Caution}! It is not always true that $1$ equation gives a surface and $2$ equations give a curve.  For example,  you can readily check that the equation
$$
x^2 + y^2 + z^2 = 0,
$$
has only $(0,0,0)$ as a solution---which is a point and not a surface. Similarly, the system of equations
$$
\begin{cases}
x^2 + y^2 + z^2=9 \\[1ex]
z = 4
\end{cases}
$$
has no solutions $(x_0, y_0, z_0)$ in $\mathbb{R}^3$! This is because the plane $z = 4$ does not intersect the sphere defined by $x^2 + y^2 + z^2 = 9$.  Try plotting this on Geogebra, or another free online $3$D calculator.  You can find more examples of these ideas in your textbook.

Sometimes, a set in $\mathbb{R}^3$ will be described using an equation or inequality in only one or two variables. This means that any variable not mentioned in the equation can take any value in $\mathbb{R}$. For example, the set
$$
\{(x,y)\in\mathbb{R}^2:\ x^2+y^2= 4\}
$$
is a circle in the $xy$-plane, centered at $(0,0)$ and with radius $2$. However, the set
$$
\{(x,y,z)\in\mathbb{R}^3:\ x^2+y^2= 4\}
$$
is a cylinder of infinite length in the 3-space, parallel to the $z$-axis. Its cross-section in the $xy$-plane is the circle above.


\subsection{Open and Closed Sets}
Let us zoom out and consider $\mathbb{R}^n$--the set of points $(x_1,...,x_n)$ in $n$-dimensional Euclidean space. You can always take $n =2$ or $3$ if it helps you make sense of what follows.

We work with the following definitions:
\begin{itemize}
\item If $P \in \mathbb{R}^n$, a \textbf{neighbourhood} of $P$ is a ball $B_r (P) : = \{Q \in \mathbb{R}^n : |PQ| < r \}$, centred at $P$ for some $r > 0$ (which is usually thought of as very small).


\begin{figure}[H]
\centering\includegraphics[width=.4\textwidth]{11fig3.pdf}
\caption{A set $S$ is shown in red.  The blue disc $P$ is the neighbourhood of some point of $S$. Notice how $P$ has a \textbf{dashed} border--this comes from the $<$ inequality in the definition of a neighbourhood. }
\end{figure}


\medskip
\item A set $S \subset \mathbb{R}^n$ is \textbf{open} if for every point $P \in S$, there is a neighbourhood $B_r (P)$ contained in $S$. Note: this just has to hold for \textit{some} $r > 0$. 

\medskip

\item A set $S \subset \mathbb{R}^n$ is \textbf{closed} if its complement $S^c : = \mathbb{R}^n \setminus S$ is open.
\end{itemize}

Let's see some examples.
\begin{itemize}
\item {\underline{Example 1}. The ball $\{(x,y,z) \in \mathbb{R}^3 : x^2 + y^2 + z^2 < 9\}$ is open.  In particular, for each point $C \in B$,  we have the neighbourhoods $B_r (C) \subset B$, so long as $0 < r < 3 - |OP|$. }

\begin{center}
\begin{figure}[H]
\centering\includegraphics[width=.4\textwidth]{11fig4.png}
\caption{Every point $C \in B$ has some neighbourhood $B_r (C)$ contained in $B$.}
\end{figure}
\end{center}



\item{ \underline{Example 2}.  The ball $\overline{B} : = \{x^2 + y^2 + z^2 \leq 9\}$ in $\mathbb{R}^3$ is \textbf{not} open.  In fact,  for any point $C_1 \in \overline{B}$ satisfying $|OC_1| = 3$, the neighbourhoods $B_r (C_1)$ will necessarily intersect the outside of $\overline{B}$--that is, the set $\overline{B}^c$--as well as the inside of $\overline{B}$.
However, the ball $\overline{B}$ \textbf{is} closed.  This is because its complement $\overline{B}^c$ is open. If we take any $C_2 \in \overline{B}^c$, then the distance $|O C_2| > 3$ (this is just the definition of being outside of $\overline{B}$). Since the inequality is strict, we can choose $0 < r < |O C_2| - 3$ such that $B_r (C_2) \subset \overline{B}^c$.


\begin{center}
\begin{figure}[H]
\centering\includegraphics[width=.5\textwidth]{11fig5.png}
\caption{The red ball $\overline{B}$ is not open, but it is closed. Compare the neighbourhoods around $C_1 \in \overline{B}$ and $C_2 \in \overline{B}^c$.}
\end{figure}
\end{center}

}

\vspace{-.15in}

\item{ \underline{Example 3}.  If $S$ is the rectangle $\{(x,y) \in \mathbb{R}^2 : -2 \leq x \leq 2, -1 < y < 1\}$, then $S$ is \textbf{neither} closed \textbf{nor} open.  Can you figure out why?}


\begin{figure}[H]
\centering\includegraphics[width=.35\textwidth]{11fig6.png}
\caption{Try taking neighbourhoods of points on the solid lines. What happens? For the complement, remember: solid lines become dashed lines and vice-versa.}
\end{figure}
\end{itemize}

\vspace{-.15in}

Having given a few examples of open and closed sets, we can now motivate the definition of boundary.  The \textbf{boundary}\footnote{
This is the {\it topological} boundary of a set. It should be distinguished from the ``Stokes boundary" of a manifold, which is a different concept that we will study in MATH 227.} 
of a set $S \subset \mathbb{R}^n$ is the set of points $P$ such that every neighbourhood of $B_r (P)$ contains both points of $S$ \textbf{and also} points of $S^c$. 

For example:
\begin{itemize}
\item{The open ball $B$ in Example 1 and the closed ball $\overline{B}$ in Example 2 above share the same boundary, the sphere $\{x^2 + y^2 + z^2 = 9\}$. }

\medskip

\item{The boundary of the rectangle $S$ in Example 3 consists of the four line segments (all solid, no dashes).}
\end{itemize}

We will use $bndry (S)$ to denote the boundary of $S$. Boundary points of $S$ may or may not be contained in $S$. However, if a set is closed, it contains all of its boundary points; similarly, if a set is open, it contains none of its boundary points. See the worked problems below.

\begin{remark}
An alternative description of closed sets in $\mathbb{R}^n$ is the following. The set $S \subset \mathbb{R}^n$ is closed if and only if for every sequence of points $P_1, P_2, ...$ such that $P_k \in S$ and $\lim_{k \rightarrow \infty} P_k = P$, one has $P \in S$.  In words, if a sequence of points in $S$ has a limit then that limit is in $S$. We will not prove this in this course.
\end{remark}

Again, as a cautious rule-of-thumb: open sets usually are described using strict inequalities like $<$ or $>$; similarly, closed sets are often described using $\leq$ or $\geq$.  For example,
$$
\{(x,y) \in \mathbb{R}^2 : x + y > 7\}  \textrm{ is an open set}.
$$
whereas
$$
\{(x,y) \in \mathbb{R}^2: -1 \leq y \leq 1\} \textrm{ is a closed set}.
$$
However, expressions involving inequalities can be tricky! So best be careful and figure out what the set actually looks like before deciding whether it is open (or closed, or neither). For example, the set
$$
\{(x,y) : x^2 + y^2 \leq 4, x < 10 \}
$$
is closed, even though it involves one $<$ inequality. This is because the inequality $x^2 + y^2 \leq 4$ actually implies that $x < 10$. So, the set is the closed disc $\{(x,y) : x^2 + y^2 \leq 4 \}$ and 
the $<$ part of the set's definition is redundant.  See the picture below. 

\begin{center}
\begin{figure}[H]
\includegraphics[width=\textwidth]{11fig7.png}
\caption{The inequality $x < 10$ was redundant. Can you see why in this picture? The vertical line comes from the equation $x = 10$.}
\end{figure}
\end{center}

\noindent
Practice working with inequalities in the following way. Verify that,
$$
x \leq |x|,  \textrm{ for all } x \in \mathbb{R} \quad \quad \textrm{and} \quad \quad x^2 \leq x^2 + y^2, \textrm{ for all } x,y \in \mathbb{R}.
$$
Then, use these two inequalities to show that $x^2 + y^2 \leq 4$ implies $x < 10$.  Hint: remember that $|x| = \sqrt{x^2}$.

\subsection{Describing Boundaries: a Final Example} We conclude with a discussion of equations for boundaries of surfaces by considering the following example. Let,
$$
S : = \{ (x,y,z) \in \mathbb{R}^3 : x^2 + y^2 + z^2 \leq 9, z \geq 2 \}.
$$
The boundary of $S$ consists of two parts: part of the sphere above the plane $z = 2$, which is described by the equation
$$
\{(x,y,z) \in \mathbb{R}^3 : x^2 + y^2 + z^2 = 9, z \geq 2\}
$$
and another disc-like part of the plane $z = 2$,  which is defined by the equation
$$
\{(x,y,z) \in \mathbb{R}^3 : x^2 + y^2 + z^2 \leq 9, z = 2 \}.
$$
However, notice that if $z = 2$, then $x^2 + y^2 + z^2 = x^2 + y^2 + 4$. So, this last part of the boundary simplifies to
$$
\{(x,y,z) \in \mathbb{R}^3 : x^2 + y^2  \leq 5, z = 2 \}.
$$
Nifty, because $x^2 + y^2 \leq 5$ is the inequality describing a disc of radius $\sqrt{5}$ in the $xy$-variables; the $z = 2$ component then lifts this disc to the $z = 2$ plane. You can see these two surfaces in Figure 2. 


We will utilize this kind of manipulation of expressions for surfaces and their boundaries very often when we consider derivatives and integrals of multivariate functions.  More to come!

\subsection{Writing Rigorous Proofs}

Most of the time, an intuitive understanding of open and closed sets will be sufficient in this course. However, a major goal of this course is for you to become proficient in formulating and writing rigorous mathematical proofs. We will not insist on this level of detail all the time, but you should be able to write out a formal proof if needed. 

A ``proof" of a mathematical statement is a formal argument justifying why that statement is true, starting from the definitions and theorems that were provided to you and using the principles of logic. This can be different from common-sense explanations. For instance, if you need to explain something informally, using examples can be a great way to do it. We will do this often in this course! But for a formal proof, examples are not sufficient; we have to use general definitions, concepts, and rules of logic. 

There are a couple of other things we will practice here that will be important later: using quantifiers (``all", ``some", ``none"), working with inequalities, and working with absolute values. We will review each of these before working on proofs themselves.


It will be important to understand what is a rigorous proof and what is not. When we give a rigorous proof, we will say so explicitly, for example:

\begin{quote}
\begin{proof} This is how we indicate a rigorous proof. A small square will indicate where the proof ends. The letters QED (from Latin, \textit{quod erat demonstrandum}) are also used in the literature for that purpose.
\end{proof}
\end{quote}

When we provide less than that (for example, a sketch of the proof with some details omitted, or a proof that is actually rigorous but only if we make stronger assumptions than those we stated), we will also say that explicitly, with some indication of what would be needed to complete the proof.

We will see many sketches of proofs in this course! All of calculus is based on approximating complicated functions by simpler functions. You have already seen this in single-variable calculus (linear approximation, Taylor polynomials). A typical {\it outline of a proof} of a theorem in calculus goes like this:
\begin{itemize}
\item[Step 1.] $X$ is true for ``nice" functions (say, linear functions).
\item[Step 2.] A more general function $f$ (say, continuous) can be approximated by a nice function $g$. Since $X$ is true for $g$, it is also true for $f$.
\end{itemize}
For an {\it actual proof}, we need to verify that the approximation in Step 2 is good enough so that the property $X$ can indeed be transferred from $g$ to $f$. This can take the form, for instance, of proving some inequalities for $f$ or estimating the error in the approximation. If you would like to take a peak ahead, an example of this is given in the proof of Theorem 3.1.3 in Section 3.1. The outline of the proof given at the beginning starts with Step 1 (linear functions are continuous) and then states that the same should be true for functions well approximated by linear functions. The actual proof (given below the outline) uses an error estimate.


{\bf A major goal of this class} is to offer you both fluency in the main ideas in calculus (typically, using various approximations) and the ability to convert such ideas to rigorous mathematics. Too much focus on detail can make it difficult to identify the main ideas. On the other hand, ideas not supported by proofs amount to building castles on quicksand: without an actual proof, you do not really know whether your claims are correct or not. 
In this class, we will approach this as follows.

\begin{itemize}

\item We will provide a representative selection of proofs, illustrating the main methods that are used in arguments of this type. Some of the proofs may be deferred to Worked Problems or Practice Problems, with hints and solutions provided as appropriate. 

\smallskip

\item In many cases, we will be satisfied with proof outlines rather than detailed proofs. This will save time, avoid long and/or repetitive arguments, and make it easier to focus on the main ideas. However, it is still the goal of this course to give you the tools to be able to work out the details of these proofs if needed. For example, some of the Practice Problems will ask you to prove a specific simple case of a more general theorem.

\smallskip

\item Finally, there are also calculus theorems whose proof is beyond the scope of this course. For instance, the theorem on maximizing and minimizing a continuous function on a compact domain (Section 4.2) requires the concept of completeness in mathematical analysis. This is covered in more advanced courses (such as MATH 320 at UBC). In this class, we will just have to state such results without proof.

\end{itemize}



\subsection{Inequalities} An important thing about inequalities is that they only work ``one way": in practice, this means that you cannot just manipulate them automatically like equalities. To give a very simple example, if $a<b$ and $b<c$, then $a<c$ by transitivity. But this works in only one direction: if $a<c$, then this does not tell us anything about $b$. Even if we know that $a<c$ {\it and} $a<b$, we still do not know anything about the relationship between $c$ and $b$.


This has implications for how you need to write proofs and problem solutions involving inequalities. Generally, arguments with inequalities have a more complex structure than a straightforward sequence of equivalences. It is therefore important to include both formulas and sentences indicating your reasoning. To illustrate this, compare the following two examples.

\medskip\noindent\underline{Example 1.} 
$x^2-3x+2=0$, $(x-1)(x-2)=0$, $x=1,2$.

It is completely clear that someone is simplifying and solving a quadratic equation. No further explanations are needed. 


\medskip\noindent\underline{Example 2.} 
$|x^2-y^2|<1$, $x^2<1/4$ and $y^2<1/4$, $\sqrt{x^2+y^2}<1/2$.

Can you even tell what is happening here?
Perhaps this person is saying this:
\begin{quote}
{\it If $|x^2-y^2|<1$, then $x^2<1/4$ and $y^2<1/4$, therefore $\sqrt{x^2+y^2}<1/2$.}
\end{quote}
This is obviously incorrect: for instance, if $x=y=10$, then $|x^2-y^2|=0$ but $\sqrt{x^2+y^2}=10\sqrt{2}>1/2$. But it is also possible that they are saying something else:
\begin{quote}
{\it We need to find a neighbourhood of $(0,0)$ where $|x^2-y^2|<1$. The given inequality holds for example when $x^2<1/4$ and $y^2<1/4$, and both of these are true when $\sqrt{x^2+y^2}<1/2$, so that the last inequality defines a neighbourhood that works.}
\end{quote}
This would be a correct argument if it had been written this way, which it was not. (We will actually use very similar arguments in the proofs for open and closed sets below, and later in $\epsilon$-$\delta$ proofs for limits.)
To be clear, it's a very good practice to include sentences in all of your solutions! But in proofs with inequalities, including sentences can really make the difference between a correct solution and something that's either impossible to follow or incorrect as stated.



An important inequality involving the absolute value is the \textbf{triangle inequality}:
$$
|a+b|\leq |a|+|b|.
$$
This looks similar to the triangle inequality in geometry: if $P,Q,R$ are three points in $\RR^n$, then
$$
|PR|\leq |PQ|+|QR|.
$$
Both inequalities are special cases of the general triangle inequality for norms in vector spaces (to be covered in your linear algebra corequisite class). 
It is useful to think about absolute values as distances on the line, for example $|a-b|$ is the distance from $a$ to $b$. 
Then the triangle inequality for the absolute value is a special case of the triangle inequality for points in $\RR^n$, if let $n=1$ and interpret $|a|, |b|, |a+b|$ as the distances on the real line between 0 and $a$, between 0 and $-b$, and between $a$ and $-b$. It is also useful to remember that if $P=(x,y)$ and $Q=(x',y')$ are two points in the plane, then
$$
|x-x'|\leq  \sqrt{(x-x')^2+(y-y')^2} = |PQ|,
$$
and similarly for the $y$-coordinates. A similar statement is also true in higher dimensions. 
In the rest of this course, we will use these inequalities without proof.

\subsection{Quantifiers} In formal logic, a \textit{quantifier} is an operation which tells us how many elements $x$ in a given set $S$ possess a given property $P$.  For us, the primary quantifiers we are concerned with are ``all''  (symbolically: $\forall$) and ``exists'' (symbolically: $\exists$).   ``All" tells us that every single element of a given set has a given property; whereas, ``exists" tells us that \textit{at least one} (but perhaps more than one) element has a given property.  The purpose of introducing quantifiers is to allow us to build formal \textit{truth statements}, which are statements which can either be true or false. The following very simple example allows us to illustrate this purpose.

Consider the following statement: ``All positive even numbers are greater than one." This breaks into three logical components: a set of objects $S$ (``positive even numbers"), a property $\calP$ (``greater than one"), and a quantifier $\forall$ (``all"). Together, these three logical components form a statement, which just so happens to be true.  Of course, if we change any one of these three components, our statement may no longer be true.  For example, the statement, ``All even numbers are greater than one", and the statement ``All positive even numbers are greater than three", are both clearly false.  

The quantifiers ``all" and ``exists" are related to one another through a process called \textit{negation}.  Before introducing a more formal definition,  let us introduce the concept of negation, and its relation to our quantifiers,  through the following example.

Consider the following statement:  ``All continuous functions are differentiable".  This is a truth statement,  with a set of objects $S$ (``continuous functions"), a property $\calP(f)$ (``$f$ is differentiable"), and a quantifier $\forall$ (``all").  Let us label the whole statement as $T$, and use shorthand to write $T = \forall_{f\in S} \calP(f)$. (We may also write the ``set of objects'' part inline, especially in displayed formulas such as (\ref{1-1-e9}) below. The important thing is to make it clear where the ``set of objects'' part ends and the property $\calP$ begins.)  Now,  from differential calculus,  we know the statement $T$ is false.  Indeed, the function $f(x) = |x|$ is a \textit{counterexample} (i.e. a specific element in the set $S$ for which $T$ is false).  

This counterexample actually shows that the related statement, ``There exists a continuous function which is \underline{not} differentiable", is a true statement.  Moreover, this related truth statement consists of the same set (``continuous functions"), but importantly has the negative ("is not differentiable")  of our original property ("is differentiable") and the quantifier has flipped (``all" became ``exists").

This property from the previous example is, in fact, true for general statements. Formally, if $S$ is a given set of elements,  $\calP$ is a property, $\neg \calP$ is its negative\footnote{
Other ways to denote the negation of $\calP$ are $!\calP$ and $\sim \calP$. All are commonly used in math literature. 
}, and we take the truth statement $T = \forall_{x\in S} \calP$, then $T$ is false if and only if the statement $\neg T = \exists_{x\in S} (\neg \calP)$ is true.  This situation was illustrated by our previous example.  Similarly, if $T$ is true, then $\neg T$ is necessarily false.  Moreover, if instead we take $T = \exists_{x\in S} \calP$ as our truth statement, then $T$ is true if and only if $\neg T = \forall_{x\in S} (\neg \calP)$ is false (and, again, vice versa).  This is the principle of negation, and holds for \textit{any} truth statements which can be formed from a set of objects, a property, and a quantifier ``all" or ``exists".

While this discussion of truth or falsehood may feel overly formal, remember: the goal is to establish a general framework for determining whether many different types of logical statements are true or false.  A proof is the rigorous and logical process by which we establish a given statement is true.  We will spend the next subsection putting together these abstract ideas, and illustrating how quantifiers are utilized in proofs.

\subsection{A First Foray into Proofs: Open Sets} Now, let's look at a couple of proofs for open and closed sets.

\medskip\noindent
{\bf Question 1.} {\it Prove directly from the definition that the open square $S=\{(x,y)\in\rr^2:\ -1<x<1,\ -1<y<1\}$ is an open set
in $\rr^2$. (Given a point $P=(x,y)\in S$, find a neigbourhood of $P$ which is contained in $S$.)}


\smallskip

Let's first think about what we need to prove. A point $P=(x,y)$ belongs to $S$ if and only if $-1<x<1$ and $-1<y<1$. In terms of absolute values, $|x|<1$ and $|y|<1$. We need to prove that every such point has a neigbourhood contained in $S$. In terms of quantifiers,
\begin{equation}\label{1-1-e9}
\forall P\in S\ \exists r>0 \hbox{ such that }B_r(P)\subset S.
\end{equation}
A good way to prove that something \textit{exists} is to actually point to it.
That is, for every $P=(x,y)$ with $|x|<1$ and $|y|<1$, we want to find $r>0$ (possibly depending on $P$) such that the entire open disc $B_r(P)=\{(x',y'):\  \sqrt{(x-x')^2+(y-y')^2}<r\}$ is contained in $S$.

How do we find such $r$? It helps to draw a picture (you should actually do it at this point). From the picture, the closest distance from $P$ to the boundary of the square is the smallest of the numbers $1-x, x-(-1), 1-y, y-(-1)$. You could work with that, but it will be easier to write the proof if we notice that this distance is also equal to $\min(1-|x|,1-|y|)$ (can you explain why?). We set $r$ to be equal to this number. Once we know what $r$ should be, we need to use inequalities (usually, the triangle inequality) to prove that $B_r(P)$ is actually contained in $S$.

(Since this is a formal proof, it would not be enough to check this only for a few selected points in the square, say $P=(0,1/2)$ and $P=(1/2,1/2)$. We have to check it for {\it all} points $P$ in the square. That's why we use the general coordinates $(x,y)$.)

Here, then, is the proof.

%\medskip\noindent
\begin{proof}
Let $P=(x,y)\in S$. We need to prove that $B_r(P)\subset S$ for some $r>0$. Since $-1<x<1$ and $-1<y<1$, we have $|x|<1$ and $|y|<1$. Let $r= \min(1-|x|,1-|y|)$. Then $r>0$. 

We claim that $B_r(P)$ is contained in $S$. To see this, let $Q=(x',y')$ be a point in $B_r(P)$. Then
$$
|x-x'|\leq \sqrt{(x-x')^2+(y-y')^2}=|PQ|<r.
$$
By the triangle inequality, $|x'|\leq |x|+|x'-x| <|x|+r\leq |x|+(1-|x|) =1$. Similarly,
$|y-y'|<r$, and by the triangle inequality $|y'|<1$. Therefore $(x',y')\in S$.


This proves that every point $P\in S$ has a neighbourhood contained in $S$, so that
$S$ is open.
\end{proof}




\medskip\noindent 
{\bf Question 2.} {\it 
Let $S'=\{(x,y,z)\in\rr^3:\ -1<x<1,\ -1<y<1,\ z=0\}$. Is $S'$ an open set in $\rr^3$? Prove your answer.}

\smallskip
Let's first figure out the answer informally. The set $S'$ is a square in the $xy$-plane in 3 dimensions. For $S'$ to be open, it would have to contain some 3-dimensional neighbourhood of each of its points. But $S'$ is 2-dimensional, so it cannot contain 3-dimensional open balls. We now write this up formally.

\begin{proof}
 $S'$ is not an open set. For example, $P=(0,0,0)$ belongs to $S'$, but has no neighbourhood
contained in $S'$. To check that last part, let $B_r(P)$ be a neighbourhood of $P$ in $\rr^3$.
Then $B_r(P)$ contains the point $Q=(0,0,r/2)$, but $Q\not\in S'$ since the $z$-coordinate of $Q$
is not 0.
\end{proof}

We mentioned earlier that open and closed sets can be characterized in terms of whether they contain their boundary points. We now prove this.

\medskip\noindent
{\bf Question 3.}
 {\it Prove that a set in $\rr^n$ is open if and only if it does not contain any of its boundary points. 
}

\begin{proof} 
Let $S\subseteq \rr^n$. 
Recall that a boundary point of $S$ is
a point $P$ such that every neighbourhood $B_r(P)$ contains at least one point of $S$ and at least one point not in $S$.


\begin{itemize}
\item We first prove that if $S$ is open then no boundary points of $S$ belong to $S$.
Suppose that $S$ is open, and let $P$ be a boundary point of $S$. If $P$ were a point in $S$, then by the definition 
of an open set, there would be a neighbourhood $B_r(P)$ containing only points of $S$
(and no points that are not in $S$). That contradicts $P$ being a boundary point.
\medskip

\item 
We now prove that if no boundary points of $S$ belong to $S$, then $S$ is open.
Suppose that $S$ contains none of its boundary points. We have to check that every $P\in S$ has a neighbourhood
$B_r(P)\subseteq S$. Let $P\in S$. For every neighbourhood $B_r(P)$, we have $P\in B_r(P)$, so every such neighbourhood contains at least one point of $S$ (specifically, the point $P$). If every such neighbourhood also contained points that are not in $S$, then every neighbourhood would contain both types of points, so $P$ would be a boundary point. But we assumed that $S$ does not contain any of its boundary points, so that's a contradiction. Therefore there must be at least one neighbourhood $B_{r}(P)$ that does not contain points not in $S$, so that for that $r$ we have $B_{r}(P)\subseteq S$. 
\end{itemize}
\end{proof}


\medskip\noindent
{\bf Question 4.} {\it 
Prove that if $S$ is a closed set in $\rr^n$, and $P$ is a boundary point of $S$, then $P\in S$. 
You can either work directly with the definitions of a closed set and a boundary point, 
or else use the statement from Q3.}


\begin{proof}
Suppose that $S$ is a closed set in $\rr^n$. Let $S^c$ be the complement of $S$, then $S^c$ is open 
(by the definition of closed sets). If $P$ is a boundary point of $S$, then every
neighbourhood $B_r(P)$ of $P$ contains both points in $S$ and points in $S^c$, so that $P$ is
also a boundary point of $S^c$. Since $S^c$ is open, $P\notin S^c$. Therefore $P\in S$.
\end{proof}



\medskip\noindent
{\bf Question 5.} {\it 
Let $S\subset\rr^2$ be a nonempty set.
Prove directly from the definition that the set 
$$S'=\{P\in\rr^2:\hbox{ there exists }Q\in S \hbox{ such that }|PQ|<1\}$$
is an open set. (You need to prove that, given a point $P=(x,y)\in S'$, there is an $r>0$ such that the neigbourhood $B_r(P)$ is contained in $S'$. Note that, in the above condition defining $S'$, the point $Q$ may depend on $P$.)}

\begin{proof}
Let $P'=(x,y)\in S'$. Then there exists $Q\in S$ such that $|PQ|<1$. Let $r=1-|PQ|$, so that $r>0$. It suffices to prove that $B_r(P)\subseteq S'$. To prove this, we need to check that any $P'\in B_r(P)$ belongs to $S'$. Let $P'\in B_r(P)$, then $|PP'|<r$, so that
$$
|P'Q|\leq |P'P|+|PQ|<r+|PQ|=1,
$$
so that the condition for $P'\in S'$ is satisfied (with the same $Q$).
\end{proof}







%\vfill
%
%\pagebreak
%
\section*{Practice Problems}


You can use the solutions to Questions 1-4 above as templates for writing proofs of this type. Note the following:

\begin{itemize}

\item If you are proving that a set $S$ is open, then for {\it every} point $P\in S$ you have to find a neighbourhood that works for that point (that is, $B_r(P)\subset S$.) You find that neighbourhood by finding a value of $r>0$ that works for $P$. The choice of $r$ is not unique, in fact if some $r>0$ works for $P$, then any $r'$ such that $0<r'<r$ also works.

\medskip\noindent
This strategy applies every time you have to prove that a set $S$ is open, but the way you choose $r$ will depend on the set $S$ (so this part will not be the same for all questions of this type).

\medskip

\item  If you are proving that $S$ is not open, then it's enough to find just one point $P\in S$ where the open set condition fails, i.e. no neighbourhood of $P$
is contained in $S$. Then the reasoning is: identify $P$, let $r>0$ be arbitrary, and prove that $B_r(P)$ is not contained in $S$.
To do that last part, for any given $r>0$ (you should keep it arbitrary, so don't assign it any value), find at least one point $Q$ such that $Q\in B_r(P)$ but $Q\not\in S$.

\end{itemize}

In the first two questions, short answers are sufficient. The remaining problems ask for formal proofs.


\begin{enumerate}[1.]


\item {
Decide whether each of the sets below is open, closed, or neither.}

\begin{enumerate}
\item $\{(x,y)\in{\mathbb R}^2:\ 0\leq x<1,\ 0\leq y<2\}$ %-- neither
\item $\{(x,y)\in{\mathbb R}^2:\ x+y<2\}$ %-- open
\item $\{(x,y)\in{\mathbb R}^2:\ 0<\sqrt{x^2+y^2}\leq 3\}$ %-- neither open nor closed
\item $\{(x,y,z)\in{\mathbb R}^2:\ |x|\geq 6\}$ %-- closed
\end{enumerate}


\medskip


\item The following conditions describe sets in $\rr^3$. 
Are these sets open, closed, or neither?
Specify the boundary of each set.



\begin{enumerate}

\item $x^2+y^2+z^2\geq 16$


\item $x^2+y^2\geq 4$, $z\geq 0$

\item $0<x<1$, $0<y<1$, $z=1$

\item $0<\sqrt{x^2+y^2}\leq 3$

\item $x\geq 0, \ x^2+y^2+z^2\geq 4$



\item $x> 0, \ 0\leq y\leq 4$
\end{enumerate}


\medskip

\item {
Prove directly from the definition that the set $S=\{(x,y,z)\in\rr^3:\  x^2+y^2< 4\}$ is an open set
in $\rr^3$. (Given a point $P=(x,y,z)\in S$, find a neigbourhood of $P$ which is contained in $S$.)}


\medskip

\item{
Let $S'=\{(x,y,z)\in\rr^3:\ x^2+y^2<4 ,\ z\geq 0\}$. Is $S'$ an open set in $\rr^3$? Is it closed? Prove your answers (again, using points and neighbourhoods).}


\medskip
\item
Prove directly from the definition that the set $S=\{(x,y)\in\rr^2:\  x+y>0\}$ is an open set
in $\rr^2$. (Given a point $P=(x,y)\in S$, find an $r>0$ such that the neigbourhood $B_r(P)$ is contained in $S$.)

\smallskip

\item 
Let $S'=\{(x,y)\in\rr^2:\ x+y>0 ,\ x-y\leq 0\}$. Is $S'$ an open set in $\rr^2$?  Prove your answers (again, using points and neighbourhoods).


\medskip

\item 
Let $S=\{(x,y)\in\rr^2:\ |x|\leq 1,\ |y|<1\}$. Prove directly from the definition (again, using points and neighbourhoods) that $S$ is {\bf not} a closed set in $\rr^2$.



\medskip

\item{
Prove from the definition that the set $S:= \{(x,y) : x^2 + 4y^2 < 1 \}$ is open in $\mathbb{R}^2$.  As above, this means: for each point $P \in S$, find an $r > 0$ such that $B_r (P) \subset S$.

\medskip

\noindent
\underline{Hint:} The calculations in this question might be a bit longer, depending on how you choose your $r>0$. It may help if you do \textbf{not} try to make $r$ as large as possible. Rather, it suffices to find \textit{some value} $r > 0$ such that $B_r (P) \subset S$.  A discussion of this idea is given in the Solution Manual.

\smallskip\noindent
(We will figure out later how to use calculus methods to find the distance from a point to a curve. This could be used to find the optimal value of $r$. However, we do not need that for the purpose of this exercise.)
}


\medskip

\item
Let $S\subset\rr^2$ be an open set. 
Prove directly from the definition that the set 
$$S'=\{(x,y)\in\rr^2:\  (2x,2y)\in S\}$$
is also an open set. (We know that $S$ is open. This means that, given a point $P=(x,y)\in S$, there is an $r>0$ such that the neigbourhood $B_r(P)$ is contained in $S$. You have to prove that the same condition is satisfied for all $P'\in S'$, possibly with a different value of $r$.)




\end{enumerate}





