# Distance function is continuous in topology induced by the metric

The question is (from Topology without tears) that: Let $(X,d)$ be a metric space and $\tau$ the corresponding topology on $X$. Fix $a \in X$. Prove that the map $f:(X,\tau) \rightarrow \mathbb{R}$ defined by $f(x) = d(a,x)$ is continuous.

My first attempt was that let an open ball, $B_{\epsilon}(a)\subset \mathbb{R}$ and show that $f^{-1}(B_{\epsilon}(a)) \subset \tau$. Since $f(x) = d(a,x)$, $f^{-1}(B_{\epsilon}(a))=B_{\epsilon}(a) \in \tau$.

I am pretty sure the last sentence is wrong. I am not sure if every open ball is an open set in topology induced by metric space.

Please give me some hint and direction. Thanks

• It suffices to show that $\{f < \alpha \}$ is open for $\alpha \geq 0$. What does $\{f < \alpha\}$ mean in terms of $d$ and $a$? More explicitly, what $x \in X$ satisfy that $f(x) < \alpha$? iNow is this set open? Feb 1, 2016 at 9:20

Not sure why you use $a$ both for elements in $\mathbb R$ and in $X$. Note by triangle inequality,

$$d(x, a)\le d(x, y)+ d(y, a)\Rightarrow d(a, x) - d(a, y)\le d(x, y)$$

Interchanging the role of $x, y$ and use $f(x) = d(a, x)$ we have

$$\tag{1}|f(x) - f(y)|\le d(x, y).$$

This inequality is sufficient for us to condlude that $f$ is continuous. Let $U$ be open in $\mathbb R$. Let $x\in f^{-1}(U)$. Then $f(x) \in U$ and there is $\epsilon>0$ so that $(f(x) -\epsilon, f(x) + \epsilon) \subset U$, as $U$ is open. Then if $y\in B_\epsilon(x)$, then $d(x, y)<\epsilon$ and by $(1)$,

$$|f(x) - f(y)|<\epsilon \Rightarrow f(y) \in (f(x)-\epsilon, f(x) +\epsilon)\subset U.$$

This implies $B_\epsilon(x) \subset f^{-1}(U)$. Thus $f^{-1}(U)$ is open and so $f$ is continuous.