# How are the Machin Pi formulas found?

Introduction:

Machin formulas obey the general form$$m\cot^{-1}u+n\cot^{-1}v=\frac {k\pi}4$$Where $u,v,k\in\mathbb{Z}^+$ and $m,n$ are nonnegative integers. With the simplest being$$\frac \pi4=\cot^{-1}1\tag1$$And$$\frac \pi4=4\arctan\frac 15-\color{blue}{\arctan\frac 1{239}}\tag{2}$$And according to Wikipedia, this can be calculated really fast with the taylor expansion series for $\arctan x$.

Question:

1. How do you generate the identities used to find Machin like formulas?

For example, the identity for $(2)$ can be derived from this identity involving complex numbers$$(1+i)^4=2(1+i)(239+i)$$And a similar one$$\frac \pi4=\arctan\frac 12+\arctan\frac 15+\arctan\frac 18$$Can be derived from$$(2+i)(5+i)(8+i)=65(1+i)$$

1. How do you generate larger examples of Machin formulas (see $(3)$ and $(4)$)?

Miscellaneous:

I'm really interested in these formulas. In fact, $1$ trillion digits of $\pi$ were calculated with the two Machin-like formulas$$\frac \pi4=12\arctan\frac 1{49}+32\arctan\frac 1{57}-5\color{blue}{\arctan\frac 1{239}}+12\arctan\frac 1{110443}\tag3$$$$\frac \pi4=44\arctan\frac 1{57}+7\color{blue}{\arctan\frac 1{239}}-12\arctan\frac 1{682}+24\arctan\frac 1{12943}\tag4$$And Shanks computed the first $100\, 000$ digits using$$\frac \pi4=6\arctan\frac 18+2\arctan\frac 1{57}+\color{blue}{\arctan\frac 1{239}}$$$$\frac \pi4=12\arctan\frac 1{18}+8\arctan\frac 1{57}-5\color{blue}{\arctan\frac 1{239}}$$Which shows how powerful these series can be.

Edit:

While researching (as much as I could), I've found it interesting that most of the Machin formulas have the term $\arctan\frac 1{239}$. Is there an underlying reason for this?