Series and Integrals Problem
Let $N$ be a positive integer. Suppose that $\phi_{1},\phi_{2},\phi_{3},\dots,\phi_{N}$ are real-valued functions defined on $[0,1]$ that satisfy
$$\begin{align}
\int_{0}^{1}\phi_{i}\phi_{j}&=0,\qquad i\neq j,\\
\int_{0}^{1}\phi_{i}^2&=1,\qquad i=1,2,\dots,N.
\end{align}$$
Suppose that the $c_{i}$ are numbers such that
$$
f(x)=\sum_{i=1}^{N}c_{i}\phi_{i}(x),\qquad x\in[0,1].\tag{1}
$$
Prove that both
$$
c_{i}=\int_{0}^{1}f\phi_{i},\text{ and }\int_{0}^{1}|f|^2=\sum_{i=1}^{N}c_{i}^2.
$$
Solution
Multiplying equation $(1)$ by $\phi_{j}$, integrating that from $0$ to $1$, and rearranging the RHS yields
$$
\int_{0}^{1}f\phi_{j}=\sum_{i=1}^{N}c_{i}\int_{0}^{1}\phi_{i}\phi_{j}=c_{j},
$$
as required. Moreover,
$$\begin{align}
\int_{0}^{1}|f|^2&=\int_{0}^{1}\left|\sum_{i=1}^{N}c_{i}\phi_{i}\right|^{2}\\
&=\int_{0}^{1}\left|\sum_{i=1}^{N}\phi_{i}\int_{0}^{1}f\phi_{i}\right|^{2}\\
&=?
\end{align}$$
I am stuck here; I have no clue how to proceed. I need to somehow get rid of the absolute value and integration signs. Could anyone give me a hint on how to continue?
Note: We are assuming that, for this case, the integration and summation signs can be interchanged.
 A: Use the fact that $\int$ is a linear operator. Thus $\int |f|^2=\sum_{i,j}\int c_i\phi_i * c_j\phi _j$ and now split the sum according to whether $i=j$ or not and use the given integrals of the $\phi_k$'s.
A: It may help to notice that $\int_{0}^{1}\phi_{i}\phi_{j}=\delta_{ij}$, where $\delta_{ij}$ is the Kroencker delta. Also, be careful with not using the same summation index multiple times. Also, $|f|^2=f^2$, for real-valued functions. This was what you were missing. The absolute value is only necessary for complex-valued functions and the proof works the same way once you recognize that $|f|^2 = f \bar{f}$. The complete proof is below; just move your mouse over it.

 $$\begin{align}\int_{0}^{1}|f|^2&= \int_0^1 f^2 \\&=\int_0^1 \left(\sum_{i=1}^{N}c_{i}\phi_{i}\right)\left(\sum_{j=1}^{N}c_{j}\phi_{j} \right) \\&=\int_0^1 \sum_{i=1}^{N}\sum_{j=1}^{N}c_ic_j \phi_i \phi_j\\&=\sum_{i=1}^{N}\sum_{j=1}^{N}c_ic_j \int_0^1\phi_i \phi_j \\&=\sum_{i=1}^{N}\sum_{j=1}^{N}c_ic_j \delta_{ij}\\&=\sum_{i=1}^{N}c_ic_i \delta_{ii}\\&=\sum_{i=1}^{N} c_i^2\end{align}$$

