# Evaluating $\int_{0}^{\frac{\pi}{2}} \frac{1}{\sin^m x+\cos^m x}dx$

I evaluated the following integral: $$I=\int_{0}^{\frac{\pi}{2}} \frac{1}{\sin^8x+\cos^8x}dx$$ My Method: Divide up and down by $$\cos^8x$$ and substitute $$t=\tan x$$, so the integral converts to $$I=\int_{0}^{\infty}\frac{(1+t^2)^3}{1+t^8}\mathrm{d}t$$ I evaluated this integral by substituting $$t^8=u$$ and using the general result $$\displaystyle \int_{0}^{\infty}\frac{u^{n-1}}{1+u}\mathrm{d}u=\frac{\pi}{\sin n\pi}$$ which can be evaluated easily. However, I wanted to generalise this integral $$I(m)=\int_{0}^{\frac{\pi}{2}}\frac{1}{\sin^mx+\cos^mx}dx$$ But the above method doesn't apply to any value of $$m$$. So, what should be the approach for the above integral?

We also know that $$I(0)=\frac{\pi}{4}$$, so maybe we could make a recurrence relation or perhaps, feynmann's technique ...

Results:

Both the even and old cases admit elementary close-form solutions, which are given below \begin{align} &\int_0^{\pi/2}\frac1{\sin^{2n}x+\cos^{2n}x}dx \\ =&\ \frac{2^{n-2}\pi}n\sum_{k=1}^n(-1)^{k+1}\cos^{n-1}\alpha_k \>\>\>\>\>\>\>\>\>\>\>\>\>\alpha_k=\frac{(2k-1)\pi}{2n} \tag1 \\ &\int_0^{\pi/2}\frac1{\sin^{2n+1}x+\cos^{2n+1}x}\ dx \>\>\>\>\>\>\>\>\>\>\>\>\> \beta_k=\frac{2\pi k}{2n+1}\\ =&\ \frac{2^{n+2}}{2n+1}\bigg( \frac{\coth^{-1}\sqrt2}{2\sqrt2}+\sum_{k=1}^n\frac{(-1)^{k}\coth^{-1}\sqrt{{\sec \beta_k}+1}}{\sec^{n-1}\beta_k\sec\frac{\beta_k}2\sqrt{{\sec \beta_k}+1}} \bigg) \tag2 \\ \end{align}

Proof:

Rewrite the integrands as

\begin{align} &\frac1{\sin^{2n}x+\cos^{2n}x} =\frac {(\tan^2x+1)^{n-1}\sec^2x}{\tan^{2n}+1} \tag3 \\ & \frac1{\sin^{2n+1}x+\cos^{2n+1}x} = \frac {(\tan^2x+1)^{n}\sec x}{\tan^{2n+1}+1} \tag4\\ \end{align}

Utilize the partial fractionalizations below \begin{align} &\frac {(y^2+1)^{n-1}}{y^{2n}+1}= \frac{2^{n-1}}n\sum_{k=1}^n(-1)^{k+1}\frac{\sin \alpha_k \cos^{n-1}\alpha_k}{y^2+2y\cos \alpha_k +1}\\ & \frac {(y^2+1)^{n}}{y^{2n+1}+1} =\frac{2^{n}}{2n+1}\bigg( \frac1{y+1}+2\sum_{k=1}^n(-1)^{k}\frac{(y+1)\cos \frac{\beta_k}2\cos^{n}\beta_k}{y^2+2y\cos \beta_k +1} \bigg)\\ \end{align} and substitute above into (3) and (4) with $$y=\tan x$$

\begin{align} &\frac1{\sin^{2n}x+\cos^{2n}x} =\frac{2^{n-1}}n\sum_{k=1}^n(-1)^{k+1}\frac{\sin \alpha_k \cos^{n-1}\alpha_k}{1+\cos \alpha_k \sin 2x}\tag5 \\ & \frac1{\sin^{2n+1}x+\cos^{2n+1}x}\\ = &\ \frac{2^{n}}{2n+1}\bigg( \frac1{\sin x+\cos x}+2\sum_{k=1}^n(-1)^{k}\frac{(\sin x+\cos x)\cos \frac{\beta_k}2\cos^{n}\beta_k}{1+\cos \beta_k \sin2x} \bigg)\tag6 \\ \end{align}

Integrate piecewise the individual integrands in (5) and (6) to arrive at the general close-form solutions (1) and (2), respectively.

Examples:

Listed below are some explicit solutions resulting from (1) and (2)

