If $S \subseteq X$ is closed, is $f(S,r)$ necessarily closed?

The answer is no.

Let $S=\{1-\frac{1}{n}\}_{n=1}^\infty$. Let $X$ be the set $S\cup [1.5,2]$ with its subspace metric. Then $f(S,1)=S\cup [1.5,2)$ is not closed in $X$ since it is not of the form $C\cap X$ for some closed set $C$ of the reals.

We indeed see that $S$ is not a compact subset of $X$, in align with William's result.


If in addition $C$ is compact, then the following proof shows $f(C,r)$ is closed for each positive real number $r$.

Suppose $z$ is a limit point of $f(C,r)$. For all $n$, find some $x_n \in f(C,r)$ and $c_n \in C$ such that $d(x_n, c_n) \leq r$ and $d(x_n, z) \leq \frac{1}{n}$. Hence by the triangle inequality, $d(z, c_n) \leq r + \frac{1}{n}$. By sequential compactness, there is a subsequence of $\{c_n : n \in \omega\}$ which converges. To avoid notation, let just suppose the subsequence was just $\{c_n : n \in \omega\}$ and it coverges to the point $c$. Since $C$ is closed, $c \in C$. Let $\epsilon > 0$. Choose $N$ large such that for all $m > N$, $d(c, c_m) < \frac{\epsilon}{2}$ and $\frac{1}{N} < \frac{\epsilon}{2}$. Then $d(z,c) \leq r + d(z, c_m) + d(c_m, c) = r + \frac{1}{m} + \frac{\epsilon}{2} \leq r + \frac{1}{N} + \frac{\epsilon}{2} \leq r + \frac{\epsilon}{2} + \frac{\epsilon}{2} = r + \epsilon$. Since $\epsilon$ is arbitrary, $d(z,c) \leq r$. Hence $z \in f(C,r)$.

This seems to show that if $C$ is a compact set, then $f(C,r)$ is closed. At the moment, I am not sure whether or not being just closed is enough.