Why does Archimedes Method to calculate Pi decrease in precision after a certain time?

973 Views Asked by At

i`m using the following recursive formula to calculate Pi based on Archimedes ideas.

$$ S' = \sqrt{2-\sqrt{4-S^2}} $$ The formula gives back the edge length of a Polygon B based on the edge length of the Polygon A. B has twice as much edges as A. To get Pi you simply Multiply S' by the count of the edges and than divide the result by two.

You start with a simple 6 side Polygon, that has the radius 1, because it consists of 3 isosceles triangles you can conclude that S is also 1. If i begin calculation with my Pyhton Programm i reach a precision of around 500 Digits of Pi after around 800 repititions, but then the precision decreases again.

Here a graphic showing the decimal precision (y-axis) against the times the formula has been repeated (x-axis): https://i.stack.imgur.com/g9lpg.jpg

Why is the precision decreasing ? Is it in the nature of the formula have I messed up a thing in my program?

EDIT: This is the python code, i used mpmath for arbitrary precision:

from sympy.mpmath import *    
decimal = []

S = mpf(1)
u = mpf(0)
pi = mpf(0)
Edge = mpf(6)
mp.dps = 100;
for n in range(0,1000):

    u = sqrt(mpf(4)-S**2)
    S = sqrt(mpf(2) - u)
    Edge = Edge*2
    pi = (S*Edge)/mpf(2)  
    decimal.append(testestellen(pi)) #tests how much decimals are right and put them in a list
1

There are 1 best solutions below

1
On BEST ANSWER

This is definitely rounding error. The Python library sympy.mpmath has a configurable precision, which you can set using mp.prec or mp.dps. Try changing these, and see what effect it has on the result.