# 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?

• I tried to use even/odd functions by letting $y=x-\pi/4$ and it didn't work. Integration by parts seems convincing, any shortcut? – Haoran Chen Sep 15 '18 at 11:48
• @HaoranChen Please edit your question and add what you have tried using odd/even properties and show how it didn't work for you. This way we can help you better. About integrating by parts, follow ILATE. – paulplusx Sep 15 '18 at 11:50
• No, I don't know the reduction formulae using gamma. – Haoran Chen Sep 15 '18 at 12:24
• See this. I don't know it will help or not but still have a look. Also, see what is a gamma function from the wiki. – paulplusx Sep 15 '18 at 12:46

Do the same thing: let the integral be $I_n$, \begin{align*} &\phantom{=}\int_0^{\pi/2} x \sin(x)^n \mathrm dx = -\int_0^{\pi/2} x \sin(x)^{n-1}\mathrm d(\cos(x)) \\ &=\left. x \sin(x)^{n-1} \cos(x) \right|_{\pi/2}^0 - \int_{\pi/2}^0 \cos(x) (\sin(x)^{n-1} + (n-1)x \sin(x)^{n-2} \cos(x))\mathrm d x \\ &= 0 + \int_0^{\pi/2} \sin(x)^{n-1}\mathrm d (\sin(x)) +(n-1) \int_0^{\pi/2} x\sin(x)^{n-2}(1 - \sin(x)^2)\mathrm dx\\ &= \frac 1n + (n-1) I_{n-2} - (n-1)I_n , \end{align*} i.e. $$\fbox{nI_n =\dfrac 1n + (n-1)I_{n-2}, }$$ with $$I_1 = 1,\quad I_2 = \frac 14 + \frac {\pi^2} {16},$$ since \begin{align*} I_2&=\int_0^{\pi/2} x\sin(x)^2\mathrm dx \\ &= \left. x \sin(x) \cos(x)\right|_{\pi/2}^0 + \int_0^{\pi/2} \cos(x) (\sin(x)+ x\cos(x)) \mathrm dx \\ &= 0 + \frac 12 + \int_0^{\pi/2} x(1 - \sin(x)^2) \mathrm dx\\ &= \frac 12 + \frac {\pi^2} 8 - I_2\\ &\implies I_2 = \frac 14 + \frac {\pi^2}{16}. \end{align*} To go further, we are going to solve the recursive relation, but seems gruesome. So I let you take it from here.

### UPDATE

According to wiki, we have a systematic method to solve this. First consider the terms with even index,

Let $J_{n} = I_{2n}$, then $$J_n = \frac 1{4n^2} + \frac {2n-1}{2n}J_{n-1},$$ then divide both side of the equation by $(2n-1)!!/(2n)!!$: $$\frac {J_n}{\dfrac {(2n-1)!!}{(2n)!!}} = \frac 1 {4n^2} \frac {(2n)!!}{(2n-1)!!}+ \frac {J_{n-1}}{\dfrac {(2n-3)!!}{(2n-2)!!}},$$ now let $P_n = J_n (2n)!!/(2n-1)!!$, then $$P_n = \frac 1{2n} \frac {(2n-2)!!}{(2n-1)!!} + P_{n-1},$$ then $$P_n = \sum_2^n \frac 1{2k}\frac {(2k-2)!!}{(2k-1)!!} + P_1,$$ which is pretty much for deriving a concrete number of $I_n$.

• @paulplusx Thanks for pointing it out. I would fix that. – xbh Sep 15 '18 at 13:35
• +1, for the recurrence equation. – paulplusx Sep 15 '18 at 13:37

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.

$I_0=\frac{\pi^2}8$ and $I_1=1$ and for $n\ge2$, \begin{align} I_n &=\int_0^{\pi/2}x\sin^n(x)\,\mathrm{d}x\tag1\\ &=-\int_0^{\pi/2}x\sin^{n-1}(x)\,\mathrm{d}\cos(x)\tag2\\ &=(n-1)\int_0^{\pi/2}x\cos^2(x)\sin^{n-2}(x)\,\mathrm{d}x+\int_0^{\pi/2}\cos(x)\sin^{n-1}(x)\,\mathrm{d}x\tag3\\ &=(n-1)\int_0^{\pi/2}x\sin^{n-2}(x)\,\mathrm{d}x-(n-1)I_n+\frac1n\tag5\\ &=\frac{n-1}nI_{n-2}+\frac1{n^2}\tag5\\ \end{align} Explanation:
$(2)$: prepare to integrate by parts
$(3)$: integrate by parts
$(4)$: $\cos^2(x)=1-\sin^2(x)$ and the $\sin^2(x)$ part replicates $I_n$
$(5)$: add $(n-1)I_n$ to both sides and divide by $n$

Using $I_0$ and $(5)$, we can compute $I_{2n}$: \begin{align} I_{2n} &=\frac{(2n-1)!!}{(2n)!!}\left[\frac{\pi^2}8+\sum_{k=0}^{n-1}\frac{(2n-2k-2)!!}{(2n-2k-1)!!}\frac1{2n-2k}\right]\\ &=\frac{\binom{2n}{n}}{4^n}\left[\frac{\pi^2}8+\sum_{k=0}^{n-1}\frac{4^{n-k}}{\binom{2n-2k}{n-k}}\frac1{(2n-2k)^2}\right] \end{align}

Using $I_1$ and $(5)$, we can compute $I_{2n+1}$: \begin{align} I_{2n+1} &=\frac{(2n)!!}{(2n+1)!!}\left[1+\sum_{k=0}^{n-1}\frac{(2n-2k-1)!!}{(2n-2k)!!}\frac1{2n-2k+1}\right]\\ &=\frac1{2n+1}\frac{4^n}{\binom{2n}{n}}\left[1+\sum_{k=0}^{n-1}\frac{\binom{2n-2k}{n-k}}{4^{n-k}}\frac1{2n-2k+1}\right] \end{align}

• How is your answer different from that of @xbh ? – paulplusx Sep 16 '18 at 7:24
• @paulplusx: xbh's answer seems to be only for even indices. Their answer is also a bit more cryptic as it requires computing $P_n$ then $J_n=I_{2n}$. This is just a personal preference, but I also find it easier to work with binomial coefficients than double factorials. – robjohn Sep 16 '18 at 7:50
• Thank you for showing the full answer to us. I myself was kind of lazy and I was bit of intimidated by the complicated recurrence, so I just gave a direction for the OP to compute the exact answers, i.e. give an example for even indices since the odd indices would not make much difference. – xbh Sep 16 '18 at 13:07