How to evaluate $\int_{0}^{\infty} \frac{x^{-\mathfrak{i}a}}{x^2+bx+1} \,\mathrm{d}x$ using complex analysis? We were told today by our teacher (I suppose to scare us) that in certain schools for physics in Soviet Russia there was as an entry examination the following integral given 

$$\int\limits_{0}^{\infty} \frac{x^{-\mathfrak{i}a}}{x^2+bx+1} \,\mathrm{d}x\,,$$ 

where $a \in \mathbb{R}$, $b \in [0,2)$, and $\mathfrak{i}$ is the imaginary unit. And since we are doing complex analysis at the moment, it can, according to my teacher, be calculated using complex methods. 

I was wondering how this could work? It seems hard to me to find a good curve to apply the residue theorem for this object, I suppose. Is there a trick to compute this integral?
$\phantom{}$ Dear MSE users, this is the new episode of Mister Feynman and Monsieur Laplace versus contour integration.

Tonight we have a scary integral, but we may immediately notice that
$$ \mathcal{L}(x^{-ia})(s) = s^{ia-1}\Gamma(1-ia),\qquad \mathcal{L}^{-1}\left(\frac{1}{x^2+bx+1}\right)(s) =\frac{e^{Bs}-e^{\overline{B}s}}{\sqrt{b^2-4}}$$
where $B$ is the root of $x^2+bx+1$ with a positive imaginary part. By the properties of the Laplace transform, the original integral is converted into
$$\frac{\Gamma(1-ia)}{\sqrt{b^2-4}}\int_{0}^{+\infty}s^{ia-1}\left(e^{Bs}-e^{\overline{B}s}\right)\,ds$$
which can be evaluated in terms of the $\Gamma$ function. Due to the reflection formula, the final outcome simplifies into
$$ \frac{\left(B^{-i a}-\overline{B}^{-i a}\right) \pi }{\sinh(\pi a)\sqrt{4-b^2}} $$
and  we may notice that $B=\exp\left[i\arccos\frac{b}{2}\right]$ allows a further simplification.

Outro: poor children.
In a complex analysis class, you’re more likely to come across the integral $$\int_{0}^{\infty} \frac{x^{\alpha}}{1+2x \cos \beta +x^{2}} \, dx = \frac{\pi \sin (\alpha \beta)}{\sin(\alpha \pi) \sin(\beta)},  \quad (-1&lt;\alpha &lt;1, \ 0 &lt; \beta &lt; \pi).$$

See this answer, for example, which uses a semicircle in the upper half-plane that is indented at the origin.

Alternatively, you could also use the keyhole contour that Shashi used.

Also see this question about the peculiar symmetry of this integral when it's written in a slightly different form.

The function on the right is not defined at $\alpha =0$. But you could show separately (by using the same contour or by completing the square) that the value of the integral at $\alpha =0$ is $$\lim_{a \to 0} \frac{\pi \sin (\alpha \beta)}{\sin(\alpha \pi) \sin(\beta)} = \frac{\beta}{\sin \beta}.$$

Now if we assign the function on the right the value $\frac{\beta}{\sin \beta}$ at $\alpha =0$, then right side of the equation is a holomorphic function for $-1 &lt;\operatorname{Re}(\alpha) &lt;1$ with $\beta$ fixed.

And since the integral on the left is absolutely convergent in the strip $-1 &lt; \operatorname{Re}(\alpha) &lt; 1$, we can use a property of the Mellin transform that states that the integral defines an holomorphic function in that strip. 

(This is very similar to property of the Laplace transform mentioned here, and can be proved in essentially the same manner.)

So by the identity theorem, the formula holds for $-1 &lt;\operatorname{Re}(\alpha) &lt;1$.

Your integral is the case $\alpha=-ia$ and $\cos(\beta) = \frac{b}{2}$.

If $b\in [0, 2)$, then $\beta$ falls between means  $0$ and $\pi$, and we get

$$\begin{align} \int_{0}^{\infty} \frac{x^{-ia}}{x^{2}+bx+1} \, dx &amp;= \frac{\pi \sin\left(-ia \arccos\left(\frac{b}{2} \right)\right)}{\sin(-ia \pi) \sin \left(\arccos \left(\frac{b}{2} \right) \right)} \\ &amp;= \frac{\pi \sinh \left(a \arccos\left(\frac{b}{2} \right) \right)}{\sinh(a \pi)\frac{\sqrt{4-b^{2}}}{2}}. \end{align} $$