Why this set is dense in $C_0(\mathbb{R})$? Let $C_0=\{f~|~ f:\mathbb{R}\to\mathbb{R}, \textrm{$f$ is continuous},\lim\limits_{\vert x\vert \to\infty}f(x)=0\}$
$A=\{f~|~f(x)=p(x)e^{-x^2}, \textrm{$p(x)$ is polynomials}\}$
Why $A$ is dense in $C_0$?
The topology induced by the supremum metric $d(f,g)=\sup\limits_{x\in\mathbb{R}}|f(x)-g(x)|$.
 A: Well, functional analysis provides very natural set up for dealing with this question.
We will prove the same for $$A_{c(x)}:= \left \{p(x) e^{-c(x)} \right\}$$
Where $c(x)$ is a fixed even degree polynomial with positive leading coefficient and of degree $\ge 2$ and $p(x)$ is any polynomial.
Note that we need to prove that $A_{c(x)}$ is dense in $C_0 (\mathbb R)$. Else, by the Hahn-Banach Theorem, there would exist a nonzero functional $\mathcal{K}$ which would be zero on $A_{c(x)}$.
By Riesz–Markov–Kakutani representation theorem (referring to Rudin, Real and Complex analysis), $\ \mathcal{K}(f) = \int_{\mathbb R} f \, \text{d} \mu$ for some real measure $\mu$. Thus $\int_{\mathbb R} p(x) e^{-c(x)} \, \text{d} \mu = 0$ for every polynomial $p(x)$. Writing $\mu$ as $\mu_1 - \mu_2$ where $\mu_1, \mu_2$ are positive finite measures we have $\int_{\mathbb R}  p(x) e^{-c(x)} \, \text{d} \mu_1 = \int_{\mathbb R}  p(x) e^{-c(x)} \, \text{d} \mu_2$.
Define the measure $\nu_i := \int_{\mathbb R}  e^{-c(x)} \text{d} \mu_i $ for $i= 1,2$. Then we have $\int_{\mathbb R}  p(x) \text{d} \nu_1 = \int_{\mathbb R}  p(x) \text{d} \nu_2  $ for every polynomial $p(x)$. (*)

Now Define $ \Phi_i(z) := \int _{\mathbb R} e^{zt} \, \text{d} \nu_i (t)$ for $z \in \mathbb C$ and $i=1,2$. It is easy to check that $\Phi_1, \Phi_2$ are entire functions (Here you actually use that $c(x)$ is in fact an even degree polynomial of degree $\ge 2$  with positive leading coefficient.).

Now by  (*) we have $\Phi_1 ^{(n)} (0) = \Phi_2 ^{(n)} (0) $ for all $n \ge 0$. So their power series representations are identical, hence they are identical as functions, i.e., $\Phi_1(z) = \Phi_2(z)$.
So in particular, for any $s \in \mathbb R$, $\Phi_1( i s) = \Phi_2 (is)$, i.e., $ \int _{\mathbb R} e^{ist} \, \text{d} \nu_1 (t) = \int _{\mathbb R} e^{ist} \, \text{d} \nu_2 (t)$. This implies that $\nu_1 = \nu_2$ (by Inversion theorem), which implies $\mu_1 = \mu_2$.
Therefore $\mu = 0$, so the functional $\mathcal K$ must be zero, contrary to our assumption. This completes the proof.
A: Let $f$ be an element of $C_0$, for every $c>0$, there exists $n_0$ such that $\mid x\mid>n_0$ implies that $\mid f(x)\mid <c/4$. Stone-Weirstrass applied to $C([-n_0,n_0])$ implies that there exists a polynomial $p$ such that $\|f(x)-p(x)\|<c/4$ for $\mid x\mid<n_0$. You have $p=e^{-x^2}(e^{x^2}p)$. By multiplying the analytic development of $e^{x^2}$ by $p$,  you can write $e^{x^2}p=lim p_i$ where $p_i$ is a polynomial. There exists $i$ such that $\| p-e^{-x^2}p_i\|<c/4$ on $[-n_0,n_0]$.
There exists $n_1$ such that $\mid x\mid>n_1$ implies that $\mid e^{-x^2}p_i\mid<c/4$.
You can suppose that $n_1<n_0$, or we replace $n_1$ by $n_0$.
Let $\mid x\mid\leq n_0$, you have $\mid f(x)-e^{-x^2}p_i(x)\mid\leq \mid f(x)-p(x)\mid+\mid p(x)-e^{-x^2}p_i\mid <c/4+c/4<c$.
Suppose that $\mid x\mid >n_2$, $\mid f(x)-e^{-x^2}p_i(x)\mid<\mid f(x)\mid+\mid e^{-x^2}p_i\mid<c/4+c/4$.
