# Computing Definite Integrals using Complex Variables and the Residue Therorem

I was trying to prove the definite integral $$\displaystyle{\int_{-\infty}^{\infty}}\frac{dx\,x\sin{x}}{x^2+a^2}={\pi}e^{-a}$$ by using contour integration and the Residue Theorem. I checked the solution and there I am having a doubt. It says :

if we consider the integrand as it stands, the contour cannot be closed with a semicircle in either the upper or the lower half-plane, because $$\sin{z}$$ is a linear combination of $$e^{iz}$$ and $$e^{−iz}$$ . If we let $$|z|\to\infty$$ in the lower half-plane, the term $$e^{iz}$$ diverges; on the other hand, the term $$e^{−iz}$$ diverges if $$|z|\to\infty$$ in the upper half-plane. You can easily get around this difficulty by writing $$\sin{z}=\displaystyle{\frac{e^{iz} − e^{−iz}}{2i}}$$ and splitting the integral into two integrals. Close the contour in the upper half-plane in the case of $$e^{iz}$$ and in the lower half-plane in the case of $$e^{−iz}$$, and pick up the residue at the enclosed pole in each case.

I do not understand that how can the term $$e^{iz}$$ diverge if we let $$|z|\to\infty$$ in the lower half plane; after all, for real $$x$$, $$e^{ix}$$ diverges as $$x\to+\infty$$ . So, shouldn't that be $$|z|\to\infty$$ in the upper half plane to make $$e^{iz}$$ diverge? Similarly I have doubt for the divergence of the term $$e^{-iz}$$ .

The solution also states an alternative method :

Alternatively, you can first write $$\sin x$$ as the imaginary part of $$e^{ix}$$, and then consider the integral $$\displaystyle{\int_{−\infty}^{\infty}}\frac{dx\,x e^{ix}}{(x^2 + a^2)}$$. The contour can now be closed in the upper half-plane (and not in the lower half-plane). After you evaluate the integral, take its imaginary part to get the value of the original integral.

My question is: why should I take the contour in the upper half plane and not in the lower half plane? Please clarify.

The issue is that the usual infinite-semicircle contour encloses imaginary numbers too. Along the negative imaginary axis,$$\lim_{x\to\color{red}{\infty}}e^{ix}=\lim_{\Im x\to-\color{blue}{\infty}}e^{-\Im x}=e^\color{blue}{\infty}=\color{blue}{\infty},$$where the red (blue) $$\infty$$ is the complex point at infinity (extended real $$+\infty$$). If this argument is hard to follow, consider e.g. $$e^{i(-10000i)}=e^{10000}$$ in the lower half of the complex plane.
Your integral is $$I=\int _{-\infty }^{\infty }\frac{x\sin \left(x\right)}{x^2+a^2}\:dx$$ Now consider the following integral: $$I\left(b\right)=\int _{-\infty }^{\infty }\frac{x\sin \left(bx\right)}{x^2+a^2}\:dx$$ $$=\underbrace{\int _{-\infty }^{\infty }\frac{\sin \left(bx\right)}{x}\:dx}_{\pi}-a^2\int _{-\infty }^{\infty }\frac{\sin \left(bx\right)}{x\left(x^2+a^2\right)}\:dx$$ $$I'\left(b\right)=-a^2\int _{-\infty }^{\infty }\frac{\cos \left(bx\right)}{x^2+a^2}\:dx$$ $$I''\left(b\right)=a^2\underbrace{\int _{-\infty }^{\infty }\frac{x\sin \left(bx\right)}{x^2+a^2}\:dx}_{I\left(b\right)}$$ $$I''\left(b\right)-a^2I\left(b\right)=0$$ The general form of that differential equation is: $$I\left(b\right)=C_1e^{ab}+C_2e^{-ab}$$ Now lets find the constants. $$I\left(0\right)=C_1+C_2=\pi$$ $$I'\left(0\right)=aC_1-aC_2=-\pi a$$ Meaning that $$C_1=0$$ and $$C_2=\pi$$ Thus, $$I\left(b\right)=\pi e^{-ab}$$ $$I=\pi e^{-a}$$