Verify solution: Is this gradient correct? So I want to calculate minus the gradient of $$\Phi_1=\sum_{l=0}^{\infty}f(l)r^{l}P_l(\cos(\theta))$$
where $P_n$ is the $n$-th Legendre polynomial
then we have $$-\nabla \Phi_1=-\left(\begin{array}{c}\sum_{l=1}^{\infty}f(l)\cdot l \cdot r^{l-1}P_l(\cos(\theta)\\ -\sum_{l=0}^{\infty}f(l)\cdot (l+1) \cdot r^{l-1}\frac{\cos(\theta)P_n(\cos(\theta))-P_{n-1}(\cos(\theta))}{\sin(\theta)}\end{array}\right)?$$
Or is it rather: $$-\nabla \Phi_1=-\left(\begin{array}{c}\sum_{l=1}^{\infty}f(l)\cdot l \cdot r^{l-1}P_l(\cos(\theta))\\ 
\sum_{l=1}^{\infty}f(l)\cdot l \cdot r^{l-1}\frac{\cos(\theta)P_n(\cos(\theta))-P_{n-1}(\cos(\theta))}{\sin(\theta)}\end{array}\right)$$
Notice that the only change that there is, is in the second component, the first might be right. $f$ is a function that does neither depend on $r$ nor does it depend on $\theta$.
 A: Let $x=\cos\theta$ and $\Phi_1=\sum_{l=0}^{\infty}f(l)r^{l}P_l(x(\theta))$
Then $-\nabla\Phi_1= -\left({\partial \Phi_1 \over \partial r },{1 \over r}{\partial \Phi_1 \over \partial \theta }\right)=-\left({\partial \Phi_1 \over \partial r },{1 \over r}{\partial \Phi_1 \over \partial x }{ dx \over d \theta }\right)$
$${\partial \Phi_1 \over \partial r}=\sum_{l=0}^{\infty}f(l)lr^{l-1}P_l(\cos(\theta))$$
According to wolfram alpha:
$${\partial P_l \over \partial x} = {-(l+1) (x P_l(x)-P_{l+1}(x)) \over (x^2-1)}$$
So, $${\partial \Phi_1 \over \partial x }=\sum_{l=0}^{\infty}f(l)r^{l}\left({-(l+1) (x P_l(x)-P_{l+1}(x)) \over (x^2-1)}\right)$$
Then,$${1 \over r}{\partial \Phi_1 \over \partial \theta }={1 \over r}{\partial \Phi_1 \over \partial x }{ dx \over d \theta }=\sum_{l=0}^{\infty}f(l)r^{l-1}\left(-{(l+1) (\cos\theta P_l(\cos\theta)-P_{l+1}(\cos\theta)) \over (\cos^2\theta-1)}\right)\cdot(-\sin\theta)$$
$$ =\sum_{l=0}^{\infty}-{(l+1)f(l)r^{l-1} (\cos\theta P_l(\cos\theta)-P_{l+1}(\cos\theta)) \over \sin\theta}$$
Finally,
$$-\nabla\Phi_1=-\left(\begin{array}{c} \sum_{l=1}^{\infty}f(l)lr^{l-1}P_l(\cos(\theta))\\\ \sum_{l=1}^{\infty}-{(l+1)f(l)r^{l-1} (\cos\theta P_l(\cos\theta)-P_{l+1}(\cos\theta)) \over \sin\theta}\end{array}\right)$$
Hope that helps.
