How to evaluate $\int 1/(1+x^{2n})\,dx$ for an arbitrary positive integer $n$? How to find
$$\int\dfrac{dx}{1+x^{2n}}$$
where $n \in \mathbb N$?
Remark
When $n=1$, the antiderivative is $\tan^{-1}x+C$. But already with $n=2$ this is something much more complicated. Is there a general method?

I realized after I wrote this up that this is given in one of the papers mentioned by Dave L. Renfro, but I did all this work and the approach is not exactly the same, so here goes.
We wish to evaluate
$$
\int \frac{1}{1+x^n}\ dx.
$$
We will do this by partial fraction decomposition.  Note that the roots of $1+x^n$ are the $2n$-th roots of unity that are not $n$-th roots of unity.  That is to say $x^{2n}-1=(x^n-1)(x^n+1)$.  It follows that the set of roots of $1+x^n$ is
$$
\left\{\exp\left(\frac{(2k-1)\pi i}{n}
\right):0\leq k\leq n-1\right\}.
$$
If we consider the roots (excluding -1 if $n$ is odd) we have that
$$
\left(x-\exp\left(\frac{(2k+1)\pi i}{n}
\right)\right)\left(x-\exp\left(\frac{(2(n-k)-1)\pi i}{n}
\right)\right)=\left(x-\exp\left(\frac{(2k+1)\pi i}{n}
\right)\right)\left(x-\exp\left(\frac{-(2k+1)\pi i}{n}
\right)\right)
$$
$$
=x^2-\left(\exp\left(\frac{(2k+1)\pi i}{n}\right)+\exp\left(\frac{-(2k+1)\pi i}{n}
\right)
\right)x+1=x^2-2\cos\left(\frac{(2k+1)\pi}{n}\right)x+1.
$$
Let $x_k=\frac{(2k+1)\pi}{n}$ and $\alpha_k=\exp((2k+1)\pi i/n)$, then by partial fraction decomposition (for $n$ even) we have that 
$$
\frac{1}{1+x^n}=\sum_{k=0}^{n/2-1}\frac{a_kx+b_k}{x^2-2\cos(x_k)x+1}=\sum_{k=0}^{n/2-1}\frac{(a_kx+b_k)\prod_{\overset{j\neq k}{j\neq n-1-k}}(x-\alpha_j)}{1+x^n}=\sum_{k=0}^{n/2-1}\frac{\frac{a_kx+b_k}{x-\alpha_{n-1-k}}\prod_{j\neq k}(x-\alpha_j)}{1+x^n}.
$$
Furthermore
$$
1=\sum_{k=0}^{n/2-1}\frac{a_kx+b_k}{x-\alpha_{k}^{-1}}\prod_{j\neq k}(x-\alpha_j).
$$
If we set $x=\alpha_k$ for $0\leq k\leq n/2$ we obtain
$$
\frac{a_k\alpha_k+b_k}{\alpha_k-\alpha_{k}^{-1}}\prod_{j\neq k}(\alpha_k-\alpha_j)=1.
$$
Note that
$$
\prod_{k=1}^{n-1}(x-\exp(k2\pi i/n))=(1+x+\cdots+x^{n-1})
$$
so
$$
\prod_{k=1}^{n-1}(1-\exp(k2\pi i/n))=n.
$$
Furthermore 
$$
\prod_{j\neq k}(\alpha_k-\alpha_j)=\prod_{j\neq k}\alpha_k(1-\frac{\alpha_j}{\alpha_k})=\alpha_k^{n-1}\prod_{k=1}^{n-1}(1-\exp(k2\pi i/n))=n\alpha_k^{n-1}=-n\alpha^{-1}.
$$
So we are left with
$$
\frac{(a_k\alpha_k+b_k)(-n\alpha_k^{-1})}{\alpha_k-\alpha_{k}^{-1}}=1.
$$
and
$$
-n(a_k+\alpha_k^{-1}b_k)=\alpha_k-\alpha_{k}^{-1}=2i\sin(x_k)
$$
implying that
$$
a_k+\cos(x_k)b_k-i\sin(x_k)b_k=-\frac{2i}{n}\sin(x_k).
$$
Hence $b_k=\frac{2}{n}$ and $a_k=-\frac{2}{n}\cos(x_k)$.  So for even $n$ we have.
$$
\frac{1}{1+x^n}=-\frac{1}{n}\sum_{k=0}^{n/2-1}\frac{2\cos(x_k)x-2}{x^2-2\cos(x_k)x+1}
$$
If $n$ is odd we have the additional term 
$$
\frac{a}{1+x}
$$
and it follows that $a\prod_{\alpha_k\neq 1}(x-\alpha_k)=a(1-x+\cdots-x^{n-2}+x^{n-1})=1$.  Setting $x=-1$ we obtain $a=\frac{1}{n}$.
Noticing that
$$
\frac{2\cos(x_k)x-2}{x^2-2\cos(x_k)x+1}=\frac{\cos(x_k)(2x-2\cos(x_k))}{x^2-2\cos(x_k)x+1}+\frac{2\cos^2(x_k)-2}{(x-\cos(x_k))^2+1-\cos^2(x_k)}
$$
$$
=\frac{\cos(x_k)(2x-2\cos(x_k))}{x^2-2\cos(x_k)x+1}-2\frac{\sin^2(x_k)}{(x-\cos(x_k))^2+\sin^{2}(x_k)}
$$
$$
=\cos(x_k)\frac{(2x-2\cos(x_k))}{x^2-2\cos(x_k)x+1}-2\sin(x_k)\frac{\csc(x_k)}{(\frac{x-\cos(x_k)}{\sin(x_k)})^2+1}.
$$
So we have for even $n$
$$
\int\frac{1}{1+x^n}\ dx=-\frac{1}{n}\sum_{k=0}^{n/2-1}\left\{\cos(x_k)\int\frac{(2x-2\cos(x_k))}{x^2-2\cos(x_k)x+1}\ dx-2\sin(x_k)\int\frac{\csc(x_k)}{(\frac{x-\cos(x_k)}{\sin(x_k)})^2+1}\ dx\right\}
$$
$$
=-\frac{1}{n}\sum_{k=0}^{n/2-1}\left\{\cos(x_k)\log|x^2-2\cos(x_k)x+1|-2\sin(x_k)\arctan\left(\frac{x-\cos(x_k)}{\sin(x_k)}\right)\right\},
$$
and for odd $n$
$$
\int\frac{1}{1+x^n}\ dx=\frac{1}{n}\log|x+1|-\frac{1}{n}\sum_{k=0}^{(n-1)/2-1}\left\{\cos(x_k)\log|x^2-2\cos(x_k)x+1|-2\sin(x_k)\arctan\left(\frac{x-\cos(x_k)}{\sin(x_k)}\right)\right\}
$$
where $x_k=(2k+1)\pi/n$, $n\in\mathbb{Z}_{>0}$.
