I was wondering on how to evaluate the following indefinite integral for all $n\in\mathbb R$.
$$\int\frac1{1+x^n}dx$$
It seems to be peculiar in that we have
$$\begin{align} \int\frac1{1+x^{-1}}dx&=x-\ln(x+1)+c\\ \int\frac1{1+x^0}dx&=\frac12x+c\\ \int\frac1{1+x^{1/2}}dx&=2\sqrt x-2\ln(1+\sqrt x)+c\\ \int\frac1{1+x^1}dx&=\ln(x+1)+c\\ \int\frac1{1+x^2}dx&=\arctan(x)+c\\ \int\frac1{1+x^3}dx&=\frac13\ln(1+x)-\frac2{3\sqrt3}\arctan\left(\sqrt{\frac43}\left(x-\frac12\right)\right)+c \end{align}$$
Naturally, there appears to be some combination of $\ln$ and $\arctan$, though no simple formula arises to solve the general case.
It is, however, easy to see that
$$\int\frac1{1+x^{-n}}dx=\int1-\frac1{1+x^n}dx$$
So there is an easy enough connection between positive and negative $n$.
Also, it is easy enough to find the series expansion, taking advantage of the above connection we just made to circumvent problems concerning convergence.
$$\frac1{1+x^n}=1-x^n+x^{2n}-x^{3n}+\dots\forall\ |x|<1$$
$$\int\frac1{1+x^n}dx=c+x-\frac1{n+1}x^{n+1}+\frac1{2n+1}x^{2n+1}-\dots$$
$$=c+\sum_{k=0}^\infty\frac{(-1)^k}{kn+1}x^{kn+1}\ \forall\ |x|<1$$
Though this isn't very much along the lines of closed form.
For $n=\frac ab$, where $a$ and $b$ are whole numbers, we can use the substitution $x=u^b$ to get
$$\int\frac1{1+x^n}dx=\int\frac{bu^{b-1}}{1+u^a}du$$
though I'm unsure where that could lead. This reduces the integral down to
$$\int\frac1{1+x^n}dx=b\int P(u)+\frac{u^{b-1-ak}}{1+u^a}du,\quad k\in\mathbb N$$
for some polynomial $P(u)$. Though I'm still clueless as to how this can be advanced.
How can I evaluate $\int\frac1{1+x^n}dx\ \forall\ n\in\mathbb R$ in closed form? Can someone prove there at least exists some closed form solution for all $n\in\mathbb Q$ if the above is not possible? If possible, use real numbers.
In THIS ANSWER, I showed that that the indefinite integral of interest is given by
$$\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} $$
for $n\ge 1$, where $x_{kr}$ and $x_{ki}$ can be written, respectively, as
$$x_{kr}=\cos \left(\frac{(2k-1)\pi}{n}\right)$$
$$x_{ki}=\sin \left(\frac{(2k-1)\pi}{n}\right)$$
For $n<0$, we simply write
$$\int \frac{1}{1+x^{-|n|}}\,dx=x-\int \frac{1}{1+x^{|n|}}\,dx$$
and use the aforementioned result with $n$ replaced with $|n|$.