# Real Analysis/Metric Spaces

| ←Uniform Convergence | Real Analysis Metric Spaces | Differentiation in R$^n$→ |
    Definition 3.1.1 A metric space is an ordered pair (X,d) where X is a set and d a function
       $d:X\times X\rightarrow \mathbb {R}$
    such that:
       1. d(x, y) ≥ 0 (non-negativity); 2. d(x, y) = 0 if and only if x = y (non-degeneracy); 3. d(x, y) = d(y, x) (symmetry); 4. d(x, z) ≤ d(x, y) + d(y, z) (triangle inequality).
    The function d is called the metric on X. It is also sometimes called a distance function or simply a distance.
Often d is omitted and one just writes X for a metric space if it is clear from the context what metric is being used.
We already know a few examples of metric spaces. The most familiar is the real numbers with the usual absolute value. That is, we take X = R and we let d(x, y) = |x − y|. To see this is a metric space we need to check that d satisfies the four properties given above. Let's check and see.
* The first property follows from the fact that the absolute value of a number is always non-negative.
* The second property follows from the fact that the only the real number 0 has absolute value equal to 0.
* The symmetry property follows form the fact that |x|=|−x|.
* The triangle inequality is the most non-trivial to check. This is usually the case. For the this metric it follows from the fact that |a+b| ≤ |a| + |b|, where we take a = x − y and b = y − z.
Another familiar example is the plane. That is we take X = R$^2$. In order to define the metric, let's recall how we usually measure the distance between two points x = (x$_1$, x$_2$) and y = (y$_1$, y$_2$) in the plane. We simply use the Pythagorean theorem,
to see that we should define $d(x,y)={\sqrt {(x_{1}-y_{1})^{2}+(x_{2}-y_{2})^{2}}}$. First notice that this is always defined, because we are squaring the terms inside the square root we are never in danger of attempting to take the square root of a negative number, so d : R$^2$×R$^2$ → R. Now we need to check that it is a metric.
* The first property follows from the fact that the square root of a number is always non-negative.
* The second property follows from the fact that the only the number 0 has a square root equal to 0.
* The symmetry property follows form the fact that (x)$^2$=(−x)$^2$.
* Again the triangle inequality is the least obvious to check. In the case of the plane, it follows from the triangle inequality from Euclidean geometry. Recall that the triangle inequality in Euclidean geometry states that the length of any side of a triangle is always less the sum of the lengths of the other two sides. A proof that does not appeal to Euclidean geometry will be given in the more general context of R$^n$.
Other examples are abundant. As alluded to above we could take X = R$^n$ with the usual metric $d(x,y)=\textstyle {\sqrt {\sum _{i=1}^{n}(x_{i}-y_{i})^{2}}}$. Or instead, we could keep X = R$^n$, and simply take a different metric. This would be a different metric space, because a metric space is the pair (X,d), so a change in d changes the metric space. Some very interesting metrics occur if you take the metric $d(x,y)=d_{p}(x,y)=\textstyle {\Big\sum _{i=1}^{n}|x_{i}-y_{i}|^{p}{\Big )}^{1/p}$, or $d(x,y)=d_{\infty }(x,y)=\textstyle \max _{i=1\ldots n}|x_{i}-y_{i}|$. Notice the first metric we defined on R$^n$ corresponds to taking p = 2. This metric is often called the Euclidean (or usual) metric, because it is the metric that is suggested by Euclidean geometry, and it is the most common metric used on R$^n$.
Metric spaces could also have a much more complex set as its set of points as well. For example, we let X = C([a,b]), that is X consists of all continuous function f : [a,b] → R. And we could let $d(f,g)=\sup _{a\leq x\leq b}|f(x)-g(x)|$. Part of the Beauty of the study of metric spaces is that the definitions, theorems, and ideas we develop are applicable to many many situations.
    Definition: Let (X, d) be a metric spaces. We define an open ball centered at x of radius r to be the set B$_r$(x):={y∈ X | d(x,y) < r}.
