Establish $\int_0^{\infty} \frac{x^a}{x^2 + b^2}dx = \frac{\pi b^{a-1}}{2 \cos(\pi a /2)}$ when $-1 < a < 1$ My attempt at a solution: (this is homework, btw)
Let $f(z) = \frac{z^a}{z^2 + b^2}dz$ then the singularities of $f$ occur at $\pm ib$.
$$
Res(f; ib) = \frac{z^a}{z + ib} \biggr |_{ib} = \frac{(ib)^a}{2ib} 
$$
$$
Res(f; -ib) = \frac{z^a}{z - ib} \biggr |_{-ib} = \frac{(-ib)^a}{-2ib} 
$$
We sum the residues and multiply by $2 \pi i$ to give the value of a contour integral containing the two poles.
$$
2 \pi i \cdot \biggl ( \frac{(ib)^a}{2ib}  - \frac{(-ib)^a}{2ib} \biggr ) = \pi b^{a-1} (i^a - (-i)^a) = \pi b^{a-1} (e^{\pi i a/2} - e^{- \pi i a/2}) =  \pi b^{a-1} 2 i \sin (\pi i a/2)
$$
We use a circle contour centered at the origin with the origin cut out (since $a$ can be negative)
Also we make the branch cut for $x^a$ along the positive real axis.  
$\gamma = [r, R]$
$\mu_R = Re^{i \theta}$, where $0 <  \theta < 2\pi$
$\kappa = [-R, -r]$
$\mu_r = re^{i \theta}$, where $0 < \theta < 2\pi$
$$
\pi b^{a-1} 2 i \sin (\pi i a/2) = \int_r^R  \frac{x^a}{x^2 + b^2}dx + \int_0^{2\pi}  \frac{(Re^{i \theta})^a}{(Re^{i \theta})^2 + b^2}i R e^{i \theta} d \theta + \int_{R}^{r} -\frac{x^a}{x^2 + b^2}dx + \int_{2\pi}^0  \frac{(re^{i \theta})^a}{(re^{i \theta})^2 + b^2}i r e^{i \theta} d \theta
$$
As $r \rightarrow 0$ and $R \rightarrow \infty$ we have that the second and fourth integrals go to zero. Thus,
$$
\pi b^{a-1} 2 i \sin (\pi i a/2) = 2 \int_0^{\infty}  \frac{x^a}{x^2 + b^2}dx  \implies \int_0^{\infty}  \frac{x^a}{x^2 + b^2}dx = \frac{\pi b^{a-1}  i \sin (\pi i a/2)}{2}
$$
So where did I go wrong?  
 A: Setting $m=2$ in this answer, it is shown that
$$
\frac{\pi}{2}\csc\left(\pi\frac{a+1}{2}\right)=\int_0^\infty\frac{x^a}{1+x^2}\,\mathrm{d}x
$$
Thus,
$$
\begin{align}
\int_0^\infty\frac{x^a}{b^2+x^2}\,\mathrm{d}x
&=\frac{\pi}{2}\csc\left(\pi\frac{a+1}{2}\right)b^{1-a}\\
&=\frac{\pi\,b^{1-a}}{2\cos\left(\frac{\pi a}{2}\right)}
\end{align}
$$
A: My corrected answer (thanks to Daniel Fischer and robjohn):
We use a circle contour centered at the origin with the origin cut out (since $a$ can be negative).
(Also we make the branch cut for $x^a$ along the positive real axis.)
$\gamma = [r, R]$
$\mu_R = Re^{i \theta}$, where $0 <  \theta < 2\pi$
$\kappa = [-R, -r]$
$\mu_r = re^{i \theta}$, where $0 < \theta < 2\pi$
$$
\int_{\Gamma} f = \int_r^R  \frac{x^a}{x^2 + b^2}dx + \int_0^{2\pi}  \frac{(Re^{i \theta})^a}{(Re^{i \theta})^2 + b^2}i R e^{i \theta} d \theta + \int_{R}^{r} \frac{e^{2 \pi i a}x^a}{x^2 + b^2}dx + \int_{2\pi}^0  \frac{(re^{i \theta})^a}{(re^{i \theta})^2 + b^2}i r e^{i \theta} d \theta
$$
As $r \rightarrow 0$ and $R \rightarrow \infty$ we have that the second and fourth integrals go to zero. Thus,
$$
 \int_{\Gamma} f = (1 - e^{2 \pi i a}) \int_0^{\infty}  \frac{x^a}{x^2 + b^2}dx 
$$
Now we calculate the residues  of $f$ occur at $\pm ib$.
$$
Res(f; ib) = \frac{z^a}{z + ib} \biggr |_{ib} = \frac{(ib)^a}{2ib} \qquad Res(f; -ib) = \frac{z^a}{z - ib} \biggr |_{-ib} = \frac{(-ib)^a}{-2ib} 
$$
We sum the residues and multiply by $2 \pi i$ to give the value of a contour integral containing the two poles.
$$
2 \pi i \cdot \biggl ( \frac{(ib)^a}{2ib}  - \frac{(-ib)^a}{2ib} \biggr ) = \pi b^{a-1} (i^a - (-i)^a) = \pi b^{a-1} (e^{\pi i a/2} - e^{3 \pi i a/2}) 
$$
Then
\begin{align*}
\int_0^{\infty}  \frac{x^a}{x^2 + b^2}dx &= \frac{ \pi b^{a-1} (e^{\pi i a/2} - e^{3 \pi i a/2}) }{1 - e^{2 \pi i a}}\\
&= \frac{ \pi b^{a-1} (e^{-\pi i a/2} - e^{ \pi i a/2}) }{e^{- \pi  i a} - e^{ \pi i a}}\\
&= \frac{ \pi b^{a-1} \sin (\pi  a/2)}{\sin( \pi  a)}\\
&= \frac{ \pi b^{a-1} \sin (\pi  a/2)}{\sin( \pi  a)}\\
&= \frac{ \pi b^{a-1} \sin (\pi  a/2)}{2 \sin( \pi  a/2) \cos( \pi  a/2)}\\
&= \frac{ \pi b^{a-1}}{2\cos( \pi  a/2)}\\
\end{align*}
