Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Suppose we have $x=\sin a \cos b, y=\sin a\sin b, z=\cos a$. I want to invert them to get $a,b$ in terms of $x,y,z$. At first sight it appears very simple, for example my first reaction would be to say that $a= \cos^{-1} z, b= \cos^{-1}{\left(x\over \sqrt{1-z^2}\right)}$. But it doesn't feel right for example that I used only $x,z$ for $b$ since $y$ also involves $b$. I think the inverse like this might not give the right range of angles, since where $\sin,\cos$ are positive don't necessarily overlap. How might I find $a,b$ in terms of more variables? I have to get $a$ to be unique in $(0,\pi)$ and $b$ unique in $(0,2\pi)$.

share|cite|improve this question
Your inverses are correct. There is no $y$ in the picture since $x$,$y$, $z$ are constrained to move on a sphere i.e. $x^2 + y^2 + z^2 = 1$. – user17762 Mar 11 '12 at 22:31

$a= \cos^{-1} z$ and $\frac{y}{x} = \tan(b) \Rightarrow b=\tan^{-1} \frac{y}{x}$

share|cite|improve this answer

Your formula is correct when $y$ is positive. But when $y$ is negative, $$b=2\pi -\arccos\left(\frac{x}{\sqrt{1-z^2}}\right).$$

Remark: Alternately, one can use $\arctan$ to almost compute $b$. But again adjustment needs to be made, depending on the sign of $y$. In a computing setting, you may be able to use the two-variable $\text{atan}$ function, which deals with the sign issue automatically.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.