Solving integral using contour integration I am trying to show that $I = \int_0^{+\infty} \frac{x^a}{x^2 + 1} = \frac{\pi / 2} {\cos \frac{\pi a}{2}}$ provided $-1 < a < 1$.
So I consider $I = \int_{C_R}\frac{z^a}{z^2 + 1}$ where $C_R$ is the positively oriented contour consisting of the real segment [-R,R] and the upper semi circle of radius R.
Now $C_R$ only contains one sigularity of the above integrand, $\exp(\frac{i \pi}{2})$.
So I take the residue at this point, multiply by $2\pi i $ and get $\pi \left( \cos \frac{a \pi}{2} + i \sin \frac{a \pi}{2}  \right)$
Now am I supposed to take the real part of this? And even then, why do I not get the desired result? Note that I should take half of the answer since the complex integral is from negative to plus infinity. However I am aware that there might be an issue here, since $a$ can be negative and not necessarily an integer, thus possibly screwing up the parity of I.
Any help would be appreciated.
 A: Because of the branch point, you need to deform your contour so as to avoid the branch point.  To do this, introduce a little circular bump above the branch point.  Thus, consider
$$\oint_C dz \frac{z^a}{z^2+1}$$
where $C$ is the above-described deformed semicircle.  The contour integral is then equal to
$$\int_{-R}^{-\epsilon} dx \frac{x^a}{x^2+1} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{\epsilon^a e^{i a \phi}}{\epsilon^2 e^{i 2 \phi}+1} \\ + \int_{\epsilon}^R dx \frac{x^a}{x^2+1} + i R \int_{0}^{\pi} d\theta \, e^{i \theta} \frac{R^a e^{i a \theta}}{R^2 e^{i 2 \theta}+1}$$
We consider the limits as $R \to \infty$ and $\epsilon \to 0$; in each of these limits, the fourth and second integrals vanish, respectively, because $a \in (-1,1)$.  Therefore, the contour integral is the sum of the first and third integrals.  Note that, in the first integral, $-1=e^{i \pi}$.  Therefore, sub $x \mapsto e^{i \pi} x$ and get
$$\left (1+e^{i \pi a} \right ) \int_0^{\infty} dx \frac{x^a}{x^2+1} $$
The contour integral, on the other hand, is equal to $i 2 \pi$ times the residue of the pole inside $C$, i.e., $z = e^{i \pi/2}$; we therefore have
$$\int_0^{\infty} dx \frac{x^a}{x^2+1} = i 2 \pi \frac{1}{2 i} \frac{e^{i \pi a/2}}{1+e^{i \pi a}} = \frac{\pi}{2 \cos{(\pi a/2)}}$$
