# How to prove the continuity of the metric function?

Given a metric space $(X,d)$, how to prove that the function $d \colon X \times X \to \mathbf{R}$ is continuous?

If we take any two arbitrary real numbers $a$ and $b$ such that $a < b$, then we need to show that the set $d^{-1} (a,b)$ given by

$$d^{-1} (a,b) := \{ (x, y) \in X \times X | a < d(x,y) < b \}$$

is open in the product topology on $X \times X$.

A basis for this product topology is the collection of all cartesian products of open balls in $(X,d)$.

• Commented Jul 26, 2017 at 7:39

For $$a, b ∈ \mathbb{ℝ}$$ such that $$a < b$$, let the ordered pair $$x \times y ∈ d^{-1} \big( (a..b) \big)$$, that is, let $$x \times y \in X \times X$$ such that $$a < d(x,y) < b. \tag{0}$$ Now choose a real number $$ε$$ such that $$U_{2ε} (d(x,y)) \subset (a..b)$$, that is, choose $$\epsilon$$ such that $$0 < \epsilon < \frac{1}{2} \min \big\{ d(x, y) -a, \, b - d(x, y) \big\}. \tag{1}$$ Now we show that $$B_d (x ; \epsilon ) \times B_d( y ; \epsilon) \subset d^{-1} \big( (a, b) \big), \tag{2}$$ where $$B_d(x; \epsilon ) := \{ p \in X \colon d(p, x) < \epsilon \}. \tag{Definition 0}$$

For any ordered pair $$x' \times y' ∈ B_d (x ; \epsilon ) \times B_d( y ; \epsilon)$$, you have $$d\left(x',y' \right) ≤ d(x',x) + d(x,y) + d(y,y') < d(x,y) + 2ε < b. \tag{3}$$ Also $$d(x,y) ≤ d(x,x') + d(x',y') + d(y',y) < d(x',y') + 2ε,$$ which implies $$a < d(x, y) - 2ε < d(x',y'). \tag{4}$$ From (3) and (4), we get $$a < d(x,y) - 2ε < d(x',y') < d(x,y) + 2ε < b,$$ that is, $$d(x',y') \in (a, b).$$ Therefore (2) above holds.

Thus we have shown that, for any point $$x \times x \in X \times X$$ such that $$x \times y \in d^{-1} \big( (a, b) \big)$$, there exists a basic open set $$B := B_d (x ; \epsilon ) \times B_d( y ; \epsilon)$$ for the product topology on $$X \times X$$ induced by the $$d$$-metric topologies on both the factors $$X$$ such that $$x \times y \in B \subset d^{-1} \big( (a, b) \big).$$ Hence $$d^{-1} \big( (a, b) \big)$$ is an open set in the product space $$X \times X$$.

Thus for every open interval $$(a, b)$$ on the real line $$\mathbb{R}$$ (with the usual topology) the inverse image set $$d^{-1} \big( (a, b) \big)$$ is also an open set in the product space $$X \times X$$. So the function $$d \colon X \times X \longrightarrow \mathbb{R}$$ is continuous.

• Sorry, I didn't recognize the notation, but by $(a..b)$ do you mean the set of all real numbers from $a$ to $b$ exclusive (i.e. the open interval)? Commented Jul 16, 2016 at 21:07
• Yeah, it’s a notation introduced by Knuth, I believe. It’s quite handy. It avoids the confusion of regarding $(a,b)$ both as a tuple and as an open interval. See the good notations thread on mathoverflow. Commented Jul 17, 2016 at 17:53
• So in the metric space $X$, we can take any point $x, y$ such that $d(x,y)=k$ with any given $k \in R$ ? Commented Jan 2, 2021 at 17:21
• @RopuToran No, why would you think that? In ℚ, you find no two points with distance exactly $\sqrt 2$. Commented Jan 3, 2021 at 13:28

Let $$(x,y)\in d^{-1}(a,b)$$. Define $$\epsilon=\frac{1}{100}\min(d(x,y)-a,b-d(x,y))$$. Then for any point $$(\xi,\gamma)\in B(x,\epsilon)\times B(y,\epsilon)$$, we have $${\color{blue} d(\xi,\gamma) }\leq d(\xi,x)+d(x,y)+d(y,\gamma)<2\epsilon+d(x,y)<{\color{blue}b}$$ and $${\color{blue} a} That is to say $$(x,y)\in B(x,\epsilon)\times B(y,\epsilon)\subseteq d^{-1}(a,b).$$

Hence any point $$(x,y)\in d^{-1}(a,b)\subseteq X\times X$$ is surrounded by some open set contained in $$d^{-1}(a,b)$$.

(After typing this answer, I realized this is EXACTLY the same as the answer by @k.stm; so thanks also to his contribution. I guess it will be hard to write a different one.)