# Close-form for integral $T(n)=\int_0^{\pi/2}\frac{1}{1+\sin^n(x)}dx$

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!

• I think this can be done with the Weierstrass substitution $u=\tan (x/2)$. This will convert the integral to the integral of a rational function which can be done in closed form. Dec 16, 2019 at 9:12
• \begin{align}T(2n)=\int_0^\infty \frac{(1+x^2)^{n-1}}{(1+x^2)^n+x^{2n}}\,dx\end{align} probably contour integral is the simpler to compute $T(2n)$.
– FDP
Dec 16, 2019 at 9:48
• For $T(1)$ it's easier to multiply the top and bottom by $1-\sin x$: $$\frac{1}{1+\sin x}=\frac{1-\sin x}{\cos^2 x}=$$ Dec 16, 2019 at 12:45
• @Zacky you make every integral easier Dec 16, 2019 at 16:31
• \begin{align}T(2n)=\pi\sum_{k=0}^\infty \frac{(-1)^k\binom{2nk}{nk}}{2^{2nk+1}}\end{align}
– FDP
Dec 16, 2019 at 23:26

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}

• fantastic! what an elegant solution! Mar 23, 2021 at 6:38
• Going over this answer again, I notice that you may have made an error in your claim that $$\int_0^{\frac\pi2} \frac{1-\cos x \cos\theta_k }{\cos^2x-2\cos x\cos\theta_k+1}dx=\int_0^{1} \frac{\tan^2\frac{\theta_k}2-t^2}{\tan^2\frac{\theta_k}2 +t^4}dt.$$ Specifically, after simplification, I get $$\int_0^{\frac\pi2} \frac{1-\cos x \cos\theta_k }{\cos^2x-2\cos x\cos\theta_k+1}dx=\int_0^{1} \frac{\tan^2\frac{\theta_k}2\color{red}{+}t^2}{\tan^2\frac{\theta_k}2 +t^4}dt.$$ Feb 7 at 21:45
• I was able to verify this using desmos: desmos.com/calculator/73p9wxzv7v Feb 7 at 21:46
• I get, verified by Desmos, $$T(n)=\frac{1-(-1)^n}{2n}+\frac{1}{n}\sum_{k=1}^{\lfloor n/2\rfloor}J(\tan\tfrac{2k+1}{2n}\pi),$$ where $$J(x)=\frac{1}{\sqrt{2x}}\left\{\frac{x-1}{2}\log\frac{1+x+\sqrt{2x}}{1+x-\sqrt{2x}}+(x+1)\left([0<x<1]\pi+\arctan\frac{\sqrt{2x}}{x-1}\right)\right\},$$ and $[0<x<1]$ is the Iverson Bracket Feb 19 at 4:34

As a suggestion, use $$\tan\left(\frac{x}{2}\right)=t$$ whenever the trig function is raised to an odd power, but use $$x=\tan t$$ when the trig is raised to an even power, that is since there will be no square roots left.

For even $$n$$, using the above, $$T(6)$$ can be simplified to: $$T(6)=\int_0^\frac{\pi}{2} \frac{dx}{1+\sin^6x}= \int_0^\infty \frac{(1+x^2)^2}{(2+x^2)(1+x+x^2)(1-x+x^2)}dx$$$$=\frac13\int_0^\infty\frac{dx}{2+x^2}+\frac16\int_0^\infty \left(\frac{1+x}{1-x+x^2}+\frac{1-x}{1+x+x^2}\right)dx$$ And one can see now easier how that nice result appears.

Similary, for $$T(8)$$ we have: $$T(8)=\int_0^\frac{\pi}{2}\frac{dx}{1+\sin^8 x}\overset{x\to \frac{\pi}{2}-x}=\int_0^\frac{\pi}{2}\frac{dx}{1+\cos^8 x}\overset{x\to \tan^{-1} x}=\int_0^\infty \frac{(1+x^2)^3}{(1+x^2)^4+1}dx$$ $$=\frac{1}{2}\int_0^\infty \frac{x^2+1+\frac{1}{\sqrt 2}}{(x^2+1)^2+\sqrt 2 (x^2+1)+1}dx+\frac12\int_0^\infty\frac{x^2+1-\frac{1}{\sqrt 2}}{(x^2+1)^2-\sqrt 2 (x^2+1)+1}dx$$ $$=\frac{\pi}{8}\left(\sqrt{1+\sqrt{2(2+\sqrt 2)}}+\sqrt{1+\sqrt{2(2-\sqrt 2)}}\right)$$

