TITLE: Why does this expression equal $\pi$?
QUESTION [9 upvotes]: 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$$

REPLY [2 votes]: 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$.