## Introduction

In June 9, 2022 Google set a brand new world document for calculating essentially the most variety of digits of Pi — 100 TRILLION! This monumental achievement was attainable utilizing the y-cruncher program operating on Google Cloud. It crunched numbers for a whopping 157 days, 23 hours, 31 minutes and seven.651 seconds.

If one billion is 100 thousand instances smaller than 100 trillion, would the runtime lower accordingly? In different phrases, wouldn’t it take solely 136 seconds?

However 136 seconds is just too formidable. House PCs are a lot much less highly effective than Google Cloud’s most formidable environments. So, how a couple of extra affordable runtime like 24 hours?

Seems, calculating even a billion digits of Pi inside 24 hours is a big pipe dream. This text explains why with proof in Python.

## Initially, what’s fallacious with `math.pi`

?

`import math`print(math.pi)

`3.141592653589793`

`math.pi`

has a precision of 15 digits. Whereas it’s not a lot, it’s sufficient for the very best accuracy calculations in science.

For instance, NASA’s Jet Propulsion Lab (JPL) makes use of 15 digits of Pi to navigate between planets. To provide you an concept, this degree of precision is sufficient to calculate the circumference of a circle with a radius of 15 billion miles. The ensuing 94 billion miles circumference could be off by not more than the width of your little finger. Take into consideration that!

So, why even hassle with a billion digits, not to mention a 100 trillion?

Effectively, to provide the geek’s reply: “As a result of it might be so freaking cool!”.

## What if we enhance the decimal precision?

Earlier than we take out the massive weapons (the algorithms!), what if we enhance decimal precision in Python when approximating π? That might be a lot less complicated.

For the approximation, we are going to use Ramanujan’s formulation for π. Mathematicians everywhere in the world use it to approximate π to an insurmountable extent.

`from decimal import Decimal…`