In mathematics, the Leibniz formula for pi, named after Gottfried Wilhelm Leibniz, states that
an alternating series. It is sometimes called the Madhava–Leibniz series as it was first discovered by the Indian mathematician Madhava of Sangamagrama or his followers in the 14th–15th century (see Madhava series), and was later independently rediscovered by James Gregory in 1671 and Leibniz in 1673. The Taylor series for the inverse tangent function, often called Gregory's series, is:
The Leibniz formula is the special case
It also is the Dirichlet L-series of the non-principal Dirichlet character of modulus 4 evaluated at , and, therefore, the value β(1) of the Dirichlet beta function.
Considering only the integral in the last term, we have:
Therefore, by the squeeze theorem, as n → ∞, we are left with the Leibniz series:
Let , when , the series to be converges uniformly, then
Therefore, if approaches so that it is continuous and converges uniformly, the proof is complete, where, the series to be converges by the Leibniz's test, and also, approaches from within the Stolz angle, so from Abel's theorem this is correct.
Leibniz's formula converges extremely slowly: it exhibits sublinear convergence. Calculating pi to 10 correct decimal places using direct summation of the series requires precisely five billion terms because 4/2k + 1 < 10−10 for k > 2 × 1010 − 1/2 (one needs to apply Calabrese error bound). To get 4 correct decimal places (error of 0.00005) one needs 5000 terms. Even better than Calabrese or Johnsonbaugh error bounds are available.
However, the Leibniz formula can be used to calculate pi to high precision (hundreds of digits or more) using various convergence acceleration techniques. For example, the Shanks transformation, Euler transform or Van Wijngaarden transformation, which are general methods for alternating series, can be applied effectively to the partial sums of the Leibniz series. Further, combining terms pairwise gives the non-alternating series
which can be evaluated to high precision from a small number of terms using Richardson extrapolation or the Euler–Maclaurin formula.