How to evaluate $\int 1/(1+x^{2n})\,dx$ for an arbitrary positive integer $n$? [duplicate]

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?

• This feels very hypergeometric to me. Is that what you're looking for? Or perhaps you have bounds? Jul 15, 2012 at 7:59
• If the integral ranges from $-\infty$ to $\infty$ there's a nice trick with the Residue theorem. Jul 15, 2012 at 8:20
• @GerryMyerson : It's not always a good thing. Jul 17, 2012 at 0:30
• @Michael, OP is zero-for-ten (and unfortunately unable to do anything about it, having been suspended for the next few weeks), I'm zero-for-one, and I try to make up for it in other ways. Jul 17, 2012 at 5:17
• See THIS ANSWER and THIS ONE for a closed-from anti-derivative. May 18 at 2:39

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}

• How was the first equality calculated? (the change in the limits of integration) May 4, 2016 at 23:15
• Apply the substitution $t\mapsto\frac1t$ to the integral $\int_1^\infty\frac{\mathrm{d}t}{1+t^{2n}}$
– robjohn
May 4, 2016 at 23:54
• See I applied that and it didn't work out - but then I've just noticed I didn't take d(1/t). Thx!! May 5, 2016 at 0:04
• I think your answer is off by a factor of 2. When you calculate the residue, you get a fraction -\frac{1}{2n}, but when you sum 2\pi i times the residues you have -\frac{2\pi i}{4n} in front. Where is that extra multiple of \frac{1}{2} coming from? Sep 28, 2022 at 22:02
• @TheEmptyFunction: Notice that the contour integral is for $(-\infty,\infty)$, but the integral is for $(0,\infty)$. The $\frac12$ comes from equation $(2)$ using the fact that the integrand is even.
– robjohn
Sep 28, 2022 at 23:37

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.

• See THIS ANSWER and THIS ONE for a closed-from anti-derivative. May 18 at 2:39

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

• See THIS ANSWER and THIS ONE for a closed-from anti-derivative. May 18 at 2:40

Eric's answer can be futher generalized to integrals like $$\int\frac{x^{m}}{x^{n}\pm 1}\mathop{\mathrm{d}x}$$ where $$m\in\mathbb{N},n\in\mathbb{N}_+\land m

\begin{aligned} \int\frac{x^{m-1}}{x^{2n}+1}\mathop{\mathrm{d}x}&=\boxed{-\frac{1}{2n}\sum_{k=1}^{n}\left(\cos\left(\frac{\left(2k-1\right)m}{2n}\pi\right)\ln\left(\left|x^{2}-2\cos\left(\frac{2k-1}{2n}\pi\right)x+1\right|\right)\\ +2\sin\left(\frac{\left(2k-1\right)m}{2n}\pi\right)\tan^{-1}\left(\cot\left(\frac{2k-1}{2n}\pi\right)-\csc\left(\frac{2k-1}{2n}\pi\right)x\right)\right)+C}\\ \int\frac{x^{m-1}}{x^{2n+1}+1}\mathop{\mathrm{d}x}&=\boxed{\frac{\left(-1\right)^{m+1}\ln\left(\left|x+1\right|\right)}{2n+1}\\ -\frac{1}{2n+1}\sum_{k=1}^{n}\left(\cos\left(\frac{\left(2k-1\right)m}{2n+1}\pi\right)\ln\left(\left|x^{2}-2\cos\left(\frac{2k-1}{2n+1}\pi\right)x+1\right|\right)\\ +2\sin\left(\frac{\left(2k-1\right)m}{2n+1}\pi\right)\tan^{-1}\left(\cot\left(\frac{2k-1}{2n+1}\pi\right)-\csc\left(\frac{2k-1}{2n+1}\right)x\right)\right)+C}\\ \int\frac{x^{m-1}}{x^{2n+2}-1}\mathop{\mathrm{d}x}&=\boxed{\frac{\ln\left(\left|x-1\right|\right)+\left(-1\right)^{m}\ln\left(\left|x+1\right|\right)}{2n+2}\\ +\frac{1}{2n+2}\sum_{k=1}^{n}\left(\cos\left(\frac{km}{n+1}\pi\right)\ln\left(\left|x^{2}-2\cos\left(\frac{k}{n+1}\pi\right)x+1\right|\right)\\ +2\sin\left(\frac{km}{n+1}\pi\right)\tan^{-1}\left(\cot\left(\frac{k}{n+1}\pi\right)-\csc\left(\frac{k}{n+1}\pi\right)x\right)\right)+C}\\ \int\frac{x^{m-1}}{x^{2n+1}-1}\mathop{\mathrm{d}x}&=\boxed{\frac{\ln\left(\left|x-1\right|\right)}{2n+1}\\ +\frac{1}{2n+1}\sum_{k=1}^{n}\left(\cos\left(\frac{2km}{2n+1}\pi\right)\ln\left(\left|x^{2}-2\cos\left(\frac{2k}{2n+1}\pi\right)x+1\right|\right)\\ +2\sin\left(\frac{2km}{2n+1}\pi\right)\tan^{-1}\left(\cot\left(\frac{2k}{2n+1}\pi\right)-\csc\left(\frac{2k}{2n+1}\pi\right)x\right)\right)+C} \end{aligned}

Bonus

1. If $$m,n\in\mathbb{Q}_+\setminus\mathbb{N}_+$$, the integral can be rewritten as

$$\int\frac{x^{\frac{r}{s}}}{x^\frac{p}{q}\pm 1}\mathop{\mathrm{d}x}$$

where $$p,q,r,s\in\mathbb{N}_+$$.

Let $$u^{\operatorname{lcm}(s,q)}=x\rightarrow{\mathop{\mathrm{d}x}}={\operatorname{lcm}}(s,q)u^{\operatorname{lcm}(s,q)-1}$$, substitute it back and both of the exponent of the numerator and denominator become integrals, optionally convert it to a proper rational function via long division, then apply the formulas above.

2. If $$m\in\mathbb{R}\setminus\mathbb{Q}\lor n\in\mathbb{R}\setminus\mathbb{Q}$$, the integral cannot be expressed in elementary functions. One way to express is to use hypergeometric funcions \begin{aligned} \int\frac{x^{\alpha-1}}{x^{\beta}\pm 1}\mathop{\mathrm{d}x}&=\boxed{\pm\frac{x^{\alpha}}{\alpha}\operatorname{_2F_1}(1,\frac{\alpha}{\beta};1+\frac{\alpha}{\beta};\mp x^{\beta})+C} \end{aligned}

• See THIS ANSWER and THIS ONE for a closed-from anti-derivative. May 18 at 2:40
• @MarkViola My answer is also in closed form, and generalized your answer the case where the degree of the numerator is greater than zero. May 18 at 3:02