Why subtract $pi$ in the definition of atan2?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Looking here the definition of the atan2
function is as follows:
$$operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0text and ygeq 0,\
arctan(frac yx)-pi & textif x<0text and y<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text andy<0,\
textundefined & textif x=0text and y=0.
endcases$$
This looks wrong to me. Or at least, not wrong but rather there seems to be a small issue with it.
My Reasoning
I was trying to figure out a function (like $atan2$) that would solve the problem of the $arctan$ function. This is because I am writing a Python function to find the complex argument of a complex number, given real and imaginary part. Here is my reasoning:
Given a non-negative tangent value, this is mapped by the arctan only in the range $left[0, fracpi2right)$.
Given a non-positive tangent value, this is mapped by the arctan only in the range $left[0, -fracpi2right)$.
However, given a non-negative tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is an angle $theta in left[0, fracpi2right)$
- $theta + pi$ which is a diametrically opposite angle in the third quadrant, that is $left[pi, -frac3pi2right)$
Similarly, given a non-positive tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is a negative angle in $theta inleft[0, -fracpi2right)$
- $theta + pi$ which is diametrically opposite angle in the second quadrant, that is $left(fracpi2, piright]$
Thus, the definition of $atan2$ that I would use, would be:
$
operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text and y<0,\
textundefined & textif x=0text and y=0.
endcases
$
Why does the Wikipedia definition subtract $pi$ when we are in the third quadrant ($x<0$ and $y<0$)? If we do this, we end up with a negative angle! Yes sure, the negative angle would have the same sine, cosine and tangent of the angle obtained by summing $pi$, but why bother?
algebra-precalculus trigonometry angle
 |Â
show 7 more comments
up vote
1
down vote
favorite
Looking here the definition of the atan2
function is as follows:
$$operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0text and ygeq 0,\
arctan(frac yx)-pi & textif x<0text and y<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text andy<0,\
textundefined & textif x=0text and y=0.
endcases$$
This looks wrong to me. Or at least, not wrong but rather there seems to be a small issue with it.
My Reasoning
I was trying to figure out a function (like $atan2$) that would solve the problem of the $arctan$ function. This is because I am writing a Python function to find the complex argument of a complex number, given real and imaginary part. Here is my reasoning:
Given a non-negative tangent value, this is mapped by the arctan only in the range $left[0, fracpi2right)$.
Given a non-positive tangent value, this is mapped by the arctan only in the range $left[0, -fracpi2right)$.
However, given a non-negative tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is an angle $theta in left[0, fracpi2right)$
- $theta + pi$ which is a diametrically opposite angle in the third quadrant, that is $left[pi, -frac3pi2right)$
Similarly, given a non-positive tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is a negative angle in $theta inleft[0, -fracpi2right)$
- $theta + pi$ which is diametrically opposite angle in the second quadrant, that is $left(fracpi2, piright]$
Thus, the definition of $atan2$ that I would use, would be:
$
operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text and y<0,\
textundefined & textif x=0text and y=0.
endcases
$
Why does the Wikipedia definition subtract $pi$ when we are in the third quadrant ($x<0$ and $y<0$)? If we do this, we end up with a negative angle! Yes sure, the negative angle would have the same sine, cosine and tangent of the angle obtained by summing $pi$, but why bother?
algebra-precalculus trigonometry angle
You said it, why bother ?
â Yves Daoust
Jul 26 at 11:50
Because in my way the definition is much more succinct, and I do not have to re-convert the angle at the end
â Euler_Salter
Jul 26 at 11:53
You reconvert the angle because you want to adopt a different convention, you can only blame yourself. The "standard" convention is not worse than another.
â Yves Daoust
Jul 26 at 11:55
2
The principal branch has $-pi < arctan2(x)le pi$. Your definition doesn't satisfy that condition.
â Mark Viola
Jul 26 at 11:59
@MarkViola That! That is what explains everything! The principal branch of the complex number is defined within that interval because otherwise we could have multiple ones just by adding $2pi$ multiples! Could you please write an answer for future reference?
â Euler_Salter
Jul 26 at 12:05
 |Â
