I am trying to find
$$I = \int_{-1}^1\left(\frac{1-x}{1+x}\right)^\frac{1}{n}dx$$
using contour integration, where $n \ge 2$ is an integer.
My method is to define $f(z) = \left(\frac{z-1}{z+1}\right)^\frac{1}{n}$, which has branch points at $z = \pm 1$, so I include a branch cut on the real axis for $[-1,1]$. I then expand around $z = \infty$, which gives $f = 1 - \frac{2}{nz} + O(z^{-2}).$
Integrating this around a circle with radius $R >>1 $ gives $-4\pi i/n$. I then collapse the contour around the branch cut, and integrate essentially along the real axis, which should give $$-4 \pi i/n = i\int_{1}^{-1}\left(\frac{1-x}{1+x}\right)^\frac{1}{n}dx + i\int_{-1}^{1}\left(\frac{1-x}{1+x}\right)^\frac{1}{n} \cdot e^{i \pi}dx = - 2i\int_{-1}^1\left(\frac{1-x}{1+x}\right)^\frac{1}{n}dx$$
where the factor of $e^{i \pi}$ arises because we are below the branch cut.
So I have $I = 2 \pi / n$, but this cannot be right, because the limit as $n \rightarrow \infty$ should be $2$. I have only recently started teaching myself complex integration so maybe it is obvious but I cannot figure out where I have went wrong.
I have been able to show (albeit by integrating numerically and playing in desmos) that the answer appears to be $$ I = \frac{2^{3/2} \pi }{n\sqrt{1-cos\left(\frac{2 \pi}{n}\right)}},$$ however obviously I would like to see how one gets this using contour integration.
I have solved it - there are two errors, both of which occur during the integration along the real axis. The first is the factor of $i$, which should be a factor or $(-1)^\frac{1}{n} = e^{-i \pi/n}$. The second is that the factor of $e^{i \pi}$ in the second integrand should be a factor of $e^{2 \pi i/n}$, reflecting the fact that we have the n$^{th}$ root, so we require to go over our branch cut $n$ times to get back to unity. This all changes the collapsing of the contour onto the real axis to:
$$\frac{-4\pi i}{n} = e^{-i \pi/n}\left[\int_1^{-1}\left(\frac{1-x}{1+x} \right) ^{1/n}dx+\int_{-1}^{1}\left(\frac{1-x}{1+x} \right) ^{1/n}\cdot e^{2 \pi i/n} dx\right] = -2i \,\sin \left(\frac{\pi}{n} \right)I_n$$
$$\therefore I_n = \frac{2\pi}{n\, \sin\left(\frac{\pi}{n}\right)}\, ,$$ which gives the result at the bottom of the my question after some manipulation.