Contour integration of $\int \frac{dx} {(1+x^2)^{n+1}}$ I want to compute 
$$
 \int_{-\infty}^\infty \frac 1{ (1+x^2)^{n+1}} dx
$$ for $n \in \mathbb N_{\geq 1}$. If I let
$$
 f(z) := \frac 1 {(z+i)^{n+1}(z-i)^{n+1}}
$$ then I see that $f$ has poles of order $n+1$ in $\pm i$. Initially I thought that 
$$
[-R,R] \cup \{R \exp(i \theta) \mid \theta \in [0,\pi] \}
$$ would be a good conture but for the residue in $i$ I get $(-1)^n (n+1) 2 i$. I know that the result must be
$$
\frac {1 \cdot 3 \cdot 5 \cdots (2n-1)}{2 \cdot 4 \cdots 2 n} \pi
$$ which looks quite different than my residue.  What goes wrong here ?
 A: I think that both of you had made mistake in calculating derivatives.
$$\underset{z=i}{\operatorname{res}}f(z)=\underset{z=i}{\operatorname{res}}\frac{1}{\left(z+i\right)^{n+1}\left(z-i\right)^{n+1}}=\frac{1}{n!}\underset{z\to i}\lim \frac{d^n}{dz^n}\left(\frac{\left(z-i\right)^{n+1}}{\left(z-i\right)^{n+1}\left(z+i\right)^{n+1}}\right)=\\
=\frac{1}{n!}\underset{z\to i}\lim \frac{d^n}{dz^n}\left(\frac{1}{\left(z+i\right)^{n+1}}\right)=\frac{1}{n!}\underset{z\to i}\lim \frac{d^{n-1}}{dz^{n-1}}\left(\frac{(-1)(n+1)}{\left(z+i\right)^{n+2}}\right)=\\
=\frac{1}{n!}\underset{z\to i}\lim \frac{d^{n-2}}{dz^{n-2}}\left(\frac{\left(-1\right)^2(n+1)(n+2)}{\left(z+i\right)^{n+3}}\right)=...=\frac{1}{n!}\underset{z\to i}\lim \left(\frac{\left(-1\right)^n(n+1)(n+2)..2n}{\left(z+i\right)^{2n+1}}\right)=\\
=\frac{1}{n!}\left(\frac{\left(-1\right)^n(n+1)(n+2)..2n}{2^{2n+1}i^{2n+1}}\right)$$
A: To compute the residue at $z=i$ of
$$
\begin{align}
\frac1{(1+z^2)^{n+1}}
&=\frac1{(z+i)^{n+1}}\frac1{(z-i)^{n+1}}\\
&=\frac1{((z-i)+2i)^{n+1}}\frac1{(z-i)^{n+1}}
\end{align}
$$
we need to compute the coefficient of $(z-i)^n$ in $\frac1{((z-i)+2i)^{n+1}}$. 
Using the binomial theorem, the full term is
$$
\begin{align}
\binom{-n-1}{n}\left(\frac{z-i}{2i}\right)^n(2i)^{-n-1}
&=(z-i)^n(-1)^n\binom{2n}{n}(2i)^{-2n-1}\\
&=(z-i)^n\color{#C00000}{\frac1i\binom{2n}{n}2^{-2n-1}}
\end{align}
$$
Thus, the integral along the contour which follows the real axis and then circles back around through the upper half-plane is $2\pi i$ times $\color{#C00000}{\text{this residue}}$. That is,
$$
\int_{-\infty}^\infty\frac{\mathrm{d}x}{(1+x^2)^{n+1}}=\frac\pi{4^n}\binom{2n}{n}
$$
A: Here is another approach to calculating the residue of $f(z) = (1+z^2)^{-n-1}$ at $z = i
$ which uses the Binomial Theorem to avoid taking derivatives.  It will simplify notation a bit if we let $w = z - i$ and calculate the residue of $f(w)$ at $w = 0$.  So consider
$$f(w) = [1 + (w+i)^2]^{-n-1} = w^{-n-1} (2i)^{-n-1} \left(1 + \frac{w}{2i} \right) ^{-n-1}$$
$$= w^{-n-1} (2i)^{-n-1} \sum_{k=0}^{\infty} \binom{-n-1}{k} (2i)^{-k} w^k $$
The coefficient of $w^{-1}$ corresponds to $k=n$ in the summation, so 
$$Res_{w=0} f(w)= (2i)^{-n-1} (2i)^{-n} \binom{-n-1}{n} = -2^{-2n-1} (-1)^n \binom{-n-1}{n} i= -2^{-2n-1} \binom{2n}{n} i$$
A: I believe your residue is wrong.
If $f$ has a pole of order $N$ in $z=a$, so that $f(z)=(z-a)^{-N}g(z)$ (where $g$ is a function which is analytic in a neighbourhood of $z=a$), then the residue of $f$ in $z=a$ is
$$\operatorname{Res}\limits_{z=a} f(z) = \frac{g^{(N-1)}(a)}{(N-1)!}.$$
In your case,
$$g^{k}(z)=(-1)^k(n+1)(n+2)\cdots(n+k)(z+i)^{-(n+k+1)},$$
so that
$$\operatorname{Res}\limits_{z=i} f(z) = \frac{(-1)^n(n+1)(n+2)\cdots2n}{n!(2i)^{2n+1}}=\frac{(2n)!}{n!n!2^{2n}2i}=\frac{1}{2i2^{2n}}\binom{2n}{n}.$$
Thus, the integral becomes
$$\frac{\pi}{2^{2n}}\binom{2n}{n}.$$
