UP | HOME

HP Voyager Programs
For HP-15C

Author: Mitch Richling
Updated: 2024-03-04
Generated: 2024-03-04

Copyright © 2024 Mitch Richling. All rights reserved.

1. Introduction

The HP-15C was designed over 40 years ago. By modern standards it is missing many features found in scientific calculators today; however, the HP-15C is far more efficient than modern machines.

Fewer keystrokes
Calculations that require half a dozen keystrokes on the HP-15C might take a couple dozen keystrokes on a modern calculator.
All functionality directly available from the keyboard
Not only do modern machines require more keystrokes, but many of those keystrokes are for navigating through menus. On the HP-15C everything is no more than a couple keystrokes away.
Great keyboard
The layout is designed for speed. Mechanically it doesn't bounce or cause double entries. It has tactical feedback to confirm key activation. These features mean long time HP-15C users can stay focused on the problem at hand while touch typing problems into the machine.

Most of the time I preform calculations with specialized mathematical software. Still each day brings a plethora of little, ad-hoc engineering computations for which the HP-15C is simply the fastest way to hammer out an answer – this is what keeps the HP-15C on my desk.

All that said, I occasionally use other machines: Classpad II, DM-42, fx-CG50, HP-48GX, HP-16C/DM-16L, & HP-12CP.

I recommend Torsten Manz's excellent HP-15C simulator software on Windows & Linux.

  • Most of the programs found here are all about efficiency:
    • Efficient replacements for STO/RCL with complex numbers
    • Reducing the tedium of matrix computations.
  • Only one is about new functionality:
    • Newton's method for functions of a complex variable

2. Store & Recall Complex Numbers

The official user guide has a pair of example programs capable of storing and recalling complex values using a matrix for storage. The programs here are similar except that they use registrars for storage – storing the real and complex parts in consecutive storage registers.

With respect to the stack, these programs attempt to behave like the built in STO & RCL functions:

  • They both preserve the stack contents
  • The STO CLPX program leaves the item to be stored in the X stack position

If the calculator is not already in complex mode, then it will be placed in complex mode by the program.

2.1. Usage

  • Inputs:
    • STO CPLX: The number to store is on stack level Y, and the first register index is on stack level X.
      The real part of Y is stored at the register indicated by the index in X, and the complex part of Y is stored in the next consecutive register.
    • RCL CPLX: The first register index is on stack level X.
  • The result stack:
    • STO CPLX: The stack is shifted down so the register index is in stack position T.
    • RCL CPLX: The register index in stack position X is replaced by the recalled complex number, and the other stack levels are left unchanged.
  • Error Conditions
    • Given register is out of bounds: An Error 3 will be produced & the stack contents will be invalidated.
    • Given register plus one is out of bounds: An Error 3 will be produced, the stack contents will be invalidated, and the value in the given register will be invalidated.

2.2. Stack Diagrams

STO_CPLX – Store Complex Number

  Before After
T: t Reg Index
Z: z t
Y: Cplx Number z
X: Reg Index Cplx Number

RCL_CPLX – Recall Complex Number

  Before After
T: t t
Z: z z
Y: y y
X: Reg Index Cplx Number

2.3. Resources Used

  • Internal Labels:
    • E RCL_CPLX
    • D STO_CPLX
  • External Labels:
    • None
  • Registers Used:
    • Two consecutive registers are used.
    • The first has its index on level X of the stack
  • Matrices:
    • None

2.4. Program Listing

STO_CPLX – Store Complex Number

Keystrokes     Key Codes     Stack Contents     Comments
f LBL D 42,21,14   x y z t    
STO I 44 25   x y z t    
R↓ 33   y z t x    
STO (i) 44 24   y z t x    
f ISG I 42, 6,25   y z t x    
g CLx 43 35   y z t x   NOP
f Re≷Im 42 30   ~y z t x    
STO (i) 44 24   ~y z t x    
f Re≷Im 42 30   y z t x   Ret
g RTN 43 32        

