$$ \text{General solution to }\int \frac{1}{x^n +1}dx \text{ where } n \text{is an integer?} $$

Close-Form General Solution:

Question

Is there a general solution to the integral $$\int \frac{1}{x^n +1}dx$$ where $x ∈ ℝ$ and $n ∈ ℤ$?

Answer

$$\begin{align*}\color{red}{\int \frac {dx}{x^n+1}} &=\int(1+x^n)^{-1}dx \\& = \int\left(1 - x^n + x^{2n} - x^{3n} + x^{4n} - x^{5n}...\right)dx \\& = x\left(1 - \frac {x^n}{n + 1} + \frac {x^{2n}}{2n + 1} -\frac {x^{3n}}{3n + 1} + \frac {x^{4n}}{4n + 1} - \frac {x^{5n}}{5n + 1}...\right) + C \\& =x\left(1 + \frac {1.\frac 1n}{1 + \frac 1n}\frac {(-x^n)^1 }{1!}+ \frac{1.2.\left(\frac 1n (\frac 1n + 1)\right)}{\left(\frac 1n + 1\right)\left(\frac 1n + 2\right)}\frac {(-x^n)^2}{2!} + \right) +C \\& = \color{red}{x_2F_1\left(1, \frac1n;1+\frac1n;-x^n\right) +C} \end{align*}$$ Here, we have used Gaussian Hypergeometric function as I believed $b$ and $c$ have telescopic ratio:) and $(a)_k$ is simply $k!$ or else considering a generalized form $$I = \int \frac {x^{l - 1}}{x^n + 1}dx$$ if $ n$ is even: $$I = -\frac 1n \sum_{r = 1}^{\frac n2} \cos\left(\frac {(2r-1)l\pi}{n}\right)\log\left(x^2 - 2x\cos\left(\frac {(2r-1)\pi}{n}\right)+1\right) + \frac 2n \sum_{r = 1}^{\frac n2}\sin\left(\frac {(2r - 1)l\pi}{n}\right)\tan^{-1}\left(\frac {x - \cos((2r - 1)\pi/n)}{\sin((2r - 1 )\pi/n)}\right)$$ if $n$ is odd: $$I = \frac{(-1)^{l-1}}{n}\log(x+1) - \frac 1n\sum_{r = 1}^{\frac {n-1}2}\cos\left(\frac {(2r - 1)l\pi}n\right)\log\left(x^2 - 2x\cos\left(\frac {(2r-1)\pi}n\right) + 1\right) + \frac 2n\sum_{r = 1}^{\frac {n-1}2}\sin\left(\frac{(2r-1)l\pi}n\right)\tan^{-1}\left(\frac {x - \cos((2r-1)\pi/n)}{\sin((2r - 1)\pi/n)}\right)$$