# HP Forums

You're currently viewing a stripped down version of our content. View the full version with proper formatting.

There have been several approaches discussed on this topic, but I wanted something that would most closely approach the on-key method used on the older calculators such as the HP 33s, where you enter the two values and the result is shown directly on the screen. The best way IMO is to create the output result as a complex number pair. The programs are as follows:

```EXPORT Rect_to_Polar(X1,X2)
BEGIN
LOCAL CRP,CIP,CTOT;
CRP:=(X1^2+X2^2)^.5;
CIP:=ATAN(X2/X1);
CTOT:=(CRP,CIP);
RETURN CTOT;
END;
```

```EXPORT Polar_to_Rect(X1,X2)
BEGIN
LOCAL CRP,CIP,CTOT;
CRP:=X1*COS(X2);
CIP:=X1*SIN(X2);
CTOT:=(CRP,CIP);
RETURN CTOT;
END;
```

To execute from either the Home or CAS screen, select the program from the Toolbox User menu, and enter the values. For example, to convert X=3 and Y=4 in rectangular form to polar, execute Rect_to_Polar as follows:

Rect_to_Polar(3,4) Enter ---> (5.0000,53.1301)

This is assuming complex numbers displayed as (a,b), angular mode in degrees and number format set as Fixed 4.

You want to enter a complex pair, then display the polar equivalent onscreen with just a few keystrokes? Would one shifted keystroke be ok?

In Home Degree mode, type (3,4) and press Enter, then press Shift multiply (looks like an angle symbol): You can convert the other direction too, if you use the angle symbol instead of a comma as you type in the ordered pair.

The drawback of this method is that it only works in Home, not CAS.

Thanks, Joe. I was already aware of the keyboard entry from Tim W's earlier post, but just wanted to do it as a general program that worked everywhere. Also, FYI, you can do the polar-to-rectangular conversion in CAS by entering the complex number in polar form, and it will automatically convert it to rectangular form.

As an aside, angular mode can be toggled by a tap on the top right corner of the screen. This opens a small window where you can tap on either angle mode symbol.

After perusing the built-in Catalog of functions, I came across functions named polar_coordinates and rectangular_coordinates that do the same thing as my programs, except that the output is presented as a 1x2 vector rather than a complex number pair. The combined program for the User Function Catalog becomes:

PR_Convert

```EXPORT Rect_to_Polar(X1,X2)
BEGIN
RETURN polar_coordinates(X1,X2);
END;
EXPORT Polar_to_Rect(X1,X2)
BEGIN
RETURN rectangular_coordinates(X1,X2);
END;
```