I don't know how to solve the following exercise:
Let $X$ be the subspace of $L^{2}(0,1)$ of a.e. constant functions. What is the projection over $X$ of a function $u \in L^2(0,1)$?
First of all, $X$ is convex, and this is trivial to prove. It's also closed. So, by the characterization of projections onto closed and convex subspace I have to find a $v \in X$ s.t.
(*) $\langle u-v,f \rangle=0$ for every $f \in X$, i.e. $\int_0^1 (u(x)-v(x))f(x)dx=0$, but $u$ and $f$ are constants, so I can't see any way to set that integral equals to $0$.
Maybe I could start by thinking about $\Vert u - v \Vert_{L^2}^2=\int_0^1|u(x)-v(x)|^2dx $ and how to minimize this integral with $v \in X$. The best I can do, I guess, is to set $v(x)=v=\max \{|u(x)|: x \in [0,1] \}$, but I still can't understand how to find a $u$ such that (*) holds.
EDIT: I need also to prove that $X$ is closed.To this aim, I take a sequence $\{ f_n \}$ in $X$ s.t. $f_n \rightarrow^{L^2} f$. I want to show that $f$ is a.e. constant. By Riesz-Fisher there exists a subsequence $\{f_{n_k} \} \in X$ such that $f_{n_k} \rightarrow f$ a.e. in $X$. How can I conclude?
The space $X$ is spanned by the constant function $1$, whose norm is $1$. Therefore, the orthogonal projection of $f$ on $X$ is $\langle u,1\rangle1$. That is, it's the constant function $\int_0^1u$.