Factorize $x^{2n}+1$ to evaluate $\int\tan^{1/n}(x)dx$ I've been attempting to find a formula for $\int\tan(x)^{1/n}dx, n\in\Bbb N$.  
I started out by performing the substitution $$u=\tan(x)^{1/n}$$
$$dx=\frac {nu^{n-1}}{1+u^{2n}}du$$ to transform the integral into $$n\int \frac{u^n}{1+u^{2n}}du$$
This is a relatively simple rational function, so it should be possible to solve via a partial fraction expansion. For the simple case where $n=2$, I was able to rewrite the integral as $$\frac{\sqrt2}{2}\left(\int\frac{u}{u^2-\sqrt2u+1}du - \int\frac{u}{u^2+\sqrt2u+1}du\right)$$
Which can then be solved by completing the square to yield $$\frac{\sqrt2}{4}\ln\left(\left(\sqrt{\tan{x}}-\frac{\sqrt2}{2}\right)^2+\frac{1}{2}\over\left(\sqrt{\tan{x}}+\frac{\sqrt2}{2}\right)^2+\frac{1}{2}\right)+\frac{\sqrt2}{2}\left(\arctan\left({\sqrt{2\tan{x}}-1}\right)+\arctan\left({\sqrt{2\tan{x}}+1}\right)\right)+C$$
However, I can't figure out how to factor the denominator for the partial fraction expansion of the general case. It will always be a product of $n$ irreducible quadratic factors, clearly, but I don't know how to locate them. I have managed to find the complex linear factors, using Euler's identity to find that they're of the form $$x\pm e^{im\pi\over{2n}}$$ where m is allowed to vary from 1 to $2n$. How can I combine these linear factors into real, irreducible quadratics for use in my partial fraction expansion? Alternatively, is there a simpler method of evaluating this integral? Any help would be vastly appreciated.
 A: With $a_k=\frac{(2k-1)\pi}{2n}$
$$x^{2n}+1= \prod_{k=1}^{2n}(x- e^{i a_k})$$
and the corresponding partial fractional decomposition is
\begin{align}
\frac{x^n}{x^{2n}+1} & = -\frac1{2n}\sum_{k=1}^{2n}\frac{e^{i(n+1)a_k}}{x-e^{i a_k}}\\
&=-\frac1{2n}\sum_{k=1}^{n}\left(
 \frac{e^{i (n+1)a_k}}{x-e^{ia_k} }+ \frac{e^{-i (n+1)a_k}}{x-e^{-ia_k}} \right)\\
&= -\frac1{n}\sum_{k=1}^{n}
 \frac{x\cos(n+1)a_k+\cos na_k }{x^2-2x\cos a_k +1} \\
 &= \frac1{n}\sum_{k=1}^{n}
 \frac{(-1)^{k+1} x\sin a_k}{x^2-2x\cos a_k +1} 
\end{align}
Then, integrate term-wise to obtain
\begin{align}
& \int\tan^{\frac1n}(t)\> dt= \int \frac{nx^n}{x^{2n}+1}dx\\
=& \sum_{k=0}^{n}\frac{(-1)^{k+1}}2\left( \sin a_k
\ln\left(x^2 - 2x\cos a_k + 1\right)
+ 2\cos a_k
\tan^{-1}\frac{x- \cos a_k}{\sin a_k}
\right)
\end{align}
A: I do not think that this is an answer but it is too long for a comment.
Adressing this problem, you enter in the world of the gaussian hypergeometric function since $$I_n=n\int \frac{u^n}{1+u^{2n}}\,du=\frac{n \,u^{n+1} }{n+1}\,\, _2F_1\left(1,\frac{n+1}{2 n};\frac{3n+1}{2 n};-u^{2 n}\right)$$ which, as you showed, can simplify for $n=2$.
In other words, back to $x$, $$I_n=\int{\tan^{\frac 1n} (x)}\,dx=\frac{n \tan ^{\frac{n+1}{n}}(x)}{n+1}\,\,\, _2F_1\left(1,\frac{n+1}{2 n};\frac{3n+1}{2 n};-\tan
   ^2(x)\right)$$
