This program is Copyright © 1976 by HewlettPackard and is used here by permission. This program was originally published in the HP67 Math Pac 1.
This program is supplied without representation or warranty of any kind. HewlettPackard Company and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.
Complex Operations 

Shift 
>z 
>1/z 
n>z^{n} 
n>z^{1/n} 
>e^{z} 
Label 
a^b 
+ 
 
x 
÷ 
Key 
A 
B 
C 
D 
E 
This program allows for chained calculations involving complex numbers. The four operations of complex arithmetic ( +,  , x, ÷ ) are provided, as well as several of the most used functions of a complex variable z (z, 1/z, z^{n}, z^{1/n} and e^{z}). Functions and operations may be mixed in the course of a calculation to allow evaluation of expressions like z_{3}/(z_{1} + z_{2}), e^z_{1}z_{2}, z_{1} + z_{2} + z_{2} ÷ z_{3}, etc., where z_{1}, z_{2}, z_{3} are complex numbers of the form a + ib.
A complex number is input to the program by keying in its real part, pressing ENTER, keying in its imaginary part, and pressing A. For example, the complex number z_{1} = 2 + 3i is input as 2 ENTER 3 A. This number is then stored by the program. There is room in the program to remember up to two complex numbers at a time. A second complex number z_{2} = 5  i could be input as 5 ENTER 1 CHS A. The program would now contain both the first and the second complex number.
The complex functions in this program act on just one number. Thus to perform a function, you need simply to input a complex number z and then perform the appropriate function. For example, to find the reciprocal of (2 + 3i), press 2 ENTER 3 A f B. The result is calculated as a + ib = 0.15  0.23i. This result is now stored in place of the original number, and further calculations will operate on this result. All complex functions operate in this same manner, with one exception: since the function z returns a real number, its result is not stored.
An arithmetic operation needs two numbers to operate on. Both numbers must be input before the operation can be performed. Suppose that z_{1} = 2 + 3i, z_{2} = 5  i, and we wish to find z_{1}  z_{2}. This can be calculated by the keystrokes 2 ENTER 3 A 5 ENTER 1 CHS A C. The result z_{3} = a + ib is found to be 3 + 4i. This result is now stored by the program in place of the second complex number z_{2}. A further calculation z_{3} x z_{4} could be performed by inputting z_{4} and pressing D for multiplication. This type of chaining can be continued indefinitely, and functions can be interspersed with arithmetic operations.
Let
z_{k} = a_{k} + ib_{k} = r_{k}e^(i_{k}) , k = 1 2 z = a + ib = re^i
Let the result in each case be u + iv.
z_{1} + z_{2} = (a_{l} + a_{2}) + i(b_{1} + b_{2}) z_{1}  z_{2} = (a_{l}  a_{2}) + i(b_{1}  b_{2}) z_{1}z_{2} = r_{1}r_{2}e^i(_{1} + _{2}) z_{1}/z_{2} = (r_{1}/r_{2})e^i(_{1}  _{2}) z = sqrt(a^{2}+b^{2}) 1/z =a/r^{2}  ib/r^{2} z^{n} = r^{n}e^(in) z^{1/n} = r^{1/n}e^(i(/n + 360k/n)) , k=0,1,....n1
(All n roots will be output and temporarily stored, k = 0, 1, ... n1; at the end of the calculation the final root will be stored.)
e^{z} = e^{a}(cos b + i sin b), where b is in radians.
The logic system for this program may be thought of as a kind of Reverse Polish Notation (RPN) with a stack whose capacity is two complex numbers. Let the bottom register of the complex stack be XC and the top register TC. These are analogous to the X and Tregisters in the calculator's own fourregister stack.* A complex number z_{1} is input to the XCregister by the keystrokes a_{1} ENTER b_{1} A. Upon input of a second complex number z_{2} (as a_{2} ENTER b_{2} A) z_{1} is moved to TC and z_{2} is placed in XC. The previous contents of TC are lost.
*Each register of the complex stack must actually hold two real numbers: the real and the imaginary part of its complex contents. Thus it takes two of the calculator's registers to represent one register in the complex stack. We will speak of the complex stack registers as though they were each just one register.
Functions operate on the XCregister, and the result (except for z) is left in XC; TC is unchanged. Arithmetic operations involve both the XC and TC registers; the result of the operation is left in XC and TC is unchanged.
Step 
Instructions 
Input Data/Units 
Keys 
Output Data/Units 
1 
Load side 1 and side 2. 

2 
Key in first complex number (a_{1} + i b_{1}). 
a_{1} 
ENTER 

b_{1} 
A 

3 
For a function go to step 7; for arithmetic, go to step 4. A complex result is u + iv. 



ARITHMETIC  
4 
Key in second complex number (a_{2} + i b_{2}). 
a_{2} 
ENTER 

b_{2} 
A 


5 
Select one of four operations: 



Add (+) 

B 
u 

v 

Subtract () 
C 
u 

v 

Multiply (x) 
D 
u 

v 

Divide (÷) 
E 
u 

v 

6 
The result of the operation has been stored; go to step 7 for a function or to step 4 for further arithmetic. 



