# Integral of $\frac{1}{x^{n}+1}$ for odd $n$

I am trying to find a general formula for $$\int \frac{1}{x^{n}+1} \, dx$$ where $$n$$ is an odd integer.

I can't find any answers on this site for this question, and I have already tried the following.

We can write $$x^{n} + 1 = (x+1)\sum_{k=0}^{n-1} (-1)^{k}x^{k}$$ and so we get $$\int \frac{1}{x^{n}+1} \, dx = \int \frac{1}{x+1} + \frac{\sum_{k=0}^{n-2} a_{k}x^{k}}{\sum_{k=0}^{n-1} (-1)^{k}x^{k}} \, dx$$ for some numbers $$a_{k}$$.

When $$n=3$$, this is easy enough to solve using partial fractions. When $$n=5$$ it is tricky but doable. For $$n \geq 7$$ it becomes intractable and even Mathematica fails to evaluate.

Is there a way to continue with my approach? Is there a better way to find a general formula?

• And related to that, the definite integral $\int_{0}^{\infty}\frac{\mathrm{d}x}{1+x^n}=\frac{\pi}{n}\csc\big(\frac{\pi}{n}\big)\space\forall\space n\in\mathbb{N}_{\ge2}$. Which, for me, is interesting. Commented May 16 at 5:18

We know that $$x^n+1=\prod _{k=1}^{n} x-e^{i{2k+1\over n}\pi}$$since all the roots are of order $$1$$, we can write $${1\over x^n+1}={1\over\prod _{k=1}^{n} (x-e^{i{2k+1\over n}\pi})}={1\over n}\sum_{k=1}^{n} {e^{-i\pi {n-1\over n}(2k+1)}\over x-e^{i{2k+1\over n}\pi}}$$by integrating we obtain$$\int{1\over x^n+1}dx={1\over n}\sum_{k=1}^{n} {e^{-i\pi {n-1\over n}(2k+1)} \ln | x-e^{i{2k+1\over n}\pi}|}+C$$

• I'm a little fuzzy about using absolute values for logarithms when the argument is complex. Would be more comfortable if you combined complex conjugate pairs of fractions making fractions with quadratic denominators, which allows an expression with real domain functions only. Commented Nov 29, 2018 at 10:47
• You're right. I wrote it that way for sake of simplicity while both the ways of expressing that lead to the same result. Commented Nov 29, 2018 at 11:11
• This is actually close to what I was thinking, but didn't manage to find a nice expression for the numerator. Thank you; I learned from this answer.
– Shai
Commented Dec 8, 2018 at 10:39
• You're welcome. I also couldn't find any better expression :) Commented Dec 8, 2018 at 20:48

It's doable but the details are pretty ugly so sorry for not completing this calculation. But I will give a complete algorithm for it.

