Integrate $\int x\sin^2 (x) dx$ Integrate $\int x\sin^2 (x) dx$
My attempt:
$$=\int x\sin^2 (x) dx\\
=x^2\sin^2 (x) - \int 2\sin (x)\cos (x)x^2 dx\\
=x^2\sin^2 (x) - \int \sin (2x) x^2 dx.$$
 A: Since $\sin^2(x)=(1-\cos(2x))/2$ then
$$\int x\sin^2 (x) dx=\frac{1}{2}\int x dx-\frac{1}{2}\int x\cos (2x) dx.$$
Now for the second integral (which is easier because the cosine is not squared) use integration by parts:
$$\int x\cos (2x) dx=\frac{1}{2}x\sin (2x)-\frac{1}{2}\int \sin (2x) dx.$$
Can you take it from here?
A: Take $\int x\sin ^2(x)dx = \int udv$, where $u = x\sin x$ and $dv = \sin (x)dx$. Then by integrating by parts we get
$$ \int x \sin ^2(x) dx = -x\sin (x)\cos x + \int (\sin x + x\cos x)\cos (x)dx =\ldots $$
Now, with $\cos ^2x = 1-\sin ^2x$ we get
$$\ldots = -x\sin (x)\cos x + \int \sin (x)\cos (x) dx + \int x\left (1-\sin ^2x\right )dx +C.$$
Collect same quantities to get
$$2\int x\sin ^2(x) dx = -x\sin (x)\cos x + \frac{\sin ^2x}{2} + \frac{x^2}{2}+C.$$
For a more pretty result, we can multiply both sides by $2$, then
$$4\int x\sin ^2(x)dx  = \sin ^2x + x^2 - x\sin (2x) + C.$$
A: Here is a method using tabular integration, where we use $\sin^2 x = \frac{1}{2} (1 - \cos 2x)$:
$$\begin{array}{c|c} D & I \\ \hline \color{red}{x} & \frac{1}{2} - \frac{1}{2} \cos(2x) \\ \hline  \color{blue}{1} & \color{red}{\frac{1}{2}x - \frac{1}{4} \sin(2x)} \\ \hline 0 & \color{blue}{\frac{1}{4}x^2 + \frac{1}{8} \cos(2x)} \end{array}$$
hence:
$$\int x \sin^2 (x) \ dx = \color{red}{+}x \left(\frac{1}{2}x - \frac{1}{4} \sin(2x) \right) \color{blue}{-}  \left(\frac{1}{4}x^2 + \frac{1}{8} \cos(2x) \right) +C$$
$$= \frac{1}{4}x^2 - \frac{1}{4} x \sin(2x) - \frac{1}{8} \cos(2x) +C.$$
