HP-35S solver questions - extremum
#1

HP-35S Solver differs from the one of HP-33S at least in two aspects:

a) It permits user to STOre the values in registers.

b) It is much prone not to find/show extremums of function solved.
(if HP-33s while failed to find a root. usually makes it possible to see closest values, HP-35S does not show them, i dunno why).


Regarding STOrage: if you store subexpression (like X>C*Y+3, where ">" designates "STO") or whole expression (X*Y+3>C), it's ok but of little use (sometimes you can get argument and/or function estimates after NO ROOT FND). But if you RCL it, solve would ask for it's value, effectively blocking usage of it for temporary data storage.

May be, the creators of HP-35s wanted to make Solver more advanced (hence the ability to use STO in EQN), but had no resources to implement reasonable additional functionality.

Well, the EQN and STO are very interesting, and should be examined more closely. Especially, using indirect registers, there may be possibility to break into calc internals here (i hope so).

Interesting thing, that usage of X>X is allowed in the EQN. I do not understand the logic yet, however.

I am now trying to write some kind of equation permitting to use Solver for extremum search. The simplest way seems to compute derivative function and find it's roots.

#2

You may be interested in a previous thread by Katie (IIRC, which is not that often) in which she wrote a function for solver which counts iterations, like a loop. This thread has been very, very difficult for me to find, can anyone help with this? It does provide a way of
"probing" into the workings of the solver. Cheers, Glenn

#3

Thanks Glenn! I suppose you speak about http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv017.cgi?read=121288

Found it in Google.

Very interesting!

While continuing to learn solver, I've found one new interesting thing: when you solve for indirect, (I) or {J), and modify I or J,
solver "precompiles" (I) or (J) used in eqn. May be it is too clumsy, so here is the sample:

EQN: (I)>I*2+3
-26
STO I
EQN
SOLVE (I)
Solver would solve for Z (-26), not for (I) with changing value of I.
#4

