Q:

Determine the orthogonal projection of $L^2$ onto $\left\{f\in L^2:\int f=0\right\}$

Let $(\Omega,\mathcal A,\mu)$ be a probability space and $$L^2_0(\mu):=\left\{f\in L^2(\mu):\int f\:{\rm d}\mu=0\right\}.$$ It's easy to see that if $c\in\mathbb R\setminus\{0\}$, then $$c\perp_{L^2(\mu)}f\Leftrightarrow\langle c,f\rangle_{L^2(\mu)}=0\Leftrightarrow\int f\:{\rm d}\mu=0\Leftrightarrow f\in L^2_0(\mu)\tag1$$ for all $f\in L^2(\mu)$ and hence $$\{c\}^\perp=L^2_0(\mu).\tag2$$

Now let $\pi_0$ denote the orthogonal projection from $L^2(\mu)$ onto $L^2_0(\mu)$. I'm confused by the following: $\operatorname{id}_{L^2(\mu)}-\pi_0$ should be the orthogonal projection from $L^2(\mu)$ onto ${L^2_0(\mu)}^\perp=\{c\}^{\perp\perp}=\overline{\{c\}}=\{c\}$, but this seems to be strange since $c$ was arbitrary. What am I missing?

A:

(1)
For $\pi_0$, observe that
\begin{align*}
f=c_f+(f-c_f),
\end{align*}
where $c_f=\int_{\Omega} f d\mu$ is the average of $f$ (assuming $\mu(\Omega)=1$).
To claim $\pi_0(f)=f-c_f$, we have to check that $f-c_f\in L^2_0(\mu)$ and 
\begin{align*} f-c_f\perp c_f, \end{align*}
which are left to you. 
(2)
$(M^{\perp})^{\perp}=\bar{M}$ only works when $M$ is a vector space. For example, in $\mathbb{R^2}$, 
\begin{align*}
((1,1)^{\perp})^{\perp}=\{(x,y)|x-y=0\}\neq\{(1,1)\}.
\end{align*}

