The symmetry of the atom forces us to work in spherical polar coordinates. In Cartesian coordinates the components of angular momentum are given by the following equations: \begin{eqnarray} \hat{l}_x &=& -i\hbar\left[\hat{y}\frac{\partial}{\partial z}-\hat{z}\frac{\partial}{\partial y}\right]\\ \hat{l}_y &=& -i\hbar\left[\hat{z}\frac{\partial }{\partial x}-\hat{x}\frac{\partial}{\partial z}\right]\\ \hat{l}_z &=& -i\hbar\left[\hat{x}\ frac{\partial}{\partial y}-\hat{y}\frac{\partial}{\partial x}\right]\label{1} \end{eqnarray}

Relationships between Cartesian and spherical coordinates:

\begin{eqnarray} x &=& rsen\theta\cos\varphi \\ y &=& rsen\theta sin\varphi \\ z &=& r\cos\theta \\ r^2 &=& x^2 +y^2+z^2 \\ \cos\theta &=& \frac{z}{r}=\frac{z}{\left(x^2+y^2+z^2\right)^ {1/2}}\\ \tan\varphi &=& \frac{y}{x} \label{2} \end{eqnarray}

Let the function $f(r,\theta,\varphi)=g(x,y,z)$ be the function, we will calculate the partial derivatives of the function $g$ with respect to the variables $x,y,z$ taking into account the following dependency: $r=r(x,y,z)$, $\theta=\theta(x,y,z)$ and $\varphi=\varphi(x,y,z)$. Applying the The chain rule to the function $g(x,y,z)$ gives us:

$$\label{10} \left(\frac{\partial g}{\partial x}\right)_{ y,z}=\left(\frac{\partial f}{\partial r}\right)_{\theta,\varphi}\cdot\left(\frac{\partial r}{\partial x}\right )_{y,z} +\left(\frac{\partial f}{\partial \theta}\right)_{r,\varphi}\cdot\left(\frac{\partial\theta}{\partial x}\right)_{y,z}+\left(\frac{\partial f}{\partial\varphi}\right)_{r,\theta}\cdot\left(\frac{\partial\varphi }{\partial x}\right)_{y,z}$$

$$\label{11} \left(\frac{\partial g}{\partial y}\right)_{ x,z}=\left(\frac{\partial f}{\partial r}\right)_{\theta,\varphi}\cdot\left(\frac{\partial r}{\partial y}\right)_{x,z} +\left(\frac{\partial f}{\partial \theta}\right)_{r,\varphi} \cdot\left(\frac{\partial\theta}{\partial y}\right)_{x,z}+\left(\frac{\partial f}{\partial\varphi}\right)_{r ,\theta}\cdot\left(\frac{\partial\varphi}{\partial y}\right)_{x,z}$$

$$\label{12} \left(\frac{\partial g}{\partial z}\right)_{x,y}=\left(\frac{\partial f}{\partial r}\right)_{\theta,\varphi}\cdot\left(\frac{\partial r}{\partial z}\right)_{x,y} +\left(\frac{\partial f}{\partial \theta}\right)_{r,\varphi} \cdot\left(\frac{\partial\theta}{\partial z}\right)_{x,y}+\left(\frac{\partial f}{\partial\varphi}\right)_{r ,\theta}\cdot\left(\frac{\partial\varphi}{\partial z}\right)_{x,y}$$

Eliminating $f$ and $g$ from the derivatives:

$$\label{13} \frac{\partial}{\partial x}=\left(\frac{\partial r}{\partial x}\right)_{y,z}\cdot\frac{\ partial}{\partial r} +\left(\frac{\partial\theta}{\partial x}\right)_{y,z}\cdot\frac{\partial}{\partial\theta}+\left (\frac{\partial\varphi}{\partial x}\right)_{y,z}\cdot\frac{\partial}{\partial\varphi}$$

$$\label{14} \frac{\partial}{\partial y}=\left(\frac{\partial r}{\partial y}\right)_{x,z}\cdot\frac {\partial}{\partial r} +\left(\frac{\partial\theta}{\partial y}\right)_{x,z}\cdot\frac{\partial}{\partial\theta}+ \left(\frac{\partial\varphi}{\partial y}\right)_{x,z}\cdot\frac{\partial}{\partial\varphi}$$

