Evaluate $\int\frac1{1+x^n}dx$ for $n\in\mathbb R$

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|$.


For positive integers $n$ you can write $$ \dfrac{1}{1+x^n} = \sum_{\omega} \dfrac{r(\omega)}{x - \omega}$$ where the sum is over the $n$'th roots of $-1$ and $r(\omega)$ is the residue of $1/(1+x^n)$ at $x = \omega$, so that your integral is $$ c + \sum_\omega r(\omega) \log(x - \omega)$$

You can also express the power series solution in terms of the Lerch Phi function: $$ c + \dfrac{x}{n} {\rm LerchPhi}(-x^n,1,1/n) $$