# Leibniz formula for π

See List of things named after Gottfried Leibniz for other formulas known under the same name.

In mathematics, the Leibniz formula for π, named after Gottfried Leibniz, states that

${\displaystyle 1\,-\,{\frac {1}{3}}\,+\,{\frac {1}{5}}\,-\,{\frac {1}{7}}\,+\,{\frac {1}{9}}\,-\,\cdots \,=\,{\frac {\pi }{4}},}$

an alternating series. It is also called the Leibniz-Madhava series as it is a special case of a more general series expansion for the inverse tangent function, first discovered by the Indian mathematician Madhava of Sangamagrama in the 14th century, the specific case first published by Leibniz around 1676.[1] The series for the inverse tangent function, which is also known as Gregory's series, can be given by:

${\displaystyle \arctan x=x-{\frac {x^{3}}{3}}+{\frac {x^{5}}{5}}-{\frac {x^{7}}{7}}+\cdots }$

The Leibniz formula for π/4 can be obtained by putting x = 1 into this series.[2]

It also is the Dirichlet L-series of the non-principal Dirichlet character of modulus 4 evaluated at s = 1, and therefore the value β(1) of the Dirichlet beta function.

### Proof

#### Proof 1

{\displaystyle {\begin{aligned}{\frac {\pi }{4}}&=\arctan(1)\\&=\int _{0}^{1}{\frac {1}{1+x^{2}}}\,dx\\[8pt]&=\int _{0}^{1}\left(\sum _{k=0}^{n}(-1)^{k}x^{2k}+{\frac {(-1)^{n+1}\,x^{2n+2}}{1+x^{2}}}\right)\,dx\\[8pt]&=\left(\sum _{k=0}^{n}{\frac {(-1)^{k}}{2k+1}}\right)+(-1)^{n+1}\left(\int _{0}^{1}{\frac {x^{2n+2}}{1+x^{2}}}\,dx\right).\end{aligned}}}

Considering only the integral in the last term, we have:

${\displaystyle 0\leq \int _{0}^{1}{\frac {x^{2n+2}}{1+x^{2}}}\,dx\leq \int _{0}^{1}x^{2n+2}\,dx={\frac {1}{2n+3}}\;\rightarrow 0{\text{ as }}n\rightarrow \infty .}$

Therefore, by the squeeze theorem, as n → ∞ we are left with the Leibniz series:

${\displaystyle {\frac {\pi }{4}}=\sum _{k=0}^{\infty }{\frac {(-1)^{k}}{2k+1}}}$

#### Proof 2

{\displaystyle {\begin{aligned}{\frac {\pi }{4}}&=\arctan(1)\\&=\int _{0}^{1}{\frac {1}{1+z^{2}}}\,dz\\[8pt]\end{aligned}}}

When ${\displaystyle |z|<1}$, ${\displaystyle \sum _{k=0}^{\infty }(-1)^{k}z^{2k}}$ converges uniformly, therefore

${\displaystyle f(z)=\arctan(z)=\int _{0}^{z}{\frac {1}{1+z^{2}}}dz=\sum _{n=0}^{\infty }{\frac {(-1)^{n}}{2n+1}}z^{2n+1}\ (|z|<1)}$

If ${\displaystyle f(z)}$ approaches ${\displaystyle f(1)}$ so that it is continuous and converges uniformly, the proof is complete. From Leibniz's test, ${\displaystyle \sum _{n=0}^{\infty }{\frac {(-1)^{n}}{2n+1}}}$ converges, also ${\displaystyle f(z)}$ approaches ${\displaystyle f(1)}$ from within the Stolz angle, so from Abel's theorem this is correct.

### Convergence

Comparison of the convergence of the Leibniz formula () and several historical infinite series for π. Sn is the approximation after taking n terms. Each subsequent subplot magnifies the shaded area horizontally by 10 times. (click for detail)

Leibniz's formula converges extremely slowly: it exhibits sublinear convergence. Calculating π to 10 correct decimal places using direct summation of the series requires about five billion terms because 4/2k + 1 < 10−10 for k > 2 × 10101/2.

However, the Leibniz formula can be used to calculate π 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

${\displaystyle {\frac {\pi }{4}}=\sum _{n=0}^{\infty }\left({\frac {1}{4n+1}}-{\frac {1}{4n+3}}\right)=\sum _{n=0}^{\infty }{\frac {2}{(4n+1)(4n+3)}}}$

which can be evaluated to high precision from a small number of terms using Richardson extrapolation or the Euler–Maclaurin formula. This series can also be transformed into an integral by means of the Abel–Plana formula and evaluated using techniques for numerical integration.

### Unusual behaviour

If the series is truncated at the right time, the decimal expansion of the approximation will agree with that of π for many more digits, except for isolated digits or digit groups. For example, taking five million terms yields

${\displaystyle 3.141592{\underline {4}}5358979323846{\underline {4}}643383279502{\underline {7}}841971693993{\underline {873}}058...}$

where the underlined digits are wrong. The errors can in fact be predicted; they are generated by the Euler numbers En according to the asymptotic formula

${\displaystyle {\frac {\pi }{2}}-2\sum _{k=1}^{\frac {N}{2}}{\frac {(-1)^{k-1}}{2k-1}}\sim \sum _{m=0}^{\infty }{\frac {E_{2m}}{N^{2m+1}}}}$

where N is an integer divisible by 4. If N is chosen to be a power of ten, each term in the right sum becomes a finite decimal fraction. The formula is a special case of the Boole summation formula for alternating series, providing yet another example of a convergence acceleration technique that can be applied to the Leibniz series. In 1992, Jonathan Borwein and Mark Limber used the first thousand Euler numbers to calculate π to 5,263 decimal places with the Leibniz formula.[3]

### Euler product

The Leibniz formula can be interpreted as a Dirichlet series using the unique non-principal Dirichlet character modulo 4. As with other Dirichlet series, this allows the infinite sum to be converted to an infinite product with one term for each prime number. Such a product is called an Euler product. It is:

{\displaystyle {\begin{aligned}{\frac {\pi }{4}}&=\left(\prod _{p\equiv 1{\pmod {4}}}{\frac {p}{p-1}}\right)\left(\prod _{p\equiv 3{\pmod {4}}}{\frac {p}{p+1}}\right)\\&={\frac {3}{4}}\cdot {\frac {5}{4}}\cdot {\frac {7}{8}}\cdot {\frac {11}{12}}\cdot {\frac {13}{12}}\cdot {\frac {17}{16}}\cdot {\frac {19}{20}}\cdot {\frac {23}{24}}\cdot {\frac {29}{28}}\cdots \end{aligned}}}

In this product, each term is a superparticular ratio, each numerator is an odd prime number, and each denominator is the nearest multiple of 4 to the numerator.[4]