weiß jemand, wie der Algorithmus heißt, der in der pi() Funktion, in der Dokumentation zum decimal Modul, verwendet wird (sofern er einen Namen hat) oder hat jemand Material zu diesem Algorithmus, wie und warum er funktioniert?
Code: Alles auswählen
def pi():
getcontext().prec += 2 # extra digits for intermediate steps
three = Decimal(3) # substitute "three=3.0" for regular floats
lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24
while s != lasts:
lasts = s
n, na = n+na, na+8
d, da = d+da, da+32
t = (t * n) / d
s += t
getcontext().prec -= 2
return +s # unary plus applies the new precision
Vielen Dank und viele Grüße
Maximilian