# Calculation of hessian and gradient of spherical harmonics

I was searching for relations that can be used to calculate the gradient and the hessian matrix of spherical harmonics in Cartesian coordinates easier. I am using the following definition of the spherical harmonics, which is also used in quantum mechanics:

$$Y_\ell^m( \theta , \varphi ) = (-1)^m \sqrt{\frac{(2\ell+1)}{4\pi}\frac{(\ell-m)!}{(\ell+m)!}} \, P_{\ell}^m ( \cos{\theta} ) \, e^{i m \varphi }$$

where $$P_{\ell}^m$$ are the associated Legendre polynomials without the Condon–Shortley phase. Performing all the partial derivative seems to be quite tedious and also hard to generalize if performed computationally for a series of $$l$$ and $$m$$.

The short answer is that the Cartesian derivatives of the spherical harmonics obey the following recurrence relation: $$\partial_z Y_\ell^m = \frac{\ell+1}{r}\sqrt{\frac{(\ell -m)(\ell+m)}{(2\ell+1)(2\ell-1)}}Y_{\ell-1}^m - \frac{\ell}{r}\sqrt{\frac{(\ell+1-m)(\ell+1+m)}{(2\ell+1)(2\ell+3)}}Y_{\ell+1}^m$$ $$(\partial_x\pm i\partial_y)Y_\ell^m = \pm \frac{\ell+1}{r}\sqrt{\frac{(\ell-1\mp m)(\ell\mp m)}{(2\ell-1)(2\ell+1)}} Y_{\ell-1}^{m\pm1} \pm \frac{\ell}{r}\sqrt{\frac{(\ell+1\pm m)(\ell+2\pm m)}{(2\ell+1)(2\ell+3)}} Y_{\ell+1}^{m\pm1}$$ You should probably check the signs, though, since everyone has their own convention on it. With these, you can express all components of the gradient and Hessian in terms of linear combinations of spherical harmonics.
The long answer is applying these operators to the spherical harmonics: $$r(\partial_x \pm i\partial_y) = e^{\pm i\phi}\left(\cos\theta\partial_\theta \pm i\frac{\partial_\phi}{\sin\theta}\right)\;\;;\;\;r\partial_z = -\sin\theta\partial_\theta$$ and then wading through a giant mess of associated Legendre polynomial identities which this answer is too narrow to contain.
• I don't quite see where the first operators $\partial_x$ and $\partial_y$ are coming from. Jun 5, 2022 at 16:56
• @pmu2022 $r\partial_x = (\cos\phi \cos\theta) \partial_\theta -(\sin\phi/\sin\theta)\partial_\phi$ and $r\partial y = (\sin\phi \cos\theta) \partial_\theta +\cos\phi/\sin\theta \partial_\phi$ are the conversions between spherical and cartesian derivatives. The choice of $\partial_x \pm i\partial_y$ is so that the two operators don't mix $m$ values, instead being a raising and lowering operator on $m$. Jun 5, 2022 at 21:08