Improving the solver experience on the 41C

02162016, 03:41 AM
Post: #1




Improving the solver experience on the 41C
One of the features I like about latermodel HP calculators is the use of named variables and the ability to solve for any one of the variables in an equation. The solver function available in the Advantage module is decent enough from a functional standpoint, but one generally needs to write multiple RPN functions for the same equation, depending on the variable being solved for. I came across this program which stores the values of all variables in registers and uses indirect register addressing to update the unknown variable during root finding. I extended this technique to make things more userfriendly. Here is the program I came up with:
Code: 01◆LBL "SLV" The SLV program has two requirements: the Advantage module SOLVE function (or another root finder) and an RPN function that you write to evaluate your equation. To illustrate how the equation function is written, let's use a simple example from classical mechanics: x=v0*t+(1/2)*a*t^2. The RPN function for this equation is written in the following manner: Code: 01◆LBL "MOT" The function starts with a global label. Following that, a check of flag 05 is performed, which informs the function whether it's being called during root finding or for generating a user prompt. When evaluating the function during root finding, SLV clears flag 05, and the current estimate for the unknown variable is stored indirectly into the appropriate register in line 04. Lines 0516 evaluate the function by recalling the values of the variables and performing the arithmetic. This is where you would enter the RPN steps for your equation f(x1,x2,...)=0. You can use up to 5 variables, and it's up to you to decide which variable goes into which register, 0105. The alpha string following LBL 00 provides a user prompt and can be designed so that the variable name appears above the toprow key corresponding to the register (key "A" for 01, etc.). Here are the instructions for running the SLV program:
I like this technique because the equation and its prompting string are stored as a single function. While it takes a moment to plan out register usage, once you've created the function, you don't need to remember which register is which any more. I'd be pleased to hear any suggestions for improvement. It seems like something similar should have been written in the past, but I was unable to find anything. The AECROM has a nice interface for entering an equation and generating a program from it, but you have to decide ahead of time which variable you're going to solve for. David Brunell Houston, Texas 

« Next Oldest  Next Newest »

Messages In This Thread 
Improving the solver experience on the 41C  quantalume  02162016 03:41 AM
RE: Improving the solver experience on the 41C  Ángel Martin  02162016, 10:19 AM
RE: Improving the solver experience on the 41C  quantalume  02162016, 07:44 PM
RE: Improving the solver experience on the 41C  Ángel Martin  02172016, 06:25 AM
RE: Improving the solver experience on the 41C  Jeff_Kearns  02202016, 04:42 PM
RE: Improving the solver experience on the 41C  Ángel Martin  02202016, 05:08 PM
RE: Improving the solver experience on the 41C  Jeff_Kearns  02202016, 05:59 PM

User(s) browsing this thread: 1 Guest(s)