Pi from String Theory Amplitudes

From the paper by Arnab Priya Saha and Aninda Sinha. A new series for π and its convergence.

π=4+n=11n!(1n+λ42n+1)((2n+1)24(n+λ)n)n1

Where (a)n1 is the Pochhammer symbol.

(a)n1=Γ(a+n1)Γ(a)

λ is a free parameter for optimizing convergence. As λ approaches infinity, the series reduces to the classic Madhava series. With λ between 10 and 100, the series takes 30 terms to converge to ten decimal places. Which is far more efficient than the classic Madhava series, which takes 5 billion terms to converge to ten decimal places.

This can be implemented in Python as follows:

import mpmath as mp

def mp_calculate_pi(lambda_val, iters):
    mp.dps = 100
    pi = mp.mpf(4)
    n = 1
    prev_pi = 0
    factorial = mp.mpf(n)

    for i in range(iters):
        term1 = 1.0 / factorial
        term2 = 1.0 / (n + lambda_val) - 4 / (2 * n + 1)
        term3 = ((2 * n + 1) ** 2) / (4 * (n + lambda_val)) - n

        pochhammer = 1
        for i in range(n - 1):
            pochhammer *= term3 + i

        prev_pi = pi
        pi += term1 * term2 * pochhammer

        # print to 30 decimal places using mpmath
        approx = mp.nstr(pi, 100)

        # Compare to mp.pi to calcualte the delta
        delta = abs(pi - mp.pi)

        # numbers of digits that pi approximate is correct to
        accuracy = round(abs(mp.log(abs(pi - mp.pi), 10)))

        # Print a line with the current iteration, pi, delta
        print(f'{n} {approx} {delta} {accuracy}')

        n += 1
        factorial = factorial * n

    return pi, n - 1

lambda_val = 42
pi, n = mp_calculate_pi(lambda_val, 30)