Solution (source code)

= Solution

Differentiate the <Legendre differential equation> and put $Q_n=P_n'$. This gives
$$
(1-x^2)Q_n''-4xQ_n'+(n-1)(n+2)Q_n=0.
$$
Multiplication by $1-x^2$ puts it in the <Sturm-Liouville theory>[self-adjoint form]
$$
\boxed{
\frac d{dx}\left((1-x^2)^2Q_n'\right)
 +(n-1)(n+2)(1-x^2)Q_n=0}.
$$
The boundary term vanishes at $x=\pm1$. Distinct eigenvalues are therefore orthogonal with weight $1-x^2$:
$$
\boxed{
\int_{-1}^{1}(1-x^2)Q_n(x)Q_m(x),dx=0,
\qquad n\ne m.}
$$