The Museum of HP Calculators

HP Forum Archive 17

[ Return to Index | Top of Index ]

Rectangular to Polar on the HP35s
Message #1 Posted by Howard Boardman on 31 July 2007, 12:27 p.m.

I have some surveying programs I'm trying to put into the 35s. They were originally written for the 33s. One of the steps is a rectangular to polar conversion. There is no "y,x->è,r" button on the 35s. What is the equivalent sequence of this on the the 35s? I am just confused by the manual. Thanks for your help.

      
Re: Rectangular to Polar on the HP35s
Message #2 Posted by Gene Wright on 31 July 2007, 12:45 p.m.,
in response to message #1 by Howard Boardman

The HP35s does not convert P->R and R->P the way previous HP calculators have done. There is no provision that does this exactly the same way.

The 35s has a DISPLAY option which changes the 5i5 style complex number (rectangular) to the magnitude THETA angle style complex number (polar).

If you're just showing results one way or the other, change the display mode.

If you need the magnitude and angle of a rectangular complex number, then the ABS function will grab the magnitude and the ABS function will grab the angle portions of a complex number, even if the display mode is "rectangular".

If you need the X and Y coordinates of a polar form complex number, then it is a bit more complicated.

First, find the magnitude and angle as described above.

Then transform these into the X and Y coordinate as:

X = magnitude x COS theta

and

Y = magnitude x SIN theta

Be aware that for arguments VERY close to 90 degrees, the COS function is less accurate than for other angles. Rather than 9, 10+ decimal positions being accurate, it drops to 4 or 5 positions.

You can read more about this in the learning module found here:

Complex numbers 2

You can see all the learing modules available for the 35s by going here:

All 35s learning modules

      
Re: Rectangular to Polar on the HP35s
Message #3 Posted by Miguel Toro on 31 July 2007, 1:00 p.m.,
in response to message #1 by Howard Boardman

You can use this handy routine written by Les Wright.

Miguel

            
Re: Rectangular to Polar on the HP35s
Message #4 Posted by Howard Boardman on 31 July 2007, 1:15 p.m.,
in response to message #3 by Miguel Toro

Thanks! That should help... what is REGZ in the program?

                  
Re: Rectangular to Polar on the HP35s
Message #5 Posted by Gene Wright on 31 July 2007, 1:36 p.m.,
in response to message #4 by Howard Boardman

It is essentially a RCL stack level Z instruction.

You enter it by pressing:

EQN

then

RDN (the roll down key)

and then move the cursor under the Z stack level and press ENTER.

                        
Re: Rectangular to Polar on the HP35s
Message #6 Posted by Alain Mellan on 31 July 2007, 5:08 p.m.,
in response to message #5 by Gene Wright

I didn't know about that (should have RTFM :-), so I entered REGZ as EQN RCL R RCL E RCL G RCL Z ENTER ... and it works.

I would seem that equations are really parsed. So I tried entering RE and IMG without much success. :-) But who knows? there may be some hidden function there?

-- alain.

                  
Re: Rectangular to Polar on the HP35s
Message #7 Posted by Les Wright on 1 Aug 2007, 10:44 p.m.,
in response to message #4 by Howard Boardman

Despite my little routine, I really lament the lack of a fully range of commands to handle complex numbers and rectangular-polar conversions.

Restoring the familiar P->R and R->P commands would be a good start. xiy to rthetaa display change is nice, and the abs and arg commands can let you get the r and theta values of the vector in polar form. It is also easy enough to create the required complex number from elements of the stack--if Re(z) is in y and Im(z) in x, i * + does the trick. So this sequence would replicate the 33s y,x -> @, r command.

x<>y
i
*
+
ARG
LASTx
ABS

But there seems to be no easy way to create a polar form complex number from stack elements that I can feed into my little routine to give the real and imaginary components of the rectangular form. One seems to have to enter it manually. For example, if I want to create 5@60, I have to enter 5 theta 60. I can't put 5 ENTER 60 on the stack and automate the procedure easily to do it for me. In the 42S, I would simply make sure I was in polar mode and execute 5 ENTER 60 COMPLEX.

If anyone has a painless way to replicate the @,r -> y,x conversion from the 33s, I would be grateful!

I really would vote for a more logical command set in this regard in the 35sii. If ROM is a premium, the calc can really afford to lose those keyboard clogging metric/imperial conversions.

Les

                        
Re: Rectangular to Polar on the HP35s
Message #8 Posted by Les Wright on 1 Aug 2007, 11:02 p.m.,
in response to message #7 by Les Wright

