(HP17BII) What way for a loop stop condition ?
|
05-09-2020, 01:06 PM
Post: #1
|
|||
|
|||
(HP17BII) What way for a loop stop condition ?
(HP17BII) What way for a loop stop condition ?
You know the Czech guess, of course (conjecture tchèque in French) ? In fact, i have a question ! Just be a little patient... A natural equation for the resolution of this sequence on the HP17BII would be as follows : Code:
with this use process : [CALC] gives [SUITE] [N] 3 [N] --> N=3 [SUITE] --> SUITE=10 [SUITE] --> SUITE=5 [SUITE] --> SUITE=16 [SUITE] --> SUITE=8 [SUITE] --> SUITE=4 [SUITE] --> SUITE=2 [SUITE] --> SUITE=1 So, 3 requires 7 steps to become 1 But, if you want an easy way to follow the number of sequences from the initial N until 1, you could modify the equation as well : Code:
with a very similar use process : [CALC] gives [SUITE] [N] [NB] DSP [FIX] 4 INPUT 3 [N] --> N=3.0000 [SUITE] --> SUITE=10.0001 [SUITE] --> SUITE=5.0002 [SUITE] --> SUITE=16.0003 [SUITE] --> SUITE=8.0004 [SUITE] --> SUITE=4.0005 [SUITE] --> SUITE=2.0006 [SUITE] --> SUITE=1.0007 and the same number of steps to move 3 to 1 This time, there is a satisfying equation... for a little sequence and if you have a good memory to remember the initial N !! So, a step further, i propose you to evolve this equation by modifying it again. Then, i use a internal variable to conserve the initial N and i do the insertion of a loop control to computerize the sequence from N to 1. This is the equation : Code:
and the use process evolves as follow : [CALC] gives [CT] [N] [MAX] DSP [ALL] 10 [MAX] 3 [N] [CT] --> CT=7 Now, you receive the number of sequence as a result of the equation with [CT]. That's OK. What is more disputable is that : - we need to know beforehand the maximum number of iterations to perform, before launching the evaluation of the equation - if we have incorrectly evaluated the maximum number of iterations necessary, we will not know it - if we choose for security a very large forecast number of iterations, the calculator will perform a very long processing without this being necessary - to be fair, the maximum should be adjusted for each evaluation of the number of sequences with each number: compare CT(3)=7 with CT(837799)=524... So, a new alternative to modifying the equation could be this : Code:
With the control of the variable [W], by RCL [W] at the end of the calculation, you should verify if the last term of the sequence is effectively 1. You should initialize MAX to 1000 (1000 [MAX]) before enter N (3 [N] or 837799 [N]) and evaluate the equation by [CT]. However, the resolution time will always be the same with a fairly long time. So, it's time for me to ask my question !! Has anyone ever solved checking the end of the loop condition dynamically on the HP17BII or HP27S ? Or on the more recent HP17BII+ ? Is there possible to have a end condition based on the evaluation of the last term of the sequence ? Have you an other proposition to rewrite this equation in order to allow the dynamic resolution of this ? (Is this possible stopping to loop as soon as the last term is 1 ?) |
|||
05-09-2020, 02:27 PM
Post: #2
|
|||
|
|||
RE: (HP17BII) What way for a loop stop condition ?
You can always terminate a solver sigma loop early on the 17bii and 17b by performing an illegal operation (like LOG(0) or /0), but that will also end the evaluation of the equation. In many cases you can save the value you want in a variable and then RCL that variable after the error message. I have used this method successfully many times, such as in my prime factor finder:
Code:
This also works on the 27s. I wouldn't try this on the 17bii+, however, unless you just want to make your life miserable. This also works on the 19b and 19bii with the added advantage that you don't need to recall FACT, it will appear automatically. Hope this helps. |
|||
05-09-2020, 02:36 PM
Post: #3
|
|||
|
|||
RE: (HP17BII) What way for a loop stop condition ?
If you're not already familiar with the Solver GET-LET document by Martin Hepperle, I would highly recommend it, along with the Technical Applications book used as a reference
https://www.hpmuseum.org/forum/thread-6573.html Remember kids, "In a democracy, you get the government you deserve." |
|||
05-09-2020, 05:43 PM
Post: #4
|
|||
|
|||
RE: (HP17BII) What way for a loop stop condition ?
(05-09-2020 02:27 PM)Don Shepherd Wrote: You can always terminate a solver sigma loop early on the 17bii and 17b by performing an illegal operation (like LOG(0) or /0), but that will also end the evaluation of the equation. In many cases you can save the value you want in a variable and then RCL that variable after the error message. I have used this method successfully many times, such as in my prime factor finder: (05-09-2020 02:36 PM)mfleming Wrote: If you're not already familiar with the Solver GET-LET document by Martin Hepperle, I would highly recommend it, along with the Technical Applications book used as a reference Thank you very much Don Shepherd and mfleming! So I'm going to insert a tiny presence of abrupt end in my equation! I will reread with pleasure the precious document published by Martin Hepperle, augmented by Don Shepherd, thanks to which I had already progressed a few years ago! That's nice ! |
|||
05-09-2020, 08:09 PM
(This post was last modified: 05-09-2020 08:13 PM by Nihotte(lma).)
Post: #5
|
|||
|
|||
RE: (HP17BII) What way for a loop stop condition ?
Based on Don Shepherd's suggestions and a new evolution of my equation, here is what it gives:
Code:
and the process becomes as follows : [CALC] gives [CT] [N] [MAX] [NB] DSP [ALL] 1000 [MAX] 3 [N] [CT] --> SOLUTION NOT FOUND RCL [NB] NB=7 27 [N] [CT] --> SOLUTION NOT FOUND RCL [NB] NB=111 La fin justifie les moyens !! (so, the end justifies the means) Thanks Don Shepherd ! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)