Of course most of our intuition for metric spaces comes from our understanding of distances in R$^2$, so we should think about what an open ball looks like in R$^2$. It is hopefully a familiar fact from calculus that the equation (x − x$_0$)$^2$ + (y − y$_0$)$^2$ = r$^2$ describes a circle of radius r. The points such that ${\sqrt {(x-x_{0})^{2}+(y-y_{0})^{2}}}<r$ is just the set of points inside this circle. None of on the boundary of the circle are contained in the set, which is why choice to call this set an open ball.
It is also instructive to examine what this definition is when X = R, and d(x, y)=|x − y|. Following the definition we have that B$_r$(x) = {y∈R | |x − y|<r}. Thus, B$_r$(x) is the open interval (x − r, x + r).
Once we have defined an open ball, the next definition we need is that of an open and close sets.
    Definition Let (X,d) be a metric space, and suppose that G ⊆ X. Then G is said to be open if for every point g ∈ G there is an r > 0 so that B$_r$(g) ⊆ G.
Before we move on to closed sets, we first must clean up one potentially awkward situation. We have just given a general definition of what it means for any set to be open, but we have been using the phrase previously been talking about "open balls." But nothing guarantees us ahead of time that our open balls are in fact open in the sense of the definition above. This could leave us in a position where we mean two different things with the expression "open ball". Thankfully it turns out that the open ball is in fact open in the sense of the definition above, but this is still a theorem and requires proof.
    Theorem Let (X, d) be any metric space. The sets B$_r$(x) are open in the sense of the previous definition.
    Proof. We need to show that for a generic ball B$_r$(x) ⊆ X, that for any point y we choose in B$_r$(x), we can find a (probably much smaller ball) around y that stays inside B$_r$(x). Our intuition is again going to come from the pictures we draw in the plane, but our proof needs to only rely on the axioms given above. So we shall let s=r-d(x,y). We know s > 0, since y ∈ B$_r$(x). Now consider the ball B$_s$(y). We wish to show that B$_s$(y) ⊆ B$_r$(x). Take any z ∈ B$_s$(y). By using the triangle inequality we see that:
    ${\begin{aligned}d(x,z)\leq d(x,y)+d(y,z)&<d(x,y)+s=d(x,y)+{\Bigr-d(x,y){\Big )}\\=r\end{aligned}}$
    Since d(x, z) < r, it follows that z ∈ B$_r$(x). $\square$
One important point needs to made about the definition of open. Consider the empty set, it is certainly a subset of the metric space X. Is it open? Well for every point x in the empty set we need to find a ball around it. This is easy because there are no points in the empty set. That is, for the empty set, the condition is vacuously true. Informally speaking, a statement that requires some property hold under various conditions is said to be vacuously true when the conditions are never met. For example, the statement "Every time I stand on the sun, I break dance" is a vacuously true statement. It may not be possible to break dance on the sun, but the statement remains true. For the statement to be false, there would have to be a time when I was standing on the sun, but I did not break dance. But since I have never stood on the sun, there is nothing to check.
Another very use, and very simple example of an open set is the whole space. For every point x∈X, we may simply take the open ball B$_1$(x), by definition this ball is a subset of X, so there is an open ball around x that remains inside of X.
    Definition Let (X,d) be a metric space, and suppose that F ⊆ X. Then F is said to be closed if the complement of F, that is X \ F, is open.
