# Solving $\int_0^{\frac{\pi}{2}}\frac{1}{\sin^{2n}(x) + \cos^{2n}(x)}\:dx$

Spurred on this question I decided to investigate the following integral:

$$$$I_n = \int_0^{\frac{\pi}{2}}\frac{1}{\sin^{2n}(x) + \cos^{2n}(x)}\:dx$$$$

Where $$n \in \mathbb{N}$$.

The approach I've taken is rather simple and whilst I've arrived at a closed form solution, I'm wondering whether the resultant sum can be expressed in terms of (non)-elementary functions. Would love to see other methods that can be used to solve this! (Using any methods).

First:

$$$$I_n = \int_0^{\frac{\pi}{2}}\frac{1}{\sin^{2n}(x) + \cos^{2n}(x)}\:dx = \int_0^{\frac{\pi}{2}}\frac{1}{\left[\sin^{2}(x)\right]^n + \left[\cos^{2}(x)\right]^n}\:dx$$$$

Using the Double-Angle Formulas:

$$$$\sin^2(x) = \frac{1 - \cos\left(2x\right)}{2} \qquad \cos^2(x) = \frac{1 + \cos\left(2x\right)}{2}$$$$

Thus:

\begin{align} I_n &= \int_0^{\frac{\pi}{2}}\frac{1}{\left[\sin^{2}(x)\right]^n + \left[\cos^{2}(x)\right]^n}\:dx = \int_0^{\frac{\pi}{2}}\frac{1}{\left[\frac{1 - \cos\left(2x\right)}{2}\right]^n + \left[\frac{1 + \cos\left(2x\right)}{2}\right]^n}\:dx \\ &= 2^n \int_0^{\frac{\pi}{2}} \frac{1}{\left[1 - \cos\left(2x\right)\right]^n + \left[1 + \cos\left(2x\right)\right]^n}\:dx \end{align}

Making the substitution $$u = 2x$$

$$$$I_n = 2^n \int_0^{\frac{\pi}{2}} \frac{1}{\left[1 - \cos\left(2x\right)\right]^n + \left[1 + \cos\left(2x\right)\right]^n}\:dx = 2^{n - 1} \int_0^{\pi} \frac{1}{\left[1 - \cos\left(u\right)\right]^n + \left[1 + \cos\left(u\right)\right]^n}\:du$$$$

Now apply the Weierstrass (/Tangent half angle) substitution $$t = \tan\left(\frac{u}{2}\right)$$:

\begin{align} I_n &= 2^{n - 1} \int_0^{\pi} \frac{1}{\left[1 - \cos\left(u\right)\right]^n + \left[1 + \cos\left(u\right)\right]^n}\:du = 2^{n - 1} \int_0^{\infty} \frac{1}{\left[1 - \frac{1 - t^2}{1 + t^2}\right]^n + \left[1 + \frac{1 - t^2}{1 + t^2}\right]^n} \frac{2\:dt}{t^2 + 1} \\ &= \int_0^{\infty} \frac{\left[1 + t^2 \right]^{n - 1}}{t^{2n} + 1}\:dt \end{align}

By the Binomial Theorem:

$$$$\left[1 + t^2 \right]^{2n - 1} = \sum_{j = 0}^{n - 1} {n - 1 \choose j}t^{2j}$$$$

Thus: \begin{align} I_n &= \int_0^{\infty} \frac{\left[1 + t^2 \right]^{2n - 1}}{t^{2n} + 1}\:dt = \sum_{j = 0}^{n - 1} {n - 1 \choose j} \int_0^{\infty} \frac{t^{2j}}{t^{2n} + 1} \end{align}

Using the solution I found here we find:

\begin{align} I_n &= \sum_{j = 0}^{n - 1} {n - 1 \choose j} \int_0^{\infty} \frac{t^{2j}}{t^{2n} + 1} = \sum_{j = 0}^{n - 1} {n - 1 \choose j} \cdot \frac{1}{2n} \cdot 1^{\frac{2j + 1}{2n} - 1}B\left(1 - \frac{2j + 1}{2n} , \frac{2j + 1}{2n}\right) \\ &= \frac{1}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j} B\left(1 - \frac{2j + 1}{2n} , \frac{2j + 1}{2n}\right) \end{align}

