# Evaluating $\int_{0}^{\frac{\pi}{2}} x^n \csc(x) dx$

Just from messing around on WolframAlpha, I've come across an interesting integral. For the integral $$\operatorname{I}\left(n\right) = \int_{0}^{\frac{\pi}{2}}x^{n}\csc\left(x\right)\,{\rm d}x\,,$$ there are some pretty interesting answers when evaluating them at certain values. For example: \begin{align} \operatorname{I}\left(1\right) & = 2C \\[2mm] \operatorname{I}\left(2\right) & = 2\pi C - {7 \over 2}\,\zeta\left(3\right) \\[2mm] \operatorname{I}\left(3\right) & = \frac{1}{128}\left[192\,\pi^{2}\,C -\psi^{\left(3\right)} \left(\frac{1}{4}\right) +\psi^{\left(3\right)}\left(\frac{3}{4}\right)\right] \\[2mm] \operatorname{I}\left(4\right) & = \pi^{3}\,C - 24\pi\,{\rm i}\operatorname{Li}_{4}\left(-{\rm i}\right) + \frac{93}{2}\,\zeta(5) - \frac{7}{480}\,{\rm i}\pi^{5} \end{align}

• With each step up, we introduce a new family of functions.
• I cannot for the life of me distinguish a pattern to try to come up with what $$\operatorname{I}\left(n\right)$$ might be.
• The only thing that I can discern, is obviously $$\operatorname{I}\left(n\right)$$ includes a term including $$\pi^{n-1}\, C$$.

Can someone give me some kind of idea as to how I might evaluate these $$?$$.

• Heard. Can go ahead and delete it now, thanks! – Luna145 yesterday

We find an explicit closed form for all $$n\in \mathbb{N}$$. Using $$\sin(x)=\dfrac{e^{ix}-e^{-ix}}{2i}$$ and the geometric series (in the distributional sense, e.g. see the last remark of this answer) we obtain $$\int_0^{\pi/2} x^n \csc(x)~dx=2i \int_0^{\pi/2} x^n \frac{e^{-ix}}{1-e^{-2ix}}~dx=2i\sum_{k=0}^{\infty} \int_0^{\pi/2} x^n e^{-(2k+1)ix}~dx. \tag{1}$$ We have the indefinite integral (eq. 2.321 in Gradshteyn and Ryzhik 7th ed.) for any $$a\in \mathbb{C}$$ $$\int x^n e^{ax}~dx=e^{ax}\left(\sum_{j=0}^n \frac{(-1)^j j! \binom{n}{j}}{a^{j+1}}x^{n-j}\right)+C,$$ which results in the definite integral $$\int_0^{\pi/2} x^n e^{ax}~dx=e^{a\pi/2} \left(\sum_{j=0}^{n} \frac{(-1)^j j! \binom{n}{j}}{a^{j+1}}\left(\frac{\pi}{2}\right)^{n-j}\right)-\frac{(-1)^n n!}{a^{n+1}}.$$ Hence for $$a=-(2k+1)i$$ we have $$\int_0^{\pi/2} x^n e^{-(2k+1)ix}~dx=i\cdot (-1)^k \left(\sum_{j=0}^{n} \frac{j! \binom{n}{j}}{i^{j+1} (2k+1)^{j+1}}\left(\frac{\pi}{2}\right)^{n-j}\right)+\frac{n!}{i^{n+1} (2k+1)^{n+1}}.$$ With this result, one can express $$(1)$$ in terms of Dirichlet beta functions $$\beta(s):=\sum_{k=0}^{\infty} \frac{(-1)^k}{(2k+1)^s},$$ and Dirichlet lambda functions $$\lambda(s):=\sum_{k=0}^{\infty} \frac{1}{(2k+1)^s}=(1-2^{-s})\zeta(s),$$ where the final equality is valid for all $$\Re(s)>1$$.

Thus, the integral is given by the following if $$n$$ is even (we use that $$i^l=i^{-l}$$ if $$l$$ is even): \scriptsize \begin{align*}\int_0^{\pi/2} x^n \csc(x)~dx&=2 i^n\cdot n!\lambda(n+1)-2 \sum\limits_{\substack{0\leq j\leq n \\ j~\mathrm{odd}}} \left(\frac{\pi}{2}\right)^{n-j} i^{j+1} j! \binom{n}{j}\beta(j+1)\\&=\frac{(-1)^{n/2}\cdot n! (2^{n+1}-1)}{2^n}\zeta(n+1)-2 \sum\limits_{\substack{0\leq j\leq n \\ j~\mathrm{odd}}} \left(\frac{\pi}{2}\right)^{n-j} i^{j+1} j! \binom{n}{j}\beta(j+1)\\&=\frac{(-1)^{n/2} \cdot n! (2^{n+1}-1)}{2^n}\zeta(n+1)+2\sum_{m=1}^{\lfloor (n+1)/2\rfloor} \left(\frac{\pi}{2}\right)^{n+1-2m} (-1)^{m-1} (2m-1)! \binom{n}{2m-1}\beta(2m). \end{align*} Otherwise, if $$n$$ is odd \begin{align*}\int_0^{\pi/2} x^n \csc(x)~dx&=-2 \sum\limits_{\substack{0\leq j\leq n \\ j~\mathrm{odd}}} \left(\frac{\pi}{2}\right)^{n-j} i^{j+1} j! \binom{n}{j}\beta(j+1)\\&=2\sum_{m=1}^{\lfloor (n+1)/2\rfloor} \left(\frac{\pi}{2}\right)^{n+1-2m} (-1)^{m-1} (2m-1)! \binom{n}{2m-1}\beta(2m). \end{align*} This agrees with @metamorphy's results (and yours). Note that we only sum over odd $$j$$ since the summands for even $$j$$ only contribute to the imaginary part of the integral, which we know is $$0$$ since the integrand is real on the domain of integration.

