Inequality involving inner product and an othonormal set of vectors $
\newcommand{\ip}[2]{\left\langle #1,#2 \right\rangle}
$
Here is the statement of the problem:
Suppose that $V$ is a real inner product space with an inner product $\langle\cdot,\cdot\rangle$, and let $\left\{ e_1,\dots,e_k\right\}$ be an orthonormal set of vectors in $V$. For any vector $v\in V$, show that
$$
\sum_{i=1}^k \ip{v}{e_i}^2 \le ||v||^2
$$
when does the equality hold?
My attempt: I'm bascially stuck from the beginning. All of my approaches indirectly had the (incorrect) assumption that $V$ can be expressed as a direct sum of subsapce of $V$ spanned by $\{e_1,\dots,e_k\}$ and its orthogonal complement, which I know is true for finite dimensional vector spaces. But I spotted that there were no assumption about $V$ being finite dimensional.
But then I couldn't think of any effective approach afterwards. Any help would be appreciated!
 A: First we prove Pythagoras Theorem for inner product space
$$
\left\|\sum \limits_{i=1}^{k}a_i e_i\right\|^2=\sum \limits_{i=1}^{k}|a_i|^2 \|e_i\|^2 \hspace{5 mm} 
$$
$e_i$  is the orthonormal base.
\begin{align}
\left\|\sum \limits_{i=1}^{k}a_i e_i\right\|^2&=\langle\sum \limits_{i=1}^{k}a_i e_i,\sum \limits_{i=1}^{k}a_i e_i \rangle
\\
&=\sum \limits_{i=1}^{k}a_i \langle e_i,\sum \limits_{j=1}^{k}a_j e_j\rangle 
\\
&= \sum \limits_{i=1}^{k}a_i \overline{\langle \sum \limits_{j=1}^{k}a_j e_j,e_i\rangle}
\\
&=\sum \limits_{i=1}^{k}a_i \langle \sum \limits_{j=1}^{k}\overline{a_j} \overline{e_j},\overline{e_i}\rangle
\\
&=\sum \limits_{i=1}^{k}a_i \sum \limits_{j=1}^{k}\overline{a_j} \langle\overline{e_j},\overline{e_i}\rangle
\\
&=\sum \limits_{i=1}^{k} \sum \limits_{j=1}^{k}a_i\overline{a_j} \langle e_i,e_j\rangle
\\
&=\sum \limits_{i=1}^{k}\overline{a_i}a_i \langle e_i,e_i\rangle=\sum \limits_{i=1}^{k}|a_i|^2 \|e_i\|^2
\end{align}
Next
\begin{align}
\left\|v-\sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i\right\|^2&=\langle v-\sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i\,,v-\sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i\ \rangle
\\
&=\langle v,v\rangle+\langle \sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i,\sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i\rangle-\langle v,\sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i\rangle-\langle \sum \limits_{i=1}^{k}\langle v,e_i\rangle e_i,v\rangle \hspace{7 mm} \text{(by Pythagoras Theorem)}
\\
&=\|v\|^2+\sum\limits_{i=1}^{k}|\langle v,e_i\rangle|^2\|e_i\|^2-\sum \limits_{i=1}^{k}\overline{\langle v,e_i\rangle}\langle \overline{e_i},\overline{v}\rangle-\sum \limits_{i=1}^{k}\langle v,e_i\rangle\langle e_i,v\rangle
\\
&=\|v\|^2+\sum\limits_{i=1}^{k}|\langle v,e_i\rangle|^2-\sum\limits_{i=1}^{k}|\langle v,e_i\rangle|^2-\sum\limits_{i=1}^{k}|\langle v,e_i\rangle|^2
\\
&=\|v\|^2-\sum\limits_{i=1}^{k}|\langle v,e_i\rangle|^2
\\
&\geqslant 0
\end{align}
So $\sum\limits_{i=1}^{k}|\langle v,e_i\rangle|^2\leqslant \|v\|^2$
A: By Pythagoras, $\|v\|^2 = \|\sum_i \langle v,e_i\rangle e_i\|^2 + \|v - \sum_i\langle v,e_i\rangle e_i\|^2$.
