I need to calculate $\int_{-\infty}^{\infty}\frac{e^{-i x}}{x^2+1}dx$ using the Residue theorem.
I know that I should choose an upper semicircle so that for
$\gamma=\left \{ z\in\mathbb{C}: z=Re^{it}, t\in[0,\pi] \right \}$
$\left | \int_{\gamma}^{ }\frac{e^{-i z}}{z^2+1}dz \right |\overset{R\rightarrow \infty}{\rightarrow}0$
Then I'm left with the original integral which now equals to
$2\pi i Res(\frac{e^{-i z}}{z^2+1},i)=2\pi i (-\frac{i e}{2})=\pi e$
But if I choose a lower semicircle the answer is
$2\pi i (-Res(\frac{e^{-i z}}{z^2+1},-i))=2\pi i (-\frac{i}{2e})=\frac{\pi}{e}$
Why do I get 2 different answers for the same integral? Where is my mistake?
Thanks
It's not as if you had an option here. The integral along the top half of the semicircle centered at $0$ with radius $R$ goes to $\infty$ as $R\to\infty$. This does not occur with the bottom half; in that case, it goes to $0$.
If the numerator was $e^{ix}$, then you would have to choose the top half and not the bottom half.