Prove that smooth compactly supported functions are dense in \(L^2(\mathbb{R}^n)\).
Solution
Let \(f\in L^2(\mathbb R^n)\) and let \(\varepsilon>0\).
First truncate both the domain and the size of \(f\). Define \[ f_N(x):=f(x)\mathbf1_{B(0,N)}(x)\mathbf1_{\{|f(x)|\le N\}}. \] Then \[ |f-f_N|^2\to0 \] pointwise and \[ |f-f_N|^2\le |f|^2\in L^1. \] By dominated convergence, \[ \|f-f_N\|_2\to0. \] Choose \(N\) so large that \[ \|f-f_N\|_2<\frac\varepsilon2. \] The function \(f_N\) is bounded and compactly supported, hence belongs to both \(L^1\) and \(L^2\).
Now let \(\rho\in C_c^\infty(\mathbb R^n)\) be a standard mollifier with \(\rho\ge0\) and \(\int\rho=1\), and set \[ \rho_\delta(x)=\delta^{-n}\rho(x/\delta). \] Then \[ \varphi_\delta:=f_N*\rho_\delta \] belongs to \(C_c^\infty(\mathbb R^n)\). Moreover, \[ \begin{aligned} \|\varphi_\delta-f_N\|_2 &=\left\|\int \rho_\delta(y) \bigl(f_N(\cdot-y)-f_N(\cdot)\bigr)\,dy\right\|_2\\ &\le \int \rho_\delta(y) \|\tau_y f_N-f_N\|_2\,dy. \end{aligned} \] Translations are continuous in \(L^2\), so the last expression tends to \(0\) as \(\delta\downarrow0\). Choose \(\delta\) so small that \[ \|\varphi_\delta-f_N\|_2<\frac\varepsilon2. \]
Therefore \[ \|f-\varphi_\delta\|_2 \le \|f-f_N\|_2+\|f_N-\varphi_\delta\|_2 <\varepsilon. \] Thus \(C_c^\infty(\mathbb R^n)\) is dense in \(L^2(\mathbb R^n)\).