Find the value of $\int_0^{\infty} \frac{x^{a-1}\,\mathrm{d}x}{1+x^{2}},\,$ where $\,0Using the Residue Theorem calculate
$$
\int_0^{\infty} \frac{x^{a-1}\,\mathrm{d}x}{1+x^{2}},\,\,\,\, \text{where}\,\,\,0<a<2.
$$
My solution comes out to be
$$ \frac{\pi}{2}[i^{a-1}-(-i)^{a-1}]$$
How to proceed from here since the solution of a rational expression must be independent of  $i$
 A: I imagine you have integrated $\,\,f(z)=\dfrac{z^{a-1}}{z^2+1},\,$ along the contour 
$\,\gamma=\gamma_1\cup\gamma_2\cup\gamma_3\cup\gamma_4,\,$ where
$$
\gamma_1=[-R,-\varepsilon],\quad\gamma_2=\{\varepsilon\mathrm{e}^{i(\pi-t)}: t\in[0,\pi]\},\quad \gamma_3=[\varepsilon,R],\quad\gamma_4=\{R\mathrm{e}^{it}: t\in[0,\pi]\}.
$$ 
In such case
$$
z^{a-1}=\mathrm{e}^{(a-1)\log z},
$$
where $\log z$ is a branch of logarithm defined in 
$$
\Omega=\mathrm{C}\setminus \{it: t\in (-\infty,0]\},
$$ 
as follows. If $z=r\mathrm{e}^{i\vartheta}$, then $\log z=\log r+i\vartheta$, with $$
\vartheta\in (-\pi/2,3\pi,2).
$$
So, in such case, Residue Theorem provides 
$$
\int_\gamma f(z)\,dz=2\pi i\,\mathrm{Res}\left(\frac{z^{a-1}}{1+z^2},i\right)=2\pi i\cdot\frac{i^{a-1}}{2i}=\pi\mathrm{e}^{i(a-1)\pi/2}=-i\pi \mathrm{e}^{ia\pi/2}.
$$ 
Clearly
$$
\lim_{R\to\infty,\,\varepsilon\to 0}\int_{\gamma_1}f(z)\,dz=
\int_{-\infty}^0\frac{z^{a-1}}{z^2+1}=(-1)^{a-1}\int_0^\infty\frac{x^{a-1}\,dx}{1+x^2}=-\mathrm{e}^{ia\pi}\int_0^\infty\frac{x^{a-1}\,dx}{1+x^2},
$$
since $(-1)^{a-1}=\mathrm{e}^{i(a-1)\pi}=-\mathrm{e}^{ia\pi},\,$ and
$$
\lim_{R\to\infty,\,\varepsilon\to 0}\int_{\gamma_3}f(z)\,dz=
\int_0^{\infty}\frac{z^{a-1}}{z^2+1}=\int_0^\infty\frac{x^{a-1}\,dx}{1+x^2}.
$$
Meanwhile,
$\lim_{\varepsilon\to 0}\int_{\gamma_2}f(z)\,dz=0$ and 
$\lim_{R\to\infty}\int_{\gamma_4}f(z)\,dz=0$. Hence, altogether
$$
(1-\mathrm{e}^{ia\pi})\int_{0}^\infty\frac{x^{a-1}\,dx}{1+x^2}=
\lim_{\varepsilon\to 0,\,\,R\to\infty}\int_\gamma f(z)\,dz=
2\pi i\,\mathrm{Res}\left(\frac{z^{a-1}}{1+z^2},i\right)
=-i\pi \mathrm{e}^{ia\pi/2}.
$$
Hence
$$
\int_{0}^\infty\frac{x^{a-1}\,dx}{1+x^2}=\frac{i\pi \mathrm{e}^{ia\pi/2}}{\mathrm{e}^{ia\pi}-1}=\frac{i\pi }{\mathrm{e}^{ia\pi/2}-\mathrm{e}^{-ia\pi/2}}=\frac{\pi}{2\sin (a\pi/2)}.
$$
A: In this answer, it is shown that for $m\gt0$ and $-1<n<m-1$
$$
\frac{\pi}{m}\csc\left(\pi\frac{n+1}{m}\right)=\int_0^\infty\frac{x^n}{1+x^m}\,\mathrm{d}x
$$
Plug in $n=a-1$ and $m=2$ to get that for $0\lt a\lt2$
$$
\int_0^\infty\frac{x^{a-1}}{1+x^2}\,\mathrm{d}x=\frac\pi2\csc\left(\frac{\pi a}2\right)
$$
