Show that $P_Eh=h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2$ 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.
 A: 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

\begin{align}\langle Qu,v\rangle &=\big\langle u-\langle u,e_1\rangle e_1-\langle u,e_2\rangle e_2,v\big\rangle\\&=\langle u,v\rangle -\langle u,e_1\rangle \langle e_1,v\rangle -\langle u,e_2\rangle \langle e_2,v\rangle\\&=\langle u,v\rangle -\langle u,e_1\rangle \overline{\langle v,e_1\rangle} -\langle u,e_2\rangle \overline{\langle v,e_2\rangle}\\&=\big\langle u,v-\langle v,e_1\rangle e_1-\langle v,e_2\rangle e_2=\langle u,Qv\rangle.\end{align}

Next, we prove that $Q$ is a projection.  That is, $Q^2=Q$.  To show this, let $h\in H$ be arbitrary.  We have

\begin{align} Q^2h&=Q(Qh)=Q\big(h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2\big)\\&=Qh-\langle h,e_1\rangle Qe_1-\langle h,e_2\rangle Qe_2\\&=Qh-\langle h,e_1\rangle \big(e_1-\langle e_1,e_1\rangle e_1-\langle e_1,e_2\rangle e_2\big) -\langle h,e_2\rangle \big(e_2-\langle e_2,e_1\rangle e_1-\langle e_2,e_2\rangle e_2\big) \\&=Qh-\langle h,e_1\rangle (e_1-e_1-0)-\langle h,e_2\rangle (e_2-0-e_2\rangle\\&=Qh-\langle h,e_1\rangle \cdot 0-\langle h,e_2\rangle\cdot 0= Qh.\end{align}

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 

$$\langle Qh,e_k\rangle =\langle h,Qe_k\rangle =\langle h,0\rangle =0$$ 

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,

 $$Qh=h-\langle h,e_1\rangle e_1-\langle h,e_2\rangle e_2=h-0e_1-0e_2=h.$$

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\}$.
