finding the angle in polar coordinates

7.1k Views Asked by At

Suppose we are given cartesian coordinates $x=r\cos\varphi$ and $y=r\sin\varphi$.

In polar coordinates these become $r=\sqrt{x^2+y^2}$ and $$\varphi=\arctan(\frac{y}{x}).$$ My question is why do we have to find $\varphi$ using arctan? If $x=r\cos\varphi$ and $y=r\sin\varphi$ then doesn't $$\varphi=\arccos(\frac{x}{r})$$ and $$\varphi=\arcsin(\frac{y}{r})?$$ These three numbers are not always the same, so how do we know when we can use $\arccos$ or $\arcsin$ instead of $\arctan$?

4

There are 4 best solutions below

4
On BEST ANSWER

The truth is that you need a function which is usually found in the programming languages under the name $\text{atan2}(y, x)$ and that operates on the four quadrants, hence takes into account the signs of $x$ and $y$.

I don't know of an equivalent in mathematical notation, except maybe $\angle(x+iy)$ or $\arg(x+iy)$ borrowed from the complex numbers

2
On

You are right, all three formulas are correct.

If they give different results, this is due to range issues: arccos always has values in $[0,\pi]$, arcsin in $[-\pi/2,\pi/2]$ and arctan in $[-\pi/2,\pi/2]$.

This is why the atan2 function is sometimes used, with a range of $[-\pi,\pi]$ : $\varphi=\text{atan2}(y,x)$.

8
On

Consider $(x,y)=(1,-1)$. Can you tell me the angle with your both definitions? Two different results!

$$\arccos(\frac{1}{\sqrt{2}})=\frac{\pi}4$$ $$\arcsin(\frac{-1}{\sqrt{2}})=-\frac{\pi}4$$

The problem is that the sign of both $x$ and $y$ are needed. With $\arccos(\frac{x}{\sqrt{x^2+y^2}})$ the sign of $y$ is lost. That is the case with sign of $x$ in $\arcsin(\frac{y}{\sqrt{x^2+y^2}})$.

With $\arctan(\frac{y}{x})$ you consider the sign of both parts. Although again due to different definitions of $\arctan$ the signs will be needed at the end.

Long story short, the best is to check the signs whatever formula you use.

0
On

Let the angle be from positive $x$ axis be $\theta$.

$$\tan \theta=\dfrac{y}{x}$$

$$\arctan(\tan \theta)=\arctan(\dfrac{y}{x}) ...(1)$$

Now $\arctan (\tan \theta)= \theta$ is not always true as range of arctan is $(\frac{-\pi}{2},\frac{\pi}{2})$

  • So for $\theta\in (\frac{-\pi}{2},\frac{\pi}{2})$, it works nicely. For other values of theta, this formula won't work.

  • Consider the case of $\theta\in (\frac{\pi}{2},\frac{3\pi}{2})$. Here, we observe that $\tan(\theta - \pi) = \tan\theta$. So that, $$\arctan(\tan(\theta - \pi)) = \arctan(\tan\theta)$$ The advantage of this wil be that $\theta-\pi\in (\frac{-\pi}{2},\frac{\pi}{2})$, so $$\arctan(\tan(\theta - \pi)) = \theta - \pi$$ We put his back in $(1)$ to get : $$\theta - \pi=\arctan(\dfrac{y}{x})$$ and we get theta. We repeat this for $\theta\in (\frac{3\pi}{2},{2\pi})$

  • As you see, to find the interval of $\theta$, we must know signs of (x,y)

  • For $\arcsin$ and $\arccos$, there are other definitions in different intervals. But as you asked, it is completely possible to represent all angles from 0 to 2 pi using any of them, provided we use correct definition of functions in different intervals, which would again require sign of x,y to distinguish the quadrant (interval).

  • This process is cumbersome and it is much better to use a function (like atan2(y,x) one pointed out by Yves Daoust).