I'm often stuck at choosing the right contour to integrate along. Are there some general rules of thumb to choose a suitable one?
For example, I got stuck at this one: $ \displaystyle \int_{0}^{\infty}\frac{x^a}{1+x^2} dx$ with $a\in \mathbb{R}$ and $0<|a|<1$
What would be the procedure to come up with a suitable contour?
In this case, there are a couple of approaches that work. Here, because the denominator just has an $x^2$, you can simply use a semicircle in the upper (or lower) half plane with a small semicircular notch cut out about the origin to avoid the branch point at the origin. In this case, you would need to split the integral along the real axis up for negative and positive values of $x$. The result is that $1-e^{i \pi a}$ times the integral is $i 2\pi$ times the residue at the pole $z=i$ for the contour in the upper half plane.
A contour that works for more general cases is a keyhole contour about the positive real axis. In this case, $1-e^{i 2 \pi a}$ times the integral is $i 2 \pi$ times the sum of the residues at the poles $z= i$ and $z= -i$. This contour works because it exploits the multivaluedness of the $x^a$ piece.