Calculating $\int_0^{\pi/2} \sqrt[n]{(\tan x)}dx=\int_0^{\infty} \frac{x^n}{1+x^{2n}}$ using contour integration Let $n$ be a natural number. I want to calculate $$\int_0^{\pi/2} \sqrt[n]{(\tan x)}dx=\int_0^{\infty} \frac{x^n}{1+x^{2n}}dx$$ using contour integration.
I declare $f(z) = \frac{z^n}{1+z^{2n}}$. This function has $2n$ simple poles of the form $exp(i\frac{-\pi}{2n} + i\frac{\pi k}{n})$ for $k = 0,1,2, ... , 2n-1$.
My problem is to find which contour to use. I thought about using the following:
$\gamma_1(t) = t$, $t \in [0,R]$
$\gamma_2(t) = Re^{it}$, $t \in [0,\frac{\pi}{n}]$
$\gamma_3(t) = te^{i\frac{\pi}{n}}$, $t \in [0,R]$
This way I have only one pole in the contour and I can use the residue theorem. 
Is this a good approach? I somehow have problem with the calculations here.
Help would be appreciated
 A: As you have defined $\gamma_3$,  that line contour is beginning at $t= R$ and comming back to 0. We are going to need to flip the sign.
$Res_{z=e^{\frac{\pi i }{2n}}} f(z) = \int_{\gamma_1} f(z) \ dz + \int_{\gamma_2} f(z) \ dz - \int_{\gamma_3} f(z) \ dz$
We are hoping to solve for $\int_{\gamma_1} f(z) \ dz$
You will need to show that $\lim_\limits{R\to\infty} \int_{\gamma_2} f(z) \ dz= 0.$
I will leave that to you.
$Res_{z=e^{\frac{\pi i }{2n}}} f(z) = \int_0^\infty f(t) \ dt - \int_0^\infty f(e^\frac{\pi i}{n} t)e^\frac{\pi i}{n} \ dt$
$Res_{z=e^{\frac{\pi i }{2n}}} f(z) = (1+e^\frac{\pi i}{n})\int_0^\infty f(t) \ dt\\
2e^{\frac{\pi i}{2n}} \cos \frac{\pi}{2n}\int_0^\infty f(t) \ dt = Res_{z=e^{\frac{\pi i }{2n}}} f(z)\\
\int_0^\infty f(t) \ dt = \frac{1}{2e^{\frac{\pi i}{2n}}\cos \frac{\pi}{2n}} Res_{z=e^{\frac{\pi i }{2n}}} f(z)$
$Res_{z=e^{\frac{\pi i }{2n}}} f(z) = 2\pi i \frac{i}{2n e^{\frac{(2n-1)\pi i }{2n}}}  = \frac{\pi e^\frac{\pi i}{2n}}{n}$
$\int_0^\infty f(t) \ dt  = \frac{\pi}{2n\cos \frac{\pi}{2n}}$
A: Substitute $x^{2n} = z$ to get
$$ \int_0^\infty \frac{x^{n}}{1+x^{2n}}dx = \frac{1}{2n}\int_0^\infty \frac{z^{-\frac12+\frac{1}{2n}}}{1+z} dz$$
Using the keyhole contour, you can find that for $n>1$:
$$\oint_C \frac{z^{-\frac12+\frac{1}{2n}}}{1+z} dz = (1-e^{2\pi i(-\frac12+\frac{1}{2n})}) \int_0^\infty \frac{z^{-\frac12+\frac{1}{2n}}}{1+z} dz = (1+e^{\frac{i\pi }{n}}) \int_0^\infty \frac{z^{-\frac12+\frac{1}{2n}}}{1+z} dz$$
On the other hand
$$\oint_C \frac{z^{-\frac12+\frac{1}{2n}}}{1+z} dz = 2\pi i \,{\rm Res}_{-1}\frac{z^{-\frac12+\frac{1}{2n}}}{1+z} =2\pi i e^{i\pi(-\frac12+\frac{1}{2n})} = 2\pi e^{\frac{i\pi }{2n}}$$
That means that 
$$ \int_0^\infty \frac{z^{-\frac12+\frac{1}{2n}}}{1+z} dz = \frac{2\pi e^{\frac{i\pi }{2n}}}{1+e^{\frac{i\pi }{n}}} = \frac{\pi}{\cos\frac{\pi}{2n}}$$
$$ \int_0^\infty \frac{x^{n}}{1+x^{2n}}dx = \frac{\pi}{2n \cos\frac{\pi}{2n}}$$
Your approach is equivalent, but without the initial change of variables.
