What is the value of the integral $\int_0^{\frac{\pi}{2}} (1+\csc(x))^{k+\frac{1}{2}} \, \,dx$?

When I was messing around with some integrals I got the result that

$$\sum_{k=0}^\infty \frac{(-1)^k}{2k+1} \int_0^{\frac{\pi}{2}} (1+\csc(x))^{k+\frac{1}{2}} \, \,dx = \frac{\pi^2}{6}$$

Now I would like to solve the integral, but I don't really have any idea (I wonder whether it's possible at all?). I tried to change $$1+\csc(x)$$ in terms of sines and cosines (using this) so that one gets

$$\int_0^{\frac{\pi}{2}} (1+\csc(x))^{k+\frac{1}{2}} \, \,dx = \int_0^{\frac{\pi}{2}} \left(\frac{\cos^2(x)}{\sin(x)(1-\sin(x))}\right)^{k+\frac{1}{2}} \, \,dx$$

...but I can't see how this would lead anywhere.

• Just out of curiosity : how did you get the nice $\frac {\pi^2}6$ ? – Claude Leibovici Aug 4 '20 at 7:38
• @ClaudeLeibovici I like messing around with integrals that have a known value ("Integral milking"), and so I used this result and used the taylor series for $\cot^{-1}(x)$. I might have done some error tho... – Casimir Rönnlöf Aug 4 '20 at 8:07
• $\large\int$ diverges for $\large k = 1,2,3,\ldots$. – Felix Marin Aug 5 '20 at 4:15

I think that there is a problem around $$x=0$$ except for $$k=0$$. Using Taylor series and bionmial expansion $$(1+\csc(x))^{k+\frac{1}{2}}=\frac 1 {x^k}\left(\frac{1}{\sqrt{x}}+\left(k+\frac{1}{2}\right) \sqrt{x}+O\left(x^{3/2}\right)\right)$$
Since $$\sum_{k\ge0}\frac{(-1)^kz^{2k+1}}{2k+1}=\arctan z$$, your series is $$\int_0^{\pi/2}\arctan\sqrt{1+\csc x}dx$$. This is $$\infty$$ as @ClaudeLeibovici noted, because for small $$x$$ the integrand is $$\sim x^{-1/2}$$. It's more interesting if we delete the $$k=0$$ case, giving $$\int_0^{\pi/2}(\arctan\sqrt{1+\csc x}-\sqrt{1+\csc x})dx$$, which WA can only numerically evaluate.