Answer
$$\frac{{{x^2}}}{4} - \frac{1}{4}x\sin 2x - \frac{1}{8}\cos 2x + C$$
Work Step by Step
$$\eqalign{
& \int {x{{\sin }^2}x} dx \cr
& {\text{Use the half - angle formula }}{\sin ^2}x = \frac{{1 - \cos 2x}}{2} \cr
& = \int {x\left( {\frac{{1 - \cos 2x}}{2}} \right)} dx \cr
& {\text{Distribute }} \cr
& = \int {\left( {\frac{x}{2} - \frac{{x\cos 2x}}{2}} \right)} dx \cr
& = \frac{1}{2}\int x dx - \frac{1}{2}\int {x\cos 2x} dx \cr
& = \frac{{{x^2}}}{4} - \frac{1}{2}\int {x\cos 2x} dx \cr
& \cr
& {\text{Calculate }}\int {x\cos 2x} dx \cr
& {\text{ by using integration by parts}} \cr
& \,\,\,\,u = x,\,\,\,du = dx \cr
& \,\,\,dv = \cos 2x,\,\,v = \frac{1}{2}\sin 2x \cr
& \,\,\int {x\cos 2x} dx = \frac{1}{2}x\sin 2x - \int {\left( {\frac{1}{2}\sin 2x} \right)dx} \cr
& \,\,\int {x\cos 2x} dx = \frac{1}{2}x\sin 2x + \frac{1}{4}\cos 2x + C \cr
& {\text{Then}}{\text{,}} \cr
& \frac{{{x^2}}}{4} - \frac{1}{2}\int {x\cos 2x} dx = \frac{{{x^2}}}{4} - \frac{1}{2}\left( {\frac{1}{2}x\sin 2x + \frac{1}{4}\cos 2x} \right) + C \cr
& = \frac{{{x^2}}}{4} - \frac{1}{4}x\sin 2x - \frac{1}{8}\cos 2x + C \cr} $$