|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 x-register and the imaginary part in the y-register. I wrote a small program to do this similar to others that have been posted:
C0001 LBL C
C0002 RPN ;Just to be sure
Given a negative number in the y-register and a fractional exponent in the x-register, say -4 and .5 this returns the correct square root, 0 in the x-register and 2 in the y-register 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 y-register 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!