In celebration of Pi Day 2024, I would like to explain how the “Arithmetic-Geometric Mean” of Gauss and Legendre can be used to give a rapid method for computing the digits of . By “rapid” here, I mean that the algorithm exhibits quadratic convergence: the number of correct digits roughly doubles with each iteration. I will mainly follow the exposition in Donald J. Newman’s 1985 paper “A Simplified Version of the Fast Algorithms of Brent and Salamin”.
The Arithmetic-Geometric Mean
Given positive real numbers and , define their arithmetic mean to be and their geometric mean to be . The Arithmetic-Geometric Mean, or AGM, of and is defined as , where and for . In other words, if , then , where denotes the iterate of . It is not difficult to show that the number of digits in which and agree roughly doubles with each iteration of , i.e., the iteration scheme converges quadratically. Indeed, we have
For example, if and , then and . For comparison, we have
The AGM first appeared in a paper of Lagrange, but it was Gauss who first connected it to the theory of elliptic integrals, which is the connection lying at the heart of the main formula in this post.
The Geometric-Harmonic Mean
Define the harmonic mean of and to be . Rather than working with the AGM, it will actually be more convenient for us to work with the Geometric-Harmonic Mean, or GHM, of and , defined as , where and .
Simple algebraic manipulations yield . Note that since , we have , so the single-variable function determines the two-variable function .
Asymptotic formula for
The main result of this post is the following asymptotic formula for the GHM:
Theorem 1: , where denotes the natural logarithm.
From this formula, we can easily derive a rapidly converging algorithm for computing , and hence . Indeed, we have . By Taylor’s approximation, , and thus . After about iterations of the GHM, we can compute the left-hand side of this formula (with ), and hence , with approximately digits of precision.
A brief history of computing
According to Chapter 11 of the book “Pi and the AGM” by Jonathan and Peter Borwein, as of 1973 the record for computing digits of was one million decimal digits, using a Machin-like formula expressing as a linear combination of special values of the arctan function.
In 1983, Kanada, Yoshino, and Tamura used an AGM-based algorithm similar to Theorem 1 above to calculate the first 16,777,216 digits of , setting a new world record.
Nowadays, it is most common to use the Chudnovsky algorithm, which itself is based on formulas for discovered by Ramanujan. This algorithm was used to calculate the first 100 trillion digits of in March 2022. The Chudnovsky/Ramanujan formula for , while quite powerful, is significantly more complicated to prove than the AGM-based algorithm discussed in this post.
Gauss’s Formula for the AGM
Our proof of Theorem 1 will use the following formula due to Gauss:
Theorem 2:
Proof: The integral is invariant under ; indeed, the change of variables gives (after some routine manipulation) Applying this invariance repeatedly gives
The substitution shows that , and hence which is equivalent to the stated formula. Q.E.D.
Proof of Theorem 1
By Theorem 2, we have Since the substitution leaves the integrand invariant, we have , where . Thus
By the generalized binomial theorem, we have Therefore
By the generalized binomial theorem once again, we have Thus
For , the substitution gives , and thus
By Taylor’s theorem, Thus Q.E.D.
Concluding remarks
- Gauss used Theorem 2 to prove that the arclength of the lemniscate is equal to . See David Cox’s paper “The Arithmetic-Geometric Mean of Gauss” for details, as well as a fascinating historical account of Gauss’s work on the subject.
- From the introduction to Newman’s paper: “In their remarkable papers, Brent and Salamin, respectively, used the theory of elliptic functions to obtain “fast” computations of the function and of the number . In both cases rather heavy use of elliptic function theory, such as the transformation law of Landen, had to be utilized. Our purpose, in this note, is to give a highly simplified version of their constructions.”
- A more “modern” application of the AGM is to the computation of periods. For example, if is an elliptic curve over in Weierstrass form, with real roots , its period lattice is spanned by and . This is, at least philosophically, related to Theorem 2 above.
- Even though the complex square root is multi-valued, so it’s not clear a priori that the AGM of two complex numbers can even be defined, there is a satisfactory complex analogue of the AGM (due, as you might have guessed, to Gauss). Using the complex AGM, one can compute the period lattice of elliptic curves over in a manner analogous to Remark 3 above.