I have a question about a step in my book, "Mathematical Methods" by McQuarrie about Bessels proof.
The solution on Bessel's inequality start with: $$ \int^1_{-1} \left[ f (x) - \sum^N_{n=0} a_n P_n(x) \right] ^2 dx \geq 0. $$ Then, \begin{align} \int^1_{-1} {f^2 (x)}dx &- 2\sum^N_{n=0} a_n \int^1_{-1} f(x)P_n(x)dx\\ &+ \sum^N_{n=0}\sum^N_{m=0}a_n a_m \int^1_{-1}P_n(x)P_m(x) dx \geq 0. \end{align} or $$ \int^1_{-1}f^2(x)dx \geq \sum^N_{n=0}\frac{2}{2n+1} a^2_n.$$
Where $P_n(x)$ are the Legendre polynomials and, $$ a_n=\frac{2n+1}{2}\int_{-1}^1 f(x)P_n(x). $$ I am confused why $$ 2\sum^N_{n=0} a_n \int^1_{-1} f(x)P_n(x)dx - \sum^N_{n=0}\sum^N_{m=0}a_n a_m \int^1_{-1}P_n(x)P_m(x) dx = \sum^N_{n=0}\frac{2}{2n+1}. $$