Q:

Laplace equation in spherical coordinates

I am trying to calculate the Laplace equation($\Delta f =\partial_x\partial_xf + \partial_y \partial_y f + \partial_z \partial_z f = 0$ )  in $\Bbb{R}^3$ for spherical coordinates.
$$g(r, \phi,\theta) = f(r \cos \theta \cos \phi, r \cos \theta \sin \phi, r \sin \theta)$$ 
\begin{align}\partial_rg(r, \phi,\theta) &= \phantom{-}\partial_x f\cos \theta \cos \phi + \partial_y f \cos \theta \sin \phi + \partial_z f \sin \theta\\
\partial_\theta g(r, \phi,\theta) &= -\partial_x f r\sin \theta \cos \phi - \partial_y f r \sin \theta \sin \phi + \partial_z f r\cos \theta\\
\partial_\phi g(r, \phi,\theta) &= -\partial_x f r\cos \theta \sin \phi + \partial_y f r\cos \theta \cos \phi  \end{align}
\begin{align}
&\partial_r\big(r^2\partial_rg(r, \phi,\theta)\big) = 2 r \partial_rg(r, \phi,\theta) + r^2 \bigg( \partial_x\partial_x f\cos^2 \theta \cos^2 \phi + 2\partial_y \partial_xf \cos^2 \theta \cos \phi\sin \phi  \\&+2\partial_z\partial_x f \cos \theta \sin \theta \cos\phi + \partial_y\partial_y f \cos^2 \theta \sin^2 \phi + 2 \partial_z\partial_y f \cos \theta \sin \theta  \sin \phi+ \partial_z\partial_z f\sin^2 \theta\bigg)\\
&\partial_\theta\big(\sin \theta\partial_\theta g(r, \phi,\theta)\big) =\cos \theta\partial_\theta g(r,\theta, \phi) + \sin \theta \bigg( -\partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi - \partial_z f r\sin \theta\\
&\qquad+\partial_x\partial_x f r^2\sin^2 \theta \cos^2 \phi + 2\partial_y\partial_x f r^2 \sin^2   \theta \cos \phi\sin \phi - 2 \partial_x\partial_z f r^2\cos \theta\sin \theta \cos \phi  \\
&\qquad +\partial_y\partial_y f r^2\sin^2 \theta \sin^2 \phi - 2\partial_z\partial_y f r^2 \cos \theta\sin\theta  \sin \phi +  \partial_z\partial_z f r^2\cos^2 \theta\bigg) \\ 
&\partial_\phi\partial_\phi g(r, \phi,\theta) = -\partial_x f r\cos \theta \cos \phi - \partial_y f r\cos \theta \sin \phi  + \partial_x\partial_x f r^2\cos^2 \theta \sin^2 \phi \\
&\qquad- 2  \partial_y \partial_x f r^2 \cos^2\theta \cos \phi\sin \phi + \partial_y\partial_y f r^2\cos^2 \theta\cos^2 \phi\\ \end{align}
According to wikipedia 

So now Let's move to the final step:
$$\frac{1}{r^2}\partial_r\big(r^2\partial_rg(r, \phi,\theta)\big)  + \frac{1}{r^2 \sin \theta}\partial_\theta\big(\sin \theta\partial_\theta g(r, \phi,\theta)\big)  + \frac{1}{r^2 \sin^2 \theta}\partial_\phi\partial_\phi g(r, \phi,\theta) = \\
 \bigg(\partial_x\partial_x f\cos^2 \theta \cos^2 \phi + \partial_x\partial_x f\sin^2 \theta \cos^2 \phi + \partial_x\partial_x f \frac{\cos^2 \theta}{\sin^2 \theta} \sin^2 \phi\bigg) \\
 + \bigg(2\partial_y \partial_xf \cos^2 \theta \cos \phi\sin \phi  + 2\partial_y\partial_x f \sin^2   \theta \cos \phi\sin \phi - 2  \partial_y \partial_x f  \frac{\cos^2\theta}{\sin^2 \theta} \cos \phi\sin \phi \bigg)\\
 + \bigg(2\partial_z\partial_x f \cos \theta \sin \theta \cos\phi - 2 \partial_x\partial_z f\cos \theta\sin \theta \cos \phi \bigg)\\
+\bigg( \partial_y\partial_y f \cos^2 \theta \sin^2 \phi +\partial_y\partial_y f \sin^2 \theta \sin^2 \phi +\partial_y\partial_y f \frac{\cos^2 \theta}{\sin ^2 \theta}\cos^2 \phi\bigg) \\
 + \bigg( 2 \partial_z\partial_y f \cos \theta \sin \theta  \sin \phi - 2\partial_z\partial_y f  \cos \theta\sin\theta  \sin \phi \bigg)\\
