Re: Solvers in 27S and 42S Message #5 Posted by Thomas Okken on 25 Oct 2006, 8:18 p.m., in response to message #3 by Anders
Quote:
OK, just so I get a better understanding, how would the following alg expression (from the museum) be typed and work in the 42S solver?
Alg:(1+infl)*(1+real)=(1+nom)
Not to take anything away from Bill's response, but sometimes an example says more than 1,000 words. Here's how you would work with your equation on the HP42S:
First, you must write a program. This program declares its parameters using MVAR instructions, which must come immediately after the program's global label (i.e. its entry point). The MVAR instructions tell the HP42S which names to display in the solver's menu.
00 { 49Byte Prgm }
01 LBL "ALG"
02 MVAR "INFL"
03 MVAR "REAL"
04 MVAR "NOM"
05 1
06 RCL+ "INFL"
07 1
08 RCL+ "REAL"
09 ×
10 1
11 RCL+ "NOM"
12 
13 .END.
After keying in this program, exit PRGM mode, and activate the solver: [Shift] [SOLVER]. A menu of programs will appear  not of all the programs in memory, just the ones where a global (ALPHA) label is immediately followed by one or more MVAR commands. From this menu, select ALG.
You will now get a second menu, containing the items INFL, REAL, and NOM. If you enter a number and then press one of those menu keys, the value from the X register is stored in the corresponding variable, exactly as if a STO command was executed (in fact, if you hold the menu key down, it will display STO "INFL" (or whichever variable you just chose)).
After having stored the known variables, you can now solve for the unknown by pressing its menu key. Pressing a menu key immediately after another menu key executes a SOLVE command (as you can verify by holding the key down). The HP42S will repeatedly invoke your program, showing the different values it tries for the unknown in the display.
Note that your example was an equality. The HP42S solver only finds zeroes of functions, but you can transform an equality into an equivalent function that the HP42S can solve by simply subtracting one side of the equality from the other.
Quote:
Btw, is it possible on the 42S to call one Solver expressions from another Solver expression (like sub routines)?
In HP42S jargon, that question would be phrased as "is it possible to use the SOLVE function from a program that was itself invoked by the SOLVE function?" The answer, alas, is no. (Note that it *is* possible to use the INTEG command from a SOLVE function, and also the other way around, but the solver and integrator can both only deal with one function at a time  in computer jargon: they are nonreentrant.)
Quote: And/Or can I call a user defined function from the 42S solver?
Technically, there is no such thing as a userdefined function on the HP42S; the only things that the user can define are plain old RPN keystroke programs. However, there is no limitation on what a program invoked by the solver can do, compared to other HP42S programs (apart from the aforementioned restriction of not being able to use the SOLVE function, and one should also be aware that the solver requires one RTN stack level).
Happy solving!
 Thomas