RCL_CPLX – Recall Complex Number

Keystrokes     Key Codes     Stack Contents     Comments
f LBL E 42,21,15   x y z t    
STO I 44 25   x y z t    
R↓ 33   y z t x    
RCL (i) 45 24   Cr y z t    
f ISG I 42,6,25   Cr y z t    
g CLx 43 35   Cr y z t   NOP
f Re≷Im 42 30   ~Cr y z t    
g CLx 43 35   ~Cr y z t   Disable stack
RCL (i) 45 24   ~C y z t    
f Re≷Im 42 30   C y z t   Ret
g RTN 43 32        

3. Newton's Method for Functions of a Complex Variable

Attempts to find a root of a function of a complex variable using Newtons method. Newton's method is iterative taking an initial guess, and generating successive guesses that, if we are fortunate, converge to a root. In what follows, the function is referred to as \(f(x)\) and the initial guess is referred to as \(x_0\). The final guess is referred to as \(x_1\).

If the calculator is not already in complex mode, then it will be placed in complex mode by the program.

3.1. Usage

  • Running the program
    • Stack Arguments:
      • X best guess for root (\(x_0\))
    • Function to solve:
      • Must be LBL 1
      • When called, \(x\) will be on every level of the stack
      • Returns \(f(x)\) to stack level Y and \(f'(x)\) to stack level X.
  • Exit Information
    • Exit Stack State:
      • Z: \(f(x_1)\) Function value at \(x_1\)
      • Y: \(|f(x_1)|\) Function magnitude at \(x_1\)
      • X: \(x_1\) Root guess
    • Exit Register State:
      • R8 \(\Re(x_1)\)
      • R9 \(\Im(x_1)\)
    • Non-normal Exits:
      • Program might not converge: In this case it will run forever. If the program is interrupted it is highly likely, but not guaranteed, the last guess will be stored in registers 8 & 9.
      • Evaluation error: If the function causes an error during evaluation, the program will stop. The last guess will be stored in R8 & R9.
      • Zero Derivative: If the derivative is zero, then an "Error 0" will occur. The last guess will be stored in R8 & R9.

3.2. Resources Used

  • Internal Labels:
    • D Program label
    • .1 Main loop target
  • External Labels:
    • 1 function to solve
    • E RCL_CPLX
    • D STO_CPLX
  • Registers Used:
    • R8 Real component of root guess
    • R9 Complex component of root guess
  • Matrices:
    • None

3.3. Program Listing

NEWTON – Newton's Method for a Function of a Complex Variable

Keystrokes     Key Codes     Stack Contents     Comments
f LBL C 42,21,13   x0 ? ? ?    
8 8   8 x0 ? ?    
GSB D 32 14   x0 ? ? 8   STO_CPLX
f LBL . 1 42,21,.1   ? ? ? ?    
8 8   8 ? ? ?    
GSB E 32 15   x0 ? ? ?   RCL_CPLX
ENTER 36   x0 x0 ? ?   x0=Previous iterate
ENTER 36   x0 x0 x0 ?    
ENTER 36   x0 x0 x0 x0    
GSB 1 32 1   df f ? ?   Function to solve
x≷y 34   f df ? ?   f=f(x0), df=f'(x0)
ENTER 36   f f df ?    
ENTER 36   f f f df    
8 8   8 f f df    
GSB E 32 15   x0 f f df   RCL_CPLX
g R↑ 43 33   df x0 f f    
g R↑ 43 33   f df x0 f    
x≷y 34   df f x0 f    
÷ 10   f÷df x0 f f    
x≷y 34   x0 f÷df f f    
ENTER 36   x0 x0 f÷df f    
R↓ 33   x0 f÷df f x0    
x≷y 34   f÷df x0 f x0    
- 30   x1 f x0 x0   x1=Current iterate
8 8   8 x1 f x0    
GSB D 32 14   x1 f x0 8   STO_CPLX
x≷y 34   f x1 x0 8    
ENTER 36   f f x1 x0    
g ABS 43 16   fM f x1 x0   fM=abs(f(x1))
1 1   1 fM f x1    
EEX 26   1 fM f x1    
7 7   1e7 fM f x1    
CHS 16   e fM f x1   e=Epsilon
g TEST 8 43,30, 8   e fM f x1   y>x?
GTO . 1 22 .1   e fM f x1    
g R↑ 43 33   x1 e fM f    
x≷y 34   e x1 fM f    
R↓ 33   x1 fM f e    
g RTN 43 32   x1 fM f e    

4. Matrix Helpers

These programs don't do anything the HP-15C can't already do. They serve two purposes: 1) Reduce the number of keystrokes required, and 2) Free the user from remembering the strange incantations required to work with complex matrices.

