Let XX be a set. A metric on XX is a function d:X×X→Rd:X\times X\rightarrow\mathbb{R} that assigns a distance to each pair of points and satisfies the metric axioms for all x,y,z∈X:x,y,z\in X:

d(x,y)≥0,  with  d(x,y)=0  if and only if  x=yd(x,y)\geq 0,\,\,\mathrm{with}\,\,d(x,y)=0\,\,\mathrm{if}\,\mathrm{and}\,\mathrm{only}\,\mathrm{if}\,\,x=y d(x,y)=d(y,x)d(x,y)=d(y,x) d(x,z)≤d(x,y)+d(y,z).d(x,z)\leq d(x,y)+d(y,z).

The third axiom is the triangle inequality. A metric space (X,d)(X,d) is a set equipped with a metric, and is written XX when the metric is understood. Any subset A⊆XA\subseteq X is a metric space with the restriction of dd to A×A,A\times A, the metric subspace A.A. The real numbers with d(x,y)=∣x−y∣d(x,y)=\lvert x-y\rvert and Rn\mathbb{R}^n with the Euclidean distance are metric spaces, the latter being the Euclidean space Rn.\mathbb{R}^n. Any set is a metric space under the discrete metric, which is 00 when x=yx=y and 11 otherwise.

A normed vector space is a vector space V\mathcal{V} over R\mathbb{R} or C\mathbb{C} with a function ∥⋅∥:V→R,\lVert\cdot\rVert:\mathcal{V}\rightarrow\mathbb{R}, its norm, that satisfies the norm axioms for all u‾,v‾∈V\underline{u},\underline{v}\in\mathcal{V} and scalars λ:\lambda:

∥v‾∥≥0,  with  ∥v‾∥=0  if and only if  v‾=0‾\lVert\underline{v}\rVert\geq 0,\,\,\mathrm{with}\,\,\lVert\underline{v}\rVert=0\,\,\mathrm{if}\,\mathrm{and}\,\mathrm{only}\,\mathrm{if}\,\,\underline{v}=\underline{0} ∥λ v‾∥=∣λ∣∥v‾∥\lVert\lambda\,\underline{v}\rVert=\lvert\lambda\rvert\lVert\underline{v}\rVert ∥u‾+v‾∥≤∥u‾∥+∥v‾∥.\lVert\underline{u}+\underline{v}\rVert\leq\lVert\underline{u}\rVert+\lVert\underline{v}\rVert.

The norm of an inner product space satisfies these axioms by the Cauchy-Schwarz inequality. Every normed vector space is a metric space with the induced metric d(u‾,v‾):=∥u‾−v‾∥.d(\underline{u},\underline{v}):=\lVert\underline{u}-\underline{v}\rVert. For p≥1p\geq 1 the pp-norm and the maximum norm on Rn\mathbb{R}^n are

∥x‾∥p:=(∑i=1n∣xi∣p)1p,∥x‾∥∞:=max⁡1≤i≤n∣xi∣,\lVert\underline{x}\rVert_p:=\left(\sum_{i=1}^{n}\lvert x_i\rvert^p\right)^{\frac{1}{p}},\qquad\lVert\underline{x}\rVert_\infty:=\max_{1\leq i\leq n}\lvert x_i\rvert,

of which ∥⋅∥2\lVert\cdot\rVert_2 is the Euclidean norm, ∥⋅∥1\lVert\cdot\rVert_1 is the Manhattan norm and ∥x‾∥p→∥x‾∥∞\lVert\underline{x}\rVert_p\rightarrow\lVert\underline{x}\rVert_\infty as p→∞.p\rightarrow\infty. The triangle inequality for the pp-norm is the Minkowski inequality.

Let (X,d)(X,d) be a metric space, x∈Xx\in X and r>0.r>0. The open ball, closed ball and sphere of radius rr centred at xx are the sets of points at distance less than, at most and exactly rr from x.x.

