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?


If the integral is taken from $0$ to $\infty$, there is more than one way to evaluate this. One is $$ \begin{align} \int_0^\infty\frac{\mathrm{d}t}{1+t^{2n}} &=\int_0^1\frac{\mathrm{d}t}{1+t^{2n}}+\int_0^1\frac{t^{2n-2}\,\mathrm{d}t}{1+t^{2n}}\\ &=\int_0^1(1-t^{2n}+t^{4n}-t^{6n}+\dots)\,\mathrm{d}t\\ &+\int_0^1(t^{2n-2}-t^{4n-2}+t^{6n-2}+\dots)\,\mathrm{d}t\\ &=1-\frac{1}{2n+1}+\frac{1}{4n+1}-\frac{1}{6n+1}+\dots\\ &+\frac{1}{2n-1}-\frac{1}{4n-1}+\frac{1}{6n-1}-\dots\\ &=\frac{1}{2n}\left(\frac{1}{0+\frac{1}{2n}}-\frac{1}{1+\frac{1}{2n}}+\frac{1}{2+\frac{1}{2n}}-\frac{1}{3+\frac{1}{2n}}+\dots\right)\\ &+\frac{1}{2n}\left(-\frac{1}{-1+\frac{1}{2n}}+\frac{1}{-2+\frac{1}{2n}}-\frac{1}{-3+\frac{1}{2n}}-\dots\right)\\ &=\frac{1}{2n}\sum_{k=-\infty}^\infty\frac{(-1)^k}{k+\frac{1}{2n}}\\ &=\frac{\pi}{2n}\csc\left(\frac{\pi}{2n}\right)\tag{1} \end{align} $$ The last step uses the result from "An Infinite Alternating Harmonic Series" on this page.


Another method is to use contour integration to evaluate $$ \frac12\int_{-\infty}^\infty\frac{\mathrm{d}t}{1+t^{2n}} =\frac12\oint_\gamma\frac{\mathrm{d}z}{1+z^{2n}}\tag{2} $$ where $\gamma$ is the path from $-\infty$ to $\infty$ along the real axis (which picks up the integral in question), then circling back counter-clockwise around the upper half-plane (which vanishes). The countour integral in $(2)$ is $2\pi i$ times the sum of the residues of $\frac{1}{1+z^{2n}}$ in the upper half-plane.

The poles of the integrand in $(2)$ are given by $$ \zeta_k=e^{\frac{\pi i}{2n}(2k+1)}\tag{3} $$ where $k=0\dots n-1$ represent the roots in the upper half-plane. All the poles are simple, so the residues are $$ \begin{align} \mathrm{Res}_{z=\zeta_k}\left(\frac{1}{1+z^{2n}}\right) &=\lim_{z\to\zeta_k}\frac{z-\zeta_k}{1+z^{2n}}\\ &=-\frac{1}{2n}\zeta_{k}\\ &=-\frac{1}{2n}e^{\frac{\pi i}{2n}(2k+1)}\tag{4} \end{align} $$ Thus, we get $$ \begin{align} \int_0^\infty\frac{\mathrm{d}t}{1+t^{2n}} &=-\frac{2\pi i}{4n}\sum_{k=0}^{n-1}e^{\frac{\pi i}{2n}(2k+1)}\\ &=-\frac{\pi i}{2n}e^{\frac{\pi i}{2n}}\frac{1-(-1)}{1-e^{\frac{\pi i}{n}}}\\ &=\frac{\pi}{2n}\csc\left(\frac{\pi}{2n}\right)\tag{5} \end{align} $$


The following papers will be useful. Note that Gopalan/Ravichandran is freely available on the internet.

M. A. Gopalan and V. Ravichandran, Note on the evaluation of $\int \frac{1}{\;1\;+\;t^{2^{n}}\;}dt$, Mathematics Magazine 67 #1 (February 1994), 53-54.

Judith A. Palagallo and Thomas E. Price, Some remarks on the evaluation of $\int \frac{dt}{\;t^{m}\;+\;1\;}$, Mathematics Magazine 70 #1 (February 1997), 59-63.

V. Ravichandran, On a series considered by Srinivasa Ramanujan, Mathematical Gazette 88 #511 (March 2004), 105-110.


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