The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

33s Solver: Hints: it's quirky, and learn ALG **EDITED**
Message #1 Posted by bill platt on 26 July 2004, 6:26 p.m.

Hello all 33s enthusiasts and NOTenthusiasts:

I have tested the 33s Solver, and found some significant differences in behavior as compared to the 32sii.

As you will recall, the 32sii allows you to use the solver in five (5) different ways:

1.  Equation List
2.  Manually define a Program (Fn=) and Solve it
3.  Write a program which sets Fn= and then solves for the 
        unkown variable in the subroutine called by Fn=.
4.  Write a program using an Equation, and do as with (2) above (set Fn= from the keyboard and solve for the variable.
5.  Do what (3) does, except that the subroutine has an equation.

In any case, if you use any of these five approaches, you will get exactly the same results (as documented):

Z register = last value of the function
y register = penultimate iteration for vairable to be solved
x register = ultimate iteration for solved variable,

and of course the variable itself will have the new value.

(Undocumented): t register = penultimate value of the function (??)

With the 33s, depending on which approach you take (equation list, RPN program, ALG program, Solve manually or with automatic subroutine, equation in program et) there are differences in the results or presentation of the reuslts.

Further, because of the ALG aspect, you now have ten (10) fundamentally different ways:

1.  equation list, run with RPN interface
2.  equation list, run with ALG interface
3.  RPN program
4.  ALG program
5.  Automatic with RPN program
6.  Automatic with ALG program
7.  Program with an equation, Run with RPN interface
8.  Program with an equation, run with ALG interface
9.  Automatic Program with equation subroutine, RPN interface
10.  Automatic Program with equation subroutine, ALG interface.

Note that a Automatic control program for solving is inherently RPN/ALG "gender" neutral: LBL J Fn=F Solve X RTN And a subroutine using an equation (expression) is also inherently gender neutral: LBL F SF 11 (eqn) x / (sq(x)-6)-1 RTN

Perhaps you might also add "using the RPN interface to run an ALG program" and "using the ALG interface to run an RPN program' which would add another four (4) flavours to versions 3 through 6 above---but let's ignore that for now!!!!

I tested the behavior by doing a "matrix" of programs for the "pole" example in the manual (repeated above in LBL J) and also using a simple polynomial with a real root: y^3-y^2+6

To sum up the results:

If you solve with an equation list, you will fill the stack and the ALGstack with the best estimates for the solution, and the final value of the function--regardless of whether "no root found" or a root is found.

If you use a program (with and equation in it or not) and you fail to find a root, then the stack and the ALG stack will not be filled with estimates.

Where solutions/estimates are written to the stack, the ALGstack will also be written to--and note that the ALGstack will be available, undisturbed, until the next SOLVE invocation---therefore--you have four extra registers to use in the 33s! This can be very handy!

So, here are some results:

If you solve the "pole" example as I mentioned above, here is what happens:

1. (equation list) RPN input. 2.3 STO x 2.7 {go to EQUATION in the Equation List} Solve X

T --- x1 z 81,649,658,092 x2 y 2.44948974278 x3 x 2.44948974279 x4

"No Root Found" hit backarrow to clear message and you see the stack as noted above.

PLEASE NOTE that the ALG "stack" is also filled as noted above.

The only difference, if you run it in ALG, is that there is no RPN stack--you see only the final result after back-arrowing, and there is the x1 x2 x3 x4 ALGstack too.

Of course, the variable X also contains the "answer".

If you chhose th use a program, it is very different! LBL E RPN RCL X ENTER ENTER X62 6 - / 1 - RTN.

Manually select this function, and tehn solve X, all in RPN, and you get this: 2.3 STO x ;put in your estimates 2.7 ;put in your estimates FN = E ;define function Solve x ;call solve "no root found" backarorrow to see stack:

t 2.3 z 2.3 And no results at all to ALGstack! y 2.3 x 2.7

The "correct iterative answer" is stored in X: 2.44948974279

Similar results are obtained running in ALG--except you don't see the stack.

Exactly teh same also if you have an ALG program and do above: LBL A ALG RCL x / ( RCL X x^2 - 6 ) - 1 ENTER RTN

Now, try using an automation step with the RPN version:

LBL D Fn=E Solve X RTN LBL E RPN RCL X ENTER ENTER X62 6 - / 1 - RTN.

In RPN: 2.3 STO x 2.7 XEQ D

T 2.44948974279 ;{last iteration} Z 2.44948974279 ;{last iteration} Y 2.44948974279 ;{last iteration} X 81649658092 ;{function value at last iteration}

Note that the "Do if True" rule caused the "no root found" event to roll directly into evaluating the routine at the last estimated x-value. Of course, you could code it to say "no root found" and stop, or try again etc.

Now, finally, try this automated business with a program sequence which uses an "Equation" (use LBL J and LBL F above, with F immediately following J)

2.3 STO x 2.7 XEQ J

"X? 2.44948974279" press R/S

T 2.7 Z 2.7 No values to the ALG stack Y 2.44948974279 X 81,649,658,092

Note that flag 11 makes the equation prompt for the variable--when we skip the RTN and go onto evaluating the subroutine.

On another day, I will post the reesults of running a matrix on a "solvable" polynomial---essentally the same as 32sii--except that the T register carries your last input estimate---rahter than as with the 32sii--which carries the penultimate function value in the T register).

