Derivative of Associated Legendre polynomials at $x = \pm 1$ I'm creating meshes for spherical harmonics, and I need a normal at a given point. Whenever I'm at the poles, $\cos{\theta} = \pm 1$, and I do not know how to find the derivative there. All the formulas I have found to describe the derivative have an $1 - x^2$ in the denominator, and I get an indeterminate form. For reference, the one I'm using is:
$$(P_\ell^m)^\prime(x) = \frac{\sqrt{1-x^2} P_\ell^{m+1}(x) + mx P_\ell^m (x)}{x^2 - 1}$$
I found the derivatives for some cases, and it seems that $m = \pm 1$ results in $\pm \infty$, $m = 0$ yields triangular numbers, and $|m| \ge 3$ makes the derivative $0$. But I can't find an overarching pattern or algorithm I can use to produce these. Is there a nice way?
 A: The singularity at the denominator can be eliminated using L'Hospital's theorem, once you notice that the associated Legendre function has value of $0$ at $\pm 1$.

Maybe this is not a right solution, because I found another formula about the derivative of the associated Legendre function here,


*

*Spherical Harmonics
and it gives a difference solution when I apply the same method.
A: Could you try using the formula from Wikipedia ?
\[  P_m^l (x) = \frac{(-1)^m}{2^\ell \ell!} (1-x^2)^{m/2} \frac{d^{\ell + m}}{dx^{\ell + m}}(1 - x^2)^{\ell} \]
Let $y = 1-x \approx 0$, 
\[  P_m^l (y) = \frac{(-1)^m}{2^\ell \ell!} y^{m/2}(2-y)^{m/2} \frac{d^{\ell + m}}{dy^{\ell + m}} y^{\ell}(2-y)^\ell \propto y^{m/2} \approx 0\]
I am guessing the derivative is always zero unless $m = 0$, the only interesting case.

Or plug in $x = \cos \theta$ and take the limit $\theta \to 0$:
\[  (P_\ell^m)^\prime(\cos \theta) = \frac{\sin \theta \, P_\ell^{m+1}(\cos \theta) + m \cos \theta \,  P_\ell^m (\cos \theta )}{\sin^2 \theta} \]
Not sure how to evaluate this... spherical harmonics are rotationally symmetric, so maybe they shouldn't have non-zero derivatives at the poles?
