Solution:
Key idea: We integrate by parts twice, ∫uvdx=u∫vdx−∫(dxdu∫vdx)dx, keeping e−x as the second function, with ∫e−xdx=−e−x. The original integral I comes back, and we solve for it.
Step 1 — First use of parts.
We take u=sinx, so dxdu=cosx.
I=sinx(−e−x)−∫cosx(−e−x)dx
I=−e−xsinx+∫e−xcosxdx
Step 2 — Second use of parts.
Now we take u=cosx, so dxdu=−sinx.
∫e−xcosxdx=cosx(−e−x)−∫(−sinx)(−e−x)dx
∫e−xcosxdx=−e−xcosx−I
Step 3 — Put this back into Step 1.
We replace the integral in Step 1 by the result of Step 2.
I=−e−xsinx−e−xcosx−I
Step 4 — Solve for I.
We add I to both sides, divide by 2 and add the constant.
2I=−e−x(sinx+cosx)
I=−21e−x(sinx+cosx)+C
Therefore, ∫e−xsinxdx=−21e−x(sinx+cosx)+C.