How can the integral $\int_0^\frac{\pi}{2} x \cos ^n{x} dx$ be reduced? I tried to write $cos^nx$ as $\cos {x} \cos ^{n-1}{x}$ and then integrate by parts with the first function being $\cos ^{n-1}{x}$ and the second function being $x  \cos {x}$. I was able to solve upto a point but then I got stuck since I was not able to find a term which I could write as $I_{n-k}$ assuming that the integral in the title is $I_n$ and $k$ is any integer less than $n$. Am I taking incorrect functions to solve by parts or do I need to do any trigonometric manipulation using the limits of the integral?
 A: Set
$$f(n)=\int_0^{\pi/2}x\cos^n(x)dx.$$
From here we have the useful identities
$$\cos^{2n}(x)=\frac1{2^{2n}}{2n\choose n}+\frac{1}{2^{2n-1}}\sum_{k=0}^{n-1}{2n-1\choose k}\cos[2(n-k)x]$$
and $$\cos^{2n+1}(x)=\frac{1}{2^{2n}}\sum_{k=0}^{n}{2n+1\choose k}\cos[(2n-2k+1)x].$$
Instead of trying to find the general case $f(n)$, go for $f(2n)$ and $f(2n+1)$ separately. Using these identities and $\int(p_1(x)+p_2(x)+...+p_n(x))dx=\int p_1(x)dx+...+\int p_n(x)dx$, you reduce the problem to finding 
$$q(a)=\int_0^{\pi/2}x\cos(ax)dx,$$
which is easy once you integrate by parts. Can you take it from here?
A: To get a recurrence for the given integral, call it $I_n$, observe that $$I_{n-2}-I_n=\int_0^{\pi/2}x\cos^{n-2}x\sin^2 x\,dx=\int_0^{\pi/2}(x\sin x)(\cos^{n-2}x\sin x)\,dx,$$ which is ready to be integrated by parts: $$I_{n-2}-I_n=\frac{1}{n-1}\int_0^{\pi/2}\cos^{n-1}x(\sin x+x\cos x)\,dx=\frac{1}{n-1}\left(\frac{1}{n}+I_{n}\right),$$ yielding $I_n=\left(1-\frac{1}{n}\right)I_{n-2}-\frac{1}{n^2}$.
