Here we explore the works of Archimedes.
Here we import necessary models and load any necessary data:
# custom libs
from packages import archimedes
What follows is the iterative computation of $\pi$ using the method attributed to Archimedes.[1], [2] You will notice that this algorithm approaches $\pi$ from above and below, essentially bounding $\pi$ between these two hyper and hypo approximations (1.3).
Mathematically stated: $$ \begin{align} c_n &= n \cdot{\sin(\frac{180^{\circ}}{n})} \tag{1.1} \\ C_n &= n \cdot{\tan(\frac{180^{\circ}}{n})} \tag{1.2} \\ c_n &< \pi < C_n \tag{1.3} \\ \lim_{n\to\infty} C_n &= \lim_{n\to\infty} n \cdot{\tan(\frac{180^{\circ}}{n})} = \pi \tag{1.4} \\ \lim_{n\to\infty} c_n &= \lim_{n\to\infty} n \cdot{\sin(\frac{180^{\circ}}{n})} = \pi \tag{1.5} \end{align} $$
Where $C_n$ represents the circumscribed polygon approximation (1.2) and $c_n$ represents the inscribed polygon approximation (1.1). Below we will apply this iterative method for polygons up to $n = 100$.
# approximate Pi up to n = 100
pi_approximate = [archimedes.pi_approximation(n) for n in range(3, 101)]
# now print out 3 - 12
for sides, (inner, outer) in enumerate(pi_approximate[:10], start=3):
# print approximations
print(f'n={sides:<3} {inner:0.10f} < π < {outer:0.10f}')
# dot dot
print('.\n' * 3)
# finally 90 - 100
for sides, (inner, outer) in enumerate(pi_approximate[-11:], start=90):
# print approximation
print(f'n={sides:<3} {inner:0.10f} < π < {outer:0.10f}')
n=3 2.5980762114 < π < 5.1961524227 n=4 2.8284271247 < π < 4.0000000000 n=5 2.9389262615 < π < 3.6327126400 n=6 3.0000000000 < π < 3.4641016151 n=7 3.0371861738 < π < 3.3710223317 n=8 3.0614674589 < π < 3.3137084990 n=9 3.0781812899 < π < 3.2757321084 n=10 3.0901699437 < π < 3.2491969623 n=11 3.0990581253 < π < 3.2298914223 n=12 3.1058285412 < π < 3.2153903092 . . . n=90 3.1409547032 < π < 3.1428692543 n=91 3.1409686462 < π < 3.1428413380 n=92 3.1409821371 < π < 3.1428143276 n=93 3.1409951952 < π < 3.1427881843 n=94 3.1410078387 < π < 3.1427628715 n=95 3.1410200851 < π < 3.1427383543 n=96 3.1410319509 < π < 3.1427145996 n=97 3.1410434516 < π < 3.1426915763 n=98 3.1410546020 < π < 3.1426692546 n=99 3.1410654163 < π < 3.1426476062 n=100 3.1410759078 < π < 3.1426266043