\begin{align} &\text{Even:}\\ &\int_0^{\pi/2}\frac1{\sin^4 x+\cos^4 x}dx =\frac\pi{\sqrt2} \\ &\int_0^{\pi/2}\frac1{\sin^6 x+\cos^6 x}dx=\pi \\ &\int_0^{\pi/2}\frac1{\sin^8 x+\cos^8 x}dx=\frac\pi2 \sqrt{10-\sqrt2} \\ &\int_0^{\pi/2}\frac1{\sin^{10} x+\cos^{10} x}dx=\sqrt5 \pi \\ &\int_0^{\pi/2}\frac1{\sin^{12} x+\cos^{12} x}dx=\frac{\pi}{3\sqrt2}(11\sqrt3-4) \\ &\int_0^{\pi/2}\frac1{\sin^{14} x+\cos^{14} x}dx=\frac{64\pi}7 \bigg(\sin^6\frac\pi7- \sin^6\frac{2\pi}7 + \sin^6\frac{3\pi}7\bigg) \\ \\ &\text{Odd:}\\ &\int_0^{\pi/2}\frac1{\sin^{3} x+\cos^{3} x}dx= \frac{2\sqrt2}3\coth^{-1}\sqrt2+\frac\pi3 \\ &\int_0^{\pi/2}\frac1{\sin^{5} x+\cos^{5} x}dx= \frac45 \bigg( \sqrt2 \coth^{-1}\sqrt2 \\ &\hspace{5cm} -\frac{\coth^{-1}{\sqrt{\sqrt5+2}}}{\sqrt{\sqrt5+2}} + \frac{\cot^{-1}{\sqrt{\sqrt5-2}}}{\sqrt{\sqrt5-2}}\bigg) \\ &\int_0^{\pi/2}\frac1{\sin^{7} x+\cos^{7} x}dx= \frac{32}7 \bigg( \frac{\coth^{-1}\sqrt2 }{2\sqrt2}\\ &\hspace{5cm} -\cos^2\frac{2\pi}7\frac{\coth^{-1}{\sqrt{\sec\frac{2\pi}7+1}}}{\sec\frac\pi7\sqrt{\sec\frac{2\pi}7+1}}\\ &\hspace{5cm} -\cos^2\frac{3\pi}7\frac{\cot^{-1}{\sqrt{\sec\frac{3\pi}7-1}}}{\sec\frac{2\pi}7\sqrt{\sec\frac{3\pi}7-1}}\\ &\hspace{5cm} +\cos^2\frac{\pi}7\frac{\cot^{-1}{\sqrt{\sec\frac{\pi}7-1}}}{\sec\frac{3\pi}7\sqrt{\sec\frac{\pi}7-1}}\ \ \bigg) \\ &\int_0^{\pi/2}\frac1{\sin^{9} x+\cos^{9} x}dx= \frac{64}9 \bigg( \frac{\coth^{-1}\sqrt2 }{2\sqrt2}-\frac\pi{64}\\ &\hspace{5cm} -\cos^3\frac{2\pi}9\frac{\coth^{-1}{\sqrt{\sec\frac{2\pi}9+1}}}{\sec\frac\pi9\sqrt{\sec\frac{2\pi}9+1}}\\ &\hspace{5cm} +\cos^3\frac{4\pi}9\frac{\coth^{-1}{\sqrt{\sec\frac{4\pi}9+1}}}{\sec\frac{2\pi}9\sqrt{\sec\frac{4\pi}9+1}}\\ &\hspace{5cm} +\cos^3\frac{\pi}9\frac{\cot^{-1}{\sqrt{\sec\frac{\pi}9-1}}}{\sec\frac{4\pi}9\sqrt{\sec\frac{\pi}9-1}}\ \ \bigg) \\ \end{align}

Partial answer: Your idea of tangent substitution works seamlessly for all positive even integers. I will write the final answer here since you mentioned you can carry out the details:

$$I(2n) = \dfrac{\pi}{2n}\sum_{k=1}^n\dfrac{\binom{n-1}{k-1}}{\sin\tfrac{2k-1}{2n}\pi}.$$

For odd integers, it gets more complicated but solvable. Do the half-tangent substitution $$t = \tan\frac x2$$ and your integral turns to: $$I_{2n+1} = 2\int_0^1\dfrac{(1+t^2)^{2n}}{(2t)^{2n+1}+(1-t^2)^{2n+1}}dt.$$

This is ugly but since one can explicitly find the roots of $$z^m+1 = 0$$, it is possible to use complex methods to calculate the above integrals in terms of sums of terms like the even integer case.