Note: This is a first draft of material developed for an MoHPC Article that I announced an intention about 30 months ago to write. Comments are welcome and encouraged. If anyone can suggest a more practical equation for illustration, please suggest. The equation should be both solvable and integratable with reasonable calculation times.
======================================================
Using SOLVE and INTEG with MISO functions on HP-15C, HP-34C, and HP-41C/CV/CX
BACKGROUND OF "SOLVE" and "INTEG":
Numerical rootfinding ("SOLVE") and numerical integration ("INTEG") of single variables were built-in or made available as sophisticated machine-coded functions on seven RPN-based Hewlett-Packard scientific calculator models.
SOLVE and INTEG are present on the following models:
- HP-34C
- HP-15C
- HP-41C/CV/CX with Advantage Pac
- HP-32S
- HP-42S
- HP-32SII
- HP-33S
(Excluded from this list are the RPL-based models, the algebraic-entry models, and the HP-71B with Math ROM.)
The SOLVE and INTEG functions were introduced in their original paradigm on the HP-34C in 1979, and later carried over to the HP-15C in 1982. For the HP-41C/CV/CX, the same functions were adapted with only slight modification in the Advantage Pac introduced in 1985.
Two fine articles regarding SOLVE and INTEG on the HP-34C appeared in HP Journal in 1979 and 1980, respectively. These are available on CD Volume 3 and the DVD-ROM from the MoHPC.
This original paradigm requires that the function to be solved or integrated, be programmed as an RPN routine. The routine must be designed to accept an input value of the variable to be solved or integrated in the stack x-register, and to return the calculated value of the function to the x-register. This user program is executed repeatedly by the SOLVE or INTEG function in order to calculate the desired result. Moreover, the program may include a SOLVE or INTEG instruction, thus allowing INTEG to be executed within SOLVE, or vice versa. This capability, incidentally, was not provided on the successor Pioneer-series models HP-32S and HP-32SII, or on the present HP-33S.
STORAGE OF VARIABLES; MISO AND SISO FUNCTIONS
Storage registers for variables on the HP-32S, HP-32SII, and HP-33S are designated by single letters. The Pioneer-series HP-42S allowed alphanumeric identifiers for variables. SOLVE and INTEG on all four of these models require the user to specify (by letter or name) the root variable to SOLVE or the dummy variable of integration to INTEG. This feature is well-suited for multiple-input, single-output (MISO) functions.
The 34C, 15C, and 41C/CV/CX, however, provided only numbered and "indirect" storage registers. The paradigm of SOLVE and INTEG on these models was designed primarily for single input, single-output (SISO) functions. It does not require that the input variable even be stored to a register.
TO USE 34C/15C/41C "SOLVE" AND "INTEG" WITH MISO FUNCTIONS:
Assume that a MISO function is to be programmed as an RPN routine on a HP-34C, HP-15C, or HP-41C/CV/CX. A user may wish to use SOLVE or INTEG successively for any selected "focus" variable with all others held constant, and without having to edit the RPN routine. Here is a simple procedure for this purpose:
1. Designate a numbered storage register for each variable in the function.
2. On the 41C/CV/CX, designate another numbered register as the indirect storage register. (Do not use a stack register, as it will be overwritten by SOLVE or INTEG.)
In PROGRAM mode:
3. Program the function as an RPN routine that meets the basic requirements and, also, always retrieves each variable from its designated storage register the first time it is used. (On the 41C/CV/CX, the label beginning the routine must be an external label.)
4. The second instruction of the routine (after LBL) should be "store to indirectly-referenced register". This is "STO (i)" on the 34C and 15C; "STO IND nn" on the 41C/CV/CX.
In RUN mode:
5. Store the desired constant values of the fixed-value variables to their storage registers.
6. Store the register number containing the floating variable to the indirect storage register.
7. Invoke SOLVE or INTEG in the usual manner.
This procedure utilizes indirect storage to make the RPN program more flexible. SOLVE and INTEG feed the each value of the floating variable as input to the user program, which immediately stores the value indirectly to its designated register. Each variable in the function is then recalled for use in calculations, so the user program need not be structured to receive any particular variable from the stack.
EXAMPLES:
f(x, y, z) = 2*x - ln y + 1/z
x in R1; y in R2; z in R3
indirect in R00 (HP-41 only)
HP-15C/HP-34C program: HP-41C/CV/CX program:
LBL A LBL "AA"
STO (i) STO IND 00
RCL 1 RCL 01
2 2
* *
RCL 2 RCL 02
LN LN
- -
RCL 3 RCL 03
1/x 1/x
+ +
RTN RTN
In RUN mode, solve for x such that f(x, y=15.1, z=5.3) = 0
HP-15C/HP-34C: HP-41C/CV/CX:
15.1 15.1
STO 2 STO 02
5.3 5.3
STO 3 STO 03
1 1
STO I STO 00
0.5 0.5
ENTER ENTER
5 5
SOLVE A "AA" (enter AA in alpha mode)
XEQ "SOLVE"
(Answer is 1.263007749)
Next, solve for y such that f(x=0.7, y, z=3.3) = 0
HP-15C/HP-34C: HP-41C/CV/CX:
0.7 0.7
STO 1 STO 01
3.3 3.3
STO 3 STO 03
2 2
STO I STO 00
0.5 0.5
ENTER ENTER
6 6
SOLVE A "AA" (enter AA in alpha mode)
XEQ "SOLVE"
(Answer is 5.490560270)
Finally, integrate f(x=1.7, y=4.1, z) over z = 1.0 to 6.0.
Specify 5 decimal-digit absolute function accuracy:
HP-15C/HP-34C: HP-41C/CV/CX:
FIX 5 FIX 5
1.7 1.7
STO 1 STO 01
4.1 4.1
STO 2 STO 02
3 3
STO I STO 00
1 1
ENTER ENTER
6 6
INTEG A "AA" (enter AA in alpha mode)
XEQ "INTEG"
(answer is 11.73682)
Edited: 28 Sept 2005, 2:48 a.m.