4.1. Fill a Matrix

4.1.1. Usage

This program provides a fast way to fill a matrix – generally cuts keystroke overhead in half.

When flag 8 is set, the real & complex parts of the number in the X stack level are used to fill consecutive matrix elements resulting in a C format matrix. This behavior is handy if we need to do computation with the elements before we store them – like converting them to rectangular form with →R. On the other hand, if the complex matrix elements are known and in rectangular format, then it may be faster to clear flag 8 and enter the real and complex parts separately.

  • Operation
    • Run the program with the following inputs:
      • Z: A matrix descriptor or number 0 (a 0 indicates the A matrix should be used)
      • Y: number of rows
      • X: Number of columns
    • The matrix element coordinate will appear on the display in r.c format.
    • The previously entered element, if there was one, will be on level Y of the stack.
    • Enter the value for the matrix position and press R/S.
      • If flag 8 is set, then the real and complex parts will be placed into the matrix in consecutive positions.
    • Repeat until all the matrix elements have been entered.
    • Note the program never ends – it just wraps back to the start.

4.1.2. Resources Used

  • Internal Labels:
    • 7 Program label
    • .7 Main loop target
    • .6 Complex if target
  • External Labels:
    • None
  • Registers Used:
    • R0 Matrix indexing
    • R1 Matrix indexing
    • I Matrix descripter
  • Matrices:
    • Matrix on stack level X when the program starts, or matrix A if X was zero.

4.1.3. Program Listing

FILL_MAT – Fill a Matrix

Keystrokes     Key Codes     Stack Contents     Comments
f LBL 7 42,21, 7   n m MATor0 t    
RCL MATRIX A 45,16,11   A n m MATor0    
STO I 44 25   A n m MATor0    
g R↑ 43 33   MATor0 A n m    
g TEST 0 43,30, 0   MATor0 A n m    
STO I 44 25   A A n m   Sto given matrix descriptor in I
R↓ 33   A n m MATor0    
R↓ 33   n m MATor0 A    
f DIM I 42,23,25   n m MATor0 A   Dim given matrix
f MATRIX 1 42,16, 1   n m MATor0 A   Set R0 & R1 to 1
LBL . 7 42,21,.7   ?orXp ? ? ?   Ep – previously entered element
. 48   - ?orXp ? ?    
1 1   1 ?orXp ? ?    
RCL × 1 45,20, 1   j/10 ?orXp ? ?    
RCL + 0 45,40, 0   j/10+i ?orXp ? ?    
R/S 31   j/10+i ? ? ?    
f USER STO (i) u 44 24   Xr ? ? ?    
f USER -   Xr ? ? ?   Exit USER mode
g CF 9 43, 5, 9   Xr ? ? ?   NOP
g F? 8 43, 6, 8   Xr ? ? ?    
GTO . 6 22 .6   Xr ? ? ?    
GTO . 7 22 .7   Xr ? ? ?    
f LBL . 6 42,21,.6   Xr ? ? ?    
f Re≷Im 42 30   Xc ? ? ?    
f USER STO (i) u 44 24   Xc ? ? ?    
f USER -   Xc ? ? ?   Exit USER mode
g CF 9 43, 5, 9   Xc ? ? ?   NOP
f Re≷Im 42 30   Xr ? ? ?   So Xp will be in Y for R/S
GTO . 7 22 .7   Xr ? ? ?    
g RTN 43 32   ? ? ? ?   Never Get Here

