Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There exists a well-known formula by John Machin: $$\frac{\pi}{4} = 4 \arctan \left(\frac{1}{5}\right) - \arctan \left(\frac{1}{239}\right).$$ Actually, it belongs to the family of Machin-like formulas of the form $$\frac{\pi}4 = \sum_k a_k \arctan {b_k}^{-1}\quad\text{for some integers}\quad(a_k,b_k)$$

For example: $$\frac{\pi}{4} = \arctan \left(\frac{1}{2}\right) + \arctan \left(\frac{1}{3}\right) = 2 \arctan \left(\frac{1}{2}\right) - \arctan \left(\frac{1}{7}\right)$$ and so forth.

These formulas are quite easy to prove, but is there any easy way to generate such $(a_n, b_n)$?

share|cite|improve this question
I don't think diophantine equations would be a correct tag. – Aryabhata Jun 10 '11 at 17:20
@Aryabhatta, I disagree. – Gerry Myerson Jun 10 '11 at 23:44
@Gerry: Typically Diphonatine means polynomial, doesn't it? I may be mistaken, though. And of course, I suppose one could convert it by taking a tan on both sides. Please feel free to add it back. – Aryabhata Jun 10 '11 at 23:45
@Aryabhatta, there are some very famous Diophantine equations that are not polynomial, e.g., the Ramanujan-Nagell equation ($2^n-7=x^2$) and Catalan's equation ($x^m-y^n=1$). I'm inclined to call something diophantine if one insists on integer solutions, regardless of the form of the expressions involved. Sometimes it's called Diophantine even if rational solutions are allowed. – Gerry Myerson Jun 11 '11 at 0:03
@Gerry: Agreed and thanks for adding it back :-) – Aryabhata Jun 11 '11 at 0:07
up vote 6 down vote accepted

The identity $\cot^{-1} x = 2 \cot^{-1} 2x - \cot^{-1} (4x^3 + 3x)$ can be used to generate an infinite number of these identities. (Got from the mathworld page:, see equation 29)

share|cite|improve this answer
Well, at least there is infinite number of such equations. – grep Jun 10 '11 at 20:34
I was most pleased when I discovered this formula for myself. I subsequently used $\pi = 32\cot ^{-1}10-4\cot ^{-1}239-16\cot ^{-1}515$ to calculate $\pi$ to about 10 places by hand. :) – PM 2Ring Feb 17 at 6:15

The best way to understand identities like this is in terms of Gaussian integers -- complex numbers whose real and imaginary parts are integers.. I'll do some examples, and then explain the general setup.

For example, notice that we have the identity: $$(5+i)^4 = 476+480 i = 2 (1+i) (239+i). \quad (*)$$ (Just multiply it out and see.)

Multiplying complex numbers adds their arguments1. So $$4 \arg(5+i) = \arg(1+i) + \arg(239+i)$$ or $$4 \tan^{-1} \frac15 = \frac{\pi}{4} + \tan^{-1} \frac1{239}$$ as desired. Similarly, $(2+i)(3+i) = 5(1+i)$ explains another one of your identities.

In general, whenever we have $\prod (a_k+i)^{b_k} = r (1+i)$ for $r$ a positive real, we get $\sum b_k \tan^{-1} a_k^{-1} = \pi/4$.

So, how do we find formulas like $(*)$? The key point is that Gaussian integers, like ordinary integers, have unique factorization into primes. The primes in the Gaussian integers come in three flavors: (a) The prime $1+i$ (b) If $p$ is an integer prime which is $3 \mod 4$, then $p$ is also a prime in the Gaussian integers. (c) If $p$ is an integer prime which is $1 \mod 4$, then we can write $p$ as $(q+ri)(q-ri)$, and $q+ri$ and $q-r_i$ will be both prime in the Gaussian integers. Also, the powers of $i$ are units which should be ignored in prime factorizations, just like $-1$ in the ordinary integers.

Whenever we have an identity like $(*)$, we must have the same prime factors on both sides. For example, $(239+i) = (3-2i)^4 (1+i) \cdot i$, $5+i = (3-2i)(1+i)$ and $2 = (1+i)^2 (-i)$, so both sides of $(*)$ are $(3-2i)^4 (1+i)^4$.

The way that I would find more identities like this would be to take a whole bunch of numbers of the form $a_k+i$ and factor them in the Gaussian integers. Then I'd look for some way to multiply them together so that the resulting power of $1+i$ is odd, and such that the exponent of $q+ri$ is equal to the exponent of $q-ri$ for all primes $q \pm ri$ of type (c). This will make $\prod (a_k+i)^{b_k}$ into something of the form $(1+i)^{\mathrm{odd}} (\mbox{something real})$. Using $(1+i)^2 = 2i$, we can turn this into $\prod (a_k+i)^{b_k} = (1+i) (\mbox{something either purely real or purely imaginary})$, and thus find a new formula for $\pi/4$.

Note that finding $b$'s with the specified properties is a matter of linear algebra, as I will show in the example below.

Example: Suppose I wanted a formula involving $\tan^{-1} (1/2)$, $\tan^{-1} (1/5)$ and $\tan^{-1}(1/8)$. (I'm cheating: I happen to know such a thing exists. A more realistic example would be to start out with $\tan^{-1}(1/b)$, for $b$ ranging from $2$ to $10$, and then see which subset works. But that would be too time consuming to write up here.)

Here are the factorizations in the Gaussian integers: $$2+i \ \mbox{is prime}$$ $$5+i = (1+i)(3-2i)$$ $$8+i = (3+2i)(2-i)$$

So $$(2+i)^{b_1} (5+i)^{b_2} (8+i)^{b_3} = (1+i)^{b_2} (2+i)^{b_1} (2-i)^{b_3} (3-2i)^{b_2} (3+2i)^{b_3}.$$

I want $b_2$ to be odd, $b_1=b_3$ and $b_2=b_3$. A little bit of linear algebra finds the solution $b_1=b_2=b_3 =1$. So I discover the identity $$(2+i)(5+i)(8+i) = 65 (1+i)$$ and $$\tan^{-1} \frac12 + \tan^{-1} \frac15 + \tan^{-1} \frac18 = \frac{\pi}{4}.$$

1 This formula might be off by an integer multiple of $2\pi$. See Joel Cohen's comment below. But I assume you are just as happy with a formula for $\pi/4+2 k \pi$.

share|cite|improve this answer
I'm nitpicking a bit, but in principle, shouldn't Gaussian integers give you a formula modulo $2 \pi$ (after which you'd easily adjust the multiple of $2\pi$ using a very rough estimate) ? – Joel Cohen Jun 10 '11 at 20:05
Yup, thanks for noting that. – David Speyer Jun 10 '11 at 20:18
Thank you for the comment. Yes, I understand that checking Machin-like formulas is very simple. The question is how to find them. Just direct bruteforcing of a's with some clever search of degrees is a bit too slow – grep Jun 10 '11 at 20:32
+1 This was neat! – Jyrki Lahtonen Jun 10 '11 at 20:38
@grep Does my explanation of how to use Gaussian factorizaton to find such identities not respond to that? – David Speyer Jun 11 '11 at 12:29

For 2-terms formulas, I've computed a generalized formula which is, I think, more efficient than any other existing Machin's formula. see my post: generalized 2-terms Machin's formula (an efficient way to compute $\pi$)

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.