pdeclib pilib modules for Pine, Rock, Pinebook, Sopine
#2
Greetings again;  got some more PI fun for you that will literally blow your SoC(s) off using nothing but the Python interpreter and the following two very short scripts -- using integer maths only:

pipipi.py

Code:
digits = 10010
pi = term = 3 * 10 ** (digits+9)

m = 2
while term:
 term = term * ((m-1) * (m-1)) // (4 * m * (m+1))
 pi += term
 m += 2

print(pi // 10 ** 9)


PI-calc2.sh

Code:
#!/usr/bin/python
from pipipi import *


Place these two scripts in your working directory;  be sure to make the PI-calc2.sh script executable with:

chmod 0754 PI-calc2.sh

To run the integer PI calculation use:

time ./PI-calc2.sh


On the Rock64 board this PI calculation will churn out 10,000+ digits of PI in just over 1/2 second.  You can experiment between the Python2 and Python3 interpreter times;  or more fun compare the times on the Pinebook vs PineA64+ vs Rock64 !

Because this small routine uses integer maths to get the digits of a never ending transcendental number, obviously the decimal point is going to be missing !  ... but all the digits will be there;  experiment by increasing the number of digits in the pipipi.py routine.  Its truly amazing to see the power of a tiny computer being used to actually "compute" in that sense of the word.

Note:   The Pinebook calculates 10K digits of PI using integer maths on the Python3 interpreter in 3/4 second !



To put this is perspective for the year 2017 the first computer to accurately  calculate PI to 10K digits occurred in 1958 (when I was three years old);  ... in 1 hour and 40 minutes !

"... in July 1958, an IBM 704 at the Paris Data Processing Center was programmed according to a combination of Machin's formula and the Gregory series;  it yielded 10,000 decimal places in 1 hour and 40 minutes." 

"A year later, in July 1959, the same program was used on an IBM 704 at the Commissarit à l'Energie Atomique in Paris, and 16,167 places were obtained in 4.3 hours."

I reproduced the above precision using integer math on the Rock64 board (16177) and arrived at the result in a blazing 1.483 seconds on the Python2 interpreter ; running on the xenial minimal image 0.3.7 !

   


Quotes taken from :

Beckmann, Petr; A History of PI. The Golem Press (NewYork, 1971)



marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )


Messages In This Thread
RE: pdeclib pilib modules for Pine, Rock, Pinebook, Sopine - by MarkHaysHarris777 - 08-06-2017, 10:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PINE A64 SBC: Clone of a functional 32GB SD card doesn't boot burningkrome 3 1,601 05-19-2023, 07:43 AM
Last Post: crocspot
  PINE A64 Ubuntu 18 or 20 IMG with touchscreen? burningkrome 0 600 04-29-2023, 05:13 AM
Last Post: burningkrome
  Pine A64 does only boot with Android 5.1 Dude 6 3,906 07-03-2022, 02:18 PM
Last Post: Dude
  Pine A64+ vs LCD do not boot DDS 3 5,960 02-23-2021, 05:33 PM
Last Post: thedu
  Autodetect if Pine unit is a Pine A64+ or PineA64-LTS pkfpeters 1 3,325 02-09-2021, 12:17 AM
Last Post: tllim
  Pine 64 | 2GB x2 & Acrylic Cases x2 for Sale | Canada - GTA ViperVi 1 4,487 01-18-2021, 03:45 PM
Last Post: squidius
  sd format?for pine 64 angegardien 3 7,746 12-06-2020, 03:53 PM
Last Post: junkyj753
  Node Red on the Pine DonFL 0 2,769 12-16-2019, 04:21 PM
Last Post: DonFL
Photo Pine A64+ from Kick starter running Pi-Hole netHolio 0 3,238 12-02-2019, 09:36 PM
Last Post: netHolio
  UK power supply (Pinebook Pro 64) skobi 0 2,303 11-17-2019, 04:55 AM
Last Post: skobi

Forum Jump:


Users browsing this thread: 1 Guest(s)