TITLE: Contour integration using Cauchy's integral formula
QUESTION [5 upvotes]: I need to show that 
$$\int_{-\infty}^\infty\frac{\sin^2(x)}{x^2+1}dx=\frac{\pi}{2}\left(1-\frac{1}{e^2}\right)$$
but I don't really know why I'm not getting the result using contour integration (I'm not supposed to use the residue theorem). 
Can't I use Cauchy's integral formula this way:
$$\int_{\gamma_r} \dfrac{\frac{\sin^2(z)}{z+i}}{z-i}dz =2\pi i\frac{\sin^2(i)}{2i}$$
along boundary of the upper semicircle of radius r? The other path would be 0 (the boundary without the path along the real axis). What's the problem with this approach?

REPLY [2 votes]: Write
$$\sin^2{x} = \frac{1}{2} (1-\cos{2 x})$$
Then the above integral is equal to
$$\frac{1}{2} \int_{-\infty}^{\infty} \frac{dx}{1+x^2} - \frac{1}{2} \int_{-\infty}^{\infty} dx\frac{\cos{2 x}}{1+x^2} = \frac{\pi}{2} -  \frac{1}{2} \int_{-\infty}^{\infty} dx\frac{\cos{2 x}}{1+x^2}$$
Consider 
$$\oint_C dz \frac{e^{i 2 z}}{1+z^2}$$
where $C$ is a semicircle in the upper half-plane of radius $R$.  By the residue theorem, this integral is equal to $i 2 \pi$ time the sum of the residues of the poles inside $C$.  In this case, the only pole inside $C$ is at $z=i$, at which the residue is $e^{-2}/(2 i)$.  
Meanwhile, the contour integral vanishes along the semicircular contour in the limit as $R \rightarrow \infty$ (why?), so we are left with the integral along the real line:
$$\int_{-\infty}^{\infty} dx\frac{e^{i 2 x}}{1+x^2} = \int_{-\infty}^{\infty} dx\frac{\cos{2 x}}{1+x^2} = i 2 \pi \frac{e^{-2}}{2 i} = \frac{\pi}{e^2}$$
The result follows.