$$\ label{15} \frac{\partial}{\partial z}=\left(\frac{\partial r}{\partial z}\right)_{x,y}\cdot\frac{\partial}{\ partial r} +\left(\frac{\partial\theta}{\partial z}\right)_{x,y}\cdot\frac{\partial}{\partial\theta}+\left(\frac{ \partial\varphi}{\partial z}\right)_{x,y}\cdot\frac{\partial}{\partial\varphi}$$

Now we only need to calculate the partial derivatives of $r,\ theta,\varphi$ with respect to $x,y,z$ using the equations (\ref{7}),(\ref{8}) and (\ref{9}). Differentiating the equation (\ref{7}):

$$\label{16} 2r\left(\frac{\partial r}{\partial x}\right)_{y,z}=2x$$

Substituting the expression for x (\ref{4})

$$\label{17} 2r\left(\frac{\partial r}{\partial x}\right)_{y,z} =2rsin\theta cos\varphi$$

Solving for the derivative:

$$\label{18} \left(\frac{\partial r}{\partial x}\right)_{y,z} =sin\theta cos\varphi$$

In a similar way, the derivatives of $r$ with respect to the variables $y,z$ are obtained.

$$\label{19} \left(\frac{\partial r}{\partial y}\right)_{x,z}=sin\theta sin\varphi$$

$$\label{20} \left(\frac{\partial r}{\partial z}\right)_{x,y}=cos\theta$$

Now we calculate the derivatives of $\theta$ with respect to $x,y,z$

$$\label{21} -sin\theta\cdot\left(\frac{\partial\theta}{\partial x}\right)_{y,z} =\frac{-z\cdot 1/2 (x^2+y^2+z^2)^{1/2}\cdot 2x}{x^2+y^2+z^2}=\frac {-z\cdot x}{r^3}$$

Substituting $x,z$ with the change to spherical, gives:

$$\label{22} -sin\theta\cdot\left (\frac{\partial\theta}{\partial x}\right)_{y,z}=-\frac{rcos\theta\cdot rsen\theta cos\varphi}{r^3}$$ Simplifying: $$\label{23} \left(\frac{\partial\theta}{\partial x}\right)_{y,z}=\frac{cos\theta\cdot cos\varphi} {r}$$

Compute analogously the derivatives of $\theta$ with respect to $y,z$

\begin{eqnarray} \left(\frac{\partial\theta}{\partial y}\right)_{x,z} & =& \frac{cos\theta\cdot sin\varphi}{r} \\ \left(\frac{\partial\theta}{\partial z}\right)_{x,y} &=& \frac{ -sin\theta}{r}\label{25} \end{eqnarray}

From equation (\ref{9}) we obtain the partial derivatives of $\varphi$ with respect to $x,y,z$

$$\label{26} \frac{1}{cos^2 \varphi}\cdot\left(\frac{\partial\varphi}{\partial x}\right)_{y,z}=-\frac{y}{x^2}=-\frac{rsen\theta sin\varphi}{r^2 sin^2\theta cos^2\varphi}=-\frac{sin\varphi}{rsen\theta cos^2\varphi}$$

Solving for the derivative gives us:

$$\label{27} \left(\frac{\partial\varphi}{\partial x}\right)_{y,z}=-\frac{sin\varphi}{rsen\theta}$$

In the same way we calculate the derivatives of $\varphi$ with respect to $x,y$.

\begin{eqnarray} \left(\frac{\partial\varphi}{\partial y}\right)_{x,z} &=& \frac{cos\varphi}{rsin\theta} \\ \left( \frac{\partial\varphi}{\partial z}\right)_{x,y} &=& 0\label{29} \end{eqnarray}

Substituting these nine derivatives into the equations (\ref{13}), (\ref{14}) and (\ref{15}), we obtain the operators $\frac{\partial}{\partial x},\frac {\partial}{\partial y},\frac{\partial}{\partial z}$

