TITLE: What is the primitive function of $\int 1/(x^{2n} +1)dx$?
QUESTION [14 upvotes]: I am a student who is preparing for IIT exam. I was just practicing calculus and encountered this problem. I tried different substitutions but none of them seemed to work. So what is the primitive function of  $$\int \frac{1}{x^{2n} +1} \, \mathrm{d}x $$ ?

REPLY [37 votes]: We have $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 1:
The integral of $\frac{1}{1+x^{2n}}$ is a special case for the development herein.  Simply let $n\to 2n$.

NOTE 2:
As requested, we will 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}}$$