B(x,r):={y∈X:d(x,y)<r},B‾(x,r):={y∈X:d(x,y)≤r},S(x,r):={y∈X:d(x,y)=r}B(x,r):=\left\{y\in X:d(x,y)<r\right\},\qquad\overline{B}(x,r):=\left\{y\in X:d(x,y)\leq r\right\},\qquad S(x,r):=\left\{y\in X:d(x,y)=r\right\}

A set U⊆XU\subseteq X is open if every point of UU is the centre of some open ball contained in U,U, and a set F⊆XF\subseteq X is closed if its complement X∖FX\setminus F is open.

U  is open⇔∀ x∈U ∃ r>0:B(x,r)⊆UU\,\,\mathrm{is}\,\mathrm{open}\Leftrightarrow\forall\,x\in U\,\exists\,r>0:B(x,r)\subseteq U

In Rn\mathbb{R}^n with the Euclidean distance this is the earlier definition of an open set. Open balls are open and closed balls, spheres and finite sets are closed; open intervals are open in R\mathbb{R} and closed intervals are closed. A set can be both open and closed, as ∅\varnothing and XX are, or neither, as [0,1)\left[0,1\right) is in R.\mathbb{R}. Under the discrete metric every set is open. Open and closed sets have the following properties:

  • ∅\varnothing and XX are open and closed;
  • the union of any collection of open sets is open and the intersection of finitely many open sets is open;
  • the intersection of any collection of closed sets is closed and the union of finitely many closed sets is closed.

The finiteness conditions cannot be dropped: ⋂n=1∞(−1n,1n)={0}\bigcap_{n=1}^{\infty}\left(-\frac{1}{n},\frac{1}{n}\right)=\left\{0\right\} is an intersection of open sets that is not open.

Let A⊆XA\subseteq X and x∈X.x\in X. xx is an interior point of AA if some open ball centred at xx is contained in A,A, a limit point of AA if every open ball centred at xx contains a point of AA other than x,x, and an isolated point of AA if x∈Ax\in A and some open ball centred at xx contains no other point of A.A. The interior int A\mathrm{int}\,A of AA is the set of its interior points, the closure A‾\overline{A} of AA is the union of AA and its limit points and the boundary ∂A\partial A of AA is the closure without the interior.

int A⊆A⊆A‾,∂A:=A‾∖int A\mathrm{int}\,A\subseteq A\subseteq\overline{A},\qquad\partial A:=\overline{A}\setminus\mathrm{int}\,A

The interior is the largest open set contained in AA and the closure is the smallest closed set containing A,A, so AA is open if and only if A=int AA=\mathrm{int}\,A and closed if and only if A=A‾,A=\overline{A}, which holds if and only if AA contains all of its limit points. The boundary is closed and x∈∂Ax\in\partial A if and only if every open ball centred at xx meets both AA and X∖A.X\setminus A. For example, in R\mathbb{R} the interval [0,1)\left[0,1\right) has interior (0,1),\left(0,1\right), closure [0,1]\left[0,1\right] and boundary {0,1},\left\{0,1\right\}, whereas the rational numbers Q\mathbb{Q} have empty interior and closure R.\mathbb{R}. A set AA is dense in XX if A‾=X,\overline{A}=X, as Q\mathbb{Q} is in R.\mathbb{R}.

A set A⊆XA\subseteq X is bounded if it is contained in some ball, and its diameter is the supremum of the distances between its points.

diam A:=sup⁡{d(x,y):x,y∈A}\mathrm{diam}\,A:=\sup\left\{d(x,y):x,y\in A\right\}

A sequence (xn)\left(x_n\right) of points of XX converges to x∈X,x\in X, written xn→x,x_n\rightarrow x, if and only if the distances d(xn,x)d\left(x_n,x\right) converge to 00 as a sequence of real numbers.

∀ε>0 ∃N∈N:d(xn,x)≤ε  ∀ n≥N\forall\varepsilon>0\,\exists N\in\mathbb{N}:d\left(x_n,x\right)\leq\varepsilon\,\,\forall\,n\geq N

