Proving $\int_\mathbb R\frac{\sin(x)}{x}dx = \pi$ using the residue theorem I've been searching the web for a way to prove that $\int^{\infty}_{-\infty}{\sin(x)/x} = \pi$ with complex analysis, because I have a problem of consistency.
I found two, carried in the following link : Computing $\int_{-\infty}^\infty \frac{\sin x}{x} \mathrm{d}x$ with residue calculus. But then I wanted to find it by using the fact that :
$\sin(x)/x = \text{Im}(e^{ix}/x)$
To do so, I shifted the integration by $-i$ in the complex plane, showing that the integral on $[-\infty , \infty]$ is equal to the one on $[-\infty -i, \infty -i]$, since the integrand vanish on the vertical borders of the rectangle when we tend to infinity. I did this to get rid of the pole on the contour of integration.
Then, by using the residues theorem on the contour $C_1 : z = y-i, y \in [-R,R]$ and $C_2 : z = Re^{it}-i, t \in [0,\pi]$. Given the integral on $C_2$ vanishes, we have then that :
$\int^{\infty}_{-\infty}{\sin(x)/x} = \text{Im}(\int^{\infty}_{-\infty}{e^{ix}/x}) = \text{Im}(2\pi i\,\text{Res}(e^{iz}/z, 0)) = 2 \pi$
Which gives me the answer with a factor of $2$. I don't understand were did I go wrong ? I think it has something to do with the fact that I take the imaginary part of the integral, but I don't really know... Can someone spot my mistake ?
If needed, I can provide further detail on my calculations.
 A: The problem with your computation is that
$$
\int_{-\infty-i}^{\infty-i}\frac{\sin(x)}{x}\,\mathrm{d}x
\ne\mathrm{Im}\left(\int_{-\infty-i}^{\infty-i}\frac{e^{ix}}{x}\,\mathrm{d}x\right)
$$
since the integrand on the left has no singularities and the integrand on the right has one at $0$. One way to get around this is to use $\mathrm{Im}\left(\frac{e^{ix}-1}{x}\right)$ which also has no singularities. Another is to use the whole of the sine function as I did in this answer to your cited question.

Using the contours
$$
\gamma_1=[-R,R]\tag{1}
$$
and
$$
\gamma_2=Re^{i[0,\pi]}\tag{2}
$$
Consider the integral
$$
\begin{align}
\int_{-\infty}^\infty\frac{\sin(x)}{x}\,\mathrm{d}x
&=\mathrm{Im}\left(\int_{-\infty}^\infty\frac{e^{ix}-1}{x}\,\mathrm{d}x\right)\\
&=\mathrm{Im}\left(\int_{\gamma_1\cup\gamma_2}\frac{e^{iz}-1}{z}\,\mathrm{d}x-\int_{\gamma_2}\frac{e^{iz}-1}{z}\,\mathrm{d}z\right)\tag{3}
\end{align}
$$
Since there are no singularities of $\frac{e^{ix}-1}{x}$, the integral over $\gamma_1\cup\gamma_2$ is $0$. However, the integral over $\gamma_2$ is a bit more interesting.
Note that
$$
\begin{align}
\left|\,\int_{\gamma_2}\frac{e^{iz}}{z}\,\mathrm{d}z\,\right|
&\le\int_0^\pi e^{-R\sin(\theta)}\,\mathrm{d}\theta\\
&=2\int_0^{\pi/2} e^{-R\sin(\theta)}\,\mathrm{d}\theta\\
&\le2\int_0^{\pi/2} e^{-2R\theta/\pi}\,\mathrm{d}\theta\\[3pt]
&=\frac\pi{R}(1-e^{-R})\\[3pt]
&\le\frac\pi{R}\\[6pt]
&\to0\tag{4}
\end{align}
$$
and
$$
\begin{align}
\int_{\gamma_2}\frac1z\,\mathrm{d}z
&=\int_0^\pi\frac1{Re^{i\theta}}iRe^{i\theta}\,\mathrm{d}\theta\\
&=\int_0^\pi i\,\mathrm{d}\theta\\[6pt]
&=i\pi\tag{5}
\end{align}
$$
Putting together $(3)$, $(4)$, and $(5)$, we get
$$
\begin{align}
\int_{-\infty}^\infty\frac{\sin(x)}{x}\,\mathrm{d}x
&=\mathrm{Im}(i\pi)\\[6pt]
&=\pi\tag{6}
\end{align}
$$
