# Approximating compactly supported $L^2$ functions with Schwartz functions "from within"?

It is well known that the class of Schwartz functions $$\mathcal{S}$$ in dense in all $$L^p$$ spaces therefore for each $$f \in L^2$$ there exists a sequence of Schwartz functions $$(f_k)$$ such that $$\lVert f - f_k \rVert_{L^2} \to 0$$ as $$k \to \infty$$.

If we suppose further that $$f$$ has compact support can we find a sequence of Schwartz functions $$(f_k)$$ such that $$\lVert f - f_k \rVert_{L^2} \to 0$$ as $$k \to \infty$$ (as above) and additionally $$\operatorname{supp}(f_k) \subseteq \operatorname{supp}(f)$$ for all $$k$$?

• Yes, we can. Meanwhile, this sort of question is best suited for MathStackExchange... This site is for fancier things. :) Dec 5, 2020 at 22:27
• Is there any theorem I can appeal to show this easily? Also I guess I'll post on MathStackExchange first next time. Dec 5, 2020 at 22:36
• @paulgarrett: What if $f = 1$ on a fat Cantor set and $f = 0$ otherwise? I do not think there is a non-zero Schwartz class function supported in a fat Cantor set... Dec 5, 2020 at 22:49
• @MateuszKwaśnicki, we might be surprised... Dec 6, 2020 at 1:55

No, this is not possible, even if you define $$\text{supp}(f)$$ only as an equivalence class (up to a null set). For a counterexample take the characteristic function $$f$$ of a closed set $$E$$ of positive measure but without interior points (like that fat Cantor set which Mateusz mentioned).
Indeed, if $$f_n$$ is a continuous function with $$\text{supp}(f_n)\subseteq\text{supp}(f)\cup N=E\cup N$$ for some null set $$N$$, then $$f_n=0$$, because otherwise $$E\cup N$$ would have to contain some interval $$(a,b)$$ which must contain a point from the complement of $$E$$ and which after shrinking (since $$E$$ is closed) can thus be assumed to lie completely in the complement of $$E$$, hence $$N\supseteq(a,b)$$, a contradiction.