Calculating ATAN2
|
12-02-2022, 08:41 PM
Post: #1
|
|||
|
|||
Calculating ATAN2
Hi all. I’ve developed a method to decompose complex numbers for Casio fx-115 Plus 1st & 2nd, 991ES 2nd and the 991EX Classwiz.
Since they all have the ARG function, I don’t need to write an ARG equivalent. Sharp, on the other hand: the EL-W516T has the ARG function, but not the EL-W516X. So, what would be the formula for ARG on the W516X? |
|||
12-02-2022, 09:48 PM
Post: #2
|
|||
|
|||
RE: Calculating ATAN2
Hello!
(12-02-2022 08:41 PM)Matt Agajanian Wrote: So, what would be the formula for ARG on the W516X? I don't think there is a simple formula because one needs to take care of different cases separately. A matter of if...then...else. I don't know if the EL-W516X can handle that on it's own. Wikipedia has an entire article about ATAN2: https://en.wikipedia.org/wiki/Atan2 Regards Max |
|||
12-02-2022, 09:50 PM
Post: #3
|
|||
|
|||
RE: Calculating ATAN2
(12-02-2022 08:41 PM)Matt Agajanian Wrote: So, what would be the formula for ARG on the W516X? I'm not familiar with that calculator but with Python you could use the following: Code: from math import pi, sqrt, atan It is based on the tangent half-angle formula: \( \begin{align} \tan \tfrac{1}{2}\theta = \frac{\sin \theta}{1+\cos \theta} \end{align} \) |
|||
12-02-2022, 09:57 PM
(This post was last modified: 12-03-2022 12:31 AM by Matt Agajanian.)
Post: #4
|
|||
|
|||
RE: Calculating ATAN2
(12-02-2022 09:48 PM)Maximilian Hohmann Wrote: Hello! Beat you to it. That Wkipedia, they have everything. Looks like I need to employ that piecewise function approach. The Python script looks like it could do the trick. Maybe a good alternative. |
|||
12-02-2022, 10:13 PM
Post: #5
|
|||
|
|||
RE: Calculating ATAN2 | |||
12-02-2022, 11:21 PM
(This post was last modified: 12-03-2022 12:27 AM by Matt Agajanian.)
Post: #6
|
|||
|
|||
RE: Calculating ATAN2
(12-02-2022 10:13 PM)Csaba Tizedes Wrote:(12-02-2022 08:41 PM)Matt Agajanian Wrote: So, what would be the formula for ARG on the W516X? Good Q. Both P→R and R→P (→rθ, →xy) are disabled in COMPLEX mode). Second, I want preserve the quadrant value. Also, it looks like the registers don’t operate. Thus, I cannot recall the real component from X nor the imaginary component from Y. |
|||
12-03-2022, 03:43 AM
Post: #7
|
|||
|
|||
RE: Calculating ATAN2
How about using acos for atan2(y,x) ?
This covered edges cases, except for (y,x) == (0,0) Code: function sign(y) return signbit(y) and -1 or 1 end lua> function test(y,x) return atan2(y,x), myatan2(y,x) end lua> test(4,3) --> 0.9272952180016122 0.9272952180016123 lua> test(4,-3) --> 2.214297435588181 2.214297435588181 lua> test(-4,3) --> -0.9272952180016122 -0.9272952180016123 lua> test(-4,-3) --> -2.214297435588181 -2.214297435588181 X axis: lua> test(0, 1) --> 0 0 lua> test(0,-1) --> 3.141592653589793 3.141592653589793 Y axis: lua> test(1, 0) --> 1.5707963267948966 1.5707963267948968 lua> test(-1,0) --> -1.5707963267948966 -1.5707963267948968 |
|||
12-03-2022, 06:47 AM
(This post was last modified: 12-03-2022 06:50 AM by Matt Agajanian.)
Post: #8
|
|||
|
|||
RE: Calculating ATAN2
(12-03-2022 03:43 AM)Albert Chan Wrote: How about using acos for atan2(y,x) ? Interesting! I worked out another formula, coincidentally with x=+/-3 and y=+/-4. I tested it with variations of (+/-3,+/-4) and received results which reflected the correct quadrant. |
|||
12-03-2022, 07:10 AM
Post: #9
|
|||
|
|||
RE: Calculating ATAN2
There is no need to use COMPLEX mode. Just add/substract like vectors in STAT mode, then store (sumX, sumY) into (X, Y) and you can do polar conversion. The complex mode is very limited, I guess all operations can be done without it in STAT+NORMAL mode.
(12-02-2022 11:21 PM)Matt Agajanian Wrote:(12-02-2022 10:13 PM)Csaba Tizedes Wrote: Why don't you use polar/rectangular conversion then RCL the value of theta from variable y?!? |
|||
12-03-2022, 08:11 PM
(This post was last modified: 12-03-2022 08:19 PM by Matt Agajanian.)
Post: #10
|
|||
|
|||
RE: Calculating ATAN2
(12-03-2022 07:10 AM)Csaba Tizedes Wrote: There is no need to use COMPLEX mode. Just add/substract like vectors in STAT mode, then store (sumX, sumY) into (X, Y) and you can do polar conversion. The complex mode is very limited, I guess all operations can be done without it in STAT+NORMAL mode. Aha (not the 80s band). That was my second thought--adapt the Vector Arithmetic conversion, summation, recall, and conversion routine introduced in the HP-21 manual. Yes. That is the definitive option. My intention was that: Since polar/rectangular representation and complex numbers kinda go together, to me, it made sense that P/R conversion and representation would be functional in complex mode. On another note, I agree and find it odd that complex mode is quite limiting about the functions allowed in that mode. Just a thought: perhaps because these Casio, Sharp, and TI models are targeted and priced for students, hence, the limited complex mode functionality. I guess we're spoiled because since the 15C, a whole range of functions were operational in complex mode. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)