I found the following equations to converting between Rectangular and Spherical coordinates on the site https://byjus.com/maths/spherical-coordinates/#:~:text=In%20three%20dimensional%20space%2C%20the,used%20to%20determine%20these%20coordinates.
Rectangular to Spherical: r = sqrt(pow(x,2 + pow(y,2) + pow(z,2)) theta = arccos (x/r) phi = arccos (x/(r sin theta))
Spherical to Rectangular: x = r sin (theta) cos (phi) y = r sin (theta) sin (phi) z = r cos (theta)
If I use the first set to convert (0, 10, 10) to spherical I get r= 10 sqrt(2), theta = 90 deg, phi = 90 deg.
But if I use the second set to convert (10 sqrt(2), 90, 90) to rectangular, I get x = 0, y = 10 sqrt(2), z = 0.
You would think that one should be the inverse of the other and return the original set.

$$\phi=\cos^{-1}(\frac{x}{r \sin \theta})$$ is just true, but not a transformation formula, because angular functions occur on both sides.
by $$\frac{y}{x}=\frac {r \sin \phi}{r \cos \phi}$$
$$\phi=\tan^{-1}\left(\frac{y}{x}\right) + if(x>0,0,\pm \pi) $$
where the conventions in the x-negative half plane vary. In numerical languages there exists the $\tan^{-1}(x,y)$ of two arguemnts as a continuous function to $(-\pi,\pi)$