Precise Pi using a simple method



 So I was messing around with the Gemini AI talking about a way to perform calculations to get to pi.

The simple, ease and new (?) way to understand is this:


The Main Formula

Result = 1 / (Total / 2)^1

How to calculate "Total"

To find the Total, you must multiply a series of terms together ($a_1, a_2, a_3...$). This is called a Geometric Product.

  1. Start with: $a = \sqrt{2}$

  2. First term: $a / 2$

  3. Next term: $\sqrt{2 + a} / 2$

  4. Total: (Term 1) * (Term 2) * (Term 3) ... * (Term N)


Step-by-Step Expansion

If you ran the loop for just 3 iterations, the full "text" formula looks like this:

Total = (sqrt(2) / 2) * (sqrt(2 + sqrt(2)) / 2) * (sqrt(2 + sqrt(2 + sqrt(2))) / 2)

Pi = 1 / (Total / 2)


--


Or in Python:


from decimal import Decimal, getcontext; getcontext().prec = 50; a = Decimal(2).sqrt(); total = a/2; [(a := (Decimal(2) + a).sqrt(), total := total * (a/2)) for _ in range(50)]; print(f"Pi: {1 / (total / 2)}") # N=50 iterations: Each step nests a square root to 'round' a polygon into a circle.


Where N=50 is the amount of decimals you want.

Comments