Definite integral of $x\sin^n x$ from $0$ to $\pi/2$ How to find
\begin{equation*}
\int_0^{\pi/2} x\sin^n x dx
\end{equation*}
where $n$ is a positive integer? I tried $y=x-\pi/4$ and that gives
\begin{equation*}
\frac{1}{2^{n/2}}\frac{\pi}{4}\int_{-\pi/4}^{\pi/4} (\sin y+\cos y)^n dy+\frac{1}{2^{n/2}}\int_{-\pi/4}^{\pi/4} y(\sin y+\cos y)^n dy.
\end{equation*}
Although some terms may be canceled, the summation of the others seems terrible.
Another method is integration by parts. Here I found the recurrence formula for $\sin^n x$:
Integrating $\int \sin^n{x} \ dx$
So the first step is to have
\begin{equation*}
\left.\left(-\frac{1}{n}x\cos x\sin^{n-1} x+\frac{n-1}{n}x\int \sin^{n-2} xdx\right)\right|_0^{\pi/2}-\int_0^{\pi/2}\left(-\frac{1}{n}\cos x\sin^{n-1} x+\frac{n-1}{n}\int_0^x \sin^{n-2} t dt\right)dx
\end{equation*}
the evaluations at $0$ and $\pi/2$ and the integral of $\cos x\sin^{n-1}x$ seem OK, but what about the second term? Any better method for this problem?

Assuming that $n$ is odd ($n=2m+1$), we may consider the triangle wave
$$ t(x) = \frac{4}{\pi}\sum_{n\geq 0}\frac{(-1)^n}{(2n+1)^2}\,\sin((2n+1)x)$$
and the fact that, by symmetry,
$$ \int_{0}^{\pi/2}x\sin^n(x)\,dx = \frac{1}{4}\int_{0}^{2\pi}t(x)\sin^n(x)\,dx. $$
On the other hand the Fourier sine series of $\sin^n(x)$ is straightforward to find:
$$ \sin^n(x) = \frac{1}{2^{n-1}}\sum_{k=0}^{m}\binom{n}{m-k} (-1)^k \sin((2k+1)x)$$
hence by the orthogonality relations:
$$\boxed{ \int_{0}^{\pi/2}x \sin^{2m+1}(x)\,dx = \frac{1}{2^{2m+1}}\sum_{k=0}^{m}\binom{2m+1}{m-k}\frac{1}{(2k+1)^2}}\tag{odd}$$
If $n$ is even we may similarly consider the Fourier cosine series of $\sin^n(x)$ and replace $x$ with the $\pi$-periodic continuation of $\frac{\pi}{2}-\left|\frac{\pi}{2}-x\right|$ over $[0,\pi]$, i.e. just a different triangle wave:
$$ T(x) = \frac{\pi}{4}-\frac{2}{\pi}\sum_{n\geq 0}\frac{\cos((4n+2)x)}{(2n+1)^2} = |t(x)|$$
leading to:
$$ \boxed{\int_{0}^{\pi/2}x \sin^{2m}(x)\,dx = \frac{\binom{2m}{m}\pi^2}{8\cdot 4^m}+\frac{1}{2^{2m}}\sum_{\substack{1\leq k\leq m\\k\text{ odd}}}\binom{2m}{m-k}\frac{1}{k^2}}\tag{even}$$
We may notice that the substitution $x\mapsto \arcsin x$, together with the Maclaurin series of $\arcsin^2$, provides a further hypergeometric representation for the given integral:
$$\begin{eqnarray*} \int_{0}^{\pi/2}x\sin^n(x)\,dx = \int_{0}^{1}\frac{\arcsin x}{\sqrt{1-x^2}}x^n\,dx &=&\sum_{m\geq 1}\frac{4^m}{2m(2m+n)\binom{2m}{m}}\\&=&\frac{1}{n+2}\cdot\phantom{}_3 F_2\left(1,1,1+\tfrac{n}{2};\tfrac{3}{2},2+\tfrac{n}{2};1\right).\end{eqnarray*}$$
The equality between the RHS of the last line and $(\text{odd})$ or $(\text{even})$ is probably a consequence of general transformation identities for hypergeometric $\phantom{}_3 F_2(\ldots;1)$ functions.
