# On the integral $\int_0^{\frac{\pi}{2}}x^{2n+1}\cot(x)dx$

While investigating the function $$A(z)=\int_0^\frac{\pi}{2} \frac{\sin(zx)}{\sin(x)}dx$$ I stumbled upon the integral $$\int_0^{\frac{\pi}{2}}x^{2n+1}\cot(x)dx$$ when attempting to calculate the taylor series of $$A(z)$$ at $$z=1$$. As the coefficients of the even powers in the series reduce to integrating over a polynomial which is fairly trivial, the only real problem I have is in determining the the coefficients of the odd powers as I cannot seem to find a pattern between the coefficients.

Wolfram Alpha evaluates the first couple of integrals as:

\begin{align*} \int_0^\frac{\pi}{2} x\cot(x)dx&=\frac{\pi\ln(2)}{2}\\ \int_0^\frac{\pi}{2}x^3\cot(x)dx&=\frac{1}{16}(\pi^3\ln(4)-9\pi\zeta(3))\\ \int_0^\frac{\pi}{2}x^5\cot(x)dx&=\frac{1}{64}(-3\pi^3\zeta(3)+225\pi\zeta(5)+\pi^5\ln(4)) \end{align*}

and in general it seems that higher powers could also be calculated in terms of the zeta function, multiples of $$\pi$$, and $$\ln(2)$$. So far I have been unsuccessful in determining a pattern for these integrals but if anyone has any ideas I would be very grateful for any help on this.

## 2 Answers

Denote your integral as $$\mathfrak{I}(n)$$ and apply IBP by choosing $$u=x^{2n+1}$$ and $$\mathrm dv=\cot(x)\mathrm dx$$ to get

\begin{align*} \mathfrak{I}(n)&=\int_0^{\pi/2}x^{2n+1}\cot(x)\mathrm dx =\underbrace{\left[(2n+1)\cdot x^{2n}\log(\sin x)\right]_0^{\pi/2}}_{\to0}-(2n+1)\int_0^{\pi/2}x^{2n}\log(\sin x)\mathrm dx\\ &=-(2n+1)\int_0^{\pi/2}x^{2n}\log(\sin x)\mathrm dx \end{align*}

Now utilizing the well-known Fourier series expansion of $$\log(\sin x)$$, which converges within $$[0,\pi]$$, and switching the order of summation and integration further gives us

\begin{align*} \mathfrak{I}(n)&=-(2n+1)\int_0^{\pi/2}x^{2n}\log(\sin x)\mathrm dx\\ &=-(2n+1)\int_0^{\pi/2}x^{2n}\left[-\log(2)-\sum_{k=1}^\infty\frac{\cos(2kx)}k\right]\mathrm dx\\ &=\log(2)\left(\frac\pi2\right)^{2n+1}+(2n+1)\sum_{k=1}^\infty\frac1k\underbrace{\int_0^{\pi/2}x^{2n}\cos(2kx)\mathrm dx}_{=J} \end{align*}

The integral $$J$$ can be computed via IBP again which explains the connection to values of the Riemann Zeta Function hence for integer $$n$$ every IBP step produces another reciprocal power of $$n$$ which overall combines to sums that can be expressed with the help of the Riemann Zeta Function.

As one may see the values for $$n=0$$ and $$n=1$$ can be easily verfied since for $$n=0$$ $$J$$ is overall $$0$$ aswell whereas for $$n=1$$ the latter integral can be expressed using the Dirichlet Eta Function. To be precise we got

\begin{align*} n=0:~~~\mathfrak{I}(0)&=\log(2)\left(\frac\pi2\right)^{1}+(1)\sum_{k=1}^\infty\frac1k\underbrace{\int_0^{\pi/2}\cos(2kx)\mathrm dx}_{=0}\\ &=\frac{\pi\log(2)}2 \end{align*}