Edit
In your comment, you reported that $$u^6+1=(u^2+\sqrt{3}u+1)(u^2-\sqrt{3}u+1)(u^2+1)$$ So, using partial fraction decomposition $$\frac{u^3}{1+u^6}=\frac{u}{3
   \left(u^2+1\right)}+\frac{u}{6 \left(u^2-\sqrt{3} u+1\right)}+\frac{u}{6 \left(u^2+\sqrt{3} u+1\right)}$$ which can be integrated leading to $$\int\frac{u^3}{1+u^6}\,du=-\frac{1}{6} \log \left(u^2+1\right)+\frac{1}{12} \log \left(u^2-\sqrt{3}
   u+1\right)+\frac{1}{12} \log \left(u \left(u+\sqrt{3}\right)+1\right)-\frac{\tan
   ^{-1}\left(\sqrt{3}-2 u\right)}{2 \sqrt{3}}-\frac{\tan ^{-1}\left(2
   u+\sqrt{3}\right)}{2 \sqrt{3}}$$ Here again, the logarithms can be combined together as well as the arctangents. 
Much more tedious is the factorization of $u^8+1$; it leads to
$$u^8+1=\left(u^2-2 u \sin \left(\frac{\pi }{8}\right)+1\right) \left(u^2+2 u \sin
   \left(\frac{\pi }{8}\right)+1\right)$$ $$ \left(u^2-2 u \cos \left(\frac{\pi
   }{8}\right)+1\right) \left(u^2+2 u \cos \left(\frac{\pi }{8}\right)+1\right)$$ leading to a small monster I shall not reproduce here (too long !).
Similarly, we could write $$u^{10}+1=(1+u^2)(u^8-u^6+u^4-u^2+1)$$ and the last term again can be factorized as the product of four quadratic polynomials.
$$\left(u^2-\sqrt{\frac{1}{2} \left(5-\sqrt{5}\right)} u+1\right)
   \left(u^2+\sqrt{\frac{1}{2} \left(5-\sqrt{5}\right)} u+1\right)$$
$$   \left(u^2-\sqrt{\frac{1}{2} \left(5+\sqrt{5}\right)} u+1\right)
   \left(u^2+\sqrt{\frac{1}{2} \left(5+\sqrt{5}\right)} u+1\right)$$
