# Why is $\int e^{-xy}\sin{x} dx = \frac{e^{-xy}(y\sin{x}+\cos{x})}{1+y^2}$

Why would $$\int e^{-xy}\sin{x} dx = \frac{e^{-xy}(y\sin{x}+\cos{x})}{1+y^2}$$

My calculation:

$$\int e^{-xy}\sin{x} dx=\Im\int e^{-xy}(\cos{x}+i\sin{x})dx$$

and $$\int e^{-xy}(\cos{x}+i\sin{x})dx=-\frac{1}{y-i}e^{x(i-y)}=-\frac{1}{y^2+1}e^{x(i-y)}$$

Now $$\Im -\frac{1}{y^2+1}e^{x(i-y)}=\Im-\frac{e^{-xy}}{y^{2}+1}(\cos{x}+i\sin{x})=-\frac{e^{-xy}}{y^{2}+1}\sin{x}$$

In the solutions, it says: $$\int e^{-xy}\sin{x} dx=\frac{e^{-xy}(y\sin{x}+\cos{x})}{1+y^2}$$

Where am I going wrong?

You dropped a $$y+i$$ factor before "now".
I get $$\int e^{-xy}\sin{x}\; dx = \color{red}{-}\frac{e^{-xy}(y\sin{x}+\cos{x})}{1+y^2} (+C)$$ Here a way using partial integration twice:
With $$I(y) = \int \underbrace{e^{-xy}}_{u}\underbrace{\sin{x}}_{v'}\;dx$$ you get $$\begin{eqnarray*} I(y) & = & -e^{-xy}\cos x - y \int e^{-xy}\cos{x} \; dx \\ & = & -e^{-xy}\cos x - y \left(e^{-xy} \sin x + y \underbrace{\int e^{-xy}\sin{x} \; dx }_{= I(y)}\right)\\ & = & -e^{-xy}\cos x - ye^{-xy} \sin x - y^2 I(y)\\ \end{eqnarray*}$$ It follows $$(1+y^2)I(y) = - -e^{-xy}(\cos x +y \sin x) \Leftrightarrow \boxed{I(y) = -\frac{e^{-xy}(y\sin{x}+\cos{x})}{1+y^2} (+C)}$$