Sine-weighted power integral recurrence (source code)

= Sine-weighted power integral recurrence
{title2=$F(k)=\pi^k-k(k-1)F(k-2)$}

Define the <definite integral> $F(k)=\int_0^\pi x^k\sin x\,dx$. For real $k>1$, two applications of <integration by parts> give
$$
F(k)=\pi^k+k\int_0^\pi x^{k-1}\cos x\,dx
=\pi^k-k(k-1)F(k-2).
$$
The boundary term $x^{k-1}\sin x$ vanishes at both endpoints. At $k=1$, direct integration gives $F(1)=\pi$, consistent with the displayed relation; $F(-1)$ is finite because $\sin x/x\to1$ at zero. This recurrence and $F(0)=2$ evaluate every nonnegative integer moment, with separate even and odd chains.