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: 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. 
A: 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.
