L’approximation de π par la méthode d’Archimède est un exemple d’algorithme du nouveau programme de spécialité mathématiques en terminale.
Applet GeoGebra : https://www.geogebra.org/m/a4fes2q4
#Programme Python pour 14 décimales exactes :
from math import sqrt
def archimede(n):
T=4
S=2*sqrt(2)
for k in range(0,n+1):
T=2*(S*T)/(S+T)
S=sqrt(S*T)
print("n =",8*2**k,"T =", T, "S =",S)
archimede(25)
#3,14159265358979 32############
#Programme Python pour 1000 décimales exactes :
from math import sqrt
from decimal import *
D=Decimal
getcontext().prec=1100
def archimede(n):
T=D(4)
S=D(2*Decimal.sqrt(D(2)))
for k in range(n):
T=D(2*(S*T)/(S+T))
S=D(Decimal.sqrt(S*T))
print(format(T,'.1001g'))
print("1000 décimales de π")
archimede(1700)