Solve $ \int{x\sin^2(x)}\ dx$ I need to solve this integral:
$$ \int{x\sin^2(x)}\ dx $$
I SOLVED it by writting: $$ \sin^2(x) = \frac{1-\cos(2x)}{2} $$
and used integration by parts for $x\cos(2x)$, and the result is:
$$ \frac{1}{4}(x^2-x\sin(2x)-\frac{\cos(2x)}{2}) + C $$
I need to know other methods of solving this integral (preferable simple methods). Thank you!
 A: Hint:- Let $$I=\displaystyle\int x\sin^2 x\ dx$$$$J=\displaystyle\int x\cos^2 x\ dx$$Now observe that, $$I+J=\displaystyle\int x\ dx$$and $$I-J=\Re\left(\displaystyle\int xe^{2ix}\ dx\right)$$where $\Re\left(\displaystyle\int xe^{2ix}\ dx\right)$ denotes the real part of the integral.
A: Although this is a more complicated sotution way ,but different from your method $$\int { x\sin ^{ 2 } (x) } dx=\int { \sin ^{ 2 } (x)d\left( \frac { { x }^{ 2 } }{ 2 }  \right) =\frac { { x }^{ 2 }\sin ^{ 2 } (x) }{ 2 }  } -\frac { 1 }{ 2 } \int { { x }^{ 2 }\sin { 2x } dx } =\\ =\frac { { x }^{ 2 }\sin ^{ 2 } (x) }{ 2 } +\frac { 1 }{ 4 } \int { { x }^{ 2 }d\cos { 2x } =\frac { { x }^{ 2 }\sin ^{ 2 } (x) }{ 2 } +\frac { 1 }{ 4 } \left( { x }^{ 2 }\cos { 2x } -2\int { x\cos { 2xdx }  }  \right) = } \\ =\frac { { x }^{ 2 }\sin ^{ 2 } (x) }{ 2 } +\frac { 1 }{ 4 } \left( { x }^{ 2 }\cos { 2x } -\int { xd\sin { 2x }  }  \right) =\frac { { x }^{ 2 }\sin ^{ 2 } (x) }{ 2 } +\frac { 1 }{ 4 } \left( { x }^{ 2 }\cos { 2x } -x\sin { 2x+\int { \sin { 2xdx }  }  }  \right) =\\ =\frac { { x }^{ 2 }\sin ^{ 2 } (x) }{ 2 } +\frac { { x }^{ 2 }\cos { 2x- } x\sin { 2x }  }{ 4 } -\frac { 1 }{ 8 } \cos { 2x } +C$$
A: $$f(x)=\int x\sin(x)^2dx$$
$$f(x)=-\frac 14\int x\left(e^{2ix}+e^{-2ix}-2\right)dx$$
By applying the Tabular Method for Integration by parts you get
$$f(x)=-\frac 14\left(\frac x{2i}e^{2ix}+\frac 14 e^{2ix}-\frac x{2i}e^{-2ix}+\frac 14e^{-2ix}-x^2\right)+C$$
Gathering the terms, yields the same result.
