(16C) e to 400 decimal places - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (16C) e to 400 decimal places (/thread-3017.html) |
(16C) e to 400 decimal places - Rick314 - 02-06-2015 02:12 AM See the attached scans of handwritten pages I wrote in 1982 to approximate e (2.71828...) to 400+ decimal places on an HP-16C. It takes about 3.5 hours to run, plus the time to enter the 2 program halves and see the results 8 digits at a time. The results are that the fractional portion of e truncated to 404 digits is: Code: 71828182 84590452 RE: (HP-16C) e to 400 decimal places - Dieter - 02-07-2015 07:20 AM (02-06-2015 02:12 AM)Rick314 Wrote: See the attached scans of handwritten pages I wrote in 1982 to approximate e (2.71828...) to 400+ decimal places on an HP-16C. Wow, what a coincidence: at the same time I wrote the same e program using the same method on my 41C. Or maybe... it's not quite that coincidental, because those were the days when things like these were done on programmable calculators. My math teacher had a similar program for his TI59 and 700 or 800 digits, while I could finally come up with more than 2200. ;-) Dieter RE: (HP-16C) e to 400 decimal places - Rick314 - 02-11-2015 01:11 AM (02-07-2015 07:20 AM)Dieter Wrote: My math teacher had a similar program for his TI59 and 700 or 800 digits, while I could finally come up with more than 2200. Hello Dieter. Your comment prompted me to resurrect my 1992 Turbo Pascal 6.0 program that approximates e to 1,000,010 decimal places (E1MEG_P.TXT, attached). Key routines were coded in 80386 assembly language, and there are 4 algorithm enhancements explained in the header that I claim as my own. I've looked into it and think it is the fastest algorithm published. In 1992 it took 6.85 hours running on a 25 MHz 80386 PC. I just re-ran it on my 2004 Windows XP 1.3 GHz Pentium 4 PC, the latest I have that still runs 80386 assembly code, and it took 2 minutes 45 seconds. That's interesting: 150x faster due just to 12 years of hardware improvements. Now we are 11 more years into the future... The first and last page of output are also attached (E1MEG_R.TXT). RE: (HP-16C) e to 400 decimal places - Thomas Klemm - 02-11-2015 09:11 AM Is the spigot algorithm used? Cheers Thomas Cf. The calculation of e to many significant digits by A. H. J. Sale RE: (HP-16C) e to 400 decimal places - Frido Bohn - 02-11-2015 02:33 PM Quote:... resurrect my 1992 Turbo Pascal 6.0 program that approximates e to 1,000,010 decimal places (E1MEG_P.TXT, attached). Wow! This is a very fine example how programs should be written. Very structured and full of explanatory comments. This yields a lot of motivation to dive deeper into this matter. Thanks for sharing! Any idea how to translate that 386-assembler code into something digestible for the Core-iN generation? Cheers Frido RE: (HP-16C) e to 400 decimal places - Dieter - 02-12-2015 12:51 PM (02-11-2015 01:11 AM)Rick314 Wrote: Hello Dieter. Your comment prompted me to resurrect my 1992 Turbo Pascal 6.0 program that approximates e to 1,000,010 decimal places (E1MEG_P.TXT, attached). Key routines were coded in 80386 assembly language, Unbelievable – that's exactly what I did in 1995! I also used Turbo Pascal 6.0 and the main calculation loop was coded in 386 assembly. Since the Pascal compiler did not support 386 instructions I used Borland's TASM for this task. However, the algorithm was the same as the one used on the '41C. ;-) Dieter RE: (HP-16C) e to 400 decimal places - Dieter - 02-12-2015 12:56 PM (02-11-2015 02:33 PM)Frido Bohn Wrote: Any idea how to translate that 386-assembler code into something digestible for the Core-iN generation? I'm not sure if I get you right, but of course even the latest Intel processors still support the commands of their earliest ancestors like the 8088, 80286 and 80386. Dieter RE: (HP-16C) e to 400 decimal places - rprosperi - 02-12-2015 06:22 PM (02-12-2015 12:56 PM)Dieter Wrote:(02-11-2015 02:33 PM)Frido Bohn Wrote: Any idea how to translate that 386-assembler code into something digestible for the Core-iN generation? The 386 in-line stuff back then probably ran in real mode, which won't work under Windows, etc. today. RE: (HP-16C) e to 400 decimal places - Frido Bohn - 02-12-2015 06:22 PM Hi Dieter, I tripped over Rick's statement, (02-11-2015 01:11 AM)Rick314 Wrote: I just re-ran it on my 2004 Windows XP 1.3 GHz Pentium 4 PC, the latest I have that still runs 80386 assembly code,...and interpreted that Pentiums would be able to manage assembler code while later processors would not. However, I may be wrong and Rick didn't have any newer Intel processor at hands. Cheers Frido RE: (HP-16C) e to 400 decimal places - Thomas Klemm - 02-12-2015 06:53 PM (02-11-2015 02:33 PM)Frido Bohn Wrote: Wow! This is a very fine example how programs should be written. Here's a very fine example how programs should not be written: Code: a[87700],b,c=87700,d,e=1e4,f=1e5,h; It calculates e to 15000 places in ~ 4.7 seconds on a Dell Precision T5400. Cf. Arndt • Haenel, \(\pi\) - Unleashed 6.4 Spigot algorithm for e p.85 A similar program (roemer) was a winning entry at the 6th International Obfuscated C Code Contest (1989): Code:
Cheers Thomas |