How resolve $$\int_{-\infty}^{\infty}\frac{\sin x}{x+i}dx$$
The hint is use $$\sin x=\frac{e^{ix}-e^{-ix}}{2i}$$
Well, when i did that
$$\int_{-\infty}^{\infty}\frac{\sin x}{x+i}dx=\frac{1}{2i}\int_{-\infty}^{\infty}\frac{e^{ix}-e^{-ix}}{x+i}dx= \frac{1}{2i}\int_{-\infty}^{\infty}\frac{e^{ix}}{x+i}dx-\frac{1}{2i}\int_{-\infty}^{\infty}\frac{e^{-ix}}{x+i}dx$$. In the second integral I use $u=-x$, then $$\frac{1}{2i}\int_{-\infty}^{\infty}\frac{e^{-ix}}{x+i}dx=-\frac{1}{2i}\int_{\infty}^{-\infty}\frac{e^{iu}}{-u+i}du=-\frac{1}{2i}\int_{-\infty}^{\infty}\frac{e^{ix}}{-x+i}dx$$
Hence the integral principal is equal to
$$\frac{1}{2i}\int_{-\infty}^{\infty}e^{ix}\left(\frac{1}{x+i}+\frac{1}{-x+i}\right)dx=\frac{1}{2i}\int_{-\infty}^{\infty}e^{ix}\left(\frac{-x+i+x+i}{-1-x^2}\right)dx$$ $$=\int_{-\infty}^{\infty}\left(\frac{-e^{ix}}{1+x^2}\right)dx$$.
The next step is look like integrate by parts i guess, but i believe is more complicate when appear $\ln (1+x^2)$. I am not sure if my way is correct, or perhaps exist other way with the hint. Please somebody can to help me. Thank you!!
Let $\gamma$ be the path along the real axis then circling back counter-clockwise through the upper half-plane, letting the circle get infinitely big. \begin{align} \left(\int_{-\infty}^\infty\frac{e^{ikx}}{x^2+a^2}\mathrm{d}x\right) &=\int_{\gamma}\frac{e^{ikx}}{x^2+a^2}\mathrm{d}x\\\\ &=2\pi i\,\mathrm{Res}\left(\frac{e^{ikx}}{x^2+a^2},ia\right)\\\\ &=2\pi i\,\lim_{z\to ia}\frac{e^{ikz}}{z+ia}\\\\ &=2\pi i\,\frac{e^{ik(ia)}}{2ia}\\\\ &=\frac{\pi}{a}e^{-ka} \end{align} Now , differentiating under the integral sign w.r.t $k$ , you get \begin{align} \int_{-\infty}^{\infty} \frac{e^{ikx}\cdot ix}{x^2+a^2}\mathrm{d}x = \frac{\pi}{a}e^{-ka} \cdot (-a) \end{align}
Setting $k=a=1$ and rearranging terms , you get \begin{align} \int_{-\infty}^{\infty} \frac{e^{ix}\cdot x}{x^2+1}\mathrm{d}x = -\frac{1}{i}\pi e^{-1}=i \frac{\pi }{e} \end{align}