Why does $\|\sum_{i=1}^{N}\langle f,\phi_i\rangle\phi_i\|^2 = \sum_{i=1}^{N}|\langle f,\phi_i\rangle|^2 $? I'm reading about Fourier analysis and there is one equality, which I don't understand. Why does: 
$$\left\|\sum_{i=1}^{N}\langle f,\phi_i\rangle\phi_i\right\|^2 = \sum_{i=1}^{N}|\langle f,\phi_i\rangle|^2  ,$$
where $f$ and $\phi_i$s are infinite dimensional complex-valued "vectors". In my book they are functions, but they are thought of as infinite dimensional vectors. The $\phi_i$s are mutually orthonormal. 
$$\langle f,g\rangle = \int_a^b f(x)\overline{g(x)}\;dx$$
$$\|f\| = \sqrt{\int_a^b |f(x)|^2\;dx}$$  
I guess I'm supposed to use the Pythagorean theorem here?: 
if vectors $\boldsymbol{a}_1$, ..., $\boldsymbol{a}_n$ are mutually orthogonal then 
$$\|\boldsymbol{a}_1+ \cdots+\boldsymbol{a}_n\|^2 = \|\boldsymbol{a}_1\|^2+\cdots+\|\boldsymbol{a}_n\|^2$$
Thank you for any help! Please let me know if you need more information :)
 A: More explicitly:
$$\left\|\sum_{i=1}^N\langle f,\phi_i\rangle\phi_i\right\|^2=\left\langle\sum_{i=1}^N\langle f,\phi_i\rangle\phi_i\,,\,\sum_{i=1}^N\langle f,\phi_i\rangle\phi_i\right\rangle=$$
$$\sum_{i,j=1}^N\langle f,\phi_i\rangle\overline{\langle f,\phi_j\rangle}\langle\phi_i\,,\,\phi_j\rangle=\sum_{i=1}^N|\langle f\,,\,\phi_i\rangle|^2$$
since
$$\langle\phi_i\,,\,\phi_j\rangle=\delta_{i,j}=\begin{cases}1&,\;\;i=j\\{}\\0&,\;\;i\neq j\end{cases}$$
A: Short answer: $|\cdots|^2=\langle\cdots,\cdots\rangle$. Expand. The crossed terms vanish by orthogonality.
A: \begin{align}
\left\|\sum_{i=1}^n \langle f,\varphi_i\rangle\varphi_i\right\|^2 &=
\left\langle\sum_{i=1}^n \langle f,\varphi_i\rangle\varphi_i,\sum_{i=1}^n \langle f,\varphi_i\rangle\varphi_i\right\rangle
=\sum_{i=1}^n\sum_{j=1}^n \big\langle\langle f,\varphi_i\rangle\varphi_i,\langle f,\varphi_j\rangle\varphi_j \big\rangle \\ &=
\sum_{i=1}^n\sum_{j=1}^n \langle f,\varphi_i\rangle\overline{\langle f,\varphi_j\rangle}\langle\varphi_i,\varphi_j\rangle=
\sum_{i=1}^n\sum_{j=1}^n \langle f,\varphi_i\rangle\overline{\langle f,\varphi_j\rangle}\delta_{ij}=\sum_{i=1}^n |\langle f,\varphi_i\rangle|^2
\end{align}
