Using Complex Analysis to Compute $\int_0 ^\infty \frac{dx}{x^{1/2}(x^2+1)}$ I am aware that there is a theorem which states that for $0<a<2$ we have $$\int_0^\infty\frac{x^{a-1}}{x^2+1}dx=\frac{\pi \cos\big(\frac{a\pi }{2}\big)}{\sin (a\pi) }$$ but I prefer to evaluate the integral using the calculus of residues (since I don't want to have to recall a theorem for almost every other problem of this type). On the other hand, I don't have a useful contour in mind. 
My attempt is the following: Let's take $f(z)=\frac{1}{z^{1/2}(z^2+1)}$ as the complexification of our integrand. Define $\gamma_R=\gamma _R^1+\gamma_R^2+\gamma_R^3$, where $\gamma_R^1(t)=t$ for $t$ from $1/R$ to $R$; $\gamma_R^2(t)=\frac{1}{R}e^{it}$, where $t$ goes from $\pi /4$ to $0$ ; and $\gamma_R^3(t)=e^{\pi i/4}t, $ where $t$ goes from $R$ to $1/R$ (see drawing).
The poles of the integrand are at $0,\pm i$, but those are not contained in the contour, so by the residue theorem $\int_{\gamma_R}f(z)dz=0$. On the other hand, $\int_{\gamma_R}=\int_{\gamma_R^1}+\int_{\gamma_R^2}+\int_{\gamma_R^3}$. As $R\to \infty$, $\int_{\gamma_R^1}f(z)dz\to \int_0 ^\infty \frac{1}{x^{1/2}(x^2+1)}dx$. Also, = $\vert \int_{\gamma_R^2}f(z)dz\vert \le \frac{\pi }{4R}\cdot \frac{1}{R^2-1}$ and the lattest expression tends to $0$ as $R\to \infty$. However, $\int_{\gamma_R^3}f(z)=i\int_R ^{1/R}tdt=\frac{i/R^2-iR^2}{2}$, which is unbounded in absolute value for large $R$. 
Is there a better contour to choose? If so, what is the intuition for finding a good contour in this case?

I think what you actually wanted to do was to use a semicircle in the upper half plane.  Generally speaking, for these integrals, you want to use a wedge of angle twice the argument of the pole.  However, you had the right idea of avoiding the branch point at the origin.  Thus, we would introduce a small semicircular detour of radius $\epsilon$ at the origin; this detour contributes nothing to the integral as $\epsilon \to 0$ for $a \gt 0$.  Thus, the contour integral is equal to
$$e^{i \pi} \int_{\infty}^0 dx \frac{e^{i \pi (a-1)} x^{a-1}}{1+x^2} + \int_0^{\infty} dx \frac{x^{a-1}}{1+x^2} + i R \int_0^{\pi} d\theta \, e^{i \theta} \frac{R^{a-1} e^{i (a-1) \theta}}{1+R^2 e^{i 2 \theta}}$$
The third integral vanishes as $R \to \infty$ when $a \lt 2$.  The first two integrals combine as
$$\left ( 1-e^{i a \pi}\right ) \int_0^{\infty} dx \frac{x^{a-1}}{1+x^2}$$
By the residue theorem, the contour integral is also equal to $i 2 \pi$ times the residue at the pole $z=e^{i \pi/2}$.  Thus,
$$\left ( 1-e^{i a \pi}\right ) \int_0^{\infty} dx \frac{x^{a-1}}{1+x^2}= i 2 \pi \frac{e^{i (a-1) \pi/2}}{2 i}$$
The result follows.
