# Show that $|f(x)-f(y)|\le d(x,y)$ for all $x,y\in M$.

Given a nonempty subset S of a metric space $(M,d)$, define $f:M\rightarrow \mathbb{R}$ by $f(x)=\inf \{ d(x,s):s\in S\}$. Show that $|f(x)-f(y)|\le d(x,y)$ for all $x,y\in M$.

So by the triangle inequality I know that $d(x,y)\le d(x,s)+d(y,s)$.

Also $f(x)\le d(x,s)$ and $f(y)\le d(y,s)$.

So $d(x,s)+d(y,s)\ge f(x)+f(y)$

Also $f(x)\le d(x,s)\implies f(x)-f(y)\le d(x,s)-f(y)$

These are the facts that I have come up with, but I fail to see how I can combine them to show that $|f(x)-f(y)|\le d(x,y)$

• Notice that your inequalities go the wrong way: $f(x)\leq d(x,s)$ for any $s\in S$ as $f(x)$ is defined by the infimum. This may help you. – Clayton Nov 11 '15 at 16:30

You have to take advantage of the infimum. Let $x \in M$ and let $s \in S$. Then $$f(x) \le d(x,s) \le d(x,y) + d(y,s).$$ Now take the infimum over all $s \in S$ corresponding to the definition of $f(y)$ to obtain $$f(x) \le d(x,y) + f(y).$$ To complete the argument just derive $f(y) \le d(x,y) + f(x)$ in an identical manner.