Evaluating $\int\frac{x^b}{1+x^a}~dx$ for $a,b\in\Bbb N$

Let $\gamma=\exp(2\pi i/a)$. The polynomial $Q(x)=x^a+1$ has $a$ simple roots $z_k=\gamma^{k+1/2}$, $0\leq k<a$. Since $z_k^a=-1$, we have $Q'(z_k)=a z_k^{a-1}=-a z_k^{-1}$, so $$ \frac{1}{Q(x)} = \sum_{k=0}^{a-1} \frac{1}{Q'(z_k)} \frac{1}{x-z_k} = -\frac{1}{a} \sum_{k=0}^{a-1} \frac{z_k}{x-z_k} $$

For the numerator we first make a reduction in the degree (when $b\geq a$).

Let $p= b \mod a \in \{0,1,...,a-1\}$ and $m=(b-p)/a$. Then $$ \frac{x^b - (-1)^m x^p}{x^a + 1} = \sum_{j=1}^m (-1)^j x^{b-ja} $$ We deduce that $$ \frac{x^b}{x^a+1} - \sum_{j=1}^m (-1)^j x^{b-ja} = \frac{(-1)^mx^p}{x^a+1} = - \frac{(-1)^m}{a} \sum_{k=0}^{a-1} z_k \frac{x^p}{x-z_k}= - \frac{(-1)^m}{a} \sum_{k=0}^{a-1} \frac{z_k^{p+1}}{x-z_k} $$ The last equality follows from the fact that the difference is a polynomial which must vanish since $p<a$. So a part from the trivial part on the LHS (which I leave aside), the problem is reduced to integrating the RHS. We have

$$ - \int \frac{(-1)^m}{a} \sum_{k=0}^{a-1} \frac{z_k^{p+1}}{x-z_k}dx = - \frac{(-1)^m}{a} \sum_{k=0}^{a-1} z_k^{p+1} \ln (x-z_k) $$ To avoid complex log and too long formulas, let us write
$$ u_{k,p} = \cos \left( \frac{2\pi (k+1/2)(p+1)}{a}\right) , \; \; v_{k,p} = \sin \left( \frac{2\pi (k+1/2)(p+1)}{a}\right) , \; \; $$ Using $\overline{z_{a-1-k}} = z_{k} = u_{k,0}+i v_{k,0}$ we obtain for $a$ even: $$ - \frac{(-1)^m}{2a} \sum_{k=0}^{\lfloor a/2 \rfloor} \left[ u_{k,p} \ln \left(x^2- 2 u_{k,0} x+1\right) + v_{k,p} \arctan \frac{x-u_{k,0}}{v_{k,0}} \right] $$ For $a$ odd you should add to this expression the "middle term" (which has no arctan part) $$ \frac{(-1)^{m+p}}{a} \ln(x+1) $$ No guarantee for the above being free of errors ...


One can use this answer for evaluating $\dfrac1{1+x^a}$ in the following form $$\frac1{1+x^a}=\sum_{k=1}^aa_k(x-x_k)^{-1} \tag {2}$$ where $a_k=\frac{-x_k}{n}$ and $x_k=e^{i(2k-1)\pi/n}$, $k=1, \cdots,n$

After that this integral can be evaluate

$$\int\frac{x^b}{1+x^a}~dx=\int\sum_{k=1}^aa_k(x-x_k)^{-1} (x-x_k+x_k)^b= \int\sum_{k=1}^aa_k(x-x_k)^{-1} \sum_{l=0}^b C_b^l(x-x_k)^l x_k^{b-l} $$ $$ =-\sum_{k=1}^a\Big(\sum_{l=1}^b\frac{C_b^l}{ln}(x-x_k)^l x_k^{b-l+1}+x_k^{b+1}\log(x-x_k)\Big) $$