# For which $f \in L^2([0,1])$ is $f^\perp \cap C^\infty$ dense in $f^\perp$?

Given $f \in L^2([0,1])$, $f \neq 0$, we can consider the orthogonal complement $f^\perp$ . The smooth functions $C^\infty([0,1])$ are dense in $L^2([0,1])$. Is the intersection $f^\perp \cap C^\infty([0,1])$ dense in $f^\perp$? If not, can we find a counterexample, and find conditions on $f$ such that the statement is true?

The following question and answer generalizes to show that the statement holds for any smooth, strictly positive function.

In general the problem amounts to showing that for any $g \in f^\perp$ there exists a sequence of smooth functions $g_n \in f^\perp$ such that $||g-g_n|| \to 0$. I've tried using the Fourier basis, to move the problem into $\ell^2$, and construct $g_n$ as a finite sequence (to guarantee smoothness) with the proposed properties. My attempts so far:

Let $\{ \phi_k \}$ denote the Fourier basis of $L^2([0,1])$, such that $f = \sum_{k} c_k \phi_k$, and $g = \sum_k d_k \phi_k$, where $g \in f^\perp$. Define $g_n = \sum_{k = - n}^n d_k^n \phi_k$ for some coefficients $d_k^n$, then $g_n$ is smooth. Choose the coeffients as $$d_k^n = \begin{cases} 0, & |k| > n \\ d_k, & c_k = 0, |k| \leq n \\ d_k - \frac{\sum_{|j| \leq n} c_j d_j}{(2n+1) c_k},& c_k \neq 0, |k| \leq n \end{cases}$$

A direct calculation show that $g_n \in f^\perp$. Showing that $g_n \to g$ amounts to show that the fraction in the definition of the coefficients goes to zero as $n \to \infty$. The numerator goes to zero since $\langle g,f \rangle = 0$. The problem is that $c_k \to 0$, so I have to estimate the fraction by something which goes to zero, and for this I have been unsuccesful. Could the approach be modified to work?

$f^\perp\cap C^\infty([0,1])$ is dense in $f^\perp$.
Indeed, given a closed finite codimensional subspace $M$ of a normed space $X$ and a dense subspace $V$ of $X$, the intersection $V\cap M$ is dense in $M$. See IV.2.8 Lemma in S. Goldberg "Unbounded linear operators". McGraw-Hill, 1966.
Not sure if I understand something wrong but here is a proposal: Let $f_n$ and $g_n$ be sequences of smooth functions converging to $f$ resp. $g \in f^\perp$. Now define $h_n=g_n-\frac{\langle f,g_n \rangle}{\langle f,f_n \rangle}f_n$. Obviously $h_n \in f^\perp$ and $h_n$ smooth. We have $$\|h_n-g\|\leq \|g_n-g\|+\frac{|\langle f,g_n \rangle|}{|\langle f,f_n \rangle|}\|f_n\|.$$ Now notice that $\|g_n-g\|\rightarrow 0$, $\langle f,g_n\rangle \rightarrow \langle f,g \rangle=0$, $\langle f,f_n\rangle \rightarrow \langle f,f \rangle>0$ and $\|f_n\|\rightarrow \|f\|$. Hence the RHS (and therefore also the LHS) converges to zero.