# 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.

• If $\Bbb R^2$ is the domain, then $f$ is not injective – ajotatxe Aug 13 '17 at 13:07
• A good start would be to visualize what this function does and try to formulate the inverse from the picture. It is probably hard to guess the right steps from a pure calculation. – klirk Aug 13 '17 at 13:07
• $f(\phi, \theta) = \langle \sin\phi\cos\theta, \ \sin\phi\sin\theta, \ \cos \color{red}{\phi} \rangle$ ? – Donald Splutterwit Aug 13 '17 at 13:10
• I think the only reason you weren't able to compute this inverse is because naturally we don't think that the domain and range should have different coordinates, but in fact, they should. For instance, if you write $f(x,y) = (2x,y)$ then the inverse may not be clear. Now if I say $(2x,y) = (u,v)$ where $(u,v)$ are the coordinates for the image space then it is clear that $g(u,v)=(u/2,v)$ is the inverse for $f$. – Faraad Armwood Aug 13 '17 at 14:50

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}$
• There are some issues with this formula. Firstly, $\tan^{-1}$ will give you an angle $\phi$ with $-\frac{\pi}{2} < \phi < -\frac{\pi}{2}.$ So we will always have $\cos\phi > 0.$ We should better use $\phi=\cos^{-1} z$ to cover all latitudes. Secondly, we do not get all longitudes with your formula, either. We have to consider the signs of $x$ and $y$, too. So we should better use the atan2 function: $\theta=\mathrm{atan2}(y,x).$ which can also be expressed in terms of complex numbers: $\theta =\arg(x+yi).$ – Reinhard Meier Aug 13 '17 at 13:32
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.