$$I(n)$$ expresses naturally using Dirichlet's $$\beta$$, in addition to Riemann's $$\zeta$$. Consider $$f(r,x)=\sum_{k=0}^\infty r^k\sin(2k+1)x=\frac{(1+r)\sin x}{1-2r\cos2x+r^2}\qquad(|r|<1)$$ so that $$\int_0^{\pi/2}x^n f(r,x)\,dx=\sum_{k=0}^\infty r^k I_{n,k}$$ with $$I_{n,k}=\int_0^{\pi/2}x^n\sin(2k+1)x\,dx$$. Now $$I_{0,k}=\frac1{2k+1},\qquad I_{n+1,k}=\frac{n+1}{(2k+1)^2}\Big((-1)^k(\pi/2)^n-nI_{n-1,k}\Big)$$ (the recurrence holds for $$n\geqslant 0$$, and is obtained using integration by parts).

It remains to do $$r\to1^-$$, when $$2f(r,x)\to\csc x$$ (and this is a dominated convergence; another tool we need here is Abel's theorem), concluding with $$I(n)=2\sum_{k=0}^\infty I_{n,k}$$, and use the recurrence given above. With $$\lambda(s)$$$${}=\sum_{n=0}^\infty(2n+1)^{-s}=(1-2^{-s})\zeta(s)$$, the first few values of $$I(n)$$ are:

\begin{align*} I(1)&=2\beta(2) \\I(2)&=2\pi\beta(2)-4\lambda(3)&&\color{gray}{\ldots\frac72\zeta(3)} \\I(3)&=\frac32\pi^2\beta(2)-12\beta(4) \\I(4)&=\pi^3\beta(2)-24\pi\beta(4)+48\lambda(5)&&\color{gray}{\ldots\frac{93}{2}\zeta(5)} \\I(5)&=\frac58\pi^4\beta(2)-30\pi^2\beta(4)+240\beta(6) \\I(6)&=\frac38\pi^5\beta(2)-30\pi^3\beta(4)+720\pi\beta(6)-1440\lambda(7)&&\color{gray}{\ldots\frac{5715}{4}\zeta(7)} \\I(7)&=\frac{7}{32}\pi^6\beta(2)-\frac{105}{4}\pi^4\beta(4)+1260\pi^2\beta(6)-10080\beta(8) \end{align*}

(I'm too lazy to make up an explicit finite-sum nasty-looking formula ;)

Reexpress the integral as

\begin{align} I(n)=&\int_{0}^{\frac{\pi}{2}} x^n \csc x\>dx \overset{t=e^{i x}}=-\frac2{i^n}\int_1^i \frac{\ln^n t}{1-t^2}dt\\ =&\frac2{i^n}\left( \int_0^1 \frac{\ln^n t}{1-t^2}dt -\int_0^1 \frac{i\ln^n (it)}{1+t^2}dt \right)\\ =&\frac2{i^{n}}\int_0^1 \frac{\ln^n t}{1-t^2}dt -\frac2{i^{n-1}} \sum_{k=0}^n\binom{n}{k} (\frac{i\pi}2)^{n-k}\int_0^1 \frac{\ln^k t}{1+t^2}dt \tag1 \end{align} and note that $$\int_0^1 \frac{\ln^n t}{1-t^2}dt=(1-2^{-n-1})n!\zeta(n+1) ,\>\>\>\>\> \int_0^1 \frac{\ln^k t}{1+t^2}dt=(-1)^k k! \beta(k+1)$$ Substitute above into (1) and keep only the real parts (i.e. odd $$k$$) to obtain \begin{align} I(n) =\>(2-2^{-n})n!\zeta(n+1)\text{Re}(i^n) - \sum_{k=1}^{[\frac{n+1}2]} (\frac{\pi}2)^{n+1-2k}\>\frac{2(-1)^k n!}{(n+1-2k)!} \>\beta(2k) \end{align}

• $+1$. Nice. That's the approach I had in mine. – Felix Marin Jul 18 at 3:54

Let $$c_k=\frac{(-1)^k2\left(2^{2k-1}-1\right)B_{2k}}{(2k)!}$$ as seen here. $$B_y$$ denotes the Bernoulli Numbers

Then $$|x|<\pi,I(n)=\int_0^\frac{\pi}{2}x^n\left(\frac 1x-\sum _{k=1}^\infty c_kx^{2k-1}\right)dx= \int_0^\frac{\pi}{2}x^{n-1}-\sum _{k=1}^\infty c_kx^{2k+n-1}dx= \frac{\left(\frac{\pi}{2}\right)^n}{n}-\sum _{k=1}^\infty c_k\frac{\left(\frac{\pi}{2}\right)^{2k+n}}{2k+n}$$

Therefore:

$$I(n)= \frac{\left(\frac{\pi}{2}\right)^n}{n}-\sum _{k=1}^\infty \frac{(-1)^k2\left(2^{2k-1}-1\right)B_{2k} \left(\frac{\pi}{2}\right)^{2k+n}}{(2k+n)(2k)!}= \left(\frac{\pi}{2}\right)^n\left(\frac 1n-2\sum _{k=1}^\infty \frac{(-1)^k\left(2^{2k-1}-1\right)B_{2k} \left(\frac{\pi}{2}\right)^{2k}}{(2k+n)(2k)!}\right)$$ Please correct me and give me feedback!