How can I show that the space of smooth functions with compact support, $C^{\infty}_K$, is dense in the space of continuous functions vanishing at infinity equipped with the supremum norm, $(C_0,|| \cdot ||_{\infty})$ ?
I already know that the space of continuous functions with compact support, $C^0_K$, is dense in $C_0$, so it suffices to show that $C^{\infty}_K$ is dense in $C^0_K$.
Best Answer
I'll assume we are talking about functions on the real line. Fix $f\in C_0(\mathbb R)$. The fact that $f$ is $C_0$ allows us to write it as a uniform limit of continuous functions with compact support$^1$. So now we can assume without loss of generality that $f$ is continuous with compact support.
Start with $h_0(x)=\begin{cases}e^{-1/x^2},&\ x>0\\0,&\ x\leq0\end{cases}$.
Next you notice that $h(x)=h_0(x)h_0(1-x)\in C^\infty_K$, with support in $[0,1]$. We can normalize it so that $\int_{\mathbb R} h=1$. Then, for each $\varepsilon>0$, you take $$ h_\varepsilon(x)=\frac1\varepsilon\,h\left(\frac x\varepsilon\right) $$ and you note that $\int_{\mathbb R}h_\varepsilon=\int_{\mathbb R}h=1$.
Now form the convolutions $$ f_\varepsilon(x)=\int_{\mathbb R}f(t)\,h_\varepsilon(x-t)\,dt. $$ It is not hard to show that because $h_\varepsilon\in C^\infty$ we have $f_\varepsilon\in C^\infty$; and because $f$ and $h_\varepsilon$ have compact support, so does $f_\varepsilon$.
Finally, given $\varepsilon>0$, as $f$ is continuous with compact support, it is uniformly continuous. So given $c>0$ there exists $\delta>0$ such that $|f(x)-f(y)|<c$ if $|x-y|<\delta$. Then \begin{align*} |f_\varepsilon(x)-f(x)|&=\left|\int_{\mathbb R} [f(x-t)-f(x)]\,h_\varepsilon(t)\,dt\right| \leq\int_{\mathbb R} |f(x-t)-f(x)|\,h_\varepsilon(t)\,dt\\ &\leq c\,\int_{|t|<\delta} h_\varepsilon(t)\,dt +2\|f\|_\infty\,\int_{|t|\geq\delta}h_\varepsilon(t)\,dt\\ &=c +2\|f\|_\infty\,\int_{|t|\geq\delta}h_\varepsilon(t)\,dt. \end{align*} with $\delta$ fixed, the last integral goes to zero as $\varepsilon\to0$ (because the support of $h_\varepsilon$ is contained in $[0,\varepsilon]$). Thus $$ \limsup_{\varepsilon\to0}|f_\varepsilon(x)-f(x)|\leq c $$ for all $x$ and all $c>0$. So $\|f_\varepsilon-f\|_\infty\to0$.