Evaluate $\int e^x \sin^2 x \mathrm{d}x$ Is the following evaluation of correct?
\begin{align*} \int e^x \sin^2 x \mathrm{d}x &= e^x \sin^2 x -2\int e^x \sin x \cos x \mathrm{d}x \\ &= e^x \sin^2 x -2e^x \sin x \cos x + 2 \int e^x (\cos^2 x - \sin^2x) \mathrm{d}x \\ &= e^x \sin^2 x -2e^x \sin x \cos x + 2 \int e^x (1 - 2\sin^2x) \mathrm{d}x \\ &= e^x \sin^2 x -2e^x \sin x \cos x + 2 \int -2 e^x  \sin^2x \mathrm{d}x + 2 e^x \\ &= e^x \sin^2 x -2e^x \sin x \cos x  + 2 e^x -4 \int e^x  \sin^2x \mathrm{d}x \end{align*}
First two steps use integration by parts. In the first step we differentiate $\sin^2 x$. In the second step we differentiate  $\sin x \cos x$.
Using this, we reach $$5\int e^x \sin^2 x \mathrm{d}x = e^x \sin^2 x -2e^x \sin x \cos x  + 2 e^x$$
$$\int e^x \sin^2 x \mathrm{d}x = \frac{e^x \sin^2 x -2e^x \sin x \cos x  + 2 e^x}{5}+C$$
I can't reach the form that most integral calculators give, which has terms $\cos(2x)$ and $\sin(2x)$ by just using trig identities, so I wonder whether the result is correct. I would also be interested in a method that immediately gives the form $$-\frac{e^x[2 \sin(2x)+ \cos(2x)-5]}{10}+C$$
 A: Notice
$$\int e^x\sin^2x\mathrm{d}x=$$ $$=\int e^x\left(\frac{1-\cos 2x}{2}\right)\mathrm{d}x$$
$$=\frac{1}{2}\int e^xdx-\frac{1}{2}\int e^x \cos 2x \mathrm{d}x$$
Using $\displaystyle \int e^{ax}\cos (bx) \mathrm{d}x=\frac{e^{ax}}{a^2+b^2}(a\cos bx+b\sin bx)$, we get 
$$=\frac{1}{2}e^x-\frac{1}{2}\frac{e^x}{1^2+2^2}(\cos 2x+2\sin 2x)+C$$
$$=\frac{1}{2}e^x-\frac{1}{10}e^x(\cos 2x+2\sin 2x)+C$$
$$=-\frac{e^x(2\sin 2x+\cos 2x-5)}{10}+C$$
A: Let $$\displaystyle I = \frac{1}{2}\int e^x 2\sin^2 xdx = \frac{1}{2}\int e^x-\frac{1}{2}\int e^x \cos  2x dx$$
Now Using $$\displaystyle \cos \phi +i\sin \phi = e^{i\phi}$$ and $$\cos \phi-i\sin \phi = e^{-i\phi}.$$
So $$\displaystyle \cos \phi = \frac{e^{i\phi}+e^{-i\phi}}{2}$$
So we get $$\displaystyle \cos 2x = \left(\frac{e^{i2x}+e^{-i2x}}{2}\right)$$
so we get $$\displaystyle J = \bf{Re}\left[\int e^{x}\cdot \left(\frac{e^{i2x}+e^{-i2x}}{2}\right)dx\right] = \frac{1}{2}\bf{Re}\int \left[e^{(1+2i)x}+e^{(1-2i)x}]\right]dx$$
So we get $$\displaystyle J = \frac{1}{2}\bf{Re}\left[\frac{e^{(1+2i)x}}{(1+2i)}+\frac{e^{1-2i}}{(1-2i)}\right]$$
$$\displaystyle  = \frac{e^x}{10}\bf{Re}\left[\left(\cos 2x+i\sin 2x\right)\cdot (1-2i)+\left(\cos 2x-i\sin 2x\right)\cdot (1+2i)\right]$$
So $$\displaystyle J = \frac{e^x}{10}\left[2\cos 2x+4\sin 2x\right] = \frac{e^x}{5}\left[\cos 2x+\sin 2x\right]$$
So $$\displaystyle I = \frac{e^x}{2}-\frac{e^x}{10}\left[\cos 2x+2\sin 2x\right]+\mathcal{C} = -\frac{e^x}{10}\left[\cos 2x+2\sin 2x-5\right]+\mathcal{C}$$
A: We have $$\int e^{x}\sin^{2}\left(x\right)dx=\frac{1}{2}\int e^{x}dx-\frac{1}{2}\int e^{x}\cos\left(2x\right)dx
 $$ and $$\int e^{x}\cos\left(2x\right)dx=\textrm{Re}\left(\int e^{x+2ix}dx\right)
 $$ then $$\int e^{x+2ix}dx=\frac{e^{x+2ix}}{1+2i}
 $$ and so $$\int e^{x}\sin^{2}\left(x\right)dx=\frac{1}{2}e^{x}-\frac{1}{2}e^{x}\left(\frac{\cos\left(2x\right)+2\sin\left(2x\right)}{5}\right)+C=$$ $$=-\frac{e^{x}\left(\cos\left(2x\right)+2\sin\left(2x\right)-5\right)}{10}+C.
 $$
