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$$
 A: 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}$.
A: 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)\ .$$
A: 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}$. 
A: 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
A: 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$.
A: 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}$.
