Computing the primitive $\int\frac{1}{1+x^n} dx$ Well, this might be a really simple one. But still... What will be the soln. to ---
\begin{aligned}
\int\frac{1}{1+x^n} dx \end{aligned}
Is substituting \begin{aligned} 1+x^n \end{aligned} by tan z the correct step?
Thanks for the Help.
 A: Here is an approach. You can get a nice closed form in terms of the hypergeomtric function
$$I = \int\frac{1}{1+x^n} dx = \sum_{k=0}^{\infty}(-1)^k \int x^{kn} dx= \sum_{k=0}^{\infty}\frac{(-1)^kx^{nk+1}}{kn+1} + c $$

$$ \implies I = x\,{\mbox{$_2$F$_1$}(1,{n}^{-1};\,1+{n}^{-1};\,-{x}^{n})}+c.$$

A: Let $f(x)=\frac{1}{x^n+1}$.  Note that we can write 
$$f(x)=\prod_{k=1}^n(x-x_k)^{-1} \tag {1}$$
where $x_k=e^{i(2k-1)\pi/n}$, $k=1, \cdots,n$.  
We can also express $(1)$ as 
$$f(x)=\sum_{k=1}^na_k(x-x_k)^{-1} \tag {2}$$
where $a_k=\frac{-x_k}{n}$.
Now, we can write
$$\begin{align}
\int\frac{1}{x^n+1}dx=-\frac1n\sum_{k=1}^nx_k\log(x-x_k)+C
\end{align}$$
which can be more explicitly written as 
$$\bbox[5px,border:2px solid #C0A000]{\int\frac{1}{x^n+1}dx=-\frac1n\sum_{k=1}^n\left(\frac12 x_{kr}\log(x^2-2x_{kr}x+1)-x_{ki}\arctan\left(\frac{x-x_{kr}}{x_{ki}}\right)\right)+C'}
$$
where $x_{kr}$ and $x_{ki}$ are the real and imaginary parts of $x_k$, respectively, and are given by
$$x_{kr}=\text{Re}\left(x_k\right)=\cos \left(\frac{(2k-1)\pi}{n}\right)$$
$$x_{ki}=\text{Im}\left(x_k\right)=\sin \left(\frac{(2k-1)\pi}{n}\right)$$
NOTE :
Here, we derive the form $a_k=-\frac{x_k}{n}$.  To that end, we use $(2)$ and observe that
$$\begin{align}
\lim_{x\to x_\ell}\left((x-x_{\ell})\sum_{k=1}^{n}a_k(x-x_k)^{-1}\right)&=\lim_{x\to x_\ell}\left((x-x_{\ell})\frac{1}{1+x^n}\right) \tag 3 
\end{align}$$
The left-hand side of $(3)$ is simply $a_{\ell}$.  For the right-hand side, straightforward application of L'Hospital's Rule yields 
$$\begin{align}
\lim_{x\to x_\ell}\left(\frac{(x-x_{\ell})}{1+x^n}\right)&=\frac{1}{nx_{\ell}^{n-1}}
\end{align}$$
Finally, we note that since $x_{\ell}^n=-1$, then 
$$\begin{align}
\frac{1}{nx_{\ell}^{n-1}}&=\frac{x_{\ell}}{nx_{\ell}^n}\\\\
&=-\frac{x_{\ell}}{n}
\end{align}$$
Thus, we have that 
$$\bbox[5px,border:2px solid #C0A000]{a_{k}=-\frac{x_k}{n}}$$
