Schwartz functions dense in weighted $L^p$ space? Upon learning about Schwartz functions, one result that is usually presented to students is that not only are Schwartz functions dense in $L^2(\mathbb{R}^n)$ but in $L^p(\mathbb{R}^n)$ for all $1 \le p < \infty$. Here, $L^p(\mathbb{R}^n)$ is the standard $L^p$ space with respect to Lebesgue measure.
With how nicely Schwartz functions behave (with their smooth rapid decay), does this result extend to weighted $L^p$ spaces? For instance, suppose we have a weight $w \in A_p$ ($1 < p < \infty$) where $A_p$ is the class of Muckenhoupt weights of parameter $p$. Let $L^p(w)$ be the space of Lebesgue measurable functions over $\mathbb{R}^n$ such that 
$$ \| f\|_{L^p(w)} = \left( \int_{\mathbb{R}^n} |f(x)|^p w(x) \,dx \right)^{1/p} < \infty$$
(so by taking $w=1$, we get back to standard $L^p$ space.)
Can we say Schwartz functions are still dense in $L^p(w)$? 
 A: First, we should replace $w$ by an suitable modifcation such that $1 \in L^1(w)$.
If $\omega$ is locally integrable (that's the case for Muckenhoupt weights), we may take smooth partition of unity $(u_m)_{m \in \mathbb{Z}^n}$ with $\mathrm{supp} \ u_m \subset [-1,1]^n + m$. Define 
$$\tag{1} u(x) := \sum_{n \in \mathbb{Z}^d} \frac{1}{2^{\|m\|_2^2} (1+w_m)}   u_m(x),$$
where $w_m = \int_{[-1,1]^n+m} w(x) \, dx$. The function (1) is smooth and non-negative. Moreover let $\widetilde{w}(x) = w(x) u(x)^p $.

Then $f \in L^p(w)$ if and only if $f/u \in L^1(\widetilde{w})$.

If for any $g \in L^p(\widetilde{w})$ there exists at least one $h \in C_c^\infty(\mathbb{R}^n)$ with $\|f-h\|_{L^p(\widetilde{w})} < \varepsilon$, then we can take $g= f/u \in L^p(\widetilde{w})$ if $f \in L^p(w)$ to get an $h \in C_c^\infty(\mathbb{R}^n)$ with $$\|f-hu\|_{L^p(w)} =\|g- h\|_{L^p(\widetilde{w})} < \varepsilon.$$
Note that $hu \in C_c(\mathbb{R}^n)$. Since $$ \int u(x)^p w(x) dx \le C \sum_{m \in \mathbb{Z}^n} \frac{1}{2^{\|m\|_2^2 p/2}} \frac{w_m}{1+w_m}  <\infty$$
we also have $1 \in L^1(w)$.

We are left to prove that the statement is true for $\widetilde{w}$. We write $w$ instead of $\widetilde{w}$. 

We only need that $1 \in L^1(w)$. By the dominated convergence theorem, we can chose $R>0$ such that
$$\int |f(x)|^p w(x) (1_{\{|f|>R\}}+1_{\{|x|>R\}}) \, dx < \varepsilon^p.$$
Set $g(x) = f(x) 1_{\{|x| \le R, |f| \le R\}}$. Then $\|f-g\|_{L^p(\omega)} \le \varepsilon$. So we may work with $g$ instead of $f$. 
Let $h \in C_c^\infty(\mathbb{R}^n)$ be non-negative with $\int h(y) dy = 1$ and $\mathrm{supp} \ h \subset [-1,1]^n$. Set $h_\delta(y):= \delta^{-n} h(y/\delta)$ (Approximation to the identity) and define
$$g_\delta(x) := \int h_\delta(x-y) g(y) dy.$$
Then $g_\delta$ is smooth and has compact support. ($g$ is bounded and has bounded suport.) Now we have $g_\delta(x) \rightarrow g(x)$ for almost all $x \in \mathbb{R}^n$ by Lebesgue's differentiation theorem. Since $|g_\delta| \le R$ and $1 \in L^1(w)$ we can apply the dominated convergence theorem (in $L^p(w)$) again to see that there exists $\delta>0$ with $\|g-g_\delta\|_{L^p(w)} < \varepsilon$.
