# How to generate similar identities to $(5+i)^4=2(1+i)(239+i)$

Introduction:

The Machin formula$$\frac \pi4=4\arctan\frac 15-\arctan\frac 1{239}\tag1$$Can be derived from the tangent angle formula. But $(1)$ can also be derived from the identity involving complex numbers$$(5+i)^4=2(1+i)(239+i)\tag{2}$$And similarly, other formulas can be found too. Such as$$\frac \pi4=12\arctan\frac 1{49}+32\arctan\frac 1{57}-5\arctan\frac 1{239}+12\arctan\frac 1{11043}\tag3$$$$m(1+i)=(49+i)^{12}(57+i)^{32}(239+i)^{-5}(11043+i)^{12}\tag4$$Where $m$ is a very large number.

Questions:

1. How do you generate identities similar to $(1)$ and $(4)$?
2. Can you provide an example of using 1.?

My Work:

The only way that I can come up with the identities is starting with$$m(1+i)=(a+i)(b+i)(c+d)(d+i)\cdots$$But that takes forever to expand, and not to mention, finding the right $a,b,c,d,\ldots$ that satisfy the equation. Is there perhaps an easier way?

The basic idea is that identities such as $(1)$ come from using the formula $$\arctan x + \arctan y = \arctan \frac{x + y}{1 - xy}.$$ Since $\frac\pi4 = \arctan 1$, we have $$\frac\pi4 = \arctan x + \arctan \frac{1-x}{1+x}$$ for any $x$ (solving for the $y = \frac{1-x}{1+x}$ that will give us $\frac{x+y}{1-xy}=1$). So we might write $$\frac\pi4 = \arctan \frac12 + \arctan \frac13$$ for example. Then we could break up each of these arctangents into smaller arctangents, and keep going.

So in fact we get lots and lots of identities. Which ones are the best ones? For speed of convergence, it's obviously best to have a very small value of $x$ in $\arctan x$; maybe $x = \frac1n$ for a pretty large integer $n.$ But it would also be nice if we could "double up" on a term: what's good about $(1)$ is that $\arctan \frac15$ is there four times, but we only need to compute it once.

We get the same arctangent twice by using the formula $$2 \arctan x = \frac{2x}{1-x^2} \qquad \Longleftrightarrow \qquad 2 \arctan \frac pq = \arctan \frac{2pq}{q^2-p^2}.$$ We can't make this work with $\frac{2pq}{q^2-p^2} = 1$, but we can make this very close to $1$, so that the leftover part is the arctangent of something very small. You might notice that $2pq$ and $q^2-p^2$ are two sides of a Pythagorean triple: $(2pq)^2 + (q^2-p^2)^2 = (q^2 + p^2)^2$. So we can't make them equal, because there's no isosceles right triangle with integer sides. But by solving Pell's equation, we can make them consecutive integers. More precisely, if we have a solution to $x^2 - 2y^2 = -1$, then we also have $\left(\frac{x-1}{2}\right)^2 + \left(\frac{x+1}{2}\right)^2 = y^2$, which we can use to get a nice double-arctangent identity.

For example, if we take $(x,y) = (7,5)$ (which satisfies $7^2 - 2\cdot 5^2 = -1$) then we get the Pythagorean triple $(3,4,5)$, which has $q=2$ and $p=1$. So this gives us the identity $2 \arctan \frac12 = \arctan \frac43$. When $x = \frac43$, $\frac{1-x}{1+x} = -\frac17$, so we have $$\frac\pi4 = \arctan \frac43 - \arctan \frac17 = 2\arctan \frac12 - \arctan \frac17.$$ If we take $(x,y) = (41,29)$, we get the Pythagorean triple $(20, 21, 29)$, which has $q=5$ and $p=2$, this gives us the identity $2 \arctan \frac25 = \arctan \frac{20}{21}$. When $x = \frac{20}{21}$, $\frac{1-x}{1+x} = \frac{1}{41}$, so $$\frac\pi 4 = \arctan \frac{20}{21} + \arctan \frac1{41} = 2 \arctan \frac25 + \arctan \frac{1}{41}.$$ Since $\frac25 \approx \frac13$, we could try to write $\arctan \frac25 = \arctan \frac13 + \arctan y$, and get $y = \frac1{17}$. So we can rewrite the identity as $$\frac\pi4 = 2 \arctan \frac13 + 2\arctan \frac1{17} + \arctan \frac1{41}.$$

We get the infamous formula with $239$ in it by taking $x=239$ and $y = 169$ as our Pell solution, which gives us the Pythagorean triple $119^2 + 120^2 = 169^2$ and $(p,q) = (5,12)$. So $2 \arctan \frac{5}{12} = \arctan \frac{120}{119}$; when $x = \frac{120}{119}$, $\frac{1-x}{1+x} = -\frac{1}{239}$, so we get the identity $$\frac\pi4 = 2\arctan \frac{5}{12} - \arctan \frac{1}{239}.$$ Here, we get extra lucky, because $5$ and $12$ form a Pythagorean triple themselves, so we can write $\arctan \frac{5}{12} = 2 \arctan \frac15$, giving you the identity $(1)$.

• Great answer! But in one step, you noticed that $\frac 25\approx\frac 13$. What would we do if it was a significantly larger number? Such as $\frac {70}{169}$? – Crescendo Apr 10 '17 at 16:01
• We can check out the continued fraction convergents to $\frac{70}{169}$ to find approximations to it. The already-familiar $\frac{5}{12}$ is one, and if $\arctan \frac{70}{169} = \arctan \frac{5}{12} + \arctan x$, then $x = -\frac{5}{2378}$, giving us $\arctan \frac{70}{169} = \arctan \frac{5}{12} + \arctan -\frac{5}{2738} = 2 \arctan \frac15 - \arctan \frac{5}{2738}$. – Misha Lavrov Apr 10 '17 at 16:16
• After trying a couple of generations, it seems like the $2\arctan\frac pq$ value will always have a continued fraction of $[0;2,2,2,2,2,2,2,\ldots]$. Is there a way to change that because then, the first term will always be $4\arctan\frac 15$. – Crescendo Apr 20 '17 at 15:56
• The next step is probably to think about triple or quadruple arctangent formulas. – Misha Lavrov Apr 20 '17 at 16:53