Solution:
Concept: When an integrand is a sum of two pieces, integrating one piece by parts can produce an integral that cancels the other piece. Integration by parts: ∫uvdx=u∫vdx−∫(dxdu∫vdx)dx.
Step 1 — Split the integral.
We separate the two terms of the bracket.
I=−∫e2xsinxdx+∫2e2xcosxdx
Step 2 — Integrate the second piece by parts.
We take cosx as the first function and 2e2x as the second, because ∫2e2xdx=e2x is simple.
∫2e2xcosxdx=cosx⋅e2x−∫(−sinx)e2xdx
∫2e2xcosxdx=e2xcosx+∫e2xsinxdx
Step 3 — Combine the pieces.
We put Step 2 into Step 1. The two integrals ∫e2xsinxdx have opposite signs, so they cancel.
I=−∫e2xsinxdx+e2xcosx+∫e2xsinxdx
I=e2xcosx+C
Step 4 — Check by differentiating.
The derivative of e2xcosx is 2e2xcosx−e2xsinx, which is the integrand.
Note: This is the pattern ∫eax[af(x)+f′(x)]dx=eaxf(x)+C; here a=2, and f(x)=cosx.
Therefore, ∫e2x(−sinx+2cosx)dx=e2xcosx+C.