Solve $\int xe^x \cos(2x) \mathrm dx$

calculusintegration

$$\int xe^x \cos(2x) \mathrm dx$$

I have been trying to solve this for some time by using integration by parts, but can't figure out how to divide it into suitable parts. It becomes some sort of loop. Can anyone help as to which ones I should take as $u$ and $v$?
Also, is there any other method to approach this problem? Because, integration by parts might get lengthy, perhaps.

Best Answer

Hint. A small trick: note that $\cos(2x)=\operatorname{Re} (e^{2ix})$, so we consider the integral $$I=\int xe^xe^{2ix}\mathrm dx=\int xe^{(1+2i)x}\mathrm dx.$$ A trivial integration by parts will give the expression of $I$ and the desired integral is obtained by taking the real part of $I$.

The expression for $I$:

\begin{align*} I=\int xe^{(1+2i)x}\mathrm dx=\frac{xe^{(1+2i)x}}{1+2i}-\frac{e^{(1+2i)x}}{(1+2i)^2}+C.\end{align*}

Taking the real part:

We compute that \begin{align*} \frac{x}{1+2i}-\frac{1}{(1+2i)^2}=\frac{(-3-4i)(x-1+2xi)}{25}=\frac{5x+3-2(5x-2)i}{25}, \end{align*} hence $$I= \frac{5x+3-2(5x-2)i}{25}e^x(\cos 2x+i\sin 2x)+C$$ and thus $$\operatorname{Re} I=\frac{e^x}{25}\left(2(5x-2)\sin 2x+(5x+3)\cos 2x\right)+C.$$

Related Question