Have fun.

Best regards,

Bill

Edited: 27 July 2004, 10:03 a.m. after one or more responses were posted

      
Re: 33s Solver: Hints: it's quirky, and learn ALG
Message #2 Posted by martin cohen on 26 July 2004, 6:53 p.m.,
in response to message #1 by bill platt

This is weird!

I wonder how the 33s was coded.

This, plus the atan2 bug, have me disappointed.

            
Re: 33s Solver: Hints: it's quirky, and learn ALG
Message #3 Posted by John Smitherman on 27 July 2004, 12:20 a.m.,
in response to message #2 by martin cohen

The list of 33s bugs keeps growing. Add the newly discovered to the following:

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv014.cgi?read=57200

But the good news is that the 33s is qualified for the professional engineering exam! ;-)

I was waiting for rev 1 before buying the 33s, but now I think that I will wait for rev 2.

John

      
OOPS!! It is not a bug. (My Fault!)
Message #4 Posted by bill platt on 27 July 2004, 9:47 a.m.,
in response to message #1 by bill platt

Sorry guys----There was no bug in my above post---just lousy programming on my part.

Both the 32Sii AND the 33s handle "no root found" or other failures to converge the same way when solving a program, rather than an equaton in the equation list:

page 14-6 in the 32sii manual (14-6 33s):

"If no solution is found for the unknown variable, the n the next program line is skipped (in accordance with the 'do if true' rule..."

So, in my coding, I had:

LBL Z
FN=E
Solve X
RTN
LBL C
FN = A
Solve x
...
...
...
...
LBL E
RPN
RCL X
ENT
ENT
x^2
6
-
/
1
-
RTN

So, note that I have a "RTN" directly after the solve, but just another program---"LBL C" on the line AFTER the "RTN". So, in cases where "NO ROOT FOUND" occurs, the "RTN " is skipped, and program execution continues withe "LBL C" which is why I got errroneous results-----so no it is not a bug--it is a (very good) feature----You as a programmer have control oof the iterative process---you can put in a counter variable(s) and have the program loop back, try again with different guesses, try so many time s and quit etc....

And all of this exists on the 32sii as well.

It was sloppy of me to forget about this during my explorations.

The aforementioned also helps to explain the "reverse" results for:

LBL D
Fn=E
Solve X
RTN
LBL E
RPN
RCL X
ENTER
ENTER
x^2
6
-
/1
-
RTN.

Recall, that if you run "D", instead of "no root found" and finding the best estimate for the "pole x-value in X, next best in y, function in Z etc, you get:

T     2.44948974279  ;{last iteration}
Z     2.44948974279  ;{last iteration}
Y     2.44948974279  ;{last iteration}
X    81649658092 ;{function value at last iteration}

which is because after the SOlve fails to find a root, it skips the RTN instruction and goes directly into routine E, evaluating it at the X=2.449....9 value.

Please note that, As Jordi Hidalgo pointed out, hte 33s handles a "pole" as above, whereas the 32sii will give an apparent root--and the only way to determine that it is infact a pole is to either have and understand the graph, or look at the final function vale to see that it is not a true root.

In the 33s case, you get "no root found" to clue you in.

So the 33s solver is ok so far. In fact it even has some superior aspects.

try the following on a 32sii:

enter the polynomial X^3-X^2+6:

LBL I
RCL Y
ENT
x^3
SWAP
x^2
-
6
+
RTN

Now, solve it manually:

Fn=I -5 STO Y 5 SOLVE Y

on the 32sii you get "no root found"! whereas on the 33s, you get the correct solution.

In order to solve this equation on the 32sii, you need to code it thus: LBL I RCL Y 3 Y^X RCL Y X^2 - 6 + RTN

Then, you will get the solution.

In other words, stack-work (as opposed to register recall, or horner) can "trip up" the solver in the 32sii, but does not appear to trip up the 33s.

Best regards,

Bill


[ Return to Index | Top of Index ]

Go back to the main exhibit hall