\begin{align} I_n &= \frac{1}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j} B\left(1 - \frac{2j + 1}{2n} , \frac{2j + 1}{2n}\right) = \frac{1}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j} \frac{\Gamma\left(1 - \frac{2j + 1}{2n}\right)\Gamma\left(\frac{2j + 1}{2n}\right)}{\Gamma\left(1 - \frac{2j + 1}{2n} + \frac{2j + 1}{2n}\right)} \\ &= \frac{1}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j}\Gamma\left(1 - \frac{2j + 1}{2n}\right)\Gamma\left(\frac{2j + 1}{2n}\right) \end{align}

As $$\frac{2j + 1}{2n} \not \in \mathbb{Z}$$ we can employ Euler's Reflection Formula to yield:

\begin{align} I_n &= \frac{1}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j}\Gamma\left(1 - \frac{2j + 1}{2n}\right)\Gamma\left(\frac{2j + 1}{2n}\right) = \frac{1}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j} \frac{\pi}{\sin\left(\pi \cdot \frac{2j + 1}{2n}\right)} \\&= \frac{\pi}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j} \operatorname{cosec}\left(\frac{\pi}{2n}\left(2j + 1\right) \right) \end{align}

Thus,

$$$$\int_0^{\frac{\pi}{2}}\frac{1}{\sin^{2n}(x) + \cos^{2n}(x)}\:dx = \frac{\pi}{2n}\sum_{j = 0}^{n - 1} {n - 1 \choose j} \operatorname{cosec}\left(\frac{\pi}{2n}\left(2j + 1\right) \right)$$$$

Edit - Realised that $$2n - 1$$ should be $$n - 1$$

Using the same method as above an by letting $$$$S_n(x) = \sin^{2n}(x) + \cos^{2n}(x)$$$$

It becomes rather easy to solve:

$$$$I_{n,m} = \int_0^{\frac{\pi}{2}} \frac{S_n(x)}{S_m(x)}\:dx$$$$

Where $$n \lt m$$. After applying the double angle formulas, $$u$$-substitution, and half tangent formula we arrive at:

$$$$I_{n,m} = \int_0^{\infty} \frac{S_n(x)}{S_m(x)}\:dx = \int_0^{\infty} \frac{t^{2n} + 1}{t^{2m} + 1} \left[1 + t^2 \right]^{m - n - 1}\:dt$$$$

Applying the Binomial Expansion:

\begin{align} I_{n,m} &= \sum_{j = 0}^{n - 1} {m - n - 1 \choose j} \int_0^{\infty} \frac{t^{2n} + 1}{t^{2m} + 1} \cdot t^{2j}\:dt \\ &= \sum_{j = 0}^{n - 1} {m - n - 1 \choose j} \int_0^{\infty} \frac{t^{2\left(n + j\right)} }{t^{2m} + 1} \:dt + \sum_{j = 0}^{n - 1} {m - n - 1 \choose j} \int_0^{\infty} \frac{t^{2j} }{t^{2m} + 1} \:dt\\ \end{align}

Again applying another of my solutions (referenced above) we arrive at:

\begin{align} I_{n,m} &= \sum_{j = 0}^{n - 1} {m - n - 1 \choose j} \frac{\pi}{2m}\operatorname{cosec}\left(\frac{\pi}{2m}\left(2\left(n + j\right) + 1\right) \right) + \sum_{j = 0}^{n - 1} {m - n - 1 \choose j}\frac{\pi}{2m}\operatorname{cosec}\left(\frac{\pi}{2m}\left(2j + 1\right) \right) \\ &= \frac{\pi}{2m}\sum_{j = 0}^{n - 1} {m - n - 1 \choose j}\left[\operatorname{cosec}\left(\frac{\pi}{2m}\left(2\left(n + j\right) + 1\right) \right) + \operatorname{cosec}\left(\frac{\pi}{2m}\left(2j + 1\right) \right) \right] \end{align}

Note: Using the same method we can easily solve

