Re: HP 35s successor? Message #37 Posted by Walter B on 18 May 2008, 6:48 a.m., in response to message #36 by Jeff O.
Proposal for 4 conversions, covering the realcomplexrectpolar topic in 2 and 3 dimensions:
>CPX converts the 2 real objects found in x and y into 1 complex object in x (or throws an error if x or y contain strings or complex objects). The result will depend on the coordinates mode settings at conversion time:
 In polar mode, if x and y contain real numbers, >CPX takes the contents of x as the magnitude and those of y as the angle and merges this pair to one complex number displayed as in 42S (e.g. 1.2 /_ 3.4, where /_ stands for the angle symbol). If x and y contain matrices, >CPX builds one complex matrix out of the elements converted individually.
 Else (in rectangular mode), the real part(s) are taken from x and imaginary from y and merged to one complex object displayed similar to 42S (e.g. 9.8 – 7.6i).
>REAL converts the complex object found in x into two real objects in x and y (or throws an error if x contains any noncomplex object). The result will depend on the coordinates mode settings at conversion time:
 In polar mode, >REAL splits the object found in x into a part containing the magnitude(s) and another one containing the angle(s), storing the angle(s) in y and the magnitude(s) in x.
 Else, >REAL splits the object in x into its real and imaginary part and stores the imaginary part in y and the real in x.
>POL converts the lowest stack level(s):
 If x contains a complex object, >POL takes its real and imaginary parts and converts re + im i into r /_ theta. An object displayed in polar mode already will remain unchanged.
 Else, if 3d, it converts x, y, z into spherical coordinates r, theta, phi.
 Else, it converts x, y into cylindrical coordinates r, theta.
Remarks for >POL: (a) The angles will be displayed in the angular mode selected (DEG, RAD or GRAD). (b) The general coordinate system will stay as set (RECT or POLAR). (c) In cases 2 and 3, the input is taken from the respective stack levels, and the conversion results r, theta, phi are put in the stack levels x, y, z , respectively. If any of the input stack levels does not contain a real number at conversion time, an error will be thrown.
>REC converts the lowest stack level(s):
 If x contains a complex object, >REC takes its radii and angles and converts r /_ theta into re + im i . An object displayed in rectangular mode already will remain unchanged.
 Else, if 3d, it assumes spherical coordinates on the stack and converts r, theta, phi into x, y, z .
 Else, it assumes cylindrical coordinates on the stack and converts r, theta into x, y.
Remarks for >REC: (a) The general coordinate system will stay as set (RECT or POLAR). (b)In cases 2 and 3, the input r, theta, phi is taken from the stack levels x, y, z, respectively, and the conversion results are put in the corresponding stack levels. If any of the input stack levels does not contain a real number at conversion time, an error will be thrown.
Hope this is sufficiently complete. It will need 4 labels on the keyboard, which are readily available when the IMP<>SI conversions are dropped or packed in a menu, as others proposed already as well. It can be done most compact:
.
These keys are taken from the 15S as shown in Datafile V27N2.
Best regards, Walter
Edited: 19 May 2008, 3:50 p.m.