4.2. Dump a Matrix

4.2.1. Usage

This program provides a fast way interate over the elements of a real or complex matrix.

  • Operation
    • Run the program with the matrix descriptor or the number 0 in stack level X.
      • If X is zero, then the RESULT matrix will be used.
    • Press R/S until all you have seen the elements you need
      • Note the program will wrap around to the first element after the last one is displayed – this is a feature.
      • If flag 8 is set, then pairs of elements are pulled from the matrix and placed on the stack as complex numbers

4.2.2. Resources Used

  • Internal Labels:
    • 4 Program label
    • .4 Main loop target
    • .8 Complex if target
  • External Labels:
    • None
  • Flags:
    • 8 – Option flag (complex mode)
    • 9 – CF used as NOP
  • Registers Used:
    • R0 Matrix indexing
    • R1 Matrix indexing
    • I Matrix descripter
  • Matrices:
    • Matrix on stack level X when the program starts, or RESULT if X was zero.

4.2.3. Program Listing

DUMP_MAT – Dump a Matrix

Keystrokes     Key Codes     Stack Contents     Comments
f LBL 4 42,21, 4   MATor0 y z t    
RCL RESULT 45 26   RESULT MATor0 y z    
STO I 44 25   RESULT MATor0 y z    
R↓ 33   MATor0 y z RESULT    
g TEST 0 43,30, 0   MATor0 y z RESULT    
STO I 44 25   MATor0 y z RESULT    
f MATRIX 1 42,16, 1   MATor0 y z RESULT   Set R0 & R1 to 1
LBL . 4 42,21,.4   ? ? ? ?    
f USER RCL (i) u 45 24   M(i)_r ? ? ?    
f USER -   M(i)_r ? ? ?   Exit USER mode
g CF 9 43, 5, 9   M(i)_r ? ? ?   NOP
g F? 8 43, 6, 8   M(i)_r ? ? ?    
GTO . 8 22 .8   M(i)_r ? ? ?    
R/S 31   M(i)_r ? ? ?    
GTO . 4 22 .4   M(i)_r ? ? ?    
f LBL . 8 42,21,.8   M(i)_r ? ? ?    
f USER RCL (i) u 45 24   M(i)_c ? ? ?    
f USER -   M(i)_c ? ? ?   Exit USER mode
g CF 9 43, 5, 9   M(i)_c ? ? ?   NOP
f I 42 25   M(i)_r ? ? ?    
R/S 31   M(i)_r ? ? ?    
GTO . 4 22 .4   M(i)_r ? ? ?    
g RTN 43 32   N/A   Never Get Here

4.3. Solve Linear System

4.3.1. Usage

This program solves the system \(AX=B\) for \(X\).

  • Program start conditions
    • The \(A\) matrix is assumed to be in A.
      • It may be an \(n\times n\) real matrix, or an \(n\times 2n\) complex matrix in C format.
      • The program determines real vs. complex from the matrix size.
    • The \(B\) matrix in B.
    • Flag 1 is set appropriately:
      • Clear: Use more memory, but preserve contents of A.
      • Set: Use less memory, but destroy contents of A.
  • Program end conditions
    • The system "solution", \(X\), will be in C. Note this might not be a valid solution if \(A\) is singular!
    • B is left unchanged!
    • The matrix descriptor for C will be in stack position Y.
    • Matrix C will be selected as the RESULT matrix.
    • Both R0 & R1 will contain 1 in expectation USER mode will be used to visit the elements of C.
    • If \(A\) is a real matrix:
      • Flag 0 will be clear
      • \(\vert A\vert\) is in stack position X
      • The LU factorization of \(A\) is in E when flag 1 is clear, and in A otherwise
    • If \(A\) is a complex matrix
      • Flag 0 will be set
      • \(\mathrm{abs}(\vert A\vert)\) is in stack position X
      • The LU factorization of \(\tilde{A}\) is in E when flag 1 is clear, and in A otherwise

