I have that $E=\{e_1,e_2\}^\perp$, and that $(e_n)_{n=1}^\infty$ is an orthonormal basis for the Hilbert space. Furthermore, I have that $P_Eh$ is called orthogonal projection of $h$ onto $E$.
I have to show that: $$P_Eh=h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2\quad\forall h\in H,$$ where $H$ is the Hilbert space.
I think I can use that $P_Eg=\sum_{n=1}^N\langle g,e_n\rangle e_n$,but I'm quite stuck, so any help would be greatly appreciated.
In my notation, $\langle\bullet,\bullet\rangle$ is linear in the first variable and anti-linear in the second variable. Let $Q:H\to H$ be defined by $$ Qh=h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2$$ for all $h\in H$. Note that $Q$ is hermitian because
Next, we prove that $Q$ is a projection. That is, $Q^2=Q$. To show this, let $h\in H$ be arbitrary. We have
Now, observe that $Qe_k=e_k$ for $k=3,4,5,\ldots$ but $Qe_1=Qe_2=0$. Therefore, for any $h\in H$, $Qh\perp e_1$ and $Qh\perp e_2$. This is because
for $k=1,2$, so $Qh\in \{e_1,e_2\}^\perp =E$. This proves that $\operatorname{im}Q\subseteq E$. The final task to show that for any $h\in E$, $Qh=h$, and this establishes the claim that $\operatorname{im} Q=E$. That is, $Q=P_E$. To see this, we suppose that $h\in E$. Thus, $h\perp e_1$ and $h\perp e_2$, so $\langle h,e_1\rangle=\langle h,e_2\rangle=0$. That is,
I think it is generally true that if $\{e_1,e_2,e_3,\ldots\}$ is an orthonormal basis of a separable Hilbert space $H$ and $P$ is the orthogonal projection onto a closure of the subspace spanned by $\{e_k:k\in A\}$, where $A$ is a subset of $\Bbb N_1$, then $$Ph=\sum_{k\in A}\langle h,e_k\rangle e_k=h-\sum_{k\in \Bbb N_1\setminus A} \langle h,e_k\rangle e_k$$ for all $h\in H$. In other words, $P$ is the projection onto the orthogonal complement of $\{e_k:k\in\Bbb{N}_1\setminus A\}$.