Now we again have two easy examples of closed sets. First let's consider the whole space X, the complement of X is X \ X = ∅. Similarly, if we consider the empty set ∅, then X \ ∅ = X. Since the set X is open, it follows that ∅ a is closed set. An important point here is that we already see that there are sets which are both open and closed. Even though the definitions involve complements, this does not mean that the two types of sets are disjoint. There are cases, depending on the metric space, when many sets are both open and closed. Even more, in every metric space the whole space and the empty set are always both open and closed, because our arguments above did not make use to the metric in any essential way.
    Theorem In a any metric space arbitrary unions and finite intersections of open sets are open.
    Proof. Let (X, d) be a metric space and suppose that for each for each λ ∈ Λ we are given open sets G$_λ$. Then the theorem states that G = ∪$_{λ∈Λ}$ G$_λ$ is open. To see this suppose that x ∈ G. Then there is some index λ$_0$ so that x ∈ G$_{λ0}$. Since we are assuming that G$_{λ0}$, there must exist an r > 0 so that B$_r$(x) ⊆ G$_{λ0}$. Since G$_{λ0}$ is one of the elements of the union defining G it follows immediately that B$_r$(x) ⊆ G. Hence G is open.
    The theorem also claims that finite intersections are open. That is, if we suppose that G$_{λ1}$, G$_{λ2}$, …, G$_{λn}$ are open sets then the theorem claims that the set G=∪$_{i=1,…,n}$ G$_{λi}$ is open. To see this suppose x ∈ G, then we know that x ∈ G$_{λi}$ for i = 1, 2, …, n. Since each of the sets G$_{λi}$ is open, we can choose real numbers r$_i$ so that B$_{ri}$(x) ⊆ G$_{λi}$. If we set r = min(r$_1$, r$_2$, …, r$_n$) then we have that B$_r$(x) ⊆ B$_{ri}$(x) ⊆ G$_{λi}$. Thus, we have that B$_r$(x) ⊆ ∪$_{i=1,…,n}$ G$_{λi}$ = G and so G is open. $\square$
    Theorem In a any metric space arbitrary intersections and finite unions of closed sets are closed.
    Proof Exercise.
    Definition Let E be a subset of a metric space X. A point p is a limit point of the set E if every neighbourhood of p contains a point q ≠ p such that q ∈ E.
    Theorem Let E be a subset of a metric space X. The set E is closed if every limit point of E is a point of E.

## Basic definitions

Let X be a metric space. Here we give some basic definitions of properties that are often discussed for subsets E of X
* If p ∈ E and p is not a limit point of E then p is called an isolated point of E.`
* A point p is an interior point of E if there is a neighborhood N of p such that N $\subset$ E.
* E is open if every point of E is an interior point of E.
* E is perfect if E is closed and if every point of E is a limit point of E.
* E is bounded if there is a real number M and a point q $\in$ X such that d(p,q) < M for all p $\in$ E.
* E is dense in X every point of X is a limit point of E or a point of E (or both).

## Basic proofs

1. Every neighborhood is an open set
    Proof: Consider a neighborhood N = $N_{r}(p)$. Now if q $\in$ N then as d(p,q) < r we have h = d(p,q) - r > 0. Consider s $\in$ $N_{h}(q)$. Now d(p,s) $\leq$ d(p,q) + d(q,s) < r - h + h = r, and so $N_{h}(q)$ $\subset$ N. Thus q is an interior point of N.
2. If p is a limit point of a set E, then every neighborhood of p contains infinitely many points of E
    Proof: Suppose there is a neighborhood N of p which contains only a finite number of points of E. Let r be the minimum of the distances of these points from p. The minimum of a finite set of positive numbers is clearly positive so that r > 0. The neighborhood $N_{r}(p)$ contains no point q of E such that q $\neq$ p which contradicts the fact that p is a limit point of E.
3. A finite set has no limit points
    Proof: This is obvious from the proof 2.
4. A set is open if and only if its complement is closed.
    Proof: Suppose E is open and x is a limit point of $E^{c}$. We need to show that x $\in E^{c}$. Now every neighborhood of x contains a point of $E^{c}$ so that x is not an interior point of E. Since E is open it means x $\notin$ E and so x $\in E^{c}$. So $E^{c}$ is closed.
    Now suppose $E^{c}$ is closed. Choose x $\in$ E. Then x $\notin E^{c}$, and so x is not a limit point of $E^{c}$. So there must be a neighborhood of x entirely inside E. So x is an interior point of E and so E is open.
5. A set is closed if and only if its complement is open.
    Proof: This is obvious from the proof 4.