Evaluating real improper integral by residues I've been trying to solve this integral and have been getting nowhere:
$$ \int_0^\infty \frac{dx}{(1+x^2)x^a} \;,\; 0<a<1 $$
The solution says that
$$ \int_0^\infty \frac{dx}{(1+x^2)x^a} = \int_0^\infty \frac{x^{1-a}}{x(1+x^2)}dx $$
$$ = \frac{1}{1-e^{2 \pi i(1-a)}} 2 \pi i \sum_{a \neq 0} Res_a \frac{z^{1-a}}{z(1+z^2)}  $$
Everything after this step is clear to me (just calculating residues) but I really don't understand this step. Could someone explain this to me, or failing that explain how else I could solve this?
Thanks for any help!
 A: Take $0<\epsilon<R$. Consider the integration path $C$ formed by the interval $[\epsilon,R]$, the circle $C_R$ of radius $R$ counterclockwise, the interval $[R,\epsilon]$ and the circle $c_\epsilon$ of radius $\epsilon$ clockwise. The function
$$
f(z)=\frac{z^{1-a}}{z(1+z^2)}
$$
is holomorphic in the interior of $C$ (we consider the branch of $z^{1-a}$ defined on $\mathbb{C}\setminus[0,\infty)$) except for two poles at $\pm i$. Then
$$
\int_C f(z)\,dz=\int_0^Rf(z)\,dz+\int_{C_R} f(z)\,dz+\int_R^0 f(z)\,dz+\int_{c_\epsilon}. f(z)\,dz
$$
As $\epsilon\to0$ and $R\to\infty$, the integrals over $c_\epsilon$ and $C_R$ tend to $0$ (check it.) When you evaluate the integral from $0$ to $R$, the value of $z^{1-a}$ is $x^{1-a}$. However, when you evaluate the integral from $R$ to $0$ you have turned around the circle once, and the value of $z^{1-a}$ is now $e^{2\pi i(1-a)}x^{1-a}$. Putting it all together we get
$$\begin{align*}
\int_C f(z)\,dz&=2\,\pi\,i\sum_{a=\pm i}\operatorname{Res}_a(f(z))\\
&=\int_0^\infty\frac{x^{1-a}}{x(1+x^2)}\,dx-e^{2\pi i(1-a)}\int_0^\infty\frac{x^{1-a}}{x(1+x^2)}\,dx.
\end{align*}$$
