More 33S weirdness  polar conversions Message #8 Posted by V. Taylor on 18 May 2004, 9:20 a.m., in response to message #1 by KC
Here's another 33s weirdness. You can calculate an even root of a negeative number, as discussed elsewhere in this forum, using complex operations. This leaves the real part in the xregister and the imaginary part in the yregister. I wrote a small program to do this similar to others that have been posted:
C0001 LBL C
C0002 RPN ;Just to be sure
C0003 0
C0004 X<>Y
COOO5 CMPLXy^x
C0006 RTN
Given a negative number in the yregister and a fractional exponent in the xregister, say 4 and .5 this returns the correct square root, 0 in the xregister and 2 in the yregister representing the complex number 0+2i in rectangular form. The weirdness comes when you try to convert this to polar form using the >theta,r key. If I just type 2 <enter> 0 >theta,r I get the expected result, magnitude 2 and angle of 90 deg. But if I perform the same operation on the result of the complex operation, seemingly the same x=0,y=2 oredered pair, I get a magnitude of 2, which is expected, but at an angle of 270 deg which is very unexepected. Normally for any ordered pair on the stack the range of theta is 180 < 0 < 180 which makes the result of 270 deg even stranger. If I run the reverse >y,x operation on the result I get y=2 and x=0 which would be expected from an angle of 270 deg. Performing another >theta,r gives the expected result of r=2 and theta=90 deg (as opposed to 270 deg as before). I'm sure this is due to the algorithm used to compute the angle and its determination of the sign of the angle, but the result seems to imply that the calculator knows that it is working on a complex number, or at least that the number in the yregister is not a normal number. I didn't think there were different data types allowed on the stack of the 33s. Is there an undocumented flag or something that indicates a complex stack? I was under the assumption that the complex key just caused the stack to be treated as a pair of complex numbers for that particular operation but the numbers in the actual stack levels are still just real numbers. In any case the angle of 270 deg outside the normal range of the function and is weird!
Virgil Taylor