Equivalently, every open ball centred at xx contains all but finitely many terms of the sequence. A convergent sequence has exactly one limit and is bounded. In Rn\mathbb{R}^n a sequence converges if and only if each of its coordinates converges, and in a metric subspace convergence means convergence in the whole space with the limit lying in the subspace. Let n1<n2<⋯n_1<n_2<\cdots be an increasing sequence of indices. The sequence (xnk)\left(x_{n_k}\right) is a subsequence of (xn),\left(x_n\right), and every subsequence of a convergent sequence converges to the same limit.

Convergence determines the closed sets: x∈A‾x\in\overline{A} if and only if xx is the limit of a sequence of points of A,A, so AA is closed if and only if it contains the limit of every convergent sequence of its points.

Let (X,dX)\left(X,d_X\right) and (Y,dY)\left(Y,d_Y\right) be metric spaces, f:X→Yf:X\rightarrow Y be a function and x0∈X.x_0\in X. ff is continuous at x0x_0 if and only if points close to x0x_0 are mapped to points close to f(x0),f\left(x_0\right), and continuous on XX if it is continuous at every point.

∀ε>0 ∃δ>0:dY(f(x),f(x0))≤ε  ∀ x∈X, dX(x,x0)<δ\forall\varepsilon>0\,\exists\delta>0:d_Y\left(f(x),f\left(x_0\right)\right)\leq\varepsilon\,\,\forall\,x\in X,\,d_X\left(x,x_0\right)<\delta

For real functions of one or several real variables this is the earlier definition of continuity. The following are equivalent:

  • ff is continuous on X;X;
  • f(xn)→f(x)f\left(x_n\right)\rightarrow f(x) whenever xn→xx_n\rightarrow x in X;X;
  • the inverse image f−1(V)f^{-1}(V) of every open set V⊆YV\subseteq Y is open in X;X;
  • the inverse image of every closed set in YY is closed in X.X.

A composition of continuous functions is continuous. The metric d:X×X→Rd:X\times X\rightarrow\mathbb{R} is itself continuous in each argument, since ∣d(x,z)−d(y,z)∣≤d(x,y),\lvert d(x,z)-d(y,z)\rvert\leq d(x,y), and in a normed vector space the norm, addition and scalar multiplication are continuous.

ff is uniformly continuous if δ\delta can be chosen to depend on ε\varepsilon alone, Lipschitz continuous with constant L≥0L\geq 0 if dY(f(x),f(y))≤L dX(x,y)d_Y\left(f(x),f(y)\right)\leq L\,d_X(x,y) for all x,y∈Xx,y\in X and an isometry if it preserves distances, dY(f(x),f(y))=dX(x,y).d_Y\left(f(x),f(y)\right)=d_X(x,y). An isometry is injective and Lipschitz continuous with constant 1,1, and Lipschitz continuity implies uniform continuity, which implies continuity.

Two metrics dd and d′d' on XX are equivalent if they have the same open sets, which holds if and only if they have the same convergent sequences with the same limits, and strongly equivalent if there are constants 0<c≤C0<c\leq C with

c d(x,y)≤d′(x,y)≤C d(x,y)  ∀ x,y∈X.c\,d(x,y)\leq d'(x,y)\leq C\,d(x,y)\,\,\forall\,x,y\in X.

Strongly equivalent metrics are equivalent and have the same bounded sets, Cauchy sequences and uniformly continuous functions, whereas equivalent metrics need not: d′(x,y)=min⁡{1,∣x−y∣}d'(x,y)=\min\left\{1,\lvert x-y\rvert\right\} is equivalent to the usual metric on R\mathbb{R} but makes R\mathbb{R} bounded. Two norms are equivalent if their induced metrics are strongly equivalent. Any two norms on Rn\mathbb{R}^n are equivalent, since

∥x‾∥∞≤∥x‾∥2≤∥x‾∥1≤n∥x‾∥∞,\lVert\underline{x}\rVert_\infty\leq\lVert\underline{x}\rVert_2\leq\lVert\underline{x}\rVert_1\leq n\lVert\underline{x}\rVert_\infty,

so open sets, convergence and continuity in Rn\mathbb{R}^n do not depend on which norm is used.