Indefinite integral of $e^{-x} \sin x$ I'm trying to solve this indefinite integral using the integration by parts
$$ \int e^{-x} \sin(x) \,dx$$
but I'm stuck on the second iteration, which takes me to:
$$\int e^{-x} \sin(x) \,dx = -e^{-x} \sin(x) -e^{-x} \cos(x)-\int e^{-x}\sin(x) \,dx$$
Given the integration by parts formula of $\int u\,dv = uv - \int v\,du$ 
Which I applied twice, once with $u=\sin(x)$ and $du=e^{-x}$, and once with $u=\cos(x)$ and $du=e^{-x}$.
At this point my only guess was to simplify, having as result:
$$1 = -e^{-x} \sin(x) -e^{-x} \cos(x)-1$$
$$  = -e^{-x} (\sin(x) + \cos(x) + 2) $$
Which however appears to be wrong, since the correct answer should be:
$$ -\frac{1}{2} e^{-x} (\cos(x) + \sin(x))$$
Thanks in advance for your help
 A: I'm not sure what led you to suspect that $\int e^{-x}\sin x\,dx=1.$ Probably, as David points out in the comments, you were attempting to mimic an approach you'd seen before, but had thought the stand-in $I$ was a $1,$ instead. Also, there should always be something on both sides of an equation, so even if $\int e^{-x}\sin x\,dx=1$ were true, then you'd have $$0=-e^{-x}\sin x-e^{-x}\cos x-2,$$ or $$0=-e^{-x}(\sin x+\cos x)-2.$$ Do you see the differences between this and your last equation, and why this is "correct" under your misunderstanding?
A lot of times, as a space- and time-saving measure, we'll represent integrals as $I$ or $J$ while integrating by parts. We don't even need a stand-in, though, to solve it. Adding $\int e^{-x}\sin x\,dx$ to both sides of your equation, you get $$2\int e^{-x}\sin x\,dx=-e^{-x}\sin x-e^{-x}\cos x.$$ Pulling out the common factor of $-e^{-x}$ on the right-hand side, then multiplying both sides by $\frac12,$ we're done.
A: A cool solution, although not necessarily one that answers your question directly, that I came across while in high school was the following one that uses complex numbers. 
$$
I=\int{e^{-x}sinx}\mbox{ }dx\\J=\int{e^{-x}cosx\mbox{ }}dx
$$
Now we have that:
$$
J + iI = \int{e^{-x}\cdot e^{ix}\mbox{ }}dx = \int{e^{x(i-1)}}dx = \frac{e^{x(i-1)}}{i-1}
$$
And now we find that 
$$
\mathcal{Im}\left(\frac{e^{x(i-1)}}{i-1}\right) = I
$$
Hence $I = -\frac{1}{2}e^{-x}(\cos x + \sin x)$
A: You can obtain the result with a careful double integration by parts, but the simplest way is to use complex exponential. Indeed
$$\mathrm e^{-x}\sin x=\operatorname{Im}(\mathrm e^{-x}\mathrm e^{ix})=\mathrm e^{(-1+i)x},$$
so that, as $$\int \mathrm e^{(-1+i)x}\,\mathrm d x=\frac{\mathrm e^{(-1+i)x}}{-1+i}=-\frac{1+i}{2}\mathrm e^{-x}\mathrm e^{ix},$$
we obtain the required integral (and the integral of $\mathrm e^{-x}\cos x$ for the same price…):
\begin{align}\int \mathrm e^{-x}\sin x\,\mathrm d x&=-\frac12\mathrm e^{-x}(\cos x+\sin x),\\
\int \mathrm e^{-x}\cos x\,\mathrm d x&=\frac12\mathrm e^{-x}(\cos x-\sin x).
\end{align}
A: 
but I'm stuck on the second iteration, which takes me to:
$\int e^{-x} \sin(x) \,dx = -e^{-x} \sin(x) -e^{-x} \cos(x)-\int
 e^{-x}\sin(x) \,dx$  

Use algebra.  Add the integral to both sides and divide by 2.
A: To calculate $\int{e^{-x}\sin{(x)}dx}$
by parts you can choose either exponential or trigonometric function 
to integrate but in the second integration you should make the same choice as  you did in the first integration 
After second integration by parts you should have integral yo want to calculate on both sides of the equation and all you need to do is add constant multiple of  this integral to the both sides of the equation and divide by the constant in front of integral on the left hand side of the equation 
And don't forget +C