The idea is to write $$\frac{1}{x^n+1} = \sum_{i=1}^{n}\frac{1}{f'(\psi_i)(x-\psi_i)}$$, where $$\psi_i$$ are the n-th roots of unity. Now you can further write the sum by grouping $$\frac{1}{f'(\psi_i)(x-\psi_i)} + \frac{1}{f'(\psi_{n-i})(x-\psi_{n-i})} = \frac{(2cos\frac{2\pi}{n})x-2}{x^2-(2cos\frac{2\pi}{n})x+1}$$ so we have actually managed to split our poly into fractions of irreducible polys over R(of degree 1 and 2!), which we know how to integrate.

• I think this is a great answer and I would love to accept them all. I think that comparing this to the other answers is mathematically interesting, because all solutions are equal which means with have some surprising equalities between seemingly unconnected expressions.
– Shai
Commented Dec 8, 2018 at 10:37

$$\frac 1 {x^{n}+1}=1-x^{n}+(-x^{n})^{2}+\cdots$$ and you can integrate this term by term for $$|x| <1$$. Note that for $$n$$ odd the integrand has a singularity at $$-1$$.

Let's find the Taylor series for $$x^a$$. Assume that $$D_b^kf(x)=\frac{\mathrm{d}^k}{\mathrm{d}x^k}f(x)\big|_{x=b}$$. $$D^0x^a=x^a$$ $$D^1x^a=ax^{a-1}$$ $$D^2x^a=a(a-1)x^{a-2}$$ $$\cdots$$ $$D^kx^a=x^{a-k}\prod_{i=0}^{k-1}(a-i)$$ We'll center our Taylor series about the point $$x=1$$. Thus, we know that our Taylor-Series coefficients are given by $$c_k=\frac1{k!}\prod_{i=0}^{k-1}(a-i)$$ And hence $$x^a=\sum_{k\geq0}\frac{(x-1)^k}{k!}\prod_{i=0}^{k-1}(a-i)$$ This series has a radius of convergence of $$1$$, which is something to keep in mind.

We proceed by noting that $$(1-x)^a=\sum_{k\geq0}(-1)^k\frac{x^k}{k!}\prod_{i=0}^{k-1}(a-i)$$ And plugging in $$a=-1$$ gives $$\frac1{1-x}=\sum_{k\geq0}(-1)^k\frac{x^k}{k!}\prod_{i=0}^{k-1}(-1-i)$$ $$\frac1{1-x}=\sum_{k\geq0}(-1)^k(-1)^k\frac{x^k}{k!}\prod_{i=0}^{k-1}(i+1)$$ $$\frac1{1-x}=\sum_{k\geq0}x^k$$ $$\frac1{1+x}=\sum_{k\geq0}(-1)^kx^k$$ $$\frac1{1+x^n}=\sum_{k\geq0}(-1)^kx^{nk}$$ So if we assume that $$|x|<1$$, we have that \begin{align} \int\frac{\mathrm{d}x}{1+x^n}=&\int\sum_{k\geq0}(-1)^kx^{nk}\mathrm{d}x\\ =&\sum_{k\geq0}(-1)^k\int x^{nk}\mathrm{d}x\\ =&\sum_{k\geq0}(-1)^k\frac{x^{nk+1}}{nk+1}\\ \end{align} And there you go.

• This is great! I had thought on similar lines just using the formula for $S_{\infty}$ of a geometric sequence, but the detail here is really interesting, particularly about convergence. Out of interest: if I compare this answer with the answer of Mostafa Ayaz, can we say that $${1\over n}\sum_{k=1}^{n} {e^{-i\pi {n-1\over n}(2k+1)} \ln | x-e^{i{2k+1\over n}\pi}|} = \sum_{k\geq0}(-1)^k\frac{x^{nk+1}}{nk+1}$$ and thus get the Taylor Polynomial of the left hand side for free?
– Shai
Commented Dec 8, 2018 at 10:41
• @Shai I guess so. Of course the equality would only hold for $|x|<1$, and $n\in \Bbb N$. There are ups and downs to each series: Taylor series works for any $n$, but only converges for $0<x<2$, while the LHS probably has a better radius of convergence, but only works for $n=1,2,3,\dots$ Commented Dec 8, 2018 at 21:15
• @shai in order to learn more about the convergence of this Taylor series, check this question of mine out: math.stackexchange.com/q/3020447/583016 Commented Dec 8, 2018 at 21:20

\begin{aligned} \int\frac{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{2k-1}{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{2k-1}{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} \end{aligned} where $$n\in\mathbb{N}$$.

Steps:

Let

$$I=\int\frac{1}{x^{n}+1}\mathop{\mathrm{d}x}$$

Do partial fraction decomposition

$$\frac{1}{x^{n}+1}=\frac{A_{1}}{x-z_{1}}+\frac{A_{2}}{x-z_{2}}+\dots+\frac{A_{n}}{x-z_{n}}$$ where $$z_{1},z_{2},\ldots,z_{n}$$ are the $$n$$ complex roots of $$x^{n}+1$$.

To find the value of $$A_{i}$$, multiply both sides of the equation with $$x-z_{i}$$ and find the limit of both sides as $$x$$ approaches $$z_{i}$$.

Only $$A_{i}$$ remains on the right side. The limit of the left side is

$$\lim_{x\to z_{i}}\frac{x-z_{i}}{x^{n}+1}=\lim_{x\to z_{i}}\frac{\left(x-z_{i}\right)'}{\left(x^{n}+1\right)'}=\lim_{x\to z_{i}}\frac{1}{nx^{n-1}}=\frac{1}{n{z_{i}}^{n-1}}=-\frac{z_{i}}{n}$$

(Note that $${z_{i}}^n=-1$$).

Becase $$n$$ is an odd number, the integral can be rewritten as

$$I=\int\frac{1}{x^{2n+1}+1}\mathop{\mathrm{d}x}$$

where $$n\in\mathbb{N}$$.

The $$2n+1$$ complex roots of $$x^{2n+1}+1$$ are $$-1,z_{1},z_{2},\dots,z_{n},\overline{z_{1}},\overline{z_{2}},\dots,\overline{z_{n}}$$, where

$$z_{k}=\mathrm{e}^{\mathrm{i}\frac{-\pi+2k\pi}{2n+1}}=\cos\left(\frac{2k-1}{2n+1}\pi\right)+\mathrm{i}\sin\left(\frac{2k-1}{2n+1}\pi\right)$$

where $$k=1,2,\dots,n$$.

So the decomposition can be rearranged as

\begin{aligned} I&=\int\left(-\frac{-1}{2n+1}\cdot\frac{1}{x+1}+\sum_{k=1}^{n}\left(-\frac{z_{k}}{2n+1}\cdot\frac{1}{x-z_{k}}-\frac{\overline{z_{k}}}{2n+1}\cdot\frac{1}{x-\overline{z_{k}}}\right)\right)\mathop{\mathrm{d}x}\\ &=\int\left(\frac{1}{2n+1}\cdot\frac{1}{x+1}-\frac{1}{2n+1}\sum_{k=1}^{n}\left(\frac{z_{k}}{x-z_{k}}+\frac{\overline{z_{k}}}{x-\overline{z_{k}}}\right)\right)\mathop{\mathrm{d}x}\\ &=\frac{1}{2n+1}\int\frac{1}{x+1}\mathop{\mathrm{d}x}-\frac{1}{2n+1}\sum_{k=1}^{n}\int\left(\frac{z_{k}}{x-z_{k}}+\frac{\overline{z_{k}}}{x-\overline{z_{k}}}\right)\mathop{\mathrm{d}x}\\ &=\frac{1}{2n+1}I_{0}-\frac{1}{2n+1}\sum_{k=1}^{n}I_{k} \end{aligned}

$$I_{0}$$ is easy

$$I_{0}=\int\frac{1}{x+1}\mathop{\mathrm{d}x}=\ln{\left|x+1\right|}+C$$

Then $$I_{k}$$

\begin{aligned} I_{k}&=\int\left(\frac{z_{k}}{x-z_{k}}+\frac{\overline{z_{k}}}{x-\overline{z_{k}}}\right)\mathop{\mathrm{d}x}\\ &=\int\frac{\left(z_{k}+\overline{z_{k}}\right)x-2z_{k}\overline{z_{k}}}{x^2-\left(z_{k}+\overline{z_{k}}\right)x+z_{k}\overline{z_{k}}}\mathop{\mathrm{d}x} \end{aligned}

Let $$z_{k}=a_{k}+b_{k}\mathrm{i}$$, then $$\overline{z_{k}}=a_{k}-b_{k}\mathrm{i}$$. Note that $$z_{k}\overline{z_{k}}={a_{k}}^2+{b_{k}}^2=\left|z_{k}\right|^2=1$$, so

\begin{aligned} I_{k}&=\int\frac{2a_{k}x-{2a_{k}}^2-{2b_{k}}^2}{x^2-2a_{k}x+{a_{k}}^2+{b_{k}}^2}\mathop{\mathrm{d}x}\\ &=\int\left(a_{k}\cdot\frac{2x-2a_{k}}{x^2-2a_{k}x+1}+2b_{k}\cdot\frac{-b_{k}}{{a_{k}}^2-2a_{k}x+x^2+{b_{k}}^2}\right)\mathop{\mathrm{d}x}\\ &=a_{k}\int\frac{2x-2a_{k}}{x^2-2a_{k}x+1}\mathop{dx}+2b_{k}\int\frac{-\frac{1}{b_{k}}}{\frac{{a_{k}}^2}{{b_{k}}^2}-\frac{2a_{k}x}{{b_{k}}^2}+\frac{x^2}{{b_{k}}^2}+1}\mathop{\mathrm{d}x}\\ &=a_{k}\int\frac{\mathop{\mathrm{d}}\left(x^2-2a_{k}x+1\right)}{x^2-2a_{k}x+1}+2b_{k}\int\frac{\mathop{\mathrm{d}}\left(\frac{a_{k}-x}{b_{k}}\right)}{\left(\frac{a_{k}-x}{b_{k}}\right)^2+1}\\ &=a_{k}\ln(\left|x^2-2a_{k}x+1\right|)+2b_{k}\tan^{-1}\left(\frac{a_{k}-x}{b_{k}}\right)+C \end{aligned}

Substitute $$a_{k}=\cos\left(\frac{2k-1}{2n+1}\pi\right),b_{k}=\sin\left(\frac{2k-1}{2n+1}\pi\right)$$ into $$I_{k}$$ and you can get the final result above.

This answer can be futher generalized to integrals like $$\int\frac{x^m}{x^n\pm 1}\mathop{\mathrm{d}x}$$. See my answer to this question.

• Welcome to math SE. How did you get this answer? Could you explain your train of thought? Commented May 14 at 12:28
• @AlainRemillard It's a bit hard to express how I get the answer because I'm not a native English speaker. Commented May 14 at 12:55
• I'm not a native speaker myself and I do my best, hoping I don't do too many mistake. Where does this come from? Have you used a particular theorem? These information could help people understand how to get such a result. Commented May 14 at 13:10
• @AlainRemillard Sorry, I'll add some details tomorrow. Commented May 14 at 14:26