Evaluating the complex integral $\int_{-\infty}^\infty \frac{\cos(x)}{x+i}\,dx$ I stumbled upon this particular integral a few minutes ago, and I have no idea how to go about it :
$$\int_{-\infty}^\infty \frac{\cos(x)}{x+i}\,dx$$
I looked up on the internet and I managed to find out that something called residue should be taken into account when dealing with such integrands, but I'm clueless at this point in matters of complex analysis. As context, a colleague of mine suggested this could be an interesting exercise. 
Any ideas ?
 A: If you are not aware of the residue theorem, things are harder, but not impossible.
Step 1. The integral is converging in virtue of Dirichlet's test, since $\cos x$ has a bounded primitive and $\left|\frac{1}{x+i}\right|$ decreases to zero as $|x|\to +\infty;$
Step 2. By symmetry (the cosine function is even) we have:
$$ I = \int_{\mathbb{R}}\frac{\cos x}{x+i}\,dx = -2i\int_{0}^{+\infty}\frac{\cos x}{1+x^2}\,dx $$
so we just need to compute a real integral;
Step 3. We may compute the Fourier cosine transform of $e^{-|x|}$ through intergration by parts. That gives that the CF of the Laplace distribution, by Fourier inversion, is everything we need to be able to state:
$$ \int_{0}^{+\infty}\frac{\cos x}{1+x^2}\,dx = \frac{\pi}{2e}.$$
A: $$\int_{-\infty}^{\infty}\frac{\cos(x)dx}{x+i} =\int_{-\infty}^{\infty}\frac{(x-i)\cos(x)dx}{x^2+1}= -i \int_{-\infty}^{\infty}\frac{\cos(x)dx}{x^2+1}= -\frac{i\pi}{e}$$
The last integral is a standard integral that can easily be done using the residue theorem [replace cos(x) by exp(i x), integrate from -R to R and then take a half circle in the upper half plane back to -R, in the limit of R to infinity that integral over the half circle vanishes and you're left with the desired integral, while by the residue theorem, the contour integral is 2 pi i times the coefficient of 1/(x-i) in the expansion around the singularity at i, basically because all contour integrals of analytic functions are zero (if you are back from where you are starting from the limits of the starting and end points are the same), but 1/z yields log(z) when integrated and going round the singularity once yields 2 pi i for the integral]
but perhaps there are elementary methods to do this integral. 
