<s>[INST] Compute $\int x^2 \cos \frac{x}{2} \mathrm{d}x$ I am trying to compute the following integral:
$$\int x^2 \cos \frac{x}{2} \mathrm{d}x$$
I know this requires integration by parts multiple times but I am having trouble figuring out what to do once you have integrated twice. This is what I have done:
Let $u = \cos \frac{x}{2}$ and $\mathrm{d}u = \frac{-\sin\left(\dfrac{x}{2}\right)}{2} \mathrm{d}x$ and $\mathrm{d}v = x^2$ and $v= \frac{x^3}{3}$. 
\begin{align}
&\int x^2 \cos \frac{x}{2} \\
&\cos \frac{x}{2} \cdot \frac{x^3}{3} - \int \frac{x^3}{3} \cdot \frac{-\sin\left(\dfrac{x}{2}\right)}{2} \mathrm{d}x
\end{align}
So now I integrate $\int \frac{x^3}{3} \cdot \frac{-\sin\left(\dfrac{x}{2}\right)}{2} \mathrm{d}x$ to get: 
\begin{align}
\frac{-\sin\left(\dfrac{x}{2}\right)}{2} \cdot \frac{x^4}{12} - \int \frac{x^4}{12} \cdot \frac{\cos x}{2}
\end{align}
Now, this is where I get stuck. I know if I continue, I will end up with $\frac{-\sin\left(\dfrac{x}{2}\right)}{2}$ again when I integrate $\cos \frac{x}{2}$. So, where do I go from here? 
Thanks!
 [/INST] let S be the integrate... That is, S x"2cosx/2 dx........let u=x"2 and dv=cosx/2dx. so that, du=2x and v=2sinx/2 dx. Therefore, S x"2cosx/2 dx= x"2(2sinx/2)-S 2sinx/2(2x) =2x"2sinx/2-S 2x.2sinx/2 dx = 2x"2sinx/2-4 S xcosx/2 dx. Apply another integration. S xcosx/2 dx. let u=x and dv=cosx/2dx. so that du=(1)dx=dx and v=2sinx/2 dx. Hence, S xcosx/2 dx=x(2cosx/2)-S 2sinx/2 dx. combining all formulas we get. S x"2cosx/2dx=2x"2sin(x/2)-2(4xcos(x/2)-S 2sin(x/2) dx). That is, S x"2sin(x/2)+8xcos(x/2)-16sin(x/2) dx = 2x"2sin(x/2)+8xcos(x/2)-16sin(x/2)+C. SO, (2x"2-16)sin(x/2)+8xcos(x/2)+C. I hope this help. By O'john
</s>