Regular guy calculating pi

I’m just a regular guy but I keep trying to write the shortest fastest way to calculate pi. And I’m learning to spell circumference and calculated

Here’s my best one yet! It makes 1/4 of a \~400,000,000 sided polygon and just measures the distance between each corner. :)

# Array Pi Estimator

# Calculate pi with circumference of polygon

# 400 million sided polygon

# 15 decimal places

# Mark B. Reid, MD

# [email protected]

# [email protected]

import sys

import math

import random

import numpy as np

pifourratio = round(math.pi, 12)

estpi = 0.000

total = 0

circle = 0

square = 0

dots = 100_000_000

print ("True Pi: ", pifourratio)

print ("Radius: ", f"{dots:,}")

print ("True Circumfrence: ", f"{round(((2 * math.pi * dots)/4), 12):,}")

print ("")

field = np.zeros(((3, (dots + 1))))

for x in range (0, (dots + 1)):

field \[0, x\] = x

field \[1, x\] = round(math.sqrt(dots\*\*2 - x\*\*2), 12)

if x % 1000000 == 0:

    print(".", end = "")

#print (field)

for x in range (0, dots):

xdist = field \[0, (x+1)\] - field\[0, x\]

ydist = field \[1, (x+1)\] - field\[1, x\]

field \[2, x+1\] = math.sqrt(xdist\*\*2 + ydist\*\*2)

calccirc = np.sum(field[2])

print ("")

print ("")

print ("Calculated circumfrence: ", f"{calccirc:,}")

calcpi = round((4 * calccirc) / (2 * dots), 12)

print ("Calulcated pi: ", calcpi)

Author: soapsuit