Answer
$$\int x \sin ^{2} x d x =\frac{1}{4}x^2-\frac{1}{4}\left(x\sin2x+\frac{1}{2}\cos2x \right)+c$$
Work Step by Step
$$
\int x \sin ^{2} x d x
$$
Since $$\sin^2x= \frac{1}{2}(1-\cos2x)$$
Then
\begin{align*}
\int x \sin ^{2} x d x&= \frac{1}{2}\int x(1-\cos2x)dx\\
&= \frac{1}{2}\int xdx-\frac{1}{2}\int x\cos2xdx\\
&=I_1-I_2
\end{align*}
where $$I_1=\frac{1}{2}\int xdx=\frac{1}{4}x^2+c$$
and $$\frac{1}{2}\int x\cos2xdx$$
Integrate by parts , let
\begin{align*}
u&=x\ \ \ \ \ \ \ dv=\cos2xdx\\
du&=dx\ \ \ \ \ \ \ v=\frac{1}{2}\sin2x
\end{align*}
then
\begin{align*}
I_2&=\frac{1}{2}\left(uv-\int vdu\right)\\
&=\frac{1}{2}\left(\frac{1}{2}x\sin2x-\frac{1}{2}\int \sin2xdx\right)\\
&=\frac{1}{4}\left(x\sin2x+\frac{1}{2}\cos2x \right)\\
\end{align*}
Hence
\begin{align*}
\int x \sin ^{2} x d x&=I_1-I_2\\
&=\frac{1}{4}x^2-\frac{1}{4}\left(x\sin2x+\frac{1}{2}\cos2x \right)+c
\end{align*}