TITLE: A limit of a uniformly convergent sequence of smooth functions
QUESTION [6 upvotes]: Is it possible to uniformly approximate every continuous function $f: \mathbf{R} \rightarrow \mathbf{R}$ by smooth functions?
In other words, is it true that for each continuous function $f: \mathbf{R} \rightarrow \mathbf{R}$ there exists a sequence $(f_n)$ of smooth functions $f_n: \mathbf{R} \rightarrow \mathbf{R}$ such that $f_n \rightarrow f$, as $n\rightarrow \infty$, uniformly on $\mathbf{R}$?
Thanks.

REPLY [7 votes]: Yes.  Approximate by polynomials $p_k(x)$ on each interval $[k,k+2]$, and put them together using a smooth partition of unity: if $\phi(x)$ is a smooth function with $\phi(x) = 0$ for
$x \le 0$, $\phi(x) = 1$ for $x \ge 1$, and $0 \le \phi(x) \le 1$ for $0 \le x \le 1$, 
take $g(x) = \phi(x-k) p_k(x) + (1 - \phi(x-k)) p_{k-1}(x)$ for $k \le x \le k+1$.