4.3.2. Resources Used

  • Internal Labels:
    • 8 Program label
  • External Labels:
    • 9 Subroutine to compute determinant
  • Flags:
    • 0 – Status flag
    • 1 – Option flag
  • Registers:
    • None
  • Matrices:
    • A
    • B
    • C
    • E – only when flag 1 is clear

4.3.3. Program Listing

LIN_SLV – Solve \(AX=B\)

Keystrokes     Key Codes     Stack Contents     Comments
f LBL 8 42,21, 8   x y z t    
GSB 9 32 9   DET(A)orABS(DET(A)) ? ? ?    
RCL MATRIX B 45,16,12   BorBc DET(A)orABS(DET(A)) ? ?    
g F? 0 43, 6, 0   BorBc DET(A)orABS(DET(A)) ? ?    
f Py,x 42 40   BorBp DET(A)orABS(DET(A)) ? ?    
RCL RESULT 45 26   LU~ BorBp DET(A)orABS(DET(A)) ?    
f RESULT C 42,26,13   LU~ BorBp DET(A)orABS(DET(A)) ?    
÷ 10   CorCp DET(A)orABS(DET(A)) ? ?    
g F? 0 43, 6, 0   CorCp DET(A)orABS(DET(A)) ? ?    
g Cy,x 43 40   CorCc DET(A)orABS(DET(A)) ? ?    
x≷y 34   DET(A)orABS(DET(A)) CorCc ? ?    
f MATRIX 1 42,16, 1   DET(A)orABS(DET(A)) CorCc ? ?    
RCL MATRIX B 45,16,12   BorBp DET(A)orABS(DET(A)) CorCc ?    
g F? 0 43, 6, 0   BorBp DET(A)orABS(DET(A)) CorCc ?    
g Cy,x 43 40   BorBc DET(A)orABS(DET(A)) CorCc ?    
R↓ 33   DET(A)orABS(DET(A)) CorCc ? BorBc    
g RTN 43 32   DET(A)orABS(DET(A)) CorCc ? BorBc    

4.4. Matrix Determinants

4.4.1. Usage

  • Program start conditions
    • The \(A\) matrix is assumed to be in A.
      • It may be an \(n\times n\) real matrix, or an \(n\times 2n\) complex matrix in C format.
      • The program determines real vs. complex from the matrix size.
    • flag 1 is set appropriately:
      • Clear: Use more memory, but preserve contents of A.
      • Set: Use less memory, but destroy contents of A.
  • Program end conditions
    • The previous contents of the stack are lost
    • If flag 1 is clear
      • A is left unchanged!
      • RESULT matrix set as E
    • If flag 1 is set
      • RESULT matrix set as A
    • \(A\) is a real matrix
      • Flag 0 will be clear
      • The \(\vert A\vert\) is in stack position X
      • The LU factorization of \(A\) is in E when flag 1 is clear, and in A otherwise
    • If \(A\) is a complex matrix
      • Flag 0 will be set
      • \(\mathrm{abs}(\vert A\vert)\) is in stack position X
      • The LU factorization of \(\tilde{A}\) is in E when flag 1 is clear, and in A otherwise

4.4.2. Resources Used

  • Internal Labels:
    • 9 – Program label
    • .9 – Conditional label
  • External Labels:
    • N/A
  • Flags:
    • 0 – exit flag
    • 1 – option flag
  • Registers:
    • N/A
  • Matrices:
    • A
    • E – only when flag 1 is clear

4.4.3. Program Listing

DET_A – Determinant of A