Looking for something else, I found this post where Dr.MV's answer would be very interesting for yur work.
A: We are going to the fact that the natural logarithm is a periodic function to find the $2n$ distinct roots of $x^{2n}+1$. Observe that  $$\forall z,w\in \mathbb{C},z\neq 0,\ln(z^w)\equiv w\ln(z)\pmod{2\pi i}$$
which is equivalent to
$$\forall z,w\in \mathbb{C},z\neq 0,\exists k\in \mathbb{Z},\ln(z^w)=w\ln(z)+2\pi ik$$
Then
\begin{align}
x^{2n}+1&=0\\
\Leftrightarrow x^{2n}&=-1\\
\end{align}
Since $x=0$ is not a root, it follows that
\begin{align}
x^{2n}&=-1\\
\Leftrightarrow \ln(x^{2n})&=\ln(-1)=\pi i\\
\Leftrightarrow \exists k\in \mathbb{Z},2n\ln(x)&=\pi i+2\pi i k\\
\Leftrightarrow \exists k\in \mathbb{Z},\ln(x)&=\frac{\pi i(1+2k)}{2n}\\
\Leftrightarrow \exists k\in \mathbb{Z},x&=\exp(\frac{\pi i(1+2k)}{2n}) \tag{1}
\end{align}
Since $\forall m\in\mathbb{Z},\exp(z)=\exp(z+2\pi im)$, we only need the first $2n$ integers in (1), that is $k\in\{1,2,\cdots,2n\}$. Hence, the $2n$ roots of $x^{2n}+1$ are given by
\begin{align}
r_1&=\exp(\frac{\pi i(1+2(1))}{2n})\\
r_2&=\exp(\frac{\pi i(1+2(2))}{2n})\\
&\vdots\\
r_{2n}&=\exp(\frac{\pi i(1+2(2n))}{2n})
\end{align}
An element $\gamma$ in a field K is a root of a polynomial with coefficients in K, iff $x-\gamma$ divides the polynomial, then
\begin{align}
x^{2n}+1&=\prod_{k=1}^{2n}x-r_k=\prod_{k=1}^{2n}x-\exp(\frac{\pi i(1+2k)}{2n})\\
\end{align}
Using Euler's formula $e^{i\theta}=\cos(\theta)+i\sin(\theta)$
\begin{align}
x^{2n}+1&=\prod_{k=1}^{2n}x-\Big(\cos(\frac{\pi (1+2k)}{2n})+i\sin(\frac{\pi (1+2k)}{2n})\Big)
\end{align}
You can finish the integration using partial fraction decomposition. A useful theorem will be the following:
Theorem 1.0 [1] Let $P(x)$ & $Q(x)$ be polynomials of real coefficients where $\deg(P)<\deg(Q)$ & $Q(x)=(x-r_1)(x-r_2)\cdots(x-r_n)$, then
$$\frac{P(x)}{Q(x)}=\sum_{i=1}^n\frac{P(r_i)}{Q'(r_i)}\frac{1}{x-r_i}$$
Theorem 1.0 can be used if $n<2n$, that is, if $0<n$. Let $0<n$, observe that
$$\int \tan^{\frac{1}{n}}(x)dx=\int \frac{nu^n}{u^{2n}+1}du$$
Let $P(u)=u^n$ & $Q(u)=u^{2n}+1=\prod_{k=1}^{2n}x-\big(\cos(\frac{\pi (1+2k)}{2n})+i\sin(\frac{\pi (1+2k)}{2n})\big)$, then $\deg(P)=n<2n=\deg(Q)$ & $Q'(u)=2nu^{2n-1}$, it follows by Theorem 1.0 that
\begin{align}
\int \frac{nu^n}{u^{2n}+1}du&=n\int \sum_{k=1}^{2n}\frac{P(r_k)}{Q'(r_k)}\frac{1}{u-r_k}du=n\int \sum_{k=1}^{2n}\frac{(r_k)^{n}}{2n(r_k)^{2n-1}}\frac{1}{u-r_k}du\\
&=\frac{1}{2}\int \sum_{k=1}^{2n}\frac{(r_k)^{n}}{(r_k)^{2n-1}}\frac{1}{u-r_k}du
=\frac{1}{2}\sum_{k=1}^{2n}\frac{(r_k)^{n}}{(r_k)^{2n-1}}\int\frac{1}{u-r_k}du\\
&=\frac{1}{2}\sum_{k=1}^{2n}\frac{(r_k)^{n}}{(r_k)^{2n-1}}\ln|u-r_k|+c
\end{align}
where $r_k$ is the kth root of $u^{2n}+1$. Substituting $r_k=\cos(\frac{\pi (1+2k)}{2n})+i\sin(\frac{\pi (1+2k)}{2n})$ and $u=\tan^{\frac{1}{n}}(x)$ we obtain
$$\frac{1}{2}\sum_{k=1}^{2n}\frac{\Big(\cos(\frac{\pi (1+2k)}{2n})+i\sin(\frac{\pi (1+2k)}{2n})\Big)^{n}}{\Big(\cos(\frac{\pi (1+2k)}{2n})+i\sin(\frac{\pi (1+2k)}{2n})\Big)^{2n-1}}\ln|\tan^{\frac{1}{n}}(x)-\cos(\frac{\pi (1+2k)}{2n})-i\sin(\frac{\pi (1+2k)}{2n})|+c$$
[1] https://en.wikipedia.org/wiki/Partial_fraction_decomposition#Procedure
