Did I derive a function for finding the angle of a complex number?

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
When presented with a complex # written in rectangular form (x + j*y), w/ the goal of converting it to polar form, the following 2 relationships are used:
- r = â ( x^2 + y^2 )
- ø = tan-1(y/x)
The equation for r works just fine but the one for ø breaks down w/ negative inputs... so either you do as I do and use whichever trig relationship makes the most sense for the given quad, or you can continue using tan but you must abide by quad dependent contingencies:
- ø = tan-1(y/x) + 180, x < 0, y < 0
- ø = tan-1(y/x) + 180, x < 0, y > 0
- ø = tan-1(y/x) + 360, x > 0, y < 0
- ø = tan-1(y/x), x > 0, y > 0
I decided to throw all of these contingencies into a single package and I would like your feedback on it:
ø = tan-1(y/x) + (1/2)((x/|x|) - 1)(180) + (1/2)((x/|x|) + 1)(-1/2)((y/|y|) - 1)(360)
Which translates to... if x < 0 ADD 180, else if x>0 AND y<0 ADD 360.
And, after simplifying, it looks like this:
ø = tan-1(y/x) - 90[(y/|y|)((x/|x|) + 1) - 2]
As far as feedback goes, I have a couple of questions:
- Is there an equation already like this?
- If so, is it simpler than mine?
- If no, you might come up with a simpler approach! Please share it w/ me if so (:! I think it would be cooler if it didn't require absolute value operations but I couldn't figure out any other way to get 1 for pos #s and -1 for neg #s.
- Did I make any mistakes? I entered complex numbers for each quad and received the correct outputs. Let me know if you spot any errors.
functions complex-numbers polar-coordinates elementary-functions
 |Â
show 1 more comment
up vote
1
down vote
favorite
When presented with a complex # written in rectangular form (x + j*y), w/ the goal of converting it to polar form, the following 2 relationships are used:
- r = â ( x^2 + y^2 )
- ø = tan-1(y/x)
The equation for r works just fine but the one for ø breaks down w/ negative inputs... so either you do as I do and use whichever trig relationship makes the most sense for the given quad, or you can continue using tan but you must abide by quad dependent contingencies:
- ø = tan-1(y/x) + 180, x < 0, y < 0
- ø = tan-1(y/x) + 180, x < 0, y > 0
- ø = tan-1(y/x) + 360, x > 0, y < 0
- ø = tan-1(y/x), x > 0, y > 0
I decided to throw all of these contingencies into a single package and I would like your feedback on it:
ø = tan-1(y/x) + (1/2)((x/|x|) - 1)(180) + (1/2)((x/|x|) + 1)(-1/2)((y/|y|) - 1)(360)
Which translates to... if x < 0 ADD 180, else if x>0 AND y<0 ADD 360.
And, after simplifying, it looks like this:
ø = tan-1(y/x) - 90[(y/|y|)((x/|x|) + 1) - 2]
As far as feedback goes, I have a couple of questions:
- Is there an equation already like this?
- If so, is it simpler than mine?
- If no, you might come up with a simpler approach! Please share it w/ me if so (:! I think it would be cooler if it didn't require absolute value operations but I couldn't figure out any other way to get 1 for pos #s and -1 for neg #s.
- Did I make any mistakes? I entered complex numbers for each quad and received the correct outputs. Let me know if you spot any errors.
functions complex-numbers polar-coordinates elementary-functions
You'd be better off writing a piecewise function with the canonical $arctan$ function. You don't realize it, but you're doing that with the $arctan$ (to begin with) and especially the absolute value functions.
â Jared
Sep 10 at 7:11
Please read this MathJax tutorial, which explains how to typeset mathematics on this site.
â N. F. Taussig
Sep 10 at 7:16
1
What if $x$ or $y$ is zero? And what do you need the formula for? Is numeric stability an issue? Note also that the standard libraries of many programming languages have aatan2(y, x)function which does the job.
â Martin R
Sep 10 at 7:37
@Jared The whole point in my quest to derive the single function was to eliminate the need for the piece wise function as I don't think they should be used when unnecessary. How would I be better off writing a piecewise function if I already wrote it (to begin with)?
â Landon
Sep 10 at 7:53
@N.F.Taussig Thank you, I will read that and use it from now on.
â Landon
Sep 10 at 7:54
 |Â
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When presented with a complex # written in rectangular form (x + j*y), w/ the goal of converting it to polar form, the following 2 relationships are used:
- r = â ( x^2 + y^2 )
- ø = tan-1(y/x)
The equation for r works just fine but the one for ø breaks down w/ negative inputs... so either you do as I do and use whichever trig relationship makes the most sense for the given quad, or you can continue using tan but you must abide by quad dependent contingencies:
- ø = tan-1(y/x) + 180, x < 0, y < 0
- ø = tan-1(y/x) + 180, x < 0, y > 0
- ø = tan-1(y/x) + 360, x > 0, y < 0
- ø = tan-1(y/x), x > 0, y > 0
I decided to throw all of these contingencies into a single package and I would like your feedback on it:
ø = tan-1(y/x) + (1/2)((x/|x|) - 1)(180) + (1/2)((x/|x|) + 1)(-1/2)((y/|y|) - 1)(360)
Which translates to... if x < 0 ADD 180, else if x>0 AND y<0 ADD 360.
And, after simplifying, it looks like this:
ø = tan-1(y/x) - 90[(y/|y|)((x/|x|) + 1) - 2]
As far as feedback goes, I have a couple of questions:
- Is there an equation already like this?
- If so, is it simpler than mine?
- If no, you might come up with a simpler approach! Please share it w/ me if so (:! I think it would be cooler if it didn't require absolute value operations but I couldn't figure out any other way to get 1 for pos #s and -1 for neg #s.
- Did I make any mistakes? I entered complex numbers for each quad and received the correct outputs. Let me know if you spot any errors.
functions complex-numbers polar-coordinates elementary-functions
When presented with a complex # written in rectangular form (x + j*y), w/ the goal of converting it to polar form, the following 2 relationships are used:
- r = â ( x^2 + y^2 )
- ø = tan-1(y/x)
The equation for r works just fine but the one for ø breaks down w/ negative inputs... so either you do as I do and use whichever trig relationship makes the most sense for the given quad, or you can continue using tan but you must abide by quad dependent contingencies:
- ø = tan-1(y/x) + 180, x < 0, y < 0
- ø = tan-1(y/x) + 180, x < 0, y > 0
- ø = tan-1(y/x) + 360, x > 0, y < 0
- ø = tan-1(y/x), x > 0, y > 0
I decided to throw all of these contingencies into a single package and I would like your feedback on it:
ø = tan-1(y/x) + (1/2)((x/|x|) - 1)(180) + (1/2)((x/|x|) + 1)(-1/2)((y/|y|) - 1)(360)
Which translates to... if x < 0 ADD 180, else if x>0 AND y<0 ADD 360.
And, after simplifying, it looks like this:
ø = tan-1(y/x) - 90[(y/|y|)((x/|x|) + 1) - 2]
As far as feedback goes, I have a couple of questions:
- Is there an equation already like this?
- If so, is it simpler than mine?
- If no, you might come up with a simpler approach! Please share it w/ me if so (:! I think it would be cooler if it didn't require absolute value operations but I couldn't figure out any other way to get 1 for pos #s and -1 for neg #s.
- Did I make any mistakes? I entered complex numbers for each quad and received the correct outputs. Let me know if you spot any errors.
functions complex-numbers polar-coordinates elementary-functions
functions complex-numbers polar-coordinates elementary-functions
asked Sep 10 at 7:06
Landon
132
132
You'd be better off writing a piecewise function with the canonical $arctan$ function. You don't realize it, but you're doing that with the $arctan$ (to begin with) and especially the absolute value functions.
â Jared
Sep 10 at 7:11
Please read this MathJax tutorial, which explains how to typeset mathematics on this site.
â N. F. Taussig
Sep 10 at 7:16
1
What if $x$ or $y$ is zero? And what do you need the formula for? Is numeric stability an issue? Note also that the standard libraries of many programming languages have aatan2(y, x)function which does the job.
â Martin R
Sep 10 at 7:37
@Jared The whole point in my quest to derive the single function was to eliminate the need for the piece wise function as I don't think they should be used when unnecessary. How would I be better off writing a piecewise function if I already wrote it (to begin with)?
â Landon
Sep 10 at 7:53
@N.F.Taussig Thank you, I will read that and use it from now on.
â Landon
Sep 10 at 7:54
 |Â
show 1 more comment
You'd be better off writing a piecewise function with the canonical $arctan$ function. You don't realize it, but you're doing that with the $arctan$ (to begin with) and especially the absolute value functions.
â Jared
Sep 10 at 7:11
Please read this MathJax tutorial, which explains how to typeset mathematics on this site.
â N. F. Taussig
Sep 10 at 7:16
1
What if $x$ or $y$ is zero? And what do you need the formula for? Is numeric stability an issue? Note also that the standard libraries of many programming languages have aatan2(y, x)function which does the job.
â Martin R
Sep 10 at 7:37
@Jared The whole point in my quest to derive the single function was to eliminate the need for the piece wise function as I don't think they should be used when unnecessary. How would I be better off writing a piecewise function if I already wrote it (to begin with)?
â Landon
Sep 10 at 7:53
@N.F.Taussig Thank you, I will read that and use it from now on.
â Landon
Sep 10 at 7:54
You'd be better off writing a piecewise function with the canonical $arctan$ function. You don't realize it, but you're doing that with the $arctan$ (to begin with) and especially the absolute value functions.
â Jared
Sep 10 at 7:11
You'd be better off writing a piecewise function with the canonical $arctan$ function. You don't realize it, but you're doing that with the $arctan$ (to begin with) and especially the absolute value functions.
â Jared
Sep 10 at 7:11
Please read this MathJax tutorial, which explains how to typeset mathematics on this site.
â N. F. Taussig
Sep 10 at 7:16
Please read this MathJax tutorial, which explains how to typeset mathematics on this site.
â N. F. Taussig
Sep 10 at 7:16
1
1
What if $x$ or $y$ is zero? And what do you need the formula for? Is numeric stability an issue? Note also that the standard libraries of many programming languages have a
atan2(y, x) function which does the job.â Martin R
Sep 10 at 7:37
What if $x$ or $y$ is zero? And what do you need the formula for? Is numeric stability an issue? Note also that the standard libraries of many programming languages have a
atan2(y, x) function which does the job.â Martin R
Sep 10 at 7:37
@Jared The whole point in my quest to derive the single function was to eliminate the need for the piece wise function as I don't think they should be used when unnecessary. How would I be better off writing a piecewise function if I already wrote it (to begin with)?
â Landon
Sep 10 at 7:53
@Jared The whole point in my quest to derive the single function was to eliminate the need for the piece wise function as I don't think they should be used when unnecessary. How would I be better off writing a piecewise function if I already wrote it (to begin with)?
â Landon
Sep 10 at 7:53
@N.F.Taussig Thank you, I will read that and use it from now on.
â Landon
Sep 10 at 7:54
@N.F.Taussig Thank you, I will read that and use it from now on.
â Landon
Sep 10 at 7:54
 |Â
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f2911611%2fdid-i-derive-a-function-for-finding-the-angle-of-a-complex-number%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'd be better off writing a piecewise function with the canonical $arctan$ function. You don't realize it, but you're doing that with the $arctan$ (to begin with) and especially the absolute value functions.
â Jared
Sep 10 at 7:11
Please read this MathJax tutorial, which explains how to typeset mathematics on this site.
â N. F. Taussig
Sep 10 at 7:16
1
What if $x$ or $y$ is zero? And what do you need the formula for? Is numeric stability an issue? Note also that the standard libraries of many programming languages have a
atan2(y, x)function which does the job.â Martin R
Sep 10 at 7:37
@Jared The whole point in my quest to derive the single function was to eliminate the need for the piece wise function as I don't think they should be used when unnecessary. How would I be better off writing a piecewise function if I already wrote it (to begin with)?
â Landon
Sep 10 at 7:53
@N.F.Taussig Thank you, I will read that and use it from now on.
â Landon
Sep 10 at 7:54