# Calculating $\pi$ using two formulas: $\pi/4 = \arctan(1/2) + \arctan(1/3)$ and $\pi/4 = 4\arctan(1/5) - \arctan(1/239)$

How can I use these two formulas to come up with two infinite series, each of which is used to calculate $\pi$?: \begin{align*} \frac{\pi}4 &= \arctan(1/2) + \arctan(1/3)\\ \frac{\pi}4 &= 4\arctan(1/5) - \arctan(1/239) \end{align*}

-
A related thread. –  Guess who it is. Dec 16 '11 at 5:17
I like $$\pi = \arctan 1 + \arctan 2 + \arctan 3$$ –  Will Jagy Dec 16 '11 at 7:47
@WillJagy, pretty but $\arctan x$ is easier to compute for $x<1$. –  lhf Dec 16 '11 at 10:22

You need the power series for $\arctan x$: $$\arctan x=x-\frac{x^3}{3}+\frac{x^5}{5}-\frac{x^7}{7}+\cdots.$$

This power series expansion is often called the Leibniz series, although more properly his name should be associated with the pretty but not terribly useful special case $x=1$. The general series was independently discovered by Gregory. It was also well-known to South Indian mathematicians around $200$ years before Leibniz or Gregory were born. The name Nilakantha is sometimes associated with the discovery, but there is unfortunately no certainty; it may go all the way back to the late fourteenth century mathematician Madhava. For details on the Kerala school of mathematics, please see Kim Plofker's book.

The "Nilakantha" series converges to $\arctan x$ when $-1\le x\le 1$, though the convergence is hopelessly slow at $x=\pm 1$.

Using $\dfrac{\pi}{4}=\arctan(1/2)+\arctan(1/3)$ we get $$\frac{\pi}{4}=\left(\frac{1}{2}-\frac{1}{3\cdot 2^3} + \frac{1}{5\cdot 2^5}-\frac{1}{7\cdot 2^7}+\cdots \right)+ \left(\frac{1}{3}-\frac{1}{3\cdot 3^3} + \frac{1}{5\cdot 3^5}-\frac{1}{7\cdot 3^7}+\cdots \right) .$$ The terms go down reasonably fast. For each part, the error made when we truncate the infinite series at a certain place is smaller, in absolute value, than the first "neglected" term.

We get better performance from the second formula that you quoted, which is called Machin's Formula. The negative powers of $5$ and $239$ go down much faster than was the case for $2$ and $3$. Moreover, the fractions $\dfrac{1}{5^{2n+1}}$ are particularly pleasant if we are using decimal arithmetic.

The Machin Formula, and relatives, together with the power series for $\arctan x$, are the method used for most high-precision approximations to $\pi$ from the eighteenth century until now. Viable alternatives have only emerged recently.

-
Ah right, thanks! –  mathemagician11 Dec 16 '11 at 5:09
In general, since Maclaurin series converge much faster when their arguments are near zero, it makes sense to use a Machin formula whose arctangent arguments are as small as they can be. –  Guess who it is. Dec 16 '11 at 5:27
+1 Nice answer, do you have any references for further reading? –  AD. Dec 16 '11 at 6:50
@AD., you'll want to see this, this, and this. –  Guess who it is. Dec 16 '11 at 7:44
@AD.: I added a reference to Plofker's Mathematics in India. There is also a fairly recent less scholarly book on Kerala mathematics by George Joseph. –  André Nicolas Dec 16 '11 at 8:25

Just to complete: To prove the equality $$\pi/4 = \arctan(1/2) + \arctan(1/3)$$ consider that $$(2+i)(3+i) =5+5i.$$ Now, taking the arguments of both sides and since the argument of a product is the sum of the arguments of the factors, the equality follows.

-
Yes, that was mentioned here. –  Guess who it is. Dec 16 '11 at 8:54
Just to complete: $$\frac{(5+i)^4}{239+i}=2+2i$$ –  Guess who it is. Dec 16 '11 at 9:16