Feigenbaum for the HP-15C [LONG] Message #4 Posted by Valentin Albillo on 4 June 2004, 6:48 a.m., in response to message #1 by Valentin Albillo
Hi,
Just to prove the point, here's a conversion of my 4-liner HP-71B program to the HP-15C !
Despite the obvious (and large) differences in language level (low-level RPN vs. high-level BASIC), numerical precision (10-digit vs. 12-digit) and above all, speed (15-30x slower), the HP-15C is perfectly up to the task, delivering Feigenbaum's constant correct to 4 digits in 18 min., which fares well compared to the 71B results (6 digits in 3.3 min.).
Also, the HP-15C program is much more compact, at 60+ bytes (47 steps) versus 71B's 174 bytes (4 multi-statement lines), i.e. just 1/3rd the size (RPN strikes again!). Listing follows with a few pertinent comments:
01 LBL A 14 LBL 0 25 RCL- 1 36 GTO 0
02 MATRIX 1 15 2 26 RCL 4 37 RTN
03 CLX 16 STOx 5 27 RCL- 0 38 LBL 1
04 STO 1 17 RCL 0 28 / 39 RCL 5
05 7 18 RCL- 1 29 STO 2 40 STO 6
06 STO 3 19 RCL/ 2 30 R/S 41 CLX
07 2 20 RCL+ 0 31 RCL 0 42 LBL 2
08 STO 5 21 ENTER 32 STO 1 43 X^2
09 3.2 22 SOLVE 1 33 RCL 4 44 -
12 STO 2 23 STO 4 34 STO 0 45 DSE 6
13 FIX 6 24 RCL 0 35 DSE 3 46 GTO 2
47 RND
To use, simply press RUN with no inputs. The program will compute and display the increasingly accurate value of Feigenbaum's constant for each iteration, stopping for you to see it. Press R/S to go on with the next iteration. After completing all 7 iterations, the program will stop displaying the last computed superstable a value, a = 1.401146+, which is the SOLVEd root of the corresponding 256th-degree polynomial.
Results:
Iteration F value Iteration time
--------------------------------------
1 3.218510 17 sec.
2 4.385687 50
3 4.600945 65
4 4.655086 83
5 4.666256 162
6 4.667830 234
7 4.669803 477
Last result is 4.669+, accurate to 4 digits within 1 ulp.
Notes:
- As the HP-15C uses 10-digit precision instead of HP-71B's 12-digit, we can't get a result accurate to more than 4-5 significant digits, so just 7 iterations will suffice. Besides, we don't need to find the high-degree polynomials' roots to full 10-digit precision, thus steps 13 FIX 6 and 47 RND provide early termination for 22 SOLVE 1, saving much time at no cost in final accuracy.
- The high-degree polynomial that is being SOLVEd is computed at steps 38-47. Notice the very tight loop 42-46 which is once again a superb practical demonstration of classic RPN's stack capabilities at its best: no matter how high the degree of the polynomial, the repeated subtraction at step 44 never exhausts the provision of a values, thanks to top-level replication, where T is replicated continuously as the stack drops and drops. If literally coded in RPL this loop would collapse the stack in no time !
- The ever bigger polynomials' roots are found using the powerful SOLVE instruction at step 22. In a running program, SOLVE behaves like a test: if a root is found, the next step is executed, else it is skipped. Normally this must be taken into account, but for this particular program, the root always exists and SOLVE always finds it for the number of iterations considered, so there's no need to code the possibility of it failing.
- Last but not least, notice how every advanced feature of the HP-15C instruction set helps to reduce step count and increase speed, from the matrix instruction at step 02, to recall arithmetic everywhere, to being able to use any numbered register for loop indexing purposes.
In conclusion, I hope you'll agree that the mere fact that this kind of computation is feasible in the HP-15C in reasonable times and with such a small, simple program, is but another proof of the outstanding quality of this wonderful machine. As "Moulin Rouge!"'s Zidler himself would say on behalf of the HP-15C: "A magnificent, opulent, tremendous, stupendous, gargantuan success"
Best regards from V.
Edited: 4 June 2004, 7:55 a.m.
|