Sum of associated Legendre functions I want to find the sums of two expressions involving the Schmidt-normalized associated Legendre functions. They are defined by
\begin{align}
S_l^0(x) &= P_l^0(x) \\
S_l^m(x) &= \sqrt{2 \frac{(l-m)!}{(l+m)!}} P_l^m(x)
\end{align}
where $P_l^m(x)$ are the usual unnormalized associated Legendre functions found for example in Abramowitz and Stegun. The sums I would like to compute are:
\begin{align}
\sum_{m=0}^l S_l^m(x)^2 &= ? \\
\sum_{m=0}^l m^2 S_l^m(x)^2 &= ?
\end{align}
I cannot find these in Gradshteyn and Ryzhik, or anywhere online. However, using GNU octave, I believe the first sum is always 1, regardless of the values of $x$ or $l$:
octave:60> x = 0.3
octave:61> P = legendre(20,x,'sch');
octave:62> sum(P.^2)
ans =  1.00000000000000
octave:63> x=0.78
octave:64> P = legendre(200,x,'sch');
octave:65> sum(P.^2)
ans =  0.999999999999993

The second sum however appears to depend on both $x$ and $l$. Any advice on how to get started would be appreciated.
 A: Special functions don't get any love on this site.  It's still a good question.  The answers you seek are 
$$S_0 :=2\sum_{m=0}^k\frac{(k-m)!}{(k+m)!}(P_k^m(x))^2=1+P_k(x)^2$$
$$S_2:=2\sum_{m=0}^km^2\frac{(k-m)!}{(k+m)!}(P_k^m(x))^2=\frac{1}{2}k(k+1)(1-x^2).$$  The technique should work for any even power of $m$ in the summation.  You need to understand distribution theory to understand the proof; try Wolfram's entry on the delta function.  For $0<x<1$ we have the identities
$$(-i)^m \frac{k!}{(m+k)!}P_k^m(x)= \frac{1}{\pi}\int_0^\pi \big(x+\sqrt{x^2-1}\cos(t)\big)^k \cos(m\,t)\,dt $$
$$(i)^m \frac{(k-m)!}{k!}P_k^m(x)= \frac{1}{\pi}\int_0^\pi \big(x+\sqrt{x^2-1}\cos(t)\big)^{-(k+1)} \cos(m\,t)\,dt .$$
These formulas follow from Gradshteyn & Ryzhik 8.711.  Note that the G&R formulas have different phase factors but the formulas presented are correct for range of $x$ given, and assuming the standard branch cut for the square root.  Note that the summation index can be increase to $\infty$ because for $m>k$ the polynomial is identically 0.  Clearly the strategy is to multiply the integrals and sum over all $m$ because the product of the left-hand sides of the previous 2 eqs. is exactly your summand.  For convenience, let $f(t)=x+\sqrt{x^2-1}\cos(t)$ and the dependence on $x$ is suppressed.
$$S_0=\frac{2}{\pi^2}\int_0^\pi dt f(t)^k \int_0^\pi du f(u)^{-(k+1)}
\sum_{m=0}^\infty \cos(m\,t) \cos(m\,u).$$ 
In a distributional sense
$$ \sum_{m=0}^\infty \cos(m\,t) \cos(m\,u) = \frac{1}{2} \sum_{m=0}^\infty \cos(m\,(t-u))+  \cos(m\,(t+u)) $$
$$  = \frac{1}{2}\Big(\frac{1}{2}+\pi\delta(t-u) + \frac{1}{2}+\pi\delta(t+u) \Big). $$
Actually, the cosine series equates to an infinite sum over Dirac deltas, but I've only shown the first for each of the series.  If the limits on the integrals were greater, then you have to include more.  In fact, because the range on the integral is positive, we can ignore the $\delta(t+u)$ as well. Therefore
$$S_0=\frac{1}{\pi^2}\int_0^\pi dt f(t)^k \int_0^\pi du  f(u)^{-(k+1)}\big(1+\pi\delta(t-u) \big)$$
$$=\frac{1}{\pi}\int_0^\pi dt f(t)^k \big( P_k^0(x)+  f(t)^{-(k+1)}\big)=P_k(x)^2 +\frac{1}{\pi}\int_0^\pi dt f(t)^{-1}=P_k(x)^2+1. $$
Repeated use of the G&R formulas have been made.  To solve $S_2$ in closed form, similar steps are take but the distributional sum is
$$ \sum_{m=0}^\infty m^2\cos(m\,t) \cos(m\,u) = -\frac{d^2}{du^2}\frac{1}{2} \sum_{m=0}^\infty \cos(m\,t) \cos(m\,u) $$
$$  = -\frac{d^2}{du^2} \frac{1}{2}\Big(1+\pi\delta(t-u)  \Big). $$
Now use, for suitable $g$ and $t$ within the integration domain 
$$ \int du \, g(u) \frac{d^2}{du^2} \delta(t-u) = g''(t). $$  The derivatives for $g \to f(t)^{-(k+1)}$ is easy enough, consisting of two terms, one of which contains a $\cos(t)$ and the other which contains a $\sin^2(t).$  Write $\sin(t)^2=(1-cos(2t))/2$ because now we will use the G&R formulas with $m>0.$  The single integrals look like
$$-S_2=(k+1)\sqrt{x^2-1}\int_0^\pi  f(t)^{-2}\cos(t) \frac{dt}{\pi}+
(k+1)(k+2)(x^2-1)\int_0^\pi  f(t)^{-3}\sin^2(t)\frac{dt}{\pi}$$
$$=(k+1)\sqrt{x^2-1}(i)P_1^1(x)+
(k+1)(k+2)(x^2-1)\frac{1}{2}\Big(P_2^0(x)+P_2^2(x)/2\Big).$$
Get another $i$ by $\sqrt{x^2-1} = i\sqrt{1-x^2}$ so the answer is totally real, as was assumed when the problem was started.  Plug in known expressions for the polynomials and simplify to get the result above.
