RPN with HP 15C and DM32: Complex Mode
HP 15C Complex Mode
This section also applies to the Swiss Micros DM15 family.
Complex mode is a separate mode for the HP 15C. Complex mode is turned on by setting flag 8. Complex mode is on when there is a “C” indicator in the display.
In complex mode, the stack is expanded. Each stack level now includes a real part and a complex part. What is in the display is always the real part.
Stack T |
Real part of T |
Imaginary part of T |
Stack Z |
Real part of Z |
Imaginary part of Z |
Stack Y |
Real part of Y |
Imaginary part of Y |
Stack X |
Real part of X |
Imaginary part of X |
The great news is that the stack handles up to four complex numbers, one for each of the stack levels.
To display the imaginary part, we have two methods:
Temporary View: Press [ f ] and hold [ COS ] (i) to temporarily view the complex part. The stack remains unaffected.
Switch: Switch the real part and the imaginary part by pressing [ f ] [ - ] (Re<>Im). Doing this switches the real and imaginary parts of the X stack.
For example: X = 9 – 8i
Enter the complex number as such: 9 [ ENTER ] 8 [ CHS ] [ I ] * (see note).
The displays shows 9.
Press [ f ] [ - ] (Re<>Im). The display shows -8 and the X stack now has the complex number X = -8 + 9i.
Press [ f ] [ - ] (Re<>Im) to switch the parts back to the original complex number.
* Note: If complex mode is turned off (no C indicator), using this key sequence sets flag 8, turning on complex mode automatically.
The switching of parts is important, because memory registers can not hold an entire complex number, but it’s separate parts. Thus, we will need two registers, one for the real part and one for the imaginary part.
HP 15C: Leaving Complex Mode
To leave complex mode, clear flag 8 (CF 8). The imaginary parts of the stack are lost.
Angle Mode
In complex mode, the trigonometric functions operate as the angles are always in radian measure regardless of the angle setting. The only functions that recognize the angle setting are the polar/rectangular conversions. To take the cosine and sine of angle that respects the conversion, use the following sequence:
angle [ENTER] 1 [ f ] [ →R ]: X stack: cos(angle), Y stack: sin(angle)
HP 15C - Solving Monic Quadratic Equations
The HP 15C’s solver only works for real numbers, so manual methods and formulas must be used to solve equations for complex numbers.
Z^2 + w1 * Z + w0 = 0
Solution: Z = (w1 ± √(w1^2 – 4 * w0)) / 2
(D = √(w1^2 – 4 * w0), Z+ = (w1 + D) / 2 Z- = Z+ - D)
Store the following:
Complex coefficient w1: Real part in register 4, Imaginary part in register 5
Complex coefficient w2: Real part in register 1, Imaginary part in register 2
The results are stored in the following registers:
Discriminant (D): Real part in register 6, imaginary part in register 3
Complex root Z+: Real part in register .0 (decimal point-0), imaginary party in register 8
Complex root Z-: Real part in register 9, imaginary part in register 7
Code (use any label you want, I use label A for example):
Key |
Key Code |
|
Key |
Key Code |
LBL A |
42, 21, 11 |
|
RCL 4 |
45, 4 |
SF 8 |
43, 4, 8 |
|
RCL 1 |
45, 1 |
RCL 4 |
45, 4 |
|
I |
42, 25 |
RCL 1 |
45, 1 |
|
- |
30 |
I |
42, 25 |
|
2 |
2 |
x^2 |
43, 11 |
|
÷ |
10 |
RCL 5 |
45, 5 |
|
STO .0 |
44, .0 |
RCL 2 |
45, 2 |
|
Re<>Im |
42, 30 |
I |
42, 25 |
|
STO 8 |
44, 8 |
4 |
4 |
|
Re<>Im |
42, 30 |
× |
20 |
|
R/S |
31 |
- |
30 |
|
RCL 6 |
45, 6 |
√ |
11 |
|
RCL 3 |
45, 3 |
STO 6 |
44, 6 |
|
I |
42, 25 |
Re<>Im |
42, 30 |
|
- |
30 |
STO 3 |
44, 3 |
|
STO 9 |
44, 9 |
Re<>Im |
42, 30 |
|
Re<>Im |
42, 30 |
|
|
|
STO 7 |
44, 7 |
|
|
|
Re<>Im |
42, 30 |
|
|
|
RTN |
43, 32 |
Example:
Z^2 + (4 + i) * Z + (2 - 5i) = 0
w1: 4 STO 4, 1 STO 1
w2: 2 STO 5, 5 CHS STO 2
[ f ] A or [ GSB ] A:
0.11724 [ f ] hold (i) 1.15309 (Z+ ≈ 0.11724 + 1.15309i)
[ R/S ]
-4.11724 [ f ] hold (i) -2.15309 (Z- ≈ -4.11724 – 2.15309i)
DM32 Complex Mode
This section also applies to the HP 32Sii, HP 32S, and the HP 41C/DM41X with the Advantage ROM plugged in. The names of the functions vary.
There is no “separate” complex mode for the DM32, all the functions are access with shifted CMPLX prefix function. The complex number functions available on the DM32 are:
CMPLX+, CMPLX-, CMPLX×, CMPLX÷
CMPLX+/- (change sign, multiply the complex number by -1)
CMPLX1/x, CMPLXe^x, CMPLXLN, CMPLXy^x
CMPLXSIN, CMPLXCOS, CMPLXTAN
The complex functions grabs the values from the four stack levels and uses them as up to two complex numbers:
Z |
Imaginary part of T + Zi |
T |
Real part of T + Zi |
Y |
Imaginary part of X + Yi |
X |
Real part of X + Yi |
Memory registers can not hold an entire complex number, but it’s separate parts. Thus, we will need two registers, one for the real part and one for the imaginary part.
To enter complex numbers, enter the imaginary part, press [ ENTER ], then enter the real part.
Square Root and Square (√ and x^2)
There is no complex square root or complex square function. We will need some creativity to tackle these functions. Here is just one way we can accomplish this task.
Assume the complex number A + Bi have the real part stored in A and imaginary part stored in B.
Square Root (√):
RCL B
RCL A
0.5
ENTER
Clx
x<>y
CMPLXy^x
Square (x^2):
RCL B
RCL A
RCL B
RCL A
CMPLX×
Angle Mode
In complex mode, the trigonometric functions operate as the angles are always in radian measure regardless of the angle setting. The only functions that recognize the angle setting are the polar/rectangular conversions. To take the cosine and sine of angle that respects the conversion, use the following sequence:
1 [ENTER] angle [ blue shift ] [ →y,x ]: X stack: cos(angle), Y stack: sin(angle)
(HP 32SII late editions: lavender/purple shift)
DM32 - Solving Monic Quadratic Equations
Like the HP 15C, the DM32’s solver only works for real numbers, so manual methods and formulas must be used to solve equations for complex numbers.
Z^2 + w1 * Z + w0 = 0
Solution: Z = (w1 ± √(w1^2 – 4 * w0)) / 2
(D = √(w1^2 – 4 * w0), Z+ = (w1 + D) / 2 Z- = Z+ - D)
Store the following:
Complex coefficient w1: Real part in A, Imaginary part in B
Complex coefficient w2: Real part in C, Imaginary part in D
The program will prompt for A, B, C, and D, in the order of imaginary part, then real part
Z^2 + (Bi + A) * Z + (Di + C) = 0
The results are stored in the following registers:
Discriminant (D): Real part in E, imaginary part in F
Complex root Z+: Real part in R, imaginary party in S
Complex root Z-: Real part in U, imaginary part in V
Code:
A01 LBL A |
A24 x<>y |
A02 INPUT B |
A25 RCL B |
A03 INPUT A |
A26 RCL A |
A04 INPUT D |
A27 CMPLX- |
A05 INPUT C |
A28 2 |
A06 RCL B |
A29 ENTER |
A07 RCL A |
A30 CLx |
A08 RCL B |
A31 x<>y |
A09 RCL A |
A32 CMPLX÷ |
A10 CMPLX× |
A33 STO S |
A11 4 |
A34 x<>y |
A12 RCL× D |
A35 STO R |
A13 4 |
A36 x<>y |
A14 RCL× C |
A37 STOP |
A15 CMPLX- |
A38 RCL F |
A16 0.5 |
A39 RCL E |
A17 ENTER |
A40 CMPLX- |
A18 CLx |
A41 STO U |
A19 x<>y |
A42 x<>y |
A20 CMPLXy^x |
A43 STO V |
A21 STO E |
A44 x<>y |
A22 x<>y |
A45 RTN |
A23 STO F |
|
Example:
Z^2 + (4 + i) * Z + (2 - 5i) = 0
[ XEQ ] A
B? 1 [R/S]
A? 4 [R/S]
D? -5 (5 [+/-] ) [R/S]
C? 2 [R/S]
Y: 1.15309, X: 0.11724 (Z+ ≈ 0.11724 + 1.15309i)
[R/S]
Y: -2.15309, X: -4.11724 (Z- ≈ -4.11724 – 2.15309i)
I hope you enjoyed this edition of RPN with HP 15C and DM2,
Eddie
All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.