Keystrokes     Key Codes     Stack Contents     Comments
f LBL 9 42,21, 9   x y z t    
f RESULT E 42,26,15   x y z t    
g F? 1 43, 6, 1   x y z t    
f RESULT A 42,26,11   x y z t    
RCL DIM A 45,23,11   n m x y    
g TEST 5 43,30, 5   n m x y    
GTO . 9 22 .9   n m x y    
g SF 0 43, 4, 0   n m x y    
RCL MATRIX A 45,16,11   A n m x    
f Py,x 42 40   Ap n m x    
f MATRIX 2 42,16, 2   A~ n m x    
f MATRIX 9 42,16, 9   SQ(ABS(DET(A))) n m x    
g ABS 43 16   SQ(ABS(DET(A))) n m x   If roundoff made it negative
√x 11   ABS(DET(A)) n m x    
F? 1 43, 6, 1   ABS(DET(A)) n m x    
g RTN 43 32   ABS(DET(A)) n m x   Rtn when A cplx & flag 1 set
RCL MATRIX A 45,16,11   A~ ABS(DET(A)) n m   Restore A to Ac form
f MATRIX 3 42,16, 3   Ap ABS(DET(A)) n m    
g Cy,x 43 40   Ac ABS(DET(A)) n m    
R↓ 33   ABS(DET(A)) x y Ac    
g RTN 43 32   ABS(DET(A)) Cc x x   Rtn when A cplx & flag 1 clear
LBL . 9 42,21,.9   n m x y    
g CF 0 43, 5, 0   n m x y    
RCL MATRIX A 45,16,11   A n m x    
f MATRIX 9 42,16, 9   DET(A) n m x    
g RTN 43 32   DET(A) n m x   Rtn when A real

5. Summary Resource Use

5.1. Labels

LBL Use   LBL Use
0 Unused   .0 Unused
1 Solver/Integrator/Newton                    .1 Used in LBL C
2 Solver/Integrator   .2 Unused
3 Solver/Integrator   .3 Unused
4 Dump A Matrix   .4 Used in LBL 4
5 Unused   .5 Unused
6 Unused   .6 Used in LBL 7
7 Fill A Matrix   .7 Used in LBL 7
8 Solve Real Linear System   .8 Used in LBL 4
9 Real Determinant   .9 Used in LBL 9
A Unused      
B Unused      
C Complex Newton's Method      
D Store Complex Number      
E Recall Complex Number      

5.2. Registers

How I normally use register storage.

Registers Use In Programs Interactive Use
0 - 1 Always for matrix indexes\(^1\) Whatever, but usually as matrix indexes
2 - 7 Always for statistics\(^1\) Whatever, but usually for statistics
8 - 9 User visible program registers Whatever, but usually for programs
.0 - .6 Whatever Whatever
.7 - .9 Unit conversion factors\(^2\) Unit conversion factors
  1. I avoid using the matrix & staticial registers in programs because I ocassionally use matrix & statstical functions in solver programs. For example, if I had used thes registers in the Complex Newton's Method program then I wouldn't be able to do that.
  2. Conversions: in to cm, lb to kg, US gal to liters. Keys 7 to 9 mirror unit conversion keys on another calculator. ;)

5.3. Matrix Registers

How I normally use matrix storage. These habits have strongly influenced the matrix helper routines.

MATRIX Use
A Determinants & LHS of matrix equations (\(AX=B\))
B RHS of matrix equations (\(AX=B\))
C Solution for \(AX=B\)
D Unused
E \(LU\) of \(A\) for determinants & matrix equations when flag 1 is clear
   

6. Meta Data

The primary URL for this page: https://richmit.github.io/voyager/hp15.html

The org mode file for this page: https://github.com/richmit/voyager/blob/main/docs/hp15.org

The HTML file for this page: https://github.com/richmit/voyager/blob/main/docs/hp15.html

The github repository housing this content: https://github.com/richmit/voyager/