Programming Exercise (HP-15C, 15C LE - and others)
|
04-02-2014, 04:25 PM
Post: #81
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
How about the ND1 from Naive Designs, a programmable RPL+ calculator that runs on iOS (iPhone, iPod, iPad)? It runs HP48 series-like RPL code with enhancements (right now, about 500 functions), as well as JavaScript.
Note: all programs return this result in the display: 0.693097183059948; when I attempted to Here is the code for RPL+; it runs in about 3.3 seconds on an iPod 4: Code: ≪ 1 10000 2 FOR r r @dup IF isEven THEN inv - ELSE inv + END -1 STEP ≫ A much faster version uses a vector and splits it into two parts; it runs in about .1 second on an iPod 4 (written by the creator of ND1: Code: ≪ 10000..1 inv unzip total swap total swap - neg ≫ And here is one version for J Code: function () { Here is a better version (no testing for even/odd, written by the creator of ND1); this runs in about .07 seconds on an iPhone 5s: Code: function() { /*as is*/ And a third way, by the same person; runs in about ,0006 seconds on an iPhone 5s: Code: function() { /*as is*/ Check out ND1 on the Apple App Store (or ND0 for a limited trial version); the website is http://www.naivedesign.com/ND1/ND1.html David Motto |
|||
04-02-2014, 09:07 PM
(This post was last modified: 04-02-2014 09:07 PM by Gerson W. Barbosa.)
Post: #82
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-02-2014 04:25 PM)DGM Wrote: Check out ND1 on the Apple App Store (or ND0 for a limited trial version); the website is http://www.naivedesign.com/ND1/ND1.html The running times are impressive! I read this too fast and skipped the limited trial version part and ended up getting ND1. I haven't done anything beyond changing the skin to Dark so far. No time to do the quick tour now, but will play with it later. Gerson. |
|||
04-03-2014, 03:47 AM
Post: #83
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
Gerson, I don't think you will regret getting ND1; this is one of the few things I have purchased for my iPod (among the thousands of free apps I have downloaded, some of which I have actually tried). I have written several number theory routines for it, which are available for download to the calculator, and others have written much better things than I have. They are available under the My Data, Shared Folders area of the calculator.
|
|||
04-04-2014, 02:10 AM
Post: #84
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
There seems to be dearth of Classics doing the original program…the -55s doing an alternate version. So the -65 does about an hour and 20 min (wasn't watching that closely), using the following fairly brute force code:
LBL A EEX 4 STO 8 f STK (clear stack) 1 gv (Roll-down) LBL 1 g^ (Roll-up) CHS ENT ENT gv gv RCL 8 ./. (div) + g DSZ GTO 1 RTN 0.693097183 |
|||
04-04-2014, 02:19 AM
Post: #85
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-02-2014 04:25 PM)DGM Wrote: Note: all programs return this result in the display: 0.693097183059948; Back to an authentic HP device, I get 0.693097183059945297 on the HP-200LX running TurboBCD: Code:
It takes 50 seconds, however. Oh, and close to nothing on my old dv2250br notebook, another authentic HP device Gerson |
|||
04-04-2014, 02:58 AM
Post: #86
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-04-2014 02:10 AM)[kby] Wrote: There seems to be dearth of Classics doing the original program…the -55s doing an alternate version. The only Classics I have are this HP-35 and an HP-45, none of which is programmable. But I could have tried a Spice (the 33C). This HP-71B version computes two terms per loop while doing the original problem: 1 S=0 @ FOR N=10000 TO 2 STEP -2 @ S=S+1/(N-1)-1/N @ NEXT N @ DISP S Gerson. |
|||
04-04-2014, 03:26 AM
Post: #87
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-04-2014 02:10 AM)[kby] Wrote: There seems to be dearth of Classics doing the original program… Here's a solution for the HP-25 using Werner's idea: Code: 01 STO 0 Cheers Thomas |
|||
04-04-2014, 04:10 AM
Post: #88
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-04-2014 03:26 AM)Thomas Klemm Wrote:(04-04-2014 02:10 AM)[kby] Wrote: There seems to be dearth of Classics doing the original program… 1h 12 minutes, extrapolating from the time it takes for 100 on Nonpareil. Cheers, Gerson. |
|||
04-04-2014, 04:56 AM
Post: #89
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
Code: S0001 LBL S Using the above code (HP 33s code shown): My HP 33s arrived at 0.69309718306 in 6:10 My HP 35s arrived at 0.69309718306 in 9:15 |
|||
04-04-2014, 07:35 AM
Post: #90
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
How about a new classic? I made an attempt to try the two-term method on the 12C 30th Anniversary Edition:
Code:
10000 R/S yields 0.693097183 Time: 32 seconds Not too bad for a super-charged old-timer. If only I could install an ARM chip in my head -- then perhaps it wouldn't be so hard to switch gears and think in terms of RPN coding again. I'm sure I've overlooked optimizations here, but I was just happy to get it pumping out reasonable answers. |
|||
04-04-2014, 07:43 AM
Post: #91
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others) | |||
04-04-2014, 11:56 AM
Post: #92
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-04-2014 07:35 AM)DavidM Wrote: How about a new classic? To get this running on a 15CLe just add labels A, 0 and 1 in the appropriate places. It returns the same answer but takes 40 seconds instead of 32. Still not bad. Marcus von Cube Wehrheim, Germany http://www.mvcsys.de http://wp34s.sf.net http://mvcsys.de/doc/basic-compare.html |
|||
04-05-2014, 01:46 AM
(This post was last modified: 04-05-2014 02:43 AM by Gerson W. Barbosa.)
Post: #93
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-05-2014 01:36 AM)Gerson W. Barbosa Wrote:(04-04-2014 11:56 AM)Marcus von Cube Wrote: To get this running on a 15CLe just add labels A, 0 and 1 in the appropriate places. It returns the same answer but takes 40 seconds instead of 32. Still not bad. P.S.: But that's exactly equivalent to Thomas Kemm's WP 34S version a few pages behind: Code:
Too bad the HP-15C lacks a DEC I instruction. This would've saved a second or two. This takes 36.6 seconds: Code:
P.P.S: A little bit closer, 35.4 seconds: Code:
|
|||
04-05-2014, 09:01 AM
(This post was last modified: 04-05-2014 10:14 AM by Steve Simpkin.)
Post: #94
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-04-2014 07:43 AM)Thomas Klemm Wrote:(04-04-2014 04:56 AM)Steve Simpkin Wrote: My HP 35s arrived at 0.69309718306 in 9:15You can probably make it even slower by using an algebraic expression. You got that right. Based on 1000 cycles I estimate it would take 27:30 to arrive at the answer using an algebraic equation. A single term version would be even slower. It's funny that my first computer (an Ohio Scientific C1P) and my latest HP calculator (a HP 35s) were purchased 35 years apart but are both powered by a 6502 microprocessor. |
|||
04-05-2014, 05:02 PM
(This post was last modified: 04-05-2014 05:08 PM by Thomas Klemm.)
Post: #95
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
Quote:I took your HP-11C program that sums an alternating series ... Let's go back to Valentin's program. It uses Euler's transform to improve convergence. While Valentin's program handles the general case we can do the same for that specific series. This leads to the following program for the HP-11C which is shorter, faster and more accurate: Code: 001 - 42,21,11 LBL A Example: 12 ENTER 10 GSB A The result 0.6931471806 is exact to all 10 places and is equal to \(log(2)\) as it should be. It takes about 17 seconds using Nonpareil which will be about the same as with the real calculator. Now beat that with brute force. Cheers Thomas For those interested here's a Python program: Code: M = 12 |
|||
04-05-2014, 05:09 PM
Post: #96
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(03-29-2014 05:41 PM)Steve Simpkin Wrote:(03-29-2014 12:36 AM)Tugdual Wrote: Nobody mentioned that entering $$\sum _{ K=1 }^{ 10000 }{ \frac { { (-1 })^{ K+1 } }{ K } }$$ on the Prime with no need for any sort of coding would instantly return 0.693097183025 The Casio ClassPad 330 takes 57.5 seconds to reach 0.6930971831 |
|||
04-06-2014, 03:37 AM
(This post was last modified: 04-06-2014 03:59 AM by Gerson W. Barbosa.)
Post: #97
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-05-2014 05:02 PM)Thomas Klemm Wrote:Quote:I took your HP-11C program that sums an alternating series ... Looks like my HP-11C is a bit slower: 18.7 seconds. (04-05-2014 05:02 PM)Thomas Klemm Wrote: Now beat that with brute force. What about another non brute force program? Code:
4 10 GSB A --> 0.6931471805 ( 13.4 s ) 5 8 GSB A --> 0.6931471806 ( 11 s ) 7 6 GSB A --> 0.6931471807 ( 8.5 s ) The first parameter is the number of terms in the continued fraction, minus one. The second parameter, always even, is the number of computed terms in the series. I have assumed the continued fraction terms follow a pattern, but this has yet to be checked. Cheers, Gerson. Edited to correct line 21 (CLx, not 0). |
|||
04-06-2014, 06:24 AM
Post: #98
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
Now we have 3 different ways to calculate the same thing:
Do you have a proof of your formula or is it still a conjecture? Congratulations to your discovery! Your method appears to be more efficient than the other two. Kind regards Thomas Quote:The first parameter is the number of terms in the continued fraction, minus one.This parameter is ignored. Instead the 2nd parameter is used twice (cf. lines 14-15). |
|||
04-06-2014, 11:24 AM
(This post was last modified: 04-06-2014 12:17 PM by Gerson W. Barbosa.)
Post: #99
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-06-2014 06:24 AM)Thomas Klemm Wrote: Now we have 3 different ways to calculate the same thing: No, the proof has yet to be found (in case there isn't one already), by someone more capable than I. I only found this empirically, using the WP 34S in double precision and the sum of the first 10000 terms of the series, the difference to ln(2) being found to be 1/20001 + (1/20001 + 4/(20001 + 9/(20001 + 16/(20001 + ... Then I assumed the next numerators to be 25, 36, 49... (04-06-2014 06:24 AM)Thomas Klemm Wrote:Quote:The first parameter is the number of terms in the continued fraction, minus one.This parameter is ignored. Instead the 2nd parameter is used twice (cf. lines 14-15). Thank you very much! The timings and results were indeed strange. I ought to have checked them more carefully. I think I got it right this time. Faster, and only one step longer: Code:
4 10 GSB A --> 0.6931471806 ( 9 s ) 5 8 GSB A --> 0.6931471805 ( 8.9 s ) 6 8 GSB A --> 0.6931471806 ( 9.6 s ) 10 4 GSB A --> 0.6931471808 ( 11 s ) 7 6 GSB A --> 0.6931471805 ( 8.6 s ) 6 6 GSB A --> 0.6931471807 ( 8.4 s ) Cheers, Gerson. P.S.: My HP-15C (2905B29505) is somewhat slower: 4 10 GSB A --> 0.6931471806 ( 10.2 s ) Code:
On the other hand the HP-15C LE might do it in about 70 ms :-) |
|||
04-06-2014, 07:14 PM
Post: #100
|
|||
|
|||
RE: Programming Exercise (HP-15C, 15C LE - and others)
(04-06-2014 11:24 AM)Gerson W. Barbosa Wrote: ... Here is the WP 34S version I used in the tests below: Code:
A few tests: ln(2) = 0.693 147 180 559 945 309 417 232 121 458 176 6 0000 10 0.693 253 968 253 968 253 968 253 968 253 968 2 0001 10 0.693 146 232 852 115 205 056 381 526 969 762 2 0002 10 0.693 147 199 088 903 124 777 564 239 447 647 5 0003 10 0.693 147 179 934 047 533 616 963 111 042 766 6 0004 10 0.693 147 180 591 838 917 151 717 921 689 047 7 0005 10 0.693 147 180 557 698 640 308 793 387 120 326 6 0006 10 0.693 147 180 560 151 141 269 127 925 193 192 9 0007 10 0.693 147 180 559 921 861 907 989 655 280 666 1 0008 10 0.693 147 180 559 948 518 422 585 061 218 105 6 0009 10 0.693 147 180 559 944 795 810 073 447 374 954 4 0010 10 0.693 147 180 559 945 403 501 429 756 457 393 5 0011 10 0.693 147 180 559 945 290 034 306 855 638 774 6 0012 10 0.693 147 180 559 945 313 843 885 909 537 467 7 0013 10 0.693 147 180 559 945 308 309 916 220 520 106 8 0014 10 0.693 147 180 559 945 309 717 580 283 035 902 1 0015 10 0.693 147 180 559 945 309 329 648 921 158 750 2 ln(2) = 0.693 147 180 559 945 309 417 232 121 458 176 6 000 100 0.693 147 303 688 304 655 980 964 290 653 683 0 001 100 0.693 147 180 547 757 700 150 739 640 428 249 6 002 100 0.693 147 180 559 948 023 068 705 311 333 583 0 003 100 0.693 147 180 559 945 308 343 448 458 203 194 3 004 100 0.693 147 180 559 945 309 417 895 721 522 250 6 005 100 0.693 147 180 559 945 309 417 231 531 226 281 8 006 100 0.693 147 180 559 945 309 417 232 122 172 268 2 007 100 0.693 147 180 559 945 309 417 232 121 457 048 9 008 100 0.693 147 180 559 945 309 417 232 121 458 178 8 009 100 0.693 147 180 559 945 309 417 232 121 458 176 5 ln(2) = 0.693 147 180 559 945 309 417 232 121 458 176 6 000 754 0.693 147 180 850 970 999 061 854 488 660 451 3 001 754 0.693 147 180 559 944 798 193 588 178 902 729 7 002 754 0.693 147 180 559 945 309 419 252 678 647 244 8 003 754 0.693 147 180 559 945 309 417 232 107 260 863 2 004 754 0.693 147 180 559 945 309 417 232 121 458 332 4 005 754 0.693 147 180 559 945 309 417 232 121 458 176 5 ln(2) = 0.693 147 180 559 945 309 417 232 121 458 176 6 0 10000 0.693 147 180 560 070 290 667 544 855 833 947 1 1 10000 0.693 147 180 559 945 309 415 982 433 958 165 6 2 10000 0.693 147 180 559 945 309 417 232 121 486 291 7 3 10000 0.693 147 180 559 945 309 417 232 121 458 176 5 Well, we got the idea. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)