(35S) Fibonacci Fun for the HP35s and the number phi
|
01-22-2015, 08:07 AM
(This post was last modified: 06-15-2017 01:35 PM by Gene.)
Post: #1
|
|||
|
|||
(35S) Fibonacci Fun for the HP35s and the number phi
Greetings,
While playing with my new FX115es Plus from Casio I ran into the infamous Fibonacci sequence, once again, Fn = Fn-1 + Fn-2 using the classic 1 1 startup: 1 1 2 3 5 8 13 21 34 ... The authors of the fx115 user guide were demonstrating the [Ans] + [PreAns] [=] iterative key sequence and were pleased that with the correct startup [1] [=], [+] [1] followed by repeating [Ans] + [PreAns] iteratively would generate the Fibonacci numbers line at a time 'till ad infinitum or 'till boredom; which ever came first prior to overflow. That's the back-story; the fx115 in not programable and although the [PreAns] feature is relatively useful, the example was not terribly enlightening. The little small exercise did give me pause to think about my new HP35s programable with classic four level stack, LASTx, RPN; ... and the iterative steps that would be necessary to conduct the same relatively painless example on the 35s--- bumping the Fibonacci sequence of numbers up the stack and out the TOP. The rules? Glad you asked: only stack manipulations allowed (no exchanges except for [x<>y]), only [+] operation, no direct nor indirect memory registers, and no loss of Fibonacci numbers until they leave the T level of the stack-- out the TOP. Also, we are assuming the classic startup of 1 1, NOT 0 1. Stop reading here and play with your HP a bit to see what you think the minimum steps are that produce the results manually, and then continue reading (you can use any classic HP to do this step). Welcome back. The setup is: Code:
Code:
So what? What if we automate the silly thing so that we can have the machine stop on whatever nth Fibonacci number we want (from a parmameter) and then allow us to step through the rest with [R/S] or watch it run 'slowly' with an embedded [PSE]? Here is the program key sequence: Code:
The machine will stop with 4 in x, waiting for the operator to accept the default, or change it to a higher integer. The largest integer which may be entered (without overflow) is 59. Clear the 4, and place 59 in the x stack position, then press [R/S]. Four and a half seconds later the stack will contain the last four Fibs from the nth and x will hold 956,722,026,041. Run the program again, this time leaving the default of 4. The stack will hold t 1 z 1 y 2 x 3 Now, press [R/S] and watch the Fibonacci numbers bump up the stack ad infinitum or boredom... whichever comes first prior to overflow. Do THAT on your FX115es Plus, I double dare you. PS It is well known that the ratio of any two consecutive Fibonacci numbers produces a more and more accurate convergence on the number phi: (SQ(5)+1)/2. This happens accurately (more or less) for the HP35s at about the 29th iteration of the above program. Stop the sequence at the 29th iteration and then press [x<>y] [/] and you should see: 1.61803398875 ~phi more or less! PSS The program may be interrupted with [R/S] but remember that since the main program never hits a RTN the program counter is stuck in the F program. Inadvertently hitting [R/S] again will restart the program (which you may not want). To avoid this, when you're done playing, either delete F or press [GTO] [.] [.] to set the program counter to the TOP. [/php] Cheers marcus Kind regards, marcus |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)