←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
 such that:


1. d(x, y) ≥ 0 (nonnegativity); 2. d(x, y) = 0 if and only if x = y (nondegeneracy); 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 nonnegative.
 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 nontrivial 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 . 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 nonnegative.
 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 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 . 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 , or . 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 . 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.
 Defintion: 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 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=rd(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:
 Since d(x, z) < r, it follows that z ∈ B_{r}(x).
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.
 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 definitionsEdit
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 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 X such that d(p,q) < M for all p E.
 E is dense in X every point of X is a limit point of E or a point of E (or both).
Basic proofsEdit
1. Every neighborhood is an open set
 Proof: Consider a neighborhood N = . Now if q N then as d(p,q) < r we have h = d(p,q)  r > 0. Consider s . Now d(p,s) d(p,q) + d(q,s) < r  h + h = r, and so 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 contains no point q of E such that q 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 . We need to show that x . Now every neighborhood of x contains a point of so that x is not an interior point of E. Since E is open it means x E and so x . So is closed.
 Now suppose is closed. Choose x E. Then x , and so x is not a limit point of . 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.