When a function $f(x)$ can be expressed as a linear combination of a orthogonal basis $\phi_n(x)$, i.e.

$\displaystyle f(x) = \sum_n a_n \phi_n(x)$

$\displaystyle \langle \phi_n|\phi_m \rangle = \delta_{nm}$

then, the integration

$\displaystyle \int |f(x)|^2 dx = \sum_n |a_n|^2 \langle \phi_n|\phi_n \rangle = \sum_n |a_n|^2$

That is.

Using this theorem, many complicated integration can be calculated as a sum.