Actually, I revisited my basic complex analysis books and I think I have a solution for the @,r -> y,x conversion. This assumes the angle is in the y register and modulus in the x, just as it would be for the 33s function:

x<>y
COS
LASTx
SIN
i
*
+
*
(send off to my little routine or hopefully a better one to decompose to Re and Im, returns Re in y register, Im in x)
x<>y (to put x component in x register and y in y, as is done on 33s)

This alternative assumes the calc is in degree mode:

x<>y
->RAD
i
*
e^x
*
(decompose to Re and Im as you wish)
x<>y

Let's say the first one is under LBL P. I try this in degree mode:

3 ENTER 4 / ATAN 5 XEQ P ENTER

and I get 4 returned in the x register, 3 in the Y, exactly as it should be!

Cumbersome, but the programs involved are very short, and it seems to work except when rounding error or the damned cosine bug compromises accuracy in certain cases.

Les

                              
Re: Rectangular to Polar on the HP35s
Message #9 Posted by Les Wright on 1 Aug 2007, 11:51 p.m.,
in response to message #8 by Les Wright

Actually, that last one was way to complicated.

I prefer this:

x<>y
COS
LASTx
SIN
REGZ
*
x<>y
LASTx
*

There is no point in computing the modulus and argument back and forth when you have it in the first place!

In short the following two little subroutines, which I put under the same label P, replicate the 33S polar-rectangular conversions, and I think most succinctly answer the OP's question:

(P001) LBL P
x<>y
i
*
+
ARG
LASTx
ABS
(P009) RTN

(P010)x<>y COS LASTx SIN REGZ * x<>y LASTx * (PO19) RTN

Examples (in degrees mode):

4 ENTER 3 / ATAN 25 XEQ P002 returns 20 in the y register, 15 in the x.

8 ENTER 6 XEQ P010 returns 53.130123542 (degrees) in the y register, 10 in the x--exactly what you would expect for a Pythagorean triple of 6-8-10.

I think the absence of the well loved conversion routines will inspire most serious users of the 35s to have subroutines like these in memory, and I hope that revisions of the machine rectify this. And, of course, that nuisance cosine bug!

Les

Edited: 2 Aug 2007, 2:00 a.m. after one or more responses were posted

                                    
Re: Rectangular to Polar on the HP35s
Message #10 Posted by Howard Boardman on 2 Aug 2007, 1:58 a.m.,
in response to message #9 by Les Wright

Thanks to all for the subroutine advice. So far I did a little modification of the little subroutine and it seems to work fine. I'm doing surveying programs for traversing, area by coordinates and so on. The following seems to work quite well for rect. to polar, although I get a negative azimuth when in the 4th quadrant (-x,y) which is entirely fine:

S001 LBL S

S002 i

S003 *

S004 +

S005 ABS

S006 LASTx

S007 ARG

S008 360

S009 RMDR

S010 90

S011 -

S012 +/-

S013 x<>y

S014 RTN

A few extra steps I realize but for the programs I had created it was easier to modify this one than to modify the others. Atleast HP had the sense to allow XEQ and GTO within programs. Its hard to make a calculator to please all professions, but at least with subroutines we can be creative and work around short-commings.

Edited: 2 Aug 2007, 2:00 a.m.

                                          
Re: Rectangular to Polar on the HP35s
Message #11 Posted by db (martinez, ca.) on 2 Aug 2007, 11:32 p.m.,
in response to message #10 by Howard Boardman

Howard;

Tight stuff man. WAY better than mine and my favorite here so far. Leave it to a surveyor. You going polar to rectangular next?

                        
Re: Rectangular to Polar on the HP35s
Message #12 Posted by Walter B on 2 Aug 2007, 1:21 a.m.,
in response to message #7 by Les Wright

Quote:
I really would vote for a more logical command set in this regard in the 35sii. If ROM is a premium, the calc can really afford to lose those keyboard clogging metric/imperial conversions.
Fully agreed! :) There are by far more important functions on the waiting list for keyboard space.
      
Re: Rectangular to Polar on the HP35s or viz-a-viz is a Disaster. NT
Message #13 Posted by Trent Moseley on 31 July 2007, 10:25 p.m.,
in response to message #1 by Howard Boardman

NT

      
Re: Rectangular to Polar on the HP35s
Message #14 Posted by Reth on 2 Aug 2007, 3:07 a.m.,
in response to message #1 by Howard Boardman

Here is my version :) cheers, reth


[ Return to Index | Top of Index ]

Go back to the main exhibit hall