Are uniformly continuous functions dense in all continuous functions? Suppose that $X$ is a metric space. Is the family of all real-valued uniformly continuous functions on $X$ dense in the space of all continuous functions with respect to the topology of uniform convergence on compact sets?
 A: Let $C(X)$ be the algebra of continuous functions endowed with the compact-open topology.
Notice that the functions $d_x : X \to [0, \infty)$ given by $d_x (y) = \min( d(x,y), 1)$ separate the points of $X$: if $d_x (p) = d_x (q)$ for all $x \in X$, taking $x = p$ gives $d_p(q) = 0$, whence $d(p,q) = 0$.
The functions $d_x$ are Lipschitz (with Lipschitz constant $1$). There are 3 cases to examine:


*

*if $d(x,y) \le 1$ and $d(x,z) \le 1$, then $| d_x(y) - d_x(z) | = |d(x,y) - d(x,z)| \le d(y,z)$ by the triangle inequality;

*if $d(x,y) \le 1$ and $d(x,z) > 1$ then
$$| d_x(y) - d_x(z) | = 1 - d(x,y) \le d(x,z) - d(x,y) \le d(y,z)$$
again by the triangle inequality; similarly for $d(x,y) > 1$ and $d(x,z) \le 1$;

*if $d(x,y) > 1$ and $d(x,z) > 1$ then $| d_x(y) - d_x(z) | = | 1 - 1 | = 0 \le d(y,z)$.
Remember now that the sum and product with scalars of Lipschitz functions are again Lipschitz, and that the product of bounded Lipschitz functions (and the $d_x$ are bounded) is again Lipschitz (of course, the Lipschitz constant changes).
Consider the subalgebra $A$ of $C(X)$ generated by the family $(d_x)_{x \in X}$ and the constant function $1$. By the preceding paragraph it will be made only of Lipschitz functions. Using the version of the Stone-Weierstrass theorem for the compact-open topology (Stephen Willard, "General Topology", 1970, p. 293, par. 44B.3), the closure of $A$ is $C(X)$, so you get that not only uniformly continuous, but even Lipschitz functions are dense in $C(X)$
A: Yes, and even more is true. The argument is as follows: let $f\colon X \to \mathbb R$ be a continuous function and let $K\subset X$ be a compact set. Then $f|_K$ is uniformly continuous; let $\omega$ be its nondecreasing subadditive modulus of continuity. By McShane-Whitney's extension formula $f|_K$ admits a uniformly continuous extension to $X$ with the same modulus - more concretely, $$F(x)=\inf\{f(k)+\omega(d(k,x))\colon k\in K\}$$ is this extension which is uniformly continuous on the whole $X$.
A: Yes. For any compact subset $K\subset X$ consider a uniformly continuous extension of $f_{|K}$ (there is such an extension even with the same subadditive modulus of continuity, see here). This shows that the uniformly continuous functions on $X$ are a dense subspace of $C(X)$ in the topology of uniform 
convergence on compacta.