\begin{align*} n=1:~~~\mathfrak{I}(1)&=\log(2)\left(\frac\pi2\right)^{3}+(2+1)\sum_{k=1}^\infty\frac1k\int_0^{\pi/2}x^2\cos(2kx)\mathrm dx\\ &=\log(2)\left(\frac\pi2\right)^{3}+3\sum_{k=1}^\infty\frac1k\left[\frac\pi4\frac{\cos(\pi k)}{k^2}\right]_0^{\pi/2}\\ &=\log(2)\left(\frac\pi2\right)^{3}-\frac{3\pi}4\sum_{k=1}^\infty\frac{(-1)^{k+1}}{k^3}\\ &=\log(2)\left(\frac\pi2\right)^{3}-\frac{3\pi}4\eta(3)\\ &=\log(2)\left(\frac\pi2\right)^{3}-\frac{9\pi}{16}\zeta(3)\\ &=\frac1{16}(\pi^3\log(4)-9\pi\zeta(3)) \end{align*}

Note that we used the relation $$\eta(s)=(1-2^{1-s})\zeta(s)$$. Similiar can be done for all integer $$n$$. So as at least close to a closed-form I can offer the following formula

$$\therefore~\mathfrak{I}(n)~=~\log(2)\left(\frac\pi2\right)^{2n+1}+(2n+1)\sum_{k=1}^\infty\frac1k\int_0^{\pi/2}x^{2n}\cos(2kx)\mathrm dx$$

• I have discussed a generalised version of these integrals in this question. Using your method I have obtained (detailed in my answer to this question) $$\mathfrak{I}(n) = \frac{(2n+1)!}{2^{2n+1}} \sum \limits_{l=0}^n (-1)^l \frac{\pi^{2(n-l)+1}}{(2(n-l)+1)!} \eta(2l+1) \, , \, n \in \mathbb{N}_0 \, ,$$ for this special case. – ComplexYetTrivial Feb 5 at 20:05
• @ComplexYetTrivial I have to thank you for the given links aswell as for your formula which is even more a closed-form than mine! I was not sure how to evaluate the given integral in a general form without invoking some kind of recursion formula. – mrtaurho Feb 5 at 21:52

Continuing off of @mrtaurho's excellent answer, we may find another form for $$C_k(n)=\int_0^{\pi/2}x^{2n}\cos(2kx)\mathrm dx$$ for $$n\in \Bbb N$$. First, we note that $$C_k(n)=\frac1{(2k)^{2n+1}}\int_0^{k\pi}x^{2n}\cos(x)\mathrm dx$$ Then we integrate by parts with $$\mathrm dv=\cos(x)\mathrm dx$$: $$C_k(n)=\frac1{(2k)^{2n+1}}x^{2n}\sin(x)\big|_0^{k\pi}-\frac{2n}{(2k)^{2n+1}}\int_0^{k\pi}x^{2n-1}\sin(x)\mathrm dx$$ $$C_k(n)=-\frac{2n}{(2k)^{2n+1}}\int_0^{k\pi}x^{2n-1}\sin(x)\mathrm dx$$ IBP once again, $$C_k(n)=-\frac{2n}{(2k)^{2n+1}}\left[-x^{2n-1}\cos(x)\big|_0^{k\pi}+(2n-1)\int_0^{k\pi}x^{2n-2}\sin(x)\mathrm dx\right]$$ $$C_k(n)=(-1)^k\frac{2n(k\pi)^{2n-1}}{(2k)^{2n+1}}-\frac{2n(2n-1)}{(2k)^{2n+1}}C_k(n-1)$$ $$C_k(n)=(-1)^k\frac{n\pi^{2n-1}}{2^{2n}k^2}-\frac{2n(2n-1)}{(2k)^{2n+1}}C_k(n-1)$$ So we have that $$\mathfrak{I}(n)=\left(\frac\pi2\right)^{2n+1}\log2-\frac{n(2n+1)}{4^n}\pi^{2n-1}\eta(3)-\frac{n(2n+1)(2n-1)}{4^n}\sum_{k\geq1}\frac{C_k(n-1)}{k^{2n+2}}$$ Which doesn't seem to give any sort of recurrence relation... :(

If I think of any new approaches I'll update my answer.