show 7 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Looking here the definition of the atan2
function is as follows:
$$operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0text and ygeq 0,\
arctan(frac yx)-pi & textif x<0text and y<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text andy<0,\
textundefined & textif x=0text and y=0.
endcases$$
This looks wrong to me. Or at least, not wrong but rather there seems to be a small issue with it.
My Reasoning
I was trying to figure out a function (like $atan2$) that would solve the problem of the $arctan$ function. This is because I am writing a Python function to find the complex argument of a complex number, given real and imaginary part. Here is my reasoning:
Given a non-negative tangent value, this is mapped by the arctan only in the range $left[0, fracpi2right)$.
Given a non-positive tangent value, this is mapped by the arctan only in the range $left[0, -fracpi2right)$.
However, given a non-negative tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is an angle $theta in left[0, fracpi2right)$
- $theta + pi$ which is a diametrically opposite angle in the third quadrant, that is $left[pi, -frac3pi2right)$
Similarly, given a non-positive tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is a negative angle in $theta inleft[0, -fracpi2right)$
- $theta + pi$ which is diametrically opposite angle in the second quadrant, that is $left(fracpi2, piright]$
Thus, the definition of $atan2$ that I would use, would be:
$
operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text and y<0,\
textundefined & textif x=0text and y=0.
endcases
$
Why does the Wikipedia definition subtract $pi$ when we are in the third quadrant ($x<0$ and $y<0$)? If we do this, we end up with a negative angle! Yes sure, the negative angle would have the same sine, cosine and tangent of the angle obtained by summing $pi$, but why bother?
algebra-precalculus trigonometry angle
Looking here the definition of the atan2
function is as follows:
$$operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0text and ygeq 0,\
arctan(frac yx)-pi & textif x<0text and y<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text andy<0,\
textundefined & textif x=0text and y=0.
endcases$$
This looks wrong to me. Or at least, not wrong but rather there seems to be a small issue with it.
My Reasoning
I was trying to figure out a function (like $atan2$) that would solve the problem of the $arctan$ function. This is because I am writing a Python function to find the complex argument of a complex number, given real and imaginary part. Here is my reasoning:
Given a non-negative tangent value, this is mapped by the arctan only in the range $left[0, fracpi2right)$.
Given a non-positive tangent value, this is mapped by the arctan only in the range $left[0, -fracpi2right)$.
However, given a non-negative tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is an angle $theta in left[0, fracpi2right)$
- $theta + pi$ which is a diametrically opposite angle in the third quadrant, that is $left[pi, -frac3pi2right)$
Similarly, given a non-positive tangent value, there are two angles that could have that tangent value:
- $arctan(tan(theta))$ which is a negative angle in $theta inleft[0, -fracpi2right)$
- $theta + pi$ which is diametrically opposite angle in the second quadrant, that is $left(fracpi2, piright]$
Thus, the definition of $atan2$ that I would use, would be:
$
operatorname atan2 (y,x)=
begincases
arctan(frac yx) & textif x>0,\
arctan(frac yx)+pi & textif x<0,\
+frac pi2 & textif x=0text and y>0,\
-frac pi 2 & textif x=0text and y<0,\
textundefined & textif x=0text and y=0.
endcases
$
Why does the Wikipedia definition subtract $pi$ when we are in the third quadrant ($x<0$ and $y<0$)? If we do this, we end up with a negative angle! Yes sure, the negative angle would have the same sine, cosine and tangent of the angle obtained by summing $pi$, but why bother?
algebra-precalculus trigonometry angle
edited Jul 26 at 11:47
asked Jul 26 at 11:43
Euler_Salter
2,0071331
2,0071331
You said it, why bother ?
â Yves Daoust
Jul 26 at 11:50
Because in my way the definition is much more succinct, and I do not have to re-convert the angle at the end
â Euler_Salter
Jul 26 at 11:53
You reconvert the angle because you want to adopt a different convention, you can only blame yourself. The "standard" convention is not worse than another.
â Yves Daoust
Jul 26 at 11:55
2
The principal branch has $-pi < arctan2(x)le pi$. Your definition doesn't satisfy that condition.
â Mark Viola
Jul 26 at 11:59
@MarkViola That! That is what explains everything! The principal branch of the complex number is defined within that interval because otherwise we could have multiple ones just by adding $2pi$ multiples! Could you please write an answer for future reference?
â Euler_Salter
Jul 26 at 12:05
 |Â
