Member-only story
Why You (Almost) Can’t Calculate Pi to a Billion Digits in Python at Home
It is harder than you think
Introduction
In June 9, 2022 Google set a new world record for calculating the most number of digits of Pi — 100 TRILLION! This monumental achievement was possible using the y-cruncher program running on Google Cloud. It crunched numbers for a whopping 157 days, 23 hours, 31 minutes and 7.651 seconds.
If one billion is 100 thousand times smaller than 100 trillion, would the runtime decrease accordingly? In other words, would it take only 136 seconds?
But 136 seconds is too ambitious. Home PCs are much less powerful than Google Cloud’s most formidable environments. So, how about a more reasonable runtime like 24 hours?
Turns out, calculating even a billion digits of Pi within 24 hours is a giant pipe dream. This article explains why with evidence in Python.
First of all, what is wrong with math.pi
?
import math
print(math.pi)
3.141592653589793
math.pi
has a precision of 15 digits. While it is not much, it is enough for the highest accuracy calculations in science.