Records are made to be broken. In March 2022, we calculated 100 trillion digits of pi using Compute Engine. This is the second time we’ve used Google Cloud to calculate a record number of digits for the mathematical constant, tripling the number of digits in just three years after our world record with 31.4 trillion digits in 2019.
We’ve updated the API to serve all of the 100 trillion digits of pi. We’ve also published the entire results on Cloud Storage so you can download the files (caution: they are really big).
This website serves pi and interactive demos that you can listen to or see pi with. Scroll down to play with the demos!
This website is not an official Google product. It is managed by volunteers of the Google Cloud Developer Advocacy team and may become unavailable without notice.
What does Pi sound like? Each Pi digit is converted to a musical note so you can get to know Pi via music!
Piano Genie is an neural network model that allows you to play a note from 1 to 8, and intelligently map it to a great sounding piano performance. In this demo, we use each digit for [0, 7] and reuse the last digit for [8, 9], and use Piano Genie to map to the next logical note for great sounding Pi.
With 100 trillion digits and playing at 314 BPM, it'll play for 605,516 years!
This demo is turned off on mobile devices. Please use the latest desktop Chrome browser for the best experience.
Visualize transitions from one digit to the next in Pi using D3.js. Each transition draws a line from a digit in the circle to another digit. Once you have a large amount of digits you can see which digits transition more often and which digits are more common.
For Google Cloud Next 2019 in San Francisco, a team created the Pi Experiment Showcase, and uses the Pi API & generative algorithm to generate unique art pieces for each of the 31.4 trillion digits of Pi.
Here is an art piece to the first 11 digits of e (2.7182818284):
Learn more about the world record & generate your own unique art piece from the Pi Experiment Showcase.
Get Pi Digits
Returns digits of Pi based on the
start digit position and
There is no SLA on this service. We may require an API key in the future & or turn off the service. This is not an official Google API.
We can use curl call the API from the command line.
.then(response => response.json())
.then(data => console.log(data));
The response looks like this.
The API also supports hexadecimal digits of pi. Use the
radix parameter to specify the base.
It will return a hexadecimal representation of pi.
This demo uses the REST API to fetch 100 digits of Pi from the specified starting point. You can also try getting the hexadecimal digits of pi.
We developed the REST API in Go and running the program in Cloud Functions (2nd gen).
The architecture looks like this:
We have the same function deployed in three regions (US, Belgium, Japan) that fetches digits from a Cloud Storage bucket in the US multi-region. The API endpoint,
api.pi.delivery is exposed via a Global HTTP(s) Load Balancer. The authorative DNS servers are provided by Cloud DNS.
Finally, this site is hosted on Firebase Hosting, which not only automatically serves the static content via a CDN, it also automatically provisions a SSL certificate for the custom domain!
We have the entire source code published on GitHub including Terraform scripts that we use to provision the infrastructure.
In 2019, Emma Haruka Iwao broke the Pi digits world record by computing 31,415,926,535,897 digits of Pi using Google Cloud Platform! Learn more details from Emma’s Calculating a record-breaking 31.4 trillion digits blog, and Alex Yee (creator of y-cruncher)’s Google Cloud Topples the Pi record article.
Back in 2017, we used y-cruncher to calculate 750 billion digits of Pi on Google Compute Engine. We used a 64-core instance, with 416GB of RAM, and tons of Local SSD + Persistent SSD.
At its peak CPU utilization, it consumed all 64 cores, and 5+TB of SSD storage.
In 2018, we were able to recalculate 750 billion digits in just 10 hours!
Happy #PiDay! We just calculated 750-billion digits of Pi calculation in 10 hours (compared to 2-days it took in 2017) using something we'll announce soon on @GCPcloud. Stayed tuned! #PiDay2018 pic.twitter.com/lFfSv63EzL— Ray Tsang (@saturnism) March 14, 2018
We also calculated 1 trillion digits of Pi using a 96-core 14TB
We are part of the Google Cloud Platform Developer Advocacy team.
Since 2015, different members of the team worked on different Pi Day demos!
In 2022, Emma Haruka Iwao, Ben Bleything, Sara Ford, and Steve McGhee together calculated 100 trillion decimals of pi. Check out the official blog for more details about the technical details and architecture of the calculation. And for more on the history of calculating pi, check out this post on The Keyword.
In the same year, Sara calculated 64 million digits of π using Cloud Functions (2nd gen), and Emma rebuilt the API with Cloud Functions and the demos with React. We also made the source code available on GitHub.
In 2020, we updated the Pi API to return 50 trillion digits, and added Machine Learning models to generate even better Pi music. The numbers were kindly donated by Timothy Mullican, former world record holder. We also had an opportunity to interview Timothy for Pi Day 2020. Check out this video if you want to hear two world record breakers discuss about pi!
In 2019, the Pi digits world record was broken by Emma Haruka Iwao. Google Cloud Experiment for Pi Day was created by Mathias Paumgarten. The Pi API was updated to serve all 31.4+ trillion digits by Ray Tsang.
In 2018, the Pi API was updated to serve 1 trillion digits by Ray Tsang.
In 2016, we calculated 500 billion digits of Pi and made it searchable. The indexing peaked at 2-million writes per second. You can learn more how we did that in the blog Calculating and searching 500 billion digits of Pi, by Francesc Campoy, Jen Tong, Ray Tsang, Sara Robinson.
The source code for the REST API and demos are available on GitHub.