A: You can use the Reduction formula:
$$I_n=\int e^{ax}\sin^n bx\mathrm. dx\\
=\frac{e^{ax}\sin^{n-1} bx (a\sin bx-nb\cos bx)}{a^2+n^2b^2}+\frac{n(n-1)b^2}{a^2+n^2b^2}I_{n-2}$$
Use $n=2,a=1,b=1$.
A: Your solution is correct. To reach to required form See here,You allready Got this
$$\int e^x \sin^2 x \mathrm{d}x = \frac{e^x \sin^2 x -2e^x \sin x \cos x  + 2 e^x}{5}+C$$
Now multiply and divide your result by $2$, you will get
$$\frac{2e^x \sin^2 x -4e^x \sin x \cos x  +4e^x}{10}+C\\
=\frac{2e^x \sin^2 x -4e^x \sin x \cos x  +4e^x+e^x-e^x}{10}+C\\
=\frac{2e^x \sin^2 x-e^x -4e^x \sin x \cos x  +5e^x}{10}+C\\
=\frac{e^x(2 \sin^2 x-1) -4e^x \sin x \cos x  +5e^x}{10}+C\\
=-\frac{e^x[2 \sin(2x)+ \cos(2x)-5]}{10}+C$$
Where we used the identities 
1) $2 \sin^2 x-1=-\cos 2x$
2)$2\sin x\cos x= \sin 2x $
A: $$\int \left(e^x\sin^2(x)\right)\text{d}x =$$
$$\int \left(e^x\left(\frac{1}{2}(1-\cos(2x))\right)\right)\text{d}x =$$
$$\frac{1}{2}\int \left(e^x-e^x\cos(2x)\right)\text{d}x =$$
$$\frac{1}{2} \left(\int \left(e^x\right) \text{d}x-\int \left(e^x\cos(2x)\right) \text{d}x\right) =$$
$$\frac{1}{2} \left(\int e^x \text{d}x-\int e^x\cos(2x) \text{d}x\right) =$$
$$\frac{1}{2} \left(e^x-\int e^x\cos(2x) \text{d}x\right) =$$

For the integrand $e^x\cos(2x)$, use the formula:
$$\int\exp(\alpha x)\cos(\beta x)\text{d}x=\frac{\exp(\alpha x)(\alpha \cos(\beta x))+\beta\sin(\beta x)}{\alpha^2+\beta^2}$$

$$\frac{1}{2} \left(e^x-\frac{e^x(2\sin(2x)+\cos(2x))}{5}\right) + C =$$
$$-\frac{e^x(2\sin(2x)+\cos(2x)-5)}{10} + C $$