show 7 more comments
You said it, why bother ?
â Yves Daoust
Jul 26 at 11:50
Because in my way the definition is much more succinct, and I do not have to re-convert the angle at the end
â Euler_Salter
Jul 26 at 11:53
You reconvert the angle because you want to adopt a different convention, you can only blame yourself. The "standard" convention is not worse than another.
â Yves Daoust
Jul 26 at 11:55
2
The principal branch has $-pi < arctan2(x)le pi$. Your definition doesn't satisfy that condition.
â Mark Viola
Jul 26 at 11:59
@MarkViola That! That is what explains everything! The principal branch of the complex number is defined within that interval because otherwise we could have multiple ones just by adding $2pi$ multiples! Could you please write an answer for future reference?
â Euler_Salter
Jul 26 at 12:05
You said it, why bother ?
â Yves Daoust
Jul 26 at 11:50
You said it, why bother ?
â Yves Daoust
Jul 26 at 11:50
Because in my way the definition is much more succinct, and I do not have to re-convert the angle at the end
â Euler_Salter
Jul 26 at 11:53
Because in my way the definition is much more succinct, and I do not have to re-convert the angle at the end
â Euler_Salter
Jul 26 at 11:53
You reconvert the angle because you want to adopt a different convention, you can only blame yourself. The "standard" convention is not worse than another.
â Yves Daoust
Jul 26 at 11:55
You reconvert the angle because you want to adopt a different convention, you can only blame yourself. The "standard" convention is not worse than another.
â Yves Daoust
Jul 26 at 11:55
2
2
The principal branch has $-pi < arctan2(x)le pi$. Your definition doesn't satisfy that condition.
â Mark Viola
Jul 26 at 11:59
The principal branch has $-pi < arctan2(x)le pi$. Your definition doesn't satisfy that condition.
â Mark Viola
Jul 26 at 11:59
@MarkViola That! That is what explains everything! The principal branch of the complex number is defined within that interval because otherwise we could have multiple ones just by adding $2pi$ multiples! Could you please write an answer for future reference?
â Euler_Salter
Jul 26 at 12:05
@MarkViola That! That is what explains everything! The principal branch of the complex number is defined within that interval because otherwise we could have multiple ones just by adding $2pi$ multiples! Could you please write an answer for future reference?
â Euler_Salter
Jul 26 at 12:05
 |Â
show 7 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
For consistency, the $textatan_2$ values are defined in a range that equals a full period.
The usual choice is $(-pi,pi]$, but this is arbitrary and inessential, provided you know it.
What really matters is that when taking the cosine and sine, the original signs are restored.
Whatever the convention, computing with angles is often tricky.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
For consistency, the $textatan_2$ values are defined in a range that equals a full period.
The usual choice is $(-pi,pi]$, but this is arbitrary and inessential, provided you know it.
What really matters is that when taking the cosine and sine, the original signs are restored.
Whatever the convention, computing with angles is often tricky.
add a comment |Â
up vote
2
down vote
For consistency, the $textatan_2$ values are defined in a range that equals a full period.
The usual choice is $(-pi,pi]$, but this is arbitrary and inessential, provided you know it.
What really matters is that when taking the cosine and sine, the original signs are restored.
Whatever the convention, computing with angles is often tricky.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
For consistency, the $textatan_2$ values are defined in a range that equals a full period.
The usual choice is $(-pi,pi]$, but this is arbitrary and inessential, provided you know it.
What really matters is that when taking the cosine and sine, the original signs are restored.
Whatever the convention, computing with angles is often tricky.
For consistency, the $textatan_2$ values are defined in a range that equals a full period.
The usual choice is $(-pi,pi]$, but this is arbitrary and inessential, provided you know it.
What really matters is that when taking the cosine and sine, the original signs are restored.
Whatever the convention, computing with angles is often tricky.
edited Jul 26 at 11:59
answered Jul 26 at 11:54
Yves Daoust
111k665203
111k665203
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2863341%2fwhy-subtract-pi-in-the-definition-of-atan2%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You said it, why bother ?
â Yves Daoust
Jul 26 at 11:50
Because in my way the definition is much more succinct, and I do not have to re-convert the angle at the end
â Euler_Salter
Jul 26 at 11:53
You reconvert the angle because you want to adopt a different convention, you can only blame yourself. The "standard" convention is not worse than another.
â Yves Daoust
Jul 26 at 11:55
2
The principal branch has $-pi < arctan2(x)le pi$. Your definition doesn't satisfy that condition.
â Mark Viola
Jul 26 at 11:59
@MarkViola That! That is what explains everything! The principal branch of the complex number is defined within that interval because otherwise we could have multiple ones just by adding $2pi$ multiples! Could you please write an answer for future reference?
â Euler_Salter
Jul 26 at 12:05