This program is Copyright © 1998 by Stefan Vorkoetter and is used here by permission.
This program is supplied without representation or warranty of any kind. Stefan Vorkoetter 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.
My HP42S recently broke down, and I obtained a used HP19C from a colleague. After repairing it, the first thing I missed (besides about 8k of memory) was the equation solving capability.
The HP42S has a solver where you can provide a program for an equation of n variables, fix any n1 of these variables, and solve for the remaining one. So, I immediately set out to write such a solver for my "new" 19C.
The solver uses the secant method, in which the two most recent guesses are used to define a line. The point where the line intercepts the xaxis is used as the next guess. When two consecutive guesses are the same, the solution has been found. I'm sure this solver is not as good as the one in the HP42S, but it works sufficiently well for my purposes. It can get into an infinite loop on periodic functions, like sin(x).
Using the solver is simple. First, rearrange your equation so all the terms are on one side. In other words, rewrite it in the form f(a_{1},...,a_{n}) = 0.
Next, enter the equation as a subroutine with label 9. The parameters are represented by the likenumbered registers (i.e. a_{1} is in register 1, and so on).
To solve for any one parameter, store values for all the other parameters in the appropriate registers, enter two initial guesses for the parameter you wish to solve for, enter the parameter number, and press GSB 0.
See the sample problem for more details.
LINE KEYSTROKES COMMENTS 01 g LBL 0 main entry point 02 STO 0 store index of variable to solve for 03 roll dn 04 STO .2 store second guess 05 roll dn 06 STO .1 store first guess 07 STO i compute f1 = f(R1,..,Ri1,..,Rn) 08 GSB 9 09 STO .0 10 RCL .2 compute f2 = f(R1,..,Ri2,..,Rn) 11 STO i 12 g LBL 1 13 GSB 9 14 STO .2 15 RCL .1 compute Ri2 < (Ri1 f2  Ri2 f1) / (f2  f1) 16 x 17 RCL i 18 STO .1 move old Ri2 to Ri1 while we're here 19 RCL .0 20 x 21  22 RCL .0 23 RCL .2 24 STO .0 move old f2 to f1 while we're here 25 x<>y 26  27 / 28 STO i save new value for Ri2 29 RCL .1 compare to previous guess 30 f x!=y keep going until they're the same 31 GTO 1 32 g RTN
R0  Index i of variable to solve for

R1..R9  Variables to solve for (up to 9)

R.0  Previous value for
f(R_{1},..,R_{n})

R.1  Previous value of R_{i}

R.2  Second guess during initialization. Current value for
f(R_{1},..,R_{n}) during main loop

The net resistance, r_{3}, of two parallel resistors of resistance r_{1} and r_{2} is given by:
r_{3}

=

r_{1} r_{2} 
  
r_{1} + r_{2}

This can be rewritten in the form f(r_{1},r_{2},r_{3}) = 0 as follows:
r_{1} r_{2}  

r_{3}

=

0

  
r_{1} + r_{2}

The following subroutine implements this equation:
LINE KEYSTROKES COMMENTS 33 g LBL 9 solver uses subroutine with label 9 34 RCL 1 35 RCL 2 36 x 37 RCL 1 38 RCL 2 39 + 40 / 41 RCL 3 42  43 g RTN
What is the resistance of a 5k Ohm and 10k Ohm resistor in parallel?:
KEYSTROKES  DISPLAY  COMMENTS 
5 STO 1  5.0000  Store 5 in R1 
10 STO 2  10.0000  Store 10 in R2 
3 ENTER  3.0000  First guess is 3 
4 ENTER  4.0000  Second guess is 4 
3 GSB 0  3.3333  Solve for R3 
The answer is 3.3333k Ohms. What resistance is needed in parallel with a 10k Ohm resistor to give a 2k Ohm parallel resistance?:
KEYSTROKES  DISPLAY  COMMENTS 
2 STO 3  2.0000  Store 2 in R3 (R2 is still 10 from the previous problem) 
3 ENTER  3.0000  First guess is 3 
4 ENTER  4.0000  Second guess is 4 
1 GSB 0  2.5000  Solve for R1 
The answer is 2.5k Ohms. If the program cannot find a solution, it will eventually end up dividing by zero, which will display Error. For example, what resistance is needed in parallel with a 10k Ohm resistor to give a 12k Ohm parallel resistance?:
KEYSTROKES  DISPLAY  COMMENTS 
12 STO 3  2.0000  Store 2 in R3 (R2 is still 10 from the previous problem) 
3 ENTER  3.0000  First guess is 3 
4 ENTER  4.0000  Second guess is 4 
1 GSB 0  Error  Solve for R1 
It's not possible to put something in parallel with a 10k Ohm resistor and end up with a higher resistance.
This program should be fairly easy to make work on other HP calculators that have indirect addressing. You may have to change some of the register usage (most of the other models don't have the .n registers). You'll also need to change the indirect addressing. The HP19C/29C use R0 as the indirect register. Some models have a specific i register, so you'll have to make the following changes:
STO i > STO (i) RCL i > RCL (i) STO 0 > STO I
Later models, such as the HP41C can use any register for indirection, so the changes would be:
STO i > STO IND 0 RCL i > RCL IND 0
Go back to the software library
Go back to the main exhibit hall