TITLE: The Schwartz Class is dense in $L^p$
QUESTION [8 upvotes]: Is there any hint to prove that for every 
$1 \le p < \infty $ the Schwartz Class is dense in $L^p$?
Thanks so much.

REPLY [2 votes]: Let $f$ be a continuous function with compact support. Because such functions are dense in $L^p, 1\le p <\infty,$ it's enough to show $f$ can be approximated by Schwartz functions in all of these $L^p$ spaces.
Suppose $f$ is supported in $[-a,a].$ Let $\epsilon>0.$ By Weierstrass, there is a polynomial $q$ such that $|q-f|<\epsilon$ in $[-a,a].$
Define the functions
$$\begin {cases}\varphi_n(t) = \exp (1/[n(t^2-a^2)]),& t\in (-a,a)\\ 0, & |t| \ge a\\ \end {cases}$$
Each $\varphi_n$ is positive on $(-a,a)$ with support $[-a,a].$  We also have $\varphi_n \in C^\infty(\mathbb R),$ bounded by $1$ everywhere, and $\varphi_n \to\chi_{(-a,a)}$ pointwise everywhere. Of course each $\varphi_n$ is in the Schwartz space.
Now $q\varphi_n$ extends to be in $C_c^\infty(\mathbb R)$ in the obvious way. Thus
$$\int_{\mathbb R}|q\varphi_n - f|^p = \int_{-a}^a |q\varphi_n - f|^p \le 2^{p-1}\left (\int_{-a}^a |q\varphi_n - q|^p + \int_{-a}^a |q-f|^p\right ).$$
If $n$ is large enough, the last integral is less than $2a\epsilon^p,$  and this is enough for what we want.