Showing that $f$ continuous Let $A$ be a compact subset of a metric space $(X, d)$. Consider the function $f : X → R$
given by $f(x) := $ sup $ \{d(x, y) : y ∈ A\}$ . Show that $f$ is continuous.
I tried taking an open subspace of $X$ and show that its open but couldn't do it further. 
Should I use some other condition of continuous function to show this ? 
 A: Let $O \subseteq \mathbb R$ be open and $x_0 \in f^{-1}O$. The goal is to show that $f^{-1}O$ is open so we want to find an open ball around $x_0$ that is contained in $f^{-1}O$.
Since $O$ is open there exists $\varepsilon > 0$ such that $(f(x_0)-\varepsilon, f(x_0)+\varepsilon)\subseteq O$. Now let $\delta = {\varepsilon \over 2}$. Then (same argument as in the $\varepsilon$-$\delta$-definition-argument) for $x$ such that $d(x,x_0) < \delta$ and for all $a \in A$:
$$ d(x_0, a) \le d(x_0,x) + d(x,a)$$
hence 
$$d(x_0, a)- d(x,a) \le d(x_0,x) < \delta$$ 
Then take the supremum on the left hand side twice  to get $\displaystyle d(x_0, a)- \sup_{a \in A} d(x,a) \le \delta$ and also  $\displaystyle \sup_{a \in A}d(x_0, a)- \sup_{a \in A} d(x,a) \le \delta$.
Hence $f(x_0) - f(x) \le \delta < \varepsilon$. Now repeat the same argument with $x$ and $x_0$ swapped so as to get $f(x) - f(x_0) < \varepsilon$. Putting both together yields $|f(x) - f(x_0)|<\varepsilon$. 
But $|f(x) - f(x_0)|<\varepsilon$ means that $f(B(x_0, \delta)) \subseteq O$ which means that $B(x_0, \delta) \subseteq f^{-1}O$.
Hence $f^{-1}O$ is open.
$$ \Box$$

Let $x_0 \in X$ and $\varepsilon > 0$ be arbitrary. Let $\delta = {\varepsilon \over 2}$ and $x$ such that $d(x,x_0) < \delta$. Then for all $a \in A$:
$$ d(x_0, a) \le d(x_0,x) + d(x,a)$$
hence 
$$d(x_0, a)- d(x,a) \le d(x_0,x) < \delta$$ 
Then take the supremum on the left hand side twice  to get $\displaystyle d(x_0, a)- \sup_{a \in A} d(x,a) \le \delta$ and also  $\displaystyle \sup_{a \in A}d(x_0, a)- \sup_{a \in A} d(x,a) \le \delta$.
Hence $f(x_0) - f(x) \le \delta < \varepsilon$. Now repeat the same argument with $x$ and $x_0$ swapped so as to get $f(x) - f(x_0) < \varepsilon$. Putting both together yields $|f(x) - f(x_0)|<\varepsilon$ as desired. 
$$ \Box$$
