Find the inverse of $f(\phi, \theta) = \langle \sin\phi\cos\theta, \ \sin\phi\sin\theta, \ \cos\phi \rangle$ 
Find the inverse of $f(\phi, \theta) = \langle \sin\phi\cos\theta, \ \sin\phi\sin\theta, \ \cos\phi \rangle$

Here $f : (0, \pi) \times (0, 2\pi) \to S^2 \subseteq \mathbb{R}^3$. I know there's no set way to calculate the inverse for any given function, but I'm stuck here, I'm not sure at all what the inverse function would look like.
If I had $g : \mathbb{R}^2 \to \mathbb{R}^3$ defined by $g(x, y) = \langle x, y, 1 \rangle$, then $g^{-1}(x, y, z) = \langle x, y \rangle$, where $g^{-1}$ would just the the projection function.
But the map $f$ I have here is more complicated, and I'm not sure how to even begin computing the inverse.
 A: Given $(x,y,z)$ which satisfy $x^2+y^2+z^2=1$. The inverse is defined by
\begin{eqnarray*}
f^{-1}(x,y,z) = \left( \phi = \tan^{-1} \left( \frac{x^2+y^2}{z} \right) , \theta =\tan^{-1} \left( \frac{y}{x} \right) \right).
\end{eqnarray*}
Edit : We have 
\begin{eqnarray*}
x= \sin \phi \cos \theta \\
y= \sin \phi \sin \theta \\
z= \cos \phi \\
\end{eqnarray*}
Square the first two equations, add them and divide by the third equation; we get $ \tan \phi =\frac{x^2+y^2}{z}$.
Divide the second equation by the first and we have $ \tan \theta = \frac{y}{x}$
A: Suppose $\langle x,y,z\rangle=\langle\cos\theta\sin\phi,\sin\theta\sin\phi,\cos\phi\rangle$.
Since $\phi\in(0,\pi)$, you recover $z$ by $z=\arccos\phi$. In particular, $\sin\phi=\sqrt{1-z^2}$, so
$$
\cos\theta=\frac{x}{\sqrt{1-z^2}},
\qquad
\sin\theta=\frac{y}{\sqrt{1-z^2}}\tag{*}
$$
Since
$$
\frac{x^2}{1-z^2}+\frac{y^2}{1-z^2}=\frac{1-z^2}{1-z^2}=1
$$
(because $x^2+y^2+z^2=1$) the relations (*) define a unique angle $\theta\in(0,2\pi)$ (note that $\cos\theta\sin\phi\ne0$ in the given domain).
How you write the inverse from (*) is not so important; probably $\theta=\arg\bigl(\frac{x+iy}{\sqrt{1-z^2}})$ is the simplest way.