For odd $$n$$, with the Weierstrass substitution after putting $$x\to \frac{\pi}{2}-x$$ we have: $$T(3)=\int_0^\frac{\pi}{2}\frac{dx}{1+\cos ^3 x}=\int_0^1 \frac{(1+x^2)^2}{1+3x^4}dx=\frac13+\frac23\int_0^1\frac{\frac13+x^2}{\frac13+x^4}dx=\frac13+\frac23f\left(\frac13\right)$$

And at the very least, what is $$T(5)$$? It seems to be very nasty.

$$T(5)=\int_0^\frac{\pi}{2}\frac{1}{1+\sin^5 x}dx\overset{x\to\frac{\pi}{2}-x}=\int_0^\frac{\pi}{2}\frac{1}{1+\cos^5 x}dx\overset{\tan\frac{x}{2}\to x}=\int_0^1 \frac{(1+x^2)^4}{1+10x^4+5x^8}dx$$ $$=\frac15\int_0^1 dx+\frac25\int_0^1\frac{1+\frac{2}{\sqrt 5}+x^2}{1+\frac{2}{\sqrt 5}+x^4}dx+\frac25\int_0^1\frac{1-\frac{2}{\sqrt 5}+x^2}{1-\frac{2}{\sqrt 5}+x^4}dx$$ $$=\frac15+\frac25f\left(1+\frac{2}{\sqrt 5}\right)+\frac25f\left(1-\frac{2}{\sqrt 5}\right)$$

$$f(t)=\int_0^1 \frac{t+x^2}{t+x^4}dx\overset{x=\sqrt[4]t y}=\sqrt[4] t\int_0^{\frac{1}{\sqrt[4]t}}\frac{1}{1+y^4}dy+\frac{1}{\sqrt[4] t}\int_0^{\frac{1}{\sqrt[4]t}}\frac{y^2}{1+y^4}dy$$ $$=\frac12\left(\sqrt[4] t+\frac{1}{\sqrt[4] t}\right)\int_0^{\frac{1}{\sqrt[4]t}}\frac{1+y^2}{1+y^4}dy+\frac12\left(\sqrt[4] t-\frac{1}{\sqrt[4] t}\right)\int_0^{\frac{1}{\sqrt[4]t}}\frac{1-y^2}{1+y^4}dy$$ $$=\frac12\left(\sqrt[4] t+\frac{1}{\sqrt[4] t}\right)\int_0^{\frac{1}{\sqrt[4]t}}\frac{\left(y-\frac1y \right)'}{\left(y-\frac1y \right)^2+2}dy-\frac12\left(\sqrt[4] t-\frac{1}{\sqrt[4] t}\right)\int_0^{\frac{1}{\sqrt[4]t}}\frac{\left(y+\frac1y \right)'}{\left(y+\frac1y \right)^2-2}dy$$ $$\small =\frac{1}{2\sqrt 2}\left(\sqrt[4] t+\frac{1}{\sqrt[4] t}\right)\left(\arctan\left(\frac{\sqrt[4]t-\frac{1}{\sqrt[4] t}}{\sqrt 2}\right)+\frac{\pi}{2}\right)+\frac1{4\sqrt 2}\left(\sqrt[4] t-\frac{1}{\sqrt[4] t}\right)\ln\left(\frac{\sqrt[4] t+\frac{1}{\sqrt[4] t}+\sqrt 2}{\sqrt[4] t+\frac{1}{\sqrt[4] t}-\sqrt 2}\right)$$

• nice work. I knew you would come through for me (+1) Dec 16, 2019 at 16:02

Another approach might be exploiting $$\frac1{y^n+1}=\frac1n\sum^n_{k=1}\frac1{1-\omega_k y}$$ where $$\omega_1,\cdots,\omega_n$$ are the roots of $$y^n+1=0$$.

Hence, $$T(n)= \frac1n\sum^n_{k=1}\int^{\pi/2}_0\frac1{1-\omega_k \sin x}dx$$

Integral calculator says that $$\int^{\pi/2}_0\frac1{1-a\sin x}dx=\frac1{\sqrt{a^2-1}}\ln \frac{1+A^-}{1-A^+}$$ where $$A^\pm=\sqrt{a^2-1}\pm a$$

Therefore, $$T(n)= \frac1n\sum^n_{k=1}\Re \frac1{\sqrt{\omega_k^2-1}}\ln \frac{1+\Omega_k^-}{1-\Omega_k^+}$$

This approach avoids complicated integration manipulations, at the price of doing tedious but basic complex analysis.

NB: I haven’t checked which branch of square root and logarithm should be taken.

• Closest to a complete answer. Expect to be accepted once you work out all the details (+1) Dec 16, 2019 at 16:04
• @clathratus Thanks for the compliment. I will finish up the answer in the coming few days, and probably also find the closed form of $T(5)$ (which I expect to be composed of 10 terms). Dec 16, 2019 at 23:21