Gauss-Legendre Algorithm



Gauss-Legendre algorithm

1. Initial value setting;

    a = 1    b = 1 / SqRt(2)    t = 1/4    x = 1

2. Repeat the following statements until the difference of a and b is within the desired accuracy;

    y = a

    a = (a+b) / 2

    b = SqRt(b*y)

    t = t - x * (y-a)^2

    x = 2 * x

3. Pi is approximated with a, b and t as;

    Pi = ((a+b)^2) / (4*t)

The algorithm has second order convergent nature. Then if you want to calculate up to n digits, iteration count of the order log2 n is sufficient. E.g. 19 times for 1 million decimal digits, 31 times for 3.2 billon decimal digits.

Note: The text is from the program SuperPi.Exe. The equations were converted to standard character set by Harry Smith.

Return to Computing Pi
Return to Harry's Home Page