Laplace's Equation in spherical coordinates
From biophysics wiki
Laplace's Equation is \begin{align} \nabla^2 u=0 \end{align} and can be solved by Separation of Variables. First we write the Laplace operator $\Delta = \nabla^2$ in spherical coordinates, given by the radius $r$, the polar angle $\theta$ and the azimuthal angle $\varphi$.

\begin{align} \nabla^2 u=\underbrace{{1 \over r^2}{\partial \over \partial r}\!\left(r^2 {\partial u \over \partial r}\right)
\! }_{r-term}+\underbrace{\!{1 \over r^2\!\sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial u \over \partial \theta}\right)
}_{\theta - term}\!+\underbrace{\!{1 \over r^2\!\sin^2\theta}{\partial^2 u \over \partial \varphi^2}}_{\varphi - term}=0
\end{align} Notice there are three terms. Each term contains derivatives of the dependent variable $u$ with respect to one of the independent variables $r,\theta$ or $\varphi$. This maybe helps to remember the operater. Notice also that we could cancel the $1/r^2$ factor. There are two important solutions to this equation. One where the solution $u$ depends on the azimuthal angle $\varphi$ and the other case, where $u$ is invariant under azimuthal rotation. Let us first discuss the letter case of azimuthal symmetrie.
Azimuthal Symmetry
Problems with azimuthal symmetrie arise e.g. in Electrostatics where the potential is independent of the $\varphi$ coordiante because of symmetric boundary conditions. If there is no $\varphi$ dependence the $\varphi$ term vanishes and the Laplace equation reduces to. \begin{align} {1 \over r^2}{\partial \over \partial r}\!\left(r^2 {\partial u \over \partial r}\right)
\!+\!{1 \over r^2\!\sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial u \over \partial \theta}\right)
\!+=0
\end{align} With the ansatz $u(r,\theta)=R(r)\cdot \Theta(\theta)$ we get by plugging in \begin{align} {1 \over r^2}{\partial \over \partial r}\!\left(r^2 {\partial R(r)\cdot \Theta(\theta) \over \partial r}\right)
\!+\!{1 \over r^2\!\sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial R(r)\cdot \Theta(\theta) \over \partial \theta}\right)
\!=0
\end{align} now we divide by $R(r)\cdot \Theta(\theta)$ and multiply by $r^2$, we get \begin{align} {1 \over R}{\partial \over \partial r}\!\left(r^2 {\partial R \over \partial r}\right)
\!+\!{1 \over \!\sin\theta \Theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial \Theta \over \partial \theta}\right)
\!=0
\end{align} The derivative of $\partial R / \partial r$ is really a total derivative $dR/dr$ since $R$ is a function of $r$ only. In the same way this is true for for $\Theta$, so we have. \begin{align} \frac{1}{R} \frac{d}{d r} \left( r^2 \frac{d R}{d r} \right) + \frac{1}{\sin \theta \Theta} \frac{d}{d \theta} \left( \sin \theta \frac{d \Theta}{d \theta} \right)=0 \end{align} The left term is a function of $R(r)$ and the right term is a function of $\Theta(\theta)$ only. The only way this is possible is that they are equal to a constant, which we call $\lambda^2$ \begin{align} \frac{1}{\sin \theta \Theta} \frac{d}{d \theta} \left( \sin \theta \frac{d \Theta}{d \theta} \right)=-\frac{1}{R} \frac{d}{d r} \left( r^2 \frac{d R}{d r} \right) = \lambda^2 \end{align} We have reduced the PDE to two ODE's. The first ODE is called an Euler-Cauchy Differential Equation. \begin{align} \frac{1}{R} \frac{d}{d r} \left( r^2 \frac{d R}{d r} \right) = -\lambda^2 \end{align} This can be recognised more easily if we multiply by $R$ and differentiate the equation to the familiar form of the
Euler-Cauchy Differential Equation \begin{align} r^2R+2rR' -\lambda^2R=0 \end{align} The Solution to the Euler-Cauchy Equation is \begin{align} R(r)=A \, r^n + \frac{B}{r^{n+1}} \end{align} by calling $\lambda^2=n(n+1)$
Let us rewrite the other ODE \begin{align} \frac{1}{\sin \theta \Theta} \frac{d}{d \theta} \left( \sin \theta \frac{d \Theta}{d \theta} \right)=n(n+1) \\ \end{align} by differentiation we have \begin{align} \Theta + \frac{\cos \theta}{\sin \theta} \Theta '=n(n+1)\Theta\\ \end{align} can be transformed into Legendre's Differential Equation by the transformation $\xi=\cos \theta$ \begin{align} \frac{d \Theta}{d \theta}&=\frac{d \Theta}{d \xi}\frac{d \xi}{d \theta}=-\sin\theta \frac{d \Theta}{d \xi}\\ \frac{d^2 \Theta}{d \theta^2}&=-\cos \theta \frac{d \Theta}{d \xi}+\sin^2\theta \frac{d^2 \Theta}{d \xi^2} \end{align} by plugging this into the ODE we get \begin{align} -\cos \theta \frac{d \Theta}{d \xi}+\sin^2\theta \frac{d^2 \Theta}{d \xi^2}+\frac{\cos \theta}{\sin \theta} (-\sin \theta) \frac{d \Theta}{d \xi}=n(n+1)\Theta\\ \end{align} which upon simlifying and replacing $\cos \theta$ by $\xi$ gives
Legendre's Differential Equation \begin{align} (1-\xi^2) \Theta - 2 \xi \Theta ' -n(n+1)\Theta=0 \end{align} with the linear combination of Legendre's Polynomial $P_n$ (of the first kind) and $Q_n$ (of the second kind) as general solution \begin{align} \Theta(\xi)=C \cdot P_n(\xi) + D \cdot Q_n(\xi) \end{align}
Now we use these Solution of the ODE's and go back to the original ansatz. We plug in the solutions into the product $u(r,\theta)=R\cdot \Theta$. What we find is the general solution of Laplace's Equation in spherical coordinates with azimuthal symmetry
\begin{align} u(r,\theta)=R(r)\cdot \Theta(\theta)= \left(A \, r^n + \frac{B}{r^{n+1}} \right) \left( C \cdot P_n(\cos \theta) + D \cdot Q_n(\cos \theta) \right) \end{align}
General Case
In general a problem won't have azimutal symmetrie and the $\varphi$ term will not cancel. We have to deal with the full operator and Laplace's equation reads \begin{align} \nabla^2 u=\underbrace{{1 \over r^2}{\partial \over \partial r}\!\left(r^2 {\partial u \over \partial r}\right)
\! }_{r-term}+\underbrace{\!{1 \over r^2\!\sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial u \over \partial \theta}\right)
}_{\theta - term}\!+\underbrace{\!{1 \over r^2\!\sin^2\theta}{\partial^2 u \over \partial \varphi^2}}_{\varphi - term}=0
\end{align} The ansatz we make to solve the Equation is a product of three functions $u(r,\theta,\varphi)=R(r)\Theta(\theta)\Phi (\varphi)$. Plugging in, multiplying by $r^2$ and dividing by $u$ we have \begin{align} {1 \over R}{\partial \over \partial r}\!\left(r^2 {\partial R \over \partial r}\right)
\! +\!{1 \over \Theta \, \sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial \Theta \over \partial \theta}\right)
\!+\!{1 \over \Phi \,\sin^2\theta}{\partial^2 \Phi \over \partial \varphi^2}=0
\end{align} we set the $r-term$ equal to $\lambda^2$ \begin{align} {1 \over R}{\partial \over \partial r}\!\left(r^2 {\partial R \over \partial r}\right)
\! =-\,{1 \over \Theta \, \sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial \Theta \over \partial \theta}\right)
\!-\,{1 \over \Phi \,\sin^2\theta}{\partial^2 \Phi \over \partial \varphi^2}=\lambda^2=n(n+1)
\end{align} This gives again the
Euler-Cauchy Differential Equation \begin{align} r^2R+2rR' -\lambda^2R=0 \end{align} with the solution \begin{align} R(r)=A \, r^n + \frac{B}{r^{n+1}} \end{align}
The variables of the remaining equation \begin{align} -\,{1 \over \Theta \, \sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial \Theta \over \partial \theta}\right)
\,-\!{1 \over \Phi \,\sin^2\theta}{\partial^2 \Phi \over \partial \varphi^2}=\lambda^2=n(n+1)
\end{align} can be further seperated. To this end we multiply by $- \sin^2 \theta$ and put the $\theta - term$ on the other side \begin{align} {1 \over \Phi}{\partial^2 \Phi \over \partial \varphi^2}= -{\sin\theta \over \Theta \, }{\partial \over \partial \theta}\!\left(\sin\theta {\partial \Theta \over \partial \theta}\right)-n(n+1)\sin^2\theta \end{align} This is the separated equation and can be written with total derivatives. The equations shall equal the constant $-m^2$ \begin{align} {1 \over \Phi}{d^2 \Phi \over d \varphi^2}=-m^2\\ {\sin\theta \over \Theta \, }{d \over d \theta}\!\left(\sin\theta {d \Theta \over d \theta}\right)+n(n+1)\sin^2\theta=m^2 \end{align}