$$$$I_{n,p} = \int_0^{\frac{\pi}{2}}\frac{1}{\left(\sin^{2n}(x) + \cos^{2n}(x) \right)^p}\:dx = \frac{1}{2n\Gamma(p)}\sum_{m = 0}^{np - 1} {np - 1 \choose m}\Gamma\left(p - \frac{2m + 1}{2n}\right)\Gamma\left(\frac{2m + 1}{2n}\right)$$$$ Where $$p \in \mathbb{N}$$

• I think that's the "closest" you can reach to the "closed form" Commented Jan 3, 2019 at 3:54
• @Digamma - Thanks. Let me know if you think of anything :-)
– user150203
Commented Jan 3, 2019 at 8:59
• Wikipedia defines "a closed-form expression is a mathematical expression that can be evaluated in a finite number of operations." So if $n$ is finite, you have a closed form. Bravo David, this one is really spectacular. Commented Jan 3, 2019 at 23:29
• Thanks @clathratus!.
– user150203
Commented Jan 4, 2019 at 1:18

I cannot seem to add much here other than a slightly quicker way for you to reach the integral you arrive at after making a tangent half-angle substitution.

Factoring out a $$\cos^{2n} x$$ term in the denominator of the original integral for $$I_n$$ we have $$I_n = \int_0^{\frac{\pi}{2}} \frac{\sec^{2n} x}{1 + \tan^{2n} x} \, dx = \int_0^{\frac{\pi}{2}} \frac{\sec^{2n - 2} x}{1 + \tan^{2n} x} \sec^2 x \, dx.$$ On setting $$t = \tan x, dt = \sec^2 x \, dx$$, we have $$I_n = \int_0^\infty \frac{(1 + t^2)^{n - 1}}{1 + t^{2n}} \, dt.$$

• Thanks @omegadot - Yes a much quicker way than the approach I took.
– user150203
Commented Jan 3, 2019 at 4:54

The closed form for $$I_n= \frac{\pi}{4} \int_{0}^{\frac{\pi}{2}} \frac{d x}{\sin ^{2n} x+\cos ^{2n} x}$$ is

$$\boxed{I_{n}=\frac{\pi^2}{8 n} \sum_{k=0}^{n-1}\left(\begin{array}{c} n-1 \\ k \end{array}\right) \csc \frac{(2 k+1) \pi}{2 n}}$$

Proof:

Letting $$t=\tan x$$ yields \begin{aligned} I_{n} &=\frac{\pi}{4} \int_{0}^{\infty} \frac{\left(1+t^{2}\right)^{n-1}}{t^{2 n}+1} \\ &= \frac{\pi}{4} \sum_{k=0}^{n-1}\left(\begin{array}{c} n-1 \\ k \end{array}\right) \int_{0}^{\infty} \frac{t^{2 k}}{t^{2 n}+1} d t . \end{aligned}

By my post, $$\int_{0}^{\infty} \frac{x^{r}}{x^{m}+1} d x=\frac{\pi}{m} \csc \frac{(r+1) \pi}{m},$$

We can now get its closed form: $$\boxed{I_{n}=\frac{\pi^2}{8 n} \sum_{k=0}^{n-1}\left(\begin{array}{c} n-1 \\ k \end{array}\right) \csc \frac{(2 k+1) \pi}{2 n}}$$

For examples:

\begin{aligned} I_{2}&=\frac{\pi^2}{16}\left(\csc \frac{\pi}{4}+\csc \frac{3 \pi}{4}\right)=\frac{\sqrt{2} \pi^{2}}{8} \\ I_{3}&=\frac{\pi^2}{24}\left(\csc \frac{\pi}{6}+2 \csc \frac{3 \pi}{6}+\csc \frac{5 \pi}{6}\right)=\frac{\pi^{2}}{4} \\ I_{4}&=\frac{\pi^2}{32} \left[\left(\begin{array}{l} 3 \\ 0 \end{array}\right) \csc \frac{\pi}{8}+\left(\begin{array}{l} 3 \\ 1 \end{array}\right) \csc \frac{3 \pi}{8}+\left(\begin{array}{l} 3 \\ 2 \end{array}\right) \csc \frac{5 \pi}{8}+\left(\begin{array}{l} 3 \\ 3 \end{array}\right) \csc \frac{6\pi}{8}\right]= \frac{\pi^2}8\sqrt{10-\sqrt2} \end{aligned}