FUNCTIONS  
7 
Select one of five functions: 



Magnitude (z) 
f A 
z 

Reciprocal (1/z) 
f B 
u 

v 

Raise z to an integer power (z^{n}) 
n 
f C 
u 

v 

Find the n^{th} root of z (z^{1/n}) Note: n roots (u+iv) will be found. 
n 
f D 
u 


v 

Raise e to the power z (e^{z}) 
f E 
u 

v 

8 
The result, if complex, has been stored; go to step 4 for arithmetic or to step 7 for another function. 



Evaluate the expression
z_{1}  z_{2} + z_{3}
where z_{1} = 23 + 13i, z_{2} = 2 + i, z_{3} = 4  3i. (Suggestion: since the program can remember only two numbers at a time, perform the calculation as
z_{1} x [l/(z_{2} + z_{3})].)
Keystrokes Outputs 2 CHS ENTER 1 A 4 ENTER 3 CHS A B 2.00 *** real(z_{2} + z_{3}) 2.00 *** imag(z_{2} + z_{3}) f B 0.25 *** 1/(z_{2} + z_{3}) 0.25 *** 23 Enter 13 A D 2.50 *** z_{1}/(z_{2} + z_{3}) 9.00 ***
Find the 3 cube roots of 8.
Keystrokes Outputs 8 ENTER 0 A 3 f D 2.00 *** 0.00 *** 1.00 *** 1.73 *** 1.00 *** 1.73 ***
Evaluate e^(z^{2}), where z = (1 + i)
Keystrokes Outputs 1 ENTER 1 A 2 f C 0.00 *** (z^{2}) 2.00 *** f B 0.00 *** (z^{2}) 0.50 *** f E 0.88 *** e^(z^{2}) 0.48 ***
LINE KEYS 001 *LBL A Input A, B 002 RCL D 003 STO B Last b>RB(b1) 004 roll dn 005 STO D Present b>RD(b2) 006 roll dn 007 RCL E Last a>RC(a1) 008 STO C 009 roll dn Presnt a>RE(a2) 010 STO E 011 RTN 012 *LBL B Add (+) 013 RCL C 014 RCL E 015 + 016 STO E a2<a1+a2 017 PRTX 018 RCL B 019 RCL D 020 + 021 STO D b2<b1+b2 022 PRTX 023 PRT SPC 024 RTN 025 *LBL C sub () 026 RCL C 027 RCL E 028  029 STO E a2<a1a2 030 PRTX 031 RCL B 032 RCL D 033  034 STO D b2<b1b2 035 PRTX 036 PRT SPC 037 RTN 038 *LBL D 039 RCL B Multiply (x) 040 RCL C 041 >P 042 RCL D r1, 1 043 RCL E 044 >P 045 *LBL 9 r2, 2, r1, 1 046 X<>Y 047 roll up 048 + 049 X<>Y 050 roll up 051 x 052 *LBL 8 053 >R r1r2 (1 + 2) 054 STO E Output routine. 055 PRTX 056 X<>Y 057 STO D 058 PRTX 059 PRT SPC 060 RTN 061 *LBL E Divide (÷) 062 RCL B 063 RCL C r1 1 064 >P 065 RCL D 066 RCL E 067 >P r2 2 r2 1 068 X<>Y 069 CHS 070 X<>Y 1/r2 2 r1 1 071 1/X 072 GTO 9 073 *LBL a a 074 RCL D 075 RCL E 076 >P r = Sqrt(a^2+b^2) 077 PRTX 078 PRT SPC 079 RTN 080 *LBL b 1/z 081 RCL D 082 RCL E 083 >P r 084 X<>Y 085 CHS 086 X<>Y 087 1/X 1/r  088 GTO 8 089 *LBL c z^n 090 STO I n>I 091 RCL D 092 RCL E 093 >P r 094 RCL I 095 Y^{X} 096 X<>Y 097 RCL I 098 x 099 X<>Y 100 GTO 8 101 *LBL d r^n n 102 STO I z^(1/n) 103 3 104 6 n>I 105 0 106 X<>Y 107 ÷ 108 STO A 109 RCL D 360/n>RA 110 RCL E 111 >P r 112 RCL I 113 1/X 114 Y^{X} 115 X<>Y 116 RCL I 117 ÷ 118 X<>Y r^(1/n) /n 119 *LBL 7 120 GSB 8 Convert>R and print 121 DSZ I 122 GTO 0 Loop n times. 123 RTN 124 *LBL 0 125 X<>Y 126 >P Back>P(r^(1/n), /n) 127 X<>Y 128 RCL A 129 + /n + *360/n)k 130 X<>Y 131 GTO 7 132 *LBL e e^z 133 RAD 134 RCL D 135 RCL E 136 e^{X} e^a b 137 >R 138 PRTX 139 STO E e^a cos b 140 X<>Y 141 PRTX 142 PRT SPC 143 STO D 144 DEG e^a sin b 145 RTN
A 360/n B b1 C a1 D b2 E a2 I n
Go back to the software library
Go back to the main exhibit hall