-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -
-
×InformationNeed Windows 11 help?Check documents on compatibility, FAQs, upgrade information and available fixes.
Windows 11 Support Center. -

Create an account on the HP Community to personalize your profile and ask a question

04-04-2013 12:45 PM
Is there a two-argument ATAN function on the HP50g that will return the correct quadrant as well as a numerical answer? I found this thread but I can't seem to make heads or tails of the long RPL program he provides at the end.
04-04-2013 02:58 PM
refer to the following comp.sys.hp48 post for additional userrpl programs written for a function 'atan2'
however, what you are trying to achieve is still not clear...
have you read the AUR definition of how the ARG function is calculated?
-------------
Argument Function: Returns the (real) polar angle θ of a complex number (x, y).
The polar angle θ is equal to:
• atan y/x for x ≥ 0
• atan y/x + π sign y for x < 0, Radians mode
• atan y/x + 180 sign y for x < 0, Degrees mode
• atan y/x + 200 sign y for x < 0, Grads mode
A real argument x is treated as the complex argument (x,0).
----------------
wikipedia is not the most accurate source, however, a quick comparison of the ARG calculation reveals the resulting calculation to be identical.
the quadrant result for ARG appears to be correct.
In the yahoo post you referenced, the OP had a specific issue to provide a solution where all angles were shown as positive values..
so for example (in degrees),
(-1, -1)
ARG
result: -135
the yahoo OP wanted a positive result of 225.
so per Wessman's suggestion...
-135
360 (or 2PI, etc)
MOD
result: 225
::: fyi, the first listing of 'code' that Wessman provided is sysrpl (and appears to have at least one typing error in the code...should be %rec>%pol... there may be more errors). The function that Wessman's code appears to perform is to automatically type-check the input, convert the X,Y value into R, ANGLE and then convert the angle to a positive value by either MOD 360 or MOD 2PI or MOD 400)
the 'code' with the SYSEVAL's is likely outdated and based on a prior ROM version. It is the same function as the SysRPL code, only written with SYSEVALs for the specific version of ROM Wessman was using at the time
04-04-2013 03:13 PM
Hi!, jason331:
Try, with this formula ...
Configure FLAG ...
03 Function -> num
create, a global variables 'X' and 'Y' and assign values
Examples:
1) X= -1; Y= -1
In RAD
-2.3561944902
In DEG
-135
2) X= 1; Y= 1
In RAD
0.785398163398
In DEG
45
3) X= 0; Y= -1
In RAD
-1.57079632679
In DEG
-90
04-04-2013 08:06 PM
No, all those pointers should not have moved. It should still work fine. 2008... shesh. That is a while ago. 🙂
That being said, the OP seems to want the quadrant number as well to be returned if I am reading that properly.
A simple direct approach is to get the angle using a MOD, and then divide by a 1/4 of your circle and do the FLOOR function on that result.
Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
04-05-2013 08:49 AM
@Tim Wessman wrote:A simple direct approach is to get the angle using a MOD, and then divide by a 1/4 of your circle and do the FLOOR function on that result.
you mean "do the FLOOR function and then add 1" OR do the CEIL function.
FYI to the OP.... the originator of the program in question in the yahoo forum post, Tim Wessman, has exception knowledge of the internal structures of the 50G.
Further, Tim has specifically stated the values for the SYSEVAL's used are not outdated and still contain valid pointer locations.
programs from unknown sources that use SYSEVAL's should be used with caution since the SYSEVAL can potentially delete memory....
you should back up the 50g memory before using any programs from any source that contains SYSEVALs. If the SYSEVAL values are incorrectly typed in, calculator memory loss can occur !
programs downloaded from hpcalc.org should be O.K.
04-05-2013 10:32 AM
you mean "do the FLOOR function function and then add 1" OR do the CEIL function.
Nuts.
That was my programming braing kicking in there. Everyone knows you start counting at 0... CEIL is the one you'd want of course. 🙂
Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
04-05-2013 10:57 AM
Thanks everyone, I'll try out the suggestions here and see what works for me.
To recap, I want to be able to enter two numbers on the stack with one of them potentially being negative, take the arctangent, and have it return an angle with respect to the positive x-axis. For example, if I enter 0.936 and -1.12, take the acrctangent, I get -40 degrees as the answer. That's not very meaningful. I would like the result to show 140 degrees instead (if my math is correct)
04-05-2013 11:56 AM
Hi!, jason331:
If you use, with the indicated equation ...
FLAG 03 Function -> num
and assign, values ...
X = -1.12
Y = 0.936
You can obtein, with EVAL ...
DEG
140.114013832 (locate, in Quadrant II)
RAD
2.44545086954
Note:
Quadrant I = +X; +Y; (between 0° and 90°)
Quadrant II = -X; +Y; (between 90° and 180°)
Quadrant III = -X ; -Y; (between 180° and 270°)
Quadrant IV = +X; -Y; (between 180° and 360°)
04-05-2013 12:13 PM
That is about the slowest possible way to calculate this and doesn't actually get the result wanted which includes the quadrant number...
Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
04-05-2013 12:23 PM
<< R->C ARG 360 MOD DUP 90 / CEIL >>
INPUT: -1.12, .936
OUTPUT: 140.11... 2
This makes some assumptions about your angle mode settings and that you are working in RPN, but you can clean thaose up. 🙂
Although I work for the HP calculator group as a head developer of the HP Prime, the views and opinions I post here are my own.
