I don't understand the result of this: $\int e^x\cos(2x) \, dx$ Sorry for the simple question, I think when I find the answer I'll be like "ow how I didn't notice this..." Unfortunately I'm bad at math and i need help on this. 
So I don't understand the result of this: $$\int e^x\cos(2x)\,dx$$
Okay I integrated by parts twice and got this:
$$e^x\cos(2x)-\left( -2e^x\sin(2x)+4\int e^x\cos(2x)\,dx \right)$$
So we found our inital integral here and so we can isolate it. But the result is:
$$\int e^x\cos(2x)\,dx = \frac{2e^x\sin(2x)+e^x\cos(2)}5 +C$$
I'm having problem isolating our integral. I have no idea what happened to the 4 multiplying the integral and I have no idea where this $5$ came from.
 A: See that the original integral popped out in the right side. So call your integral:
$$I=\int e^x \cos{2x} \space dx$$
So now you have that:
$$I=e^x \cos{2x}+2e^x \sin{2x} -4I$$
And now you can just solve for I (you have an equation), and you have your integral (plus the constant, of course):
$$I=\frac{e^x \cos{2x}+2e^x \sin{2x} }{5}+C$$
A: Note that if we distribute the minus sign as Zach's comment suggested, we get
$$\int e^x\cos(2x)\,dx=e^x\cos(2x)+2e^x\sin(2x)-4\int e^x\cos(2x)\,dx).$$
Furthermore, if I add $4\int e^x\cos(2x)\,dx$ to both sides, I then have
$$5\int e^x\cos(2x)\,dx=e^x\cos(2x)+2e^x\sin(2x).$$ Finally, dividing both sides by $5$ achieves $$\int e^x\cos(2x)\,dx=\frac{e^x\cos(2x)+2e^x\sin(2x)}{5},$$ to which you would only need add a $+C$ to.
A: \begin{align}
& \int e^x\cos(2x)\,dx \\[10pt]
= {} & e^x\cos(2x)-\left( -2e^x\sin(2x)+4\int e^x\cos(2x)\,dx \right) \\[10pt]
\text{Adding } & 4\int e^x \cos(2x)\,dx \text{ to both sides yields} \\[10pt]
& 5\int e^x\cos(2x)\,dx = e^x\cos(2x) + 2e^2\sin(2x) + \text{constant.} \\[10pt]
\text{Then } & \text{divide both sides by $5$.}
\end{align}
A: Adding to @Villa's answer and now that you know how to solve it, you may replace $e^{x}$ by $e^{ax}$ and $\cos(2x)$ by $\cos(bx)$ then you can derive that:
$$\int e^{ax}\cos(bx)\,dx=\frac{e^{ax}}{a^2+b^2}\left(a\cos(bx)+b\sin(bx)\right)$$
Also,
$$\int e^{ax}\sin(bx)\,dx=\frac{e^{ax}}{a^2+b^2}\left(a\sin(bx)-b\cos(bx)\right)$$
This will save you some time.
