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?
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,
and it gives a difference solution when I apply the same method.