The orthogonality of the Legendre polynomials can be proven using the Legendre differential equation.

If \(P_n\) and \(P_m\) are solutions to eq332a, then
$$\frac{d}{dx}\biggr[(1-x^2)\frac{dP_n}{dx}\biggr]+n(n+1)P_n=0\;\;\;\;\;\;\;\;351$$
$$\frac{d}{dx}\biggr[(1-x^2)\frac{dP_m}{dx}\biggr]+m(m+1)P_m=0\;\;\;\;\;\;\;\;352$$
Multiplying eq351 and eq352 by \(P_m\) and \(P_n\), respectively, and subtracting the results yields
$$\frac{d}{dx}(1-x^2)\biggr(P_m\frac{dP_n}{dx}-P_n\frac{dP_m}{dx}\biggr)+[n(n+1)-m(m+1)]P_mP_n=0\;\;\;\;\;\;\;\;353$$
The Legendre polynomials are used to describe spherical harmonics, where \(x=cos\theta\) and \(0\leq\theta\leq\pi\). Therefore, the orthogonality of the Legendre polynomials is analysed within the interval of \(-1\leq x\leq 1\). Integrating eq353 with respect to \(x\) gives
$$\biggr[(1-x^2)\biggr(P_m\frac{dP_n}{dx}-P_n\frac{dP_m}{dx}\biggr)\biggr]_{-1}^1+[n(n+1)-m(m+1)]\int_{-1}^1P_mP_n\;dx=0$$
$$[n(n+1)-m(m+1)]\int_{-1}^1P_mP_n\;dx=0$$
If \(m\neq n\), the factor \([n(n+1)-m(m+1)]\) is not zero, and hence
$$\int_{-1}^1P_mP_n\;dx=0\;\;\;\;\;\;\;\;354$$