\begin{eqnarray} \frac{\partial}{\partial x} &=& sin\theta cos\varphi\cdot\ frac{\partial}{\partial r}+\frac{cos\theta cos\varphi}{r}\cdot\frac{\partial}{\partial\theta}-\frac{sin\varphi}{rsen\theta }\cdot\frac{\partial}{\partial\varphi}\\ \frac{\partial}{\partial y} &=& sin\theta sin\varphi\cdot\frac{\partial}{\partial r} +\frac{cos\theta sin\varphi}{r}\cdot\frac{\partial}{\partial\theta}+\frac{cos\varphi}{rsen\theta}\cdot\frac{\partial}{ \partial\varphi} \\ \frac{\partial}{\partial z} &=& cos\theta\cdot\frac{\partial}{\partial r}-\frac{sin\theta}{r}\cdot \frac{\partial}{\partial\theta}\label{32} \end{eqnarray}

To finish we substitute the calculated expressions in the equations (\ref{1}), (\ref{2}) and (\ref{3}), thus completing the change to spherical. $$\hat{l}_x =-i\hbar\left[y\frac{\partial}{\partial z}-z\frac{\partial}{\partial y}\right]=$$

$$-i\hbar\left[rsen\theta sin\varphi\left(\cancel{cos\theta\frac{\partial}{\partial r}} -\frac{sin\theta} {r}\frac{\partial}{\partial\theta}\right)-rcos\theta\left(\cancel{sin\theta sin\varphi\frac{\partial}{\partial r}} +\frac{ cos\theta sin\varphi}{r}\frac{\partial}{\partial\theta}+\frac{cos\varphi}{rsen\theta}\frac{\partial}{\partial\varphi}\right) \right]$$

Using $sin^2 \theta + cos^2 \theta =1$ and $cotg\theta =\frac{cos\theta}{sin\theta}$ and simplifying:

$$\hat{l}_x =i\hbar\left[sin\varphi\frac{\partial}{\partial \theta}+cotg\theta cos\varphi \frac{\partial}{\partial\varphi}\right ]$$

Analogously we obtain the operator $\hat{l}_y$ in spherical polar coordinates.

$$\hat{l}_y =-i\hbar\left[z\frac{\partial}{\partial x}-x\frac{\partial}{\partial z}\right]=$$

$$-i\hbar\left[rcos\theta \left(\cancel{sin\theta cos\varphi\frac{\partial}{\partial r}} +\frac{cos\theta cos \varphi}{r}\frac{\partial}{\partial\theta}+\frac{sin\varphi}{rsen\theta}\frac{\partial}{\partial\varphi}\right)-rsen\theta cos\varphi\left(\cancel{cos\theta\frac{\partial}{\partial r}} -\frac{sin\theta}{r}\frac{\partial}{\partial\theta}\right) \right]$$

Using $sin^2 \theta + cos^2 \theta =1$ and $cotg\theta =\frac{cos\theta}{sin\theta}$ and simplifying:

$$\hat{l}_y =-i\hbar\left[cos\varphi\frac{\partial}{\partial \theta}-cotg\theta sin\varphi \frac{\partial}{\partial\varphi}\right]$$

Repeating the same procedure we obtain $\hat{l}_z$ in spherical form.

$$\hat{l}_z = -i\hbar\left[{x}\frac{\partial}{\partial y}-{y}\frac{\partial}{\partial x}\right ]=-i\hbar\frac{\partial}{\partial\varphi}$$

We can also calculate the operator $\hat{l}^2 = \hat{l}^2_{x}+\hat {l}^2_{y}+\hat{l}^2_{z}$ in spherical coordinates

$$\hat{l}^2 = -\hbar^2 \left(\frac{\partial^ 2}{\partial\theta^2}+cotg\theta\frac{\partial}{\partial\theta}+\frac{1}{sin^2\theta}\frac{\partial^2}{\partial \varphi^2}\right)$$

Note that the angular momentum operators are only a function of the coordinates $\theta$ and $\varphi$ and not of $r$.