I tried to calculate the $\int_{-\infty}^{\infty}\frac{\sin{x}}{x}\mathrm{d}x$ by the complex integral $\oint_{\gamma}\frac{\sin{z}}{z}\mathrm{d}z$, where $\gamma$ is the half-circle with $y > 0$.
$$\begin{align*} \int_{-\infty}^{\infty}\frac{\sin{x}}{x}\mathrm{d}x &= \Im\left \{\oint_{\gamma}\frac{\mathrm{e}^{iz}}{z}\mathrm{d}z \right \}=\Im\left \{ 2\pi i Res\left [ \frac{\mathrm{e}^{iz}}{z}, 0 \right ] \right \}=\Im\left \{ 2\pi i \lim_{z\to0} \left ( z \frac{\mathrm{e}^{iz}}{z} \right ) \right \} \\ &= \Im\left \{ 2\pi i \lim_{z\to0} \mathrm{e}^{iz} \right \}=\Im\left \{ 2\pi i {e}^{i0} \right \}=\Im\left \{ 2\pi i \cdot 1 \right \}=2\pi \end{align*}$$ Now, I know the integral $\int_{-\infty}^{\infty}\frac{\sin{x}}{x}\mathrm{d}x = \pi$ by many other theorems. So, what did I do wrong?
If you know, can you please write the correct answer? Thanks!
Define for real $\;r>0\;$ :
$$\gamma_r^{\pm}:=\left\{\,z\in\Bbb C\;|\;\;|z|=r\;,\;\;\text{Im}>0\,\right\}$$
where the sign is $\;+\;$ if we take that half circle in the positive direction, and $\;-\;$ otherwise.
Now take the closed, simple path
$$\gamma:=[-R,-\epsilon]\cup\gamma_\epsilon^-\cup[\epsilon, R]\cup\gamma_R^+\;\;,\;\;\;0<R\in\Bbb R$$
Use now the corollary of this lemma to get for $\;f(z)=\cfrac{e^{iz}}z\;$ ,
$$\int_{\gamma_\epsilon^-}f(z)\,dz\xrightarrow[\epsilon\to0]{}-i\pi\cdot1=-\pi i$$
and then
$$0=\lim_{R\to\infty,\,\epsilon\to0}\int_\gamma f(z)\,dz=\int_{-\infty}^\infty f(x)\,dx-\pi i+0$$
and now just equate imaginary parts and we're done. Observe the integral over $\;\gamma_R\;$ vanishes at the limit because of Jordan's Lemma...or directly also by Cauchy's Estimate.