Samiksha Jaiswal (Editor)

Gauss–Legendre algorithm

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The Gauss–Legendre algorithm is an algorithm to compute the digits of π. It is notable for being rapidly convergent, with only 25 iterations producing 45 million correct digits of π. However, the drawback is that it is computer memory-intensive and therefore sometimes Machin-like formulas are used instead.

Contents

The method is based on the individual work of Carl Friedrich Gauss (1777–1855) and Adrien-Marie Legendre (1752–1833) combined with modern algorithms for multiplication and square roots. It repeatedly replaces two numbers by their arithmetic and geometric mean, in order to approximate their arithmetic-geometric mean.

The version presented below is also known as the Gauss–Euler, Brent–Salamin (or Salamin–Brent) algorithm; it was independently discovered in 1975 by Richard Brent and Eugene Salamin. It was used to compute the first 206,158,430,000 decimal digits of π on September 18 to 20, 1999, and the results were checked with Borwein's algorithm.

Algorithm

  1. Initial value setting:
    a 0 = 1 b 0 = 1 2 t 0 = 1 4 p 0 = 1.
  2. Repeat the following instructions until the difference of a n and b n is within the desired accuracy:
    a n + 1 = a n + b n 2 , b n + 1 = a n b n , t n + 1 = t n p n ( a n a n + 1 ) 2 , p n + 1 = 2 p n .
  3. π is then approximated as:
    π ( a n + 1 + b n + 1 ) 2 4 t n + 1 .

The first three iterations give (approximations given up to and including the first incorrect digit):

3.140 3.14159264 3.1415926535897932382

The algorithm has quadratic convergence, which essentially means that the number of correct digits doubles with each iteration of the algorithm.

Limits of the arithmetic–geometric mean

The arithmetic–geometric mean of two numbers, a0 and b0, is found by calculating the limit of the sequences

a n + 1 = a n + b n 2 , b n + 1 = a n b n ,

which both converge to the same limit.
If a 0 = 1 and b 0 = cos φ then the limit is π 2 K ( sin φ ) where K ( k ) is the complete elliptic integral of the first kind

K ( k ) = 0 π / 2 d θ 1 k 2 sin 2 θ .

If c 0 = sin φ , c i + 1 = a i a i + 1 . then

i = 0 2 i 1 c i 2 = 1 E ( sin φ ) K ( sin φ )

where E ( k ) is the complete elliptic integral of the second kind:

E ( k ) = 0 π / 2 1 k 2 sin 2 θ d θ .

Gauss knew of both of these results.

Legendre’s identity

For φ and θ such that φ + θ = 1 2 π Legendre proved the identity:

K ( sin φ ) E ( sin θ ) + K ( sin θ ) E ( sin φ ) K ( sin φ ) K ( sin θ ) = 1 2 π .

Gauss–Euler method

The values φ = θ = π 4 can be substituted into Legendre’s identity and the approximations to K, E can be found by terms in the sequences for the arithmetic geometric mean with a 0 = 1 and b 0 = sin π 4 = 1 2 .

References

Gauss–Legendre algorithm Wikipedia