From the same thread (Message #13):

Quote:
It seems that when recalling an indirect register from within an equation the index isn't updated for each iteration. Instead (I) refers always to the same register.

Welcome to the club.

Best regards

Thomas

PS: Reading this thread again I suddenly realized that Katie's trick could be used with the HP-17BII to solve the N-queens problem.

#5

Quote:
Reading this thread again I suddenly realized that Katie's trick could be used with the HP-17BII to solve the N-queens problem.

Thomas, please elaborate on this. I looked at the sample programs for the n-queens benchmark recently and came to the conclusion that, since there seemed to be one or two indefinite loops in that algorithm, the 17bii solver would not be able to handle that since it does not support indefinite loops. I'm curious, what did you have in mind?

thx, Don

#6

From message #3 Posted by Katie Wasserman on 13 Aug 2007, 10:45 a.m.,
in response to message #2 by Don Shepherd

Quote:
If you tell it to solve: INV(A) = -INV(A)+ 0x(I+1 STO I), solve for A and give it a starting value of I=0 and A=1, it will run for about 2400 iterations on the 35s. after that point the solver will end up solving the equation by coming up with A ~= 1E499. 2400 is pretty much all the iterations you'd ever want to do on this calculator -- it ain't that fast -- I'll call it a near-infinite number of iterations for our purpose.

(...)

Quote:
I don't have a 17BII+ but on the 17BII you can do the same thing in the solver: INV(A)=-INV(A)+0xL(I:I+1). Start with I=0 and A=1, solver for A and RCL I when it finishes and you'll find that I has a value of about 2400, showing that this many iterations have been done. Unfortunately you can't 'STO (I)' on the 17BII because it has no way to write to an array (although you can read the items in a list from within the solver). Of course you would never really do this on the 17BII you'd use: X=Sigma(I:1:N:1,whatever you want to do). Note that 'Sigma' is the summation sign and 'whatever you want to do' will be evaluated N times and the results will be summed and returned in X.

Of course we really want to do this because we need a means to exit a loop on a specific condition. I'm not sure at all whether all this would work to write a solver program for the N-queens problem. But at least it seems the solver isn't limited to a for-loop.

From message #6 Posted by Katie Wasserman on 15 Aug 2007, 3:40 a.m.,
in response to message #5 by Thomas Klemm

Quote:
It's possible to simulate nested loops in the solver by doing something like:
(1-IDIV(C,N^2))*INV(A)=(IDIV(C,N^2)-1)*INV(A)
+ 0*
(C+1 STO C +
IDIV(C,N) STO I +
RMDR(C,N) STO J +
....

HTH

Thomas

Edited: 31 Jan 2011, 12:09 a.m.

#7

Thanks Thomas, I remember that thread from 2007 and Katies work then. Fascinating stuff.

When I looked at the BASIC program (thinking it would be easier to understand than the RPN and RPL solutions) for the n-queens problem here, there seemed to be about 4 overlapping indefinite loops: lines 40-100, 70-150, 90-130, and 140-170. I didn't know exactly what these loops were doing, but since they weren't definite loops I didn't think the 17bii solver could handle them.

I did learn of a way to actually exit a loop early on the 17bii solver from user Mike Ingle about 4 years ago, but you exited early by halting the program with a programmed divide by 0 after you stored some value of interest in one of the menu variables, which you could RCL after the program stopped. That might work for one indefinite loop, but not 4!

I would present a "steely-eyed missle man" award to the person who could implement the n-queens problem on the 17bii solver.

Don

#8

Don, I've started a new thread concerning this problem.

Best regards

Thomas

#9

I wrote: "But if you RCL it, solve would ask for it's value, effectively blocking usage of it for temporary data storage."

Katie wrote (http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv017.cgi?read=121288):

"The get, G(), function I was referring to is a special function in the 17bii solver (and several other HP calculators going back to the 27S) that recalls the value of a variable each time it's encountered. When used in combination with the let, L(), function it allows for side-effects in the solver. The 35s solver apparently has the L() function (in the form of STO) but not the G() function, or so it seems."

I think it is wrong. G() (RCL) works. The only problem is you should enter first value of it (seed) at the launch of solver.

Strangely, Katie make use of it in her examples. Something i do not understand. Or G() is not equivalent to RCL?

More: solver uses local (to it) copy of variable solved.


so it is possible to use it in expression.

0 STO A
A/A+0x(777>A)
SOLVE
RCL A
777

Edited: 1 Feb 2011, 5:19 p.m.



Possibly Related Threads…
Thread Author Replies Views Last Post
  hp-prime solver and variable name fabrice48 22 8,120 12-10-2013, 03:25 AM
Last Post: fabrice48
  Solver issue with HP 17BII - different from 19BII Jeff Kearns 13 4,469 11-28-2013, 02:36 AM
Last Post: Don Shepherd
  HP Prime Triangle solver BruceH 29 8,400 11-28-2013, 12:03 AM
Last Post: Dale Reed
  HP prime: linear solver app Alberto Candel 1 1,408 11-21-2013, 01:57 AM
Last Post: Michael Carey
  HP Prime: Linear Solver app bug BruceH 0 1,122 11-15-2013, 06:36 PM
Last Post: BruceH
  HP Prime questions: I/O and Meta programming Andy Gryc 2 1,478 10-31-2013, 11:22 PM
Last Post: Andy Gryc
  HP Prime Solver Variables Issue Anibal Morones Ruelas 8 2,988 10-19-2013, 09:45 AM
Last Post: Harold A Climer
  HP Prime triangle solver oddity BruceH 0 1,025 10-13-2013, 09:08 PM
Last Post: BruceH
  Using units in Numeric Solver Harold A Climer 1 1,245 10-13-2013, 10:44 AM
Last Post: Tim Wessman
  Meltiple Equation Solver PRIME Vs. HP 50G Harold A Climer 5 1,779 10-07-2013, 05:11 PM
Last Post: CR Haeger

Forum Jump: