Context:
I have recently become interested in integrals of the form $$T(n)=\int_0^{\pi/2}\frac{dx}{1+\sin(x)^n},$$ and I conjecture that $T(n)$ has a closed form evaluation for all $n\in\Bbb Z_{\ge0}$, or at least all non-negative even integers $n$. Trivially, one has $T(0)=\pi/4$. Less trivially, there is $T(1)=1$ (easy with $t=\tan(x/2)$), and $T(2)=\frac\pi{2\sqrt{2}}$ as seen here. The integral $J=T(3)$, however, is not so easy. We see that this integral is $$3J=\int_0^{\pi/2}\frac{dx}{1+\sin x}-\int_0^{\pi/2}\frac{\sin (x)dx}{\sin(x)^2-\sin(x)+1}+2\int_0^{\pi/2}\frac{dx}{\sin(x)^2-\sin(x)+1}.$$ The first integral is easy, and we get $$3J=1-J_1+J_2.$$ The next integral is $$J_1=\int_0^{\pi/2}\frac{\sin (x)dx}{\sin(x)^2-\sin(x)+1},$$ which is, from $t=\tan(x/2)$, $$J_1=2\int_0^1\frac{\frac{2t}{1+t^2}}{(\frac{2t}{1+t^2})^2-\frac{2t}{1+t^2}+1}\frac{dt}{1+t^2},$$ which is the awful $$J_1=4\int_0^1\frac{tdt}{t^4-2t^3+6t^2-2t+1}.$$ I found that nothing but brute force could tackle this integral, so I used partial fractions and got $$J_1=4\sum_{a\in A}\frac{1}{f'(a)}\left(1+a\log(1-a)-a\log(-a)\right)$$ where $$A=\left\{\frac12\left(1+p_1i\sqrt3+p_2\sqrt{-6+2p_3i\sqrt3}\right):p_1,p_2,p_3\in\{-1,1\}\right\}$$ is the set of roots of the polynomial $f(z)=z^4-2z^3+6z^2-2z+1,$ and $\log(z)$ is the complex logarithm.
However, the remaining integral is a little worse. We have from the substitution $t=\tan(x/2)$ the awful $$J_2=4\int_0^1\frac{1+t^2}{1-2t+5t^2-2t^3}dt.$$ We can do the same sort of trick here as with the last integral and get $$J_2=4\sum_{b\in B}\frac1{g'(b)}\int_0^1\frac{t^2+1}{t-b}dt$$ where $$B=\{z\in\Bbb C: 1-2z+5z^2-2z^3=0\}$$ is the set of roots of the polynomial $g(z)=1-2z+5z^2-2z^3$. These roots do indeed have explicit evaluations. The integral in the summation is easy enough to calculate, but I'm not going to, as we already see that the integral has a closed form.
Next up, Wolfram evaluates $$T(4)=\int_0^1\frac{dx}{1+\sin(x)^4}=\frac\pi4\sqrt{1+\sqrt2},$$ as well as $$T(6)=\int_0^{\pi/2}\frac{dx}{1+\sin(x)^6}=\frac{\pi}{12}(\sqrt{2}+2\sqrt{3}),$$ which is here.
In fact, we may evaluate $T(2n)$ in terms of hypergeometric functions, which may have a general closed form. We do so by noting that $$\frac{1}{1+\sin(x)^{2n}}=\sum_{k\ge0}(-1)^k\sin(x)^{2nk}$$ so that $$T(2n)=\sum_{k\ge0}(-1)^k\int_0^{\pi/2}\sin(x)^{2nk}dx=\frac{\sqrt\pi}{2}\sum_{k\ge0}(-1)^k\frac{\Gamma(nk+\tfrac12)}{(nk)!}.$$ This is $$T(2n)=\frac\pi2\,_{n}F_{n-1}\left(1-\tfrac{1}{2n},A_n;B_n;-1\right)$$ where $$\begin{align} A_n&=\left\{\frac{2r+1}{2n}:0\le r\in\Bbb Z\le n-2\right\}\\ B_n&=\left\{\frac{r}{n}:1\le r\in\Bbb Z\le n-1\right\}. \end{align}$$ Whether or not this hypergeometric has a closed form I am unsure, but it looks simple enough to be evaluated exactly.
Questions:
Can $T(n)$ be computed in closed form of all $n$? If not, when can it be computed in closed form?
And at the very least, what is $T(5)$? It seems to be very nasty.
Thanks!
The close-form result, valid for both odd and even $n$, is $$T(n) = \frac{1-(-1)^n}{2n}+ \frac1n \sum_{k=1}^{[\frac n2]}\beta_{k}^+(\frac\pi2+\tan^{-1}\beta_k^-)- \beta_k^- \coth^{-1} \beta_k^+ \tag1$$ with $$\beta_k^{\pm }= \frac1{\sqrt2}\left(\sqrt{\cot\frac{(2k-1)\pi}{2n}} \pm \sqrt{\tan\frac{(2k-1)\pi}{2n}} \right) $$
Proof: Note
$$\frac1{1+y^n}=-\frac1n\sum_{k=1}^n \frac{e^{i\theta_k}}{y-e^{i\theta_k}}, \>\>\>\>\> \theta_ k = \frac{(2k-1)\pi}n$$ and combine conjugate pairs
$$\frac1{1+y^n}=\frac{1-(-1)^n}{2n(1+y)} + \frac2n \sum_{k=1}^{[\frac n2]} \frac{1-y \cos\theta_k }{y^2-2y\cos\theta_k+1} $$ Set $y = \cos x$ to integrate
\begin{align} T(n)&=\int_0^{\pi/2}\frac{dx}{1+\sin^n x} = \int_0^{\pi/2}\frac{dx}{1+\cos^n x} \\ &= \frac1{2n}\int_0^{\frac\pi2}\frac{1-(-1)^n}{1+\cos x}dx + \frac2n \sum_{k=1}^{[\frac n2]} \int_0^{\frac\pi2} \frac{1-\cos x \cos\theta_k }{\cos^2x-2\cos x\cos\theta_k+1}dx\\ &= \frac{1-(-1)^n}{2n} + \frac2n \sum_{k=1}^{[\frac n2]} \int_0^{1} \frac{\tan^2\frac{\theta_k}2-t^2}{\tan^2\frac{\theta_k}2 +t^4}dt \end{align} where the half-angle substitution $t=\tan\frac x2$ is applied. Then, integrate over $t$ to arrive at the close-form expression (1). Note that the general result (1) simplifies considerably for even $n$ as the summation over the inverse trig functions vanishes. Explicitly, for $n =2m$ $$T(2m)= \frac\pi{4m} \sum_{k=1}^{m} \sqrt{\csc\theta_k+1}\tag2 $$ where $\beta_k^+ = \sqrt{\csc\theta_k+1}$ is recognized.
Listed below are some actual results per the close-form (1) or (2).
Even $n$: \begin{align} T(2) &= \frac\pi4 \sqrt{\csc\frac\pi2+1}=\frac{\pi}{2\sqrt2}\\ T(4) &= \frac\pi8 \left(\sqrt{\csc\frac\pi4+1} + \sqrt{\csc\frac{3\pi}4+1} \right)=\frac{\pi}{4}\sqrt{\sqrt2+1}\\ T(6) &= \frac\pi{12} \left(\sqrt2+\sqrt{\csc\frac\pi6+1} + \sqrt{\csc\frac{5\pi}6+1} \right)=\frac{\pi}{12}(\sqrt2+2\sqrt3)\\ T(8) &= \frac\pi8 \left(\sqrt{\csc\frac\pi8+1} + \sqrt{\csc\frac{3\pi}8+1} \right)\\ &=\frac{\pi}{8}\left(\sqrt{\sqrt{2(2+\sqrt2)}+1} + \sqrt{\sqrt{2(2-\sqrt2)}+1}\right)\\ T(10) &= \frac\pi{10} \left(\frac1{\sqrt2}+\sqrt{\csc\frac\pi{10}+1} + \sqrt{\csc\frac{3\pi}{10}+1} \right)\\ &=\frac{\pi}{10}\left(\frac1{\sqrt2}+ \sqrt[4]5+\sqrt{2+\sqrt5}\right)\\ T(12) &= \frac{\pi}{12} \sqrt{1+\sqrt2}\left(1+ \sqrt{2+2\sqrt3}\right) \end{align}
Odd $n$: \begin{align} T(3) &=\frac13 +\frac{\sqrt[4]3+\frac1{\sqrt[4]3}}{3\sqrt2} \left(\frac\pi2+ \tan^{-1} \frac{\sqrt[4]3-\frac1{\sqrt[4]3}}{\sqrt2} \right) - \frac{\sqrt[4]3-\frac1{\sqrt[4]3}}{3\sqrt2} \coth^{-1} \frac{\sqrt[4]3+\frac1{\sqrt[4]3}}{\sqrt2} \\ T(5) &=\frac15 +\frac15\sqrt{ \sqrt{2+\frac2{\sqrt5}}+1} \left(\frac\pi2+ \tan^{-1} \sqrt{ \sqrt{2+\frac2{\sqrt5}}-1}\right) \\ &\hspace{10mm} +\frac15\sqrt{ \sqrt{2-\frac2{\sqrt5}}+1} \left(\frac\pi2- \tan^{-1} \sqrt{ \sqrt{2-\frac2{\sqrt5}}-1}\right) \\ &\hspace{10mm} -\frac15\sqrt{ \sqrt{2+\frac2{\sqrt5}}-1} \coth^{-1} \sqrt{ \sqrt{2+\frac2{\sqrt5}}+1} \\ &\hspace{10mm} +\frac15\sqrt{ \sqrt{2-\frac2{\sqrt5}}-1} \coth^{-1} \sqrt{ \sqrt{2-\frac2{\sqrt5}}+1} \\ T(7) &=\frac17 +\frac17\sqrt{ \csc\frac\pi7+1} \left(\frac\pi2+ \tan^{-1} \sqrt{ \csc\frac\pi7-1}\right) \\ &\hspace{10mm} +\frac17\sqrt{ \csc\frac{3\pi}7+1} \left(\frac\pi2+ \tan^{-1} \sqrt{ \csc\frac{3\pi}7-1}\right) \\ &\hspace{10mm} +\frac17\sqrt{ \csc\frac{5\pi}7+1} \left(\frac\pi2- \tan^{-1} \sqrt{ \csc\frac{5\pi}7-1}\right) \\ &\hspace{10mm} -\frac17\sqrt{ \csc\frac{\pi}7-1} \coth^{-1} \sqrt{ \csc\frac{\pi}7+1} \\ &\hspace{10mm} -\frac17\sqrt{ \csc\frac{3\pi}7-1} \coth^{-1} \sqrt{ \csc\frac{3\pi}7+1} \\ &\hspace{10mm} +\frac17\sqrt{ \csc\frac{5\pi}7-1} \coth^{-1} \sqrt{ \csc\frac{5\pi}7+1} \\ \end{align}