# Why does this expression equal $\pi$?

I noticed that the following expression equals $\pi$ and I was curious as to why. Is it just a coincidence, or is there a meaningful explanation?

$$\int_{-\infty}^\infty\frac{1}{x^2+1}~dx=\pi$$

-
It is susceptible to use of residues, with a semi-circle contour with diameter on $[-R,R]$, but the $\arctan$ method is much more straightforward. – Jonas Meyer Jul 29 '11 at 8:04
@Geoff: I came up with a bell curve and decided to integrate it on my CAS calculator – anonymous coward Jul 29 '11 at 8:08
Would it be perverse to factor the denominator (with complex coefficients) and integrate using partial fractions? Some knowledge of complex logarithms will get you a $\pi$ in the answer. – GEdgar Jul 29 '11 at 13:35
– Qiaochu Yuan Jul 29 '11 at 15:34
In my experience, things in math are rarely coincidences. As Qiaochu points out, I asked a related question a while back, and he gives a very nice answer in that thread. – AnonymousCoward Jul 29 '11 at 21:28

The value follows from the identity $\int_{0}^{a} (x^2 + 1)^{-1} dx = \arctan a$, the evenness of the integrand about the origin, and the limit $\lim_{a \to \infty} \arctan a = \tfrac{\pi}{2}$.

-

One way to see this is by noting that $$\arctan(x)' = \cos^2(\arctan(x)) = {1 \over 1 + \tan^2(\arctan(x))} = {1 \over 1 + x^2}$$ where we used that $\tan(x)' = {1 \over \cos^2(x)}$, the rule for the differentiation of the inverse function and the simple identity $$\tan^2(x) + 1 = {\sin^2(x) + \cos^2(x) \over \cos^2(x)} = {1 \over \cos^2(x)}.$$ Since $\lim\limits_{x \to \pm \pi/2} \tan(x) = \pm \infty$ and $\tan(x)$ is a bijection for $x \in (-\pi/2, \pi/2)$ the claim follows.

Another way to see this is by interpreting the integral as the one along a closed curve in the complex domain where the curve first runs along the real axis and then closes upon itself by making "an infinite half-circle" in the upper half-plane (formally, we take circle of radius $R$ and in the end take the limit $R \to \infty$). Since the integral along the closed curve equals the sum of residues enclosed by it times $2 \pi i$ and since the only pole in the upper half plane is located at $x = i$ it follows that the integral is equal to ${2\pi i \over 2i} = \pi$. If you are not familiar with the residue concept, it's just a coefficient of the function that stands at the $(z-a)^{-1}$ term of the Laurent expansion. In this case we have $${1 \over 1 + z^2} = {1 \over (z + i)(z-i)}$$ so the coefficient at $z=i$ is given by ${1 \over z + i} = {1 \over 2i}$.

-
The trigonometric explanation makes the most sense to me, thanks for an interesting answer! – anonymous coward Jul 29 '11 at 8:12
@Charlie: indeed, that explanation is more straightforward but it kind of requires you to know the answer beforehand (i.e. to know derivatives of all the elementary functions). The second method is much more robust. One can e.g. use it to integrate $1 \over P(x)$ for any polynomial $P(x)$ (assuming it grows sufficiently quickly so that we can discard the boundary term coming the half-circle). This is because the first method gives us much more information than the second one: it allows us to integrate $\int_a^b {1 \over 1+x^2} dx$ for any $a,b \in \mathbb R$ not just the infinite ones. – Marek Jul 29 '11 at 8:20
People remember the derivative of $\tan$ as anything other than $1+\tan^2$?! Colour me surprised - $\frac{1}{\cos^2}$ has always been kind of a secondary cute form of $\tan'$ for me at least (PS: Disregard my first comment if you happen to have read it. I completely failed at reading comprehension on the post. Sorry about that) – kahen Sep 12 '11 at 21:54

I have told this story before: Choose a large $N$ and put $$t_k:=\tan{k\pi\over 2N+1} \qquad (-N\leq k\leq N)\ .$$ Then $t_N=\tan\bigl({\pi\over2}(1-{1\over 2N+1}\bigr)\gg 1$, similarly for $t_{-N}$, and for $t\in [t_{k-1},t_k]$ one has $t^2 \doteq t_{k-1}t_k$. Therefore we can approximate the given integral in the following way by a Riemann sum: $$\int_{-\infty}^\infty {1\over 1+t^2}\ dt\doteq\sum_{k=-N+1}^N {1\over 1+t_{k-1}t_k} (t_k-t_{k-1})\ .$$ On the right hand side all $2N$ summands are seen to have the same value $\tan{\pi\over 2N+1}\ll 1$ (by the formula for $\tan(\alpha-\beta)$) , and our Riemann sum computes to $$2N\ \tan{\pi\over 2N+1}\ \to\ \pi\qquad(N\to\infty)\ .$$

-

Here is another approach, which avoids taking $\arctan(\infty)$, etc.: let $u = \frac{1}{x}$, so that $\frac{du}{dx} = \frac{-1}{x^2}.$ Then we obtain $\int_{1}^{\infty} \frac{1}{1+u^{2}} du = \int_{0}^{1} \frac{1}{1+x^2}dx$. Hence $\int_{- \infty}^{\infty} \frac{1}{1+x^2} dx = 4\int_{0}^{1} \frac{1}{1+x^2}dx = 4 \arctan(1) = 4\frac{\pi}{4} = \pi$. As is well-known, the last integral can also be evaluated by integrating $\frac{1}{1+x^2} = (1 - x^2 + x^4 -\ldots )$ term by term (this needs a little justification but is permissible here), to obtain the famous formula $\frac{\pi}{4} = \sum_{n=0}^{\infty} \frac{(-1)^n}{2n+1}$.

-

One answer is that atanx is the primitive. If you want to calculate it by complex analysis see here How to justify term-by-term expansion to compute an integral

-
In my opinion this would better fit as a comment to the question, as the highest voted answer already contains it except the link. – t.b. Sep 12 '11 at 22:01

This is an elucidation of the "perverse" suggestion of GEdgar in the comments.

Note that the fraction decomposes as

$$\frac{1}{i}\left(\frac{1}{x-i}-\frac{1}{x+i}\right).$$

The indefinite integral of this is

$$\frac{1}{i}(\log(x+i)-\log(x-i))=\frac{1}{i}\log\left(\frac{x+i}{x-i} \right)=\frac{1}{i}\log\left(\frac{x^2-1+2ix}{x^2+1} \right)$$

We are considering $x$ to be a real number here. As $x$ tends to infinity, the real part of the argument of the logarithm above approaches $0$, and the complex part approaches $\pi/2$. By similar reasoning, as $x$ goes to negative infinity, the value of the logarithm becomes $-i\pi/2$. Subtracting, we get $(1/i)(i\pi)=1$.

-