Calculation of pi on many machines
|
11-22-2020, 08:05 PM
Post: #1
|
|||
|
|||
Calculation of pi on many machines
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%2...20time.pdf |
|||
11-22-2020, 10:50 PM
Post: #2
|
|||
|
|||
RE: Calculation of pi on many machines
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! --Bob Prosperi |
|||
11-22-2020, 11:02 PM
Post: #3
|
|||
|
|||
RE: Calculation of pi on many machines
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. |
|||
11-23-2020, 01:01 AM
Post: #4
|
|||
|
|||
RE: Calculation of pi on many machines
7 seconds for 4900 digits on the iPhone 7 running Ron Knapp’s program (Free42).
Code:
|
|||
11-23-2020, 01:57 AM
Post: #5
|
|||
|
|||
RE: Calculation of pi on many machines
(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... --Bob Prosperi |
|||
11-23-2020, 04:51 AM
Post: #6
|
|||
|
|||
RE: Calculation of pi on many machines
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. |
|||
11-23-2020, 08:36 AM
Post: #7
|
|||
|
|||
RE: Calculation of pi on many machines
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 |
|||
11-23-2020, 12:56 PM
Post: #8
|
|||
|
|||
RE: Calculation of pi on many machines
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...587#147587 Cheers PeterP Cheers, PeterP |
|||
11-23-2020, 01:52 PM
(This post was last modified: 11-23-2020 02:14 PM by Gerson W. Barbosa.)
Post: #9
|
|||
|
|||
RE: Calculation of pi on many machines
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. |
|||
11-23-2020, 06:38 PM
Post: #10
|
|||
|
|||
RE: Calculation of pi on many machines
(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. |
|||
11-23-2020, 07:47 PM
Post: #11
|
|||
|
|||
RE: Calculation of pi on many machines
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 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
11-23-2020, 08:56 PM
(This post was last modified: 11-23-2020 09:50 PM by Gerson W. Barbosa.)
Post: #12
|
|||
|
|||
RE: Calculation of pi on many machines
(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. |
|||
11-24-2020, 01:49 AM
Post: #13
|
|||
|
|||
RE: Calculation of pi on many machines
On EMU48 on my phone (Galaxy S9+):
<< 4900 DIGITS STO FPI >> 8.876 seconds. |
|||
11-24-2020, 07:34 AM
Post: #14
|
|||
|
|||
RE: Calculation of pi on many machines
On my Core I7 with PiFast 4.3:
2000000 digits in 3.08" :) Greetings, Massimo -+×÷ ↔ left is right and right is wrong |
|||
11-24-2020, 08:57 AM
Post: #15
|
|||
|
|||
RE: Calculation of pi on many machines
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 )\) |
|||
11-24-2020, 06:29 PM
Post: #16
|
|||
|
|||
RE: Calculation of pi on many machines
(11-24-2020 01:49 AM)John Keith Wrote: On EMU48 on my phone (Galaxy S9+): FPI ? is that a builtin command? Wikis are great, Contribute :) |
|||
11-24-2020, 06:57 PM
(This post was last modified: 11-24-2020 06:58 PM by Gerson W. Barbosa.)
Post: #17
|
|||
|
|||
RE: Calculation of pi on many machines
(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) |
|||
11-25-2020, 01:10 PM
(This post was last modified: 12-04-2020 11:17 AM by Gerson W. Barbosa.)
Post: #18
|
|||
|
|||
RE: Calculation of pi on many machines
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:
|
|||
11-26-2020, 02:40 PM
Post: #19
|
|||
|
|||
RE: Calculation of pi on many machines
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. |
|||
03-08-2021, 02:30 AM
Post: #20
|
|||
|
|||
RE: Calculation of pi on many machines
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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 7 Guest(s)