When converting coordinates from rectangular to cylindrical, to spherical, etc. we will eventually come across having to use $ArcTan(y/x)$, and/or $ArcCos(z/\rho)$ to derive $\theta$ and/or $\phi$. However, sometimes the $x$ coordinate used in $ArcTan(y/x)$ may very well be $0$, which makes the fraction undefined. How do we retrieve the angle we need in this situation?
2026-03-25 09:28:34.1774430914
On
How do we deal with ArcTan (or other inverse functions) of undefined values?
5k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
There are 2 best solutions below
3
On
When converting from rectangular to cylindrical, the statement that $\theta=\arctan \frac yx$ is a bit sloppy. You need to start with if $x=0, \theta = \pm \frac \pi 2$ depending on the sign of $y$ because the arctangent never returns $\pm \frac \pi 2$. Then you can use the arctangent formula, but you may have to add $\pi$ depending on the quadrant. Computer languages have an atan2 function that takes care of all that for you. The conversion to spherical is similar.
if $x = \rho\cos\theta\sin\phi\\y = \rho\sin\theta\sin\phi\\z = \rho\cos\phi$
then $\frac {y}{x} = \tan \theta$ and $\arctan \frac{y}{x} = \arctan (\tan\theta) = \theta$ if $\theta \in (-\frac{\pi}{2},\frac {\pi}{2})$
If $\theta$ is not in the correct interval you will need to add (or subtract) some multiple of $\pi$
If $x=0$ then $\arctan \frac{y}{x}$ is undefined, but you may be able to find a limit as x approaches 0.