I am trying to figure out the example below, but I still cannot get the right result (I don't know it though, I am just sure this is not the right one).

What should be the proper procedure to solve this example?
Thank you very much
I am trying to figure out the example below, but I still cannot get the right result (I don't know it though, I am just sure this is not the right one).

What should be the proper procedure to solve this example?
Thank you very much
You need to use the integration by parts two times: if
$$\int x^2 \sin x dx$$
then $u=x^2 \Rightarrow du=2x dx$ and $dv=\sin x dx \Rightarrow v=-\cos x$. Then, $$\int x^2 \sin x dx =-x^2\cos x-\int -\cos x \cdot 2x dx=-x^2\cos x+2\int x\cos x dx. $$
Now, $u=x \Rightarrow du =dx$ and $dv=\cos xdx \Rightarrow v=\sin x$ and so $$\int x^2\sin x dx = -x^2\cos x+2\left( x\sin x -\int \sin x dx\right)= $$ $$=-x^2\cos x+2x\sin x+2\cos x +c. $$
Note that this exercise which "bothered him" the question was the factor $ x ^ 2 $, so we apply integration by parts twice to "extract" this factor.