TITLE: Evaluating an Integral by Residue Theorem
QUESTION [6 upvotes]: Its been awhile since I have taken complex analysis and I am wondering how to solve the following integral when $a>0, \ a=0,$ and $a<0$ for $$\int^{\infty}_0\frac{\cos ax+x\sin ax}{1+x^2}dx.$$
I know I can use the residue theorem thus  $$\int^{\infty}_0\left(\frac{\cos ax}{1+x^2}+\frac{x\sin ax}{1+x^2}\right)dx.$$

REPLY [4 votes]: Alternatively, you could consider $ \displaystyle f(z) = \frac{e^{iaz}}{z-i}$.
Then for $a >0$ we can use Jordan's lemma to conclude $$\int_{-\infty}^{\infty} \frac{e^{iax}}{x-i} \ dx = 2 \pi i \ \text{Res}[f(z),i] = 2 \pi i e^{-a}. $$
But $$ \begin{align} \int_{-\infty}^{\infty} \frac{e^{iax}}{x-i} \ dx &= \int_{-\infty}^{\infty} \frac{\Big(\cos(ax) + i \sin(ax) \Big)(x+i)}{x^{2}+1} \ dx \\ &= \int_{-\infty}^{\infty} \frac{x \cos (ax) - \sin(ax) + i \Big(\cos(ax) + x \sin(ax) \Big)}{x^{2}+1} \ dx . \end{align}$$
And equating the imaginary parts on both sides of the equation we get $$\int_{0}^{\infty} \frac{\cos (ax) + x \sin(ax)}{x^{2}+1} \ dx =  \pi e^{-a}. $$
Now if $a<0$, $ \displaystyle \int f(z) \ dz$ will vanish along the lower half of the circle $|z|=R$ as $R \to \infty$.
And since $f(z)$ is analytic in the lower half-plane, the integral in question evaluates to zero.