Calculation of pi on many machines - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Calculation of pi on many machines (/thread-15940.html) Pages: 1 2 |
Calculation of pi on many machines - Benoit Maag - 11-22-2020 08:05 PM Not a new subject by a long shot, the attached PDF lists programs to calculate pi with many decimals on many machines and benchmarking their relative speeds (see graph at the end). This is an update of a previous article, adding the 41CL, WP 34S, DM 42, DM 41X to the benchmark. It is incredible what these little machines can do... Includes: - HP-41C, 41CL - DM42, DM41X - WP 34S - HP-15C-LE - HP-65 (yes, it is possible!) - HP-29C - HP-67 - Casio fx-6300G and fx-7000GA And if you have an HP-71B, Valentin has a 6 line program (!) at: https://albillo.hpcalc.org/programs/HP%20Program%20VA710%20-%20HP-71B%20Producing%20Digits%20of%20Pi%20one%20at%20a%20time.pdf RE: Calculation of pi on many machines - rprosperi - 11-22-2020 10:50 PM Thanks for all your time doing the testing, documenting it all and sharing it here Benoit. There's LOTS of real useful and interesting stuff just in the chart alone. Among them: a. the 65 is faster the 67 b. the 41 is only a tad faster than the earlier machines and the 29 is faster still c. the surprisingly high performance of the early Casio machines d. the amazing speed of the DM42 e. the quite different slope of the 65 and 29 (gotta go read that in detail) Looking forward to reading it in more detail. Thanks! RE: Calculation of pi on many machines - Gene - 11-22-2020 11:02 PM The 29 is slower than the 41. That's the 29-LP with the upgrade. The 41 has no time shown for 42 digits so the graph point is an interpolation assuming a linear time - hard to know if the HP-65 is faster without a direct time for the 41. RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-23-2020 01:01 AM 7 seconds for 4900 digits on the iPhone 7 running Ron Knapp’s program (Free42). Code:
RE: Calculation of pi on many machines - rprosperi - 11-23-2020 01:57 AM (11-22-2020 11:02 PM)Gene Wrote: The 29 is slower than the 41. That's the 29-LP with the upgrade. Thanks Gene. That explains why I did a double-take about the 29 being faster, I knew I had seen it slower, but then I also saw it faster and thought I recalled wrong. Well, 29C vs. 29LP, so it was wrong, kinda... RE: Calculation of pi on many machines - Benoit Maag - 11-23-2020 04:51 AM Bob, To answer some of your questions: a. The comparison is not quite apples to apples. For most of the machines (including the HP-67), the data is stored as #####.##### (5 + 5 digits) and the calculation is performed on 5 digits at a time. This means each registered has to be split into 5 digits which are processed separately. But this is not possible on the HP-65 because there is not enough program memory and no indirect addressing. So the data is stored as 0.####### (7 digits), there is no need to split registers and this is why it is faster than the HP-67. It would be interesting to see how the 67 performs with the 65 program c. I was surprised by the Casio as well, especially the fox-6300G which is a cheap machine. I think the speed is attributable to the very simple programming language d. The DM42 is super fast because the data is stored as 17+17 digits and all calculations are made 17 digits at a time. I have not checked the performance with a 5+5 digit program. BTW, for the WP 34S, I tested both 5+5 and 8+8 digit data e. I am not sure why the slopes would be different. After all, the time is proportional to the square of the number of desired digits so all curves should be parallel More to come as I would like to run the benchmark on the 32sii, 35s, RPL machines, BASIC sharps and casios, NumWorks (python), TI-58, and maybe the RPN-1250 I presented at HHC 2018, though it is not a bcd machine and has poor calculation precision (11-22-2020 10:50 PM)rprosperi Wrote: Thanks for all your time doing the testing, documenting it all and sharing it here Benoit. RE: Calculation of pi on many machines - Paul Dale - 11-23-2020 08:36 AM I would expect that the WP 34S in double precision would be faster than in single precision -- 34 digits instead of 16 and most intermediate computations are carried in the high precision regardless. I somewhat suspect that the greatest accuracy could be achieved in integer mode where there are no wasted bits in registers. Pauli RE: Calculation of pi on many machines - PeterP - 11-23-2020 12:56 PM There are also some MCODE versions available for HP41 which you might or might not want to include... https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv019.cgi?read=147587#147587 Cheers PeterP RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-23-2020 01:52 PM Your DM-42 version is about three times faster than Ron Knapp’s (17/5 = 3.4), except that it doesn’t work here. I’ve double-checked the listing and compared it against the 41 version, but there must be something I may have overlooked. Code:
Edited to fix a typo and a phrase. RE: Calculation of pi on many machines - John Keith - 11-23-2020 06:38 PM (11-23-2020 04:51 AM)Benoit Maag Wrote: More to come as I would like to run the benchmark on the 32sii, 35s, RPL machines, ... A note as to RPL machines: the LongFloat library for the 49/50 can calculate pi up to 9999 digits. I would still be interested in seeing how a userRPL program would compare in speed. RE: Calculation of pi on many machines - Werner - 11-23-2020 07:47 PM My current HP-41 compatible version runs in less than a minute (58s) on the DM-42 on USB, producing 1017 correct digits, using Pi = 16*ATAN(1/5) - 4*ATAN(1/239) It runs unchanged on a 41, 42 and Free42/DM42, but will use all available precision, ie. 10 digits on a 41, 12 on a 42 and 34 on Free42/DM42. It is written so that it can use any ATAN formula X*ATAN(N/D), as long as N^2+D^2 is less than 'half-length', ie 10^5 for a 41, 10^6 for a 42S and 10^17 for Free42/DM42. Using another ATAN formula, I can get the DM42 USB time under 38 seconds (but it won't run on a 41 or 42 any more). Cheers, Werner RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-23-2020 08:56 PM (11-23-2020 06:38 PM)John Keith Wrote:(11-23-2020 04:51 AM)Benoit Maag Wrote: More to come as I would like to run the benchmark on the 32sii, 35s, RPL machines, ... Code:
50 digits: 24.70 s 100 digits: 136.59 s ( HP 50g ) Unpractical running times henceforward, but then again my implementation might be far from optimal. EXPAND takes too much time for long expressions. P.S.: If you prefer resorting to an external library, a LongFloat version is available here. 707 digits in 1858 seconds or roughly half an hour. RE: Calculation of pi on many machines - John Keith - 11-24-2020 01:49 AM On EMU48 on my phone (Galaxy S9+): << 4900 DIGITS STO FPI >> 8.876 seconds. RE: Calculation of pi on many machines - Massimo Gnerucci - 11-24-2020 07:34 AM On my Core I7 with PiFast 4.3: 2000000 digits in 3.08" :) RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-24-2020 08:57 AM On my HP-42S, using my code and my formula: 12 digits in 1.7" :-) 00 { 55-Byte Prgm } 01▸LBL "π" 02 4 03 0 04 8 05 RCL× ST T 06 RCL+ ST Z 07▸LBL 00 08 R↑ 09 RCL+ ST X 10 STO× ST X 11 STO× ST T 12 DSE ST X 13 STO÷ ST T 14 X<>Y 15 STO+ ST Z 16 X<> ST Z 17 STO÷ ST Y 18 X<> ST L 19 R↓ 20 X<>Y 21 DSE ST T 22 GTO 00 23 DSE ST X 24 + 25 1/X 26 0.5 27 + 28 × 29 END 5 XEQ π → 3.14159265358 \(\pi \approx \left ( \frac{4}{3} \times \frac{16}{15}\times \frac{36}{35}\times\frac{64}{63} \times \cdots \times \frac{ 4n ^{2}}{ 4n ^{2}-1}\right ) \left ( 2+\frac{4}{8n+3+\frac{3}{8n+4+\frac{15}{8n+4+ \frac{35}{8n+4 + \frac{63}{\dots\frac{\ddots }{8n+4+\frac{4n^{2}-1}{8n+4}}} }}} } \right )\) RE: Calculation of pi on many machines - pier4r - 11-24-2020 06:29 PM (11-24-2020 01:49 AM)John Keith Wrote: On EMU48 on my phone (Galaxy S9+): FPI ? is that a builtin command? RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-24-2020 06:57 PM (11-24-2020 06:29 PM)pier4r Wrote:(11-24-2020 01:49 AM)John Keith Wrote: On EMU48 on my phone (Galaxy S9+): No, it’s from the LongFloat library, the first 1000 digits being hard-coded: 1000 digits in 0.066 s, 1100 in 51.710 s. (Real HP 50g) RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-25-2020 01:10 PM This is an RPL version of the HP-42S program above: Code:
# 8F62h, 258 bytes 51 decimal digits: 10.502 s 85 decimal digits: 32.557 s 153 decimal digits: 160.952 s 357 decimal digits: 4393.037 s (HP 50g) ——— PS: Actually, the RPL program above is based on one of my older formulae. The following program is slower, but it is in accordance with the formula I used in the RPN program: Code:
# 5CB1h, 301.5 bytes 51 decimal digits: 12.344 s 85 decimal digits: 42.373 s 153 decimal digits: 308.168 s (HP 50g) 1000 decimal digits: 2988.379 s (iPhone7, emulated HP 49g+, m48+) Algorithm: Code:
——— PPS: This is a longer version of the previous program, but it’s significantly faster for larger numbers of decimal digits (and even faster than the first program). Also, as in the previous program, all decimal digits are correct (actual digits, no roundings). Code:
# E567h, 354 bytes 51 decimal digits: 10.355 s 85 decimal digits: 31.200 s 153 decimal digits: 157.039 s 357 decimal digits: 3820.207 s (HP 50g) 1000 decimal digits: 2588.102 s (iPhone7, emulated HP 49g+, m48+) Algorithm: Code:
RE: Calculation of pi on many machines - Gerson W. Barbosa - 11-26-2020 02:40 PM The Science et Vie formula makes for very short programs, but they are too slow. Code:
# FE89h, 200 bytes. 51 decimal digits: 634.528 s. Most of the slowness is due to the difficulty of EXPAND to process the long resulting algebraic expression, however. For benchmarking purposes it is better to take a more conventional approach. RE: Calculation of pi on many machines - berndpr - 03-08-2021 02:30 AM Dear Benoit! Quote: And if you have an HP-71B, Valentin has a 6 line program (!) at: This spigot program for pi is not the best and fastet algorithm and needs a lot of storage. But it's very short. I have used the same references to make a similar program and it's nearly identical to Valentin's. But I got another program from a japanese person (Hiro510) which is using different version of pi/4 approximations (like Leibniz, Machin, Klingenstirna, Gauss, Störmer, Takano Kikuo and 2 unknown). Some are very fast like Kikuo's and some are extremly slow like Leibniz's. But if you are interested, the calculation of e (Euler constant) with a similar spigot program is much more faster and need much less storage. Bye Berndpr |