100 Trillion Digits Edit
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.
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.
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).
About this site Edit
This website serves pi and interactive demos that you can listen to or see pi with. Scroll down to play with the demos!
To learn more about how this site works, check out the Serving the Pi section. We’ve also published the entire source code of the demos and infrastructure, including Terraform scripts, on GitHub.
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.
Listen (Piano Genie) Edit
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!
Listen (Bach Doodle) Edit
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.
fetch("https://api.pi.delivery/v1/pi?start=0&numberOfDigits=100") .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.
Fetching Digits Edit
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.
Serving the API Edit
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.
The frontend code is developed in TypeScript and React.
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.
Calculating Pi Edit
In 2022, Sara Ford and Ben Bleything calculated 64 million digits of π using Cloud Functions (2nd gen).
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.
Sometimes, you just need a big honkin' VM @googlecloud pic.twitter.com/WUtLIhW4bs— Greg Wilson (@gregsramblings) March 5, 2017
At its peak CPU utilization, it consumed all 64 cores, and 5+TB of SSD storage.
Consumed all 64 cores on a @googlecloud vm, of 8x375GB Local SSD & using 382GB of 416GB RAM for some serious computation pic.twitter.com/Fzptt1nDCw— Ray Tsang (@saturnism) March 6, 2017
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
Near full utilization of a 96-cores & 1.4TB of RAM n1-megamem-96 instance on @GCPcloud pic.twitter.com/C6JxMHrrzj— Ray Tsang (@saturnism) March 13, 2018
Who are We? Edit
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 2017, we made this site and the Pi API, by Francesc Campoy, Guillaume Laforge, Ian Lewis, Ray Tsang, Sandeep Dinesh.
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.
In 2015, we calculated 250 billion digits of Pi, by Greg Wilson, Ray Tsang.
Source Code Edit
The source code for the REST API and demos are available on GitHub.