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?