+ \bigg( \partial_z\partial_z f\sin^2 \theta + \partial_z\partial_z f \cos^2 \theta\bigg) \\
+ \bigg(\frac{2}{r} \partial_rg(r, \phi,\theta) +\frac{\cos \theta}{r^2 \sin \theta}\partial_\theta g(r,\theta, \phi)  + \frac{ -\partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi - \partial_z f r\sin \theta}{r^2 } \\
+ \frac{-\partial_x f r\cos \theta \cos \phi - \partial_y f r\cos \theta \sin \phi}{r^2 \sin^2 \theta}\bigg)$$
I assume there is a typo in wikipedia and what is meant is not 
$$\frac{1}{r^2}\partial_r\big(r^2\partial_rg(r, \phi,\theta)\big)  + \frac{1}{r^2 \sin \theta}\partial_\theta\big(\sin \theta\partial_\theta g(r, \phi,\theta)\big)  + \frac{1}{r^2 \sin^2 \theta}\partial_\phi\partial_\phi g(r, \phi,\theta) $$
but $$\frac{1}{r^2}\partial_r\big(r^2\partial_rg(r, \phi,\theta)\big)  + \frac{1}{r^2 \sin \theta}\partial_\theta\big(\sin \theta\partial_\theta g(r, \phi,\theta)\big)  + \frac{1}{r^2 \cos^2 \theta}\partial_\phi\partial_\phi g(r, \phi,\theta)  $$
This will give us 
$$\frac{1}{r^2}\partial_r\big(r^2\partial_rg(r, \phi,\theta)\big)  + \frac{1}{r^2 \sin \theta}\partial_\theta\big(\sin \theta\partial_\theta g(r, \phi,\theta)\big)  + \frac{1}{r^2 \cos^2 \theta}\partial_\phi\partial_\phi g(r, \phi,\theta) = \\ \bigg(\partial_x\partial_x f + \partial_y\partial_y f + \partial_z\partial_z f\bigg) \\
+ \bigg(\frac{2}{r} \partial_rg(r, \phi,\theta) +\frac{\cos \theta}{r^2 \sin \theta}\partial_\theta g(r,\theta, \phi)  + \frac{ -\partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi - \partial_z f r\sin \theta}{r^2 } \\
+ \frac{-\partial_x f r\cos \theta \cos \phi - \partial_y f r\cos \theta \sin \phi}{r^2 \cos^2 \theta}\bigg)$$
It remains only to show that
$$\bigg(\frac{2}{r} \partial_rg(r, \phi,\theta) +\frac{\cos \theta}{r^2 \sin \theta}\partial_\theta g(r,\theta, \phi)  + \frac{ -\partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi - \partial_z f r\sin \theta}{r^2 } \\
+ \frac{-\partial_x f r\cos \theta \cos \phi - \partial_y f r\cos \theta \sin \phi}{r^2 \cos^2 \theta}\bigg) = 0 $$
but I am finding 
$$\bigg(\frac{2}{r} \partial_rg(r, \phi,\theta) +\frac{\cos \theta}{r^2 \sin \theta}\partial_\theta g(r,\theta, \phi)  + \frac{ -\partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi - \partial_z f r\sin \theta}{r^2 } \\
+ \frac{-\partial_x f r\cos \theta \cos \phi - \partial_y f r\cos \theta \sin \phi}{r^2 \cos^2 \theta}\bigg) \\= \frac{1}{r} \bigg(2 \big(\partial_x f \cos \theta \cos \phi + \partial_y f  \cos   \theta \sin \phi  + \partial_z f \sin \theta\big)\\
- \partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi + \partial_z f \frac{\cos^2 \theta}{\sin \theta}\\
-\partial_x f r\cos \theta \cos \phi - \partial_y f r \cos   \theta \sin \phi - \partial_z f \sin \theta \\
+\frac{-\partial_x f  \cos \phi - \partial_y f \sin \phi}{ \cos \theta}\bigg)  =\\
\frac{1}{r^2}\bigg( \partial_z f \frac{\cos^2 \theta}{\sin \theta} +\frac{-\partial_x f  \cos \phi - \partial_y f \sin \phi}{ \cos \theta}\bigg)
 $$
So the question is: Is the expression in wikipedia (https://en.wikipedia.org/wiki/Spherical_harmonics#Laplace.27s_spherical_harmonics) right? What step is wrong in the above reasoning? 

A:

Wikipedia is correct. You made the mistake here:
$$g(r, \phi,\theta) = f(r \cos \theta \cos \phi, r \cos \theta \sin \phi, r \sin \theta)$$ 
the correct one is:
$$g(r, \phi,\theta) = f( r \sin \theta \cos \phi,r \sin \theta \sin \phi, r \cos \theta)$$ 

