# How to integrate $\int_0^1\frac{dx}{1+x+x^2+\cdots+x^n}$

I am interested in finding a solution to the integral $$I_n=\int_0^1\frac{dx}{\sum_{k=0}^nx^k}$$ Since the denominator is a geometric series with $$a=1$$ and $$r=x$$ and it is within the radius of convergence, we should be able to say $$\sum_{k=0}^nx^k=\frac{1-x^{n+1}}{1-x}=\frac{x^{n+1}-1}{x-1}$$ and $$I_n=\int_0^1\frac{x-1}{x^{n+1}-1}dx$$ It makes sense to me that, for all values of $$n$$, $$I_n$$ is convergent since the bottom of the function is always above zero and the integral exists for $$n\to\infty$$ however I cannot seem to find a nice closed form for this.

One thought I did have was using: $$\sum\ln(x_i)=\ln\left(\prod x_i\right)$$ but I cannot seem to make it work. Does anyone have any hints for this type of problem as I would like to try and complete it myself. Thanks :)

• I think you've made an error in the exponent. Shouldn't it be $$I_n=\int_0^1\frac{x-1}{x^\color{red}{n+1}-1}dx$$ Dec 23, 2020 at 17:49
• $\displaystyle x^{n + 1} \mapsto x$. Dec 23, 2020 at 17:49
• The closed for for $I_n$ doesn't seem to turn out neat. The limit is $1/2$. Dec 23, 2020 at 18:03
• One thing you may want to try is to make a change of variable and see if you can turn it into an improper integral so as to try the residue theorem. Dec 23, 2020 at 18:06
• @saulspatz: No, the sum remains (unless the digamma function is used). Dec 24, 2020 at 1:38

$$I_n=\int_{0}^{1}\frac{dx}{1+x+x^2+\ldots+x^n}=\underbrace{\int_{0}^{1}\frac{1-x}{1-x^{n+1}}dx}_{x\rightarrow y^{\frac{1}{n+1}}}=\frac{1}{n+1}\int_{0}^{1}\frac{y^\frac{1}{n+1}-y^\frac{2}{n+1}}{y(1-y)}dy$$

$$=\frac{1}{n+1}\int_{0}^{1}\left(\frac{y^\frac{1}{n+1}-y^\frac{2}{n+1}}{y}+\frac{y^\frac{1}{n+1}-y^\frac{2}{n+1}}{1-y}\right)dy$$

$$1-\frac{n+1}{2(n+2)}+\frac{1}{n+1}\int_{0}^{1}\left(\frac{y^{\frac{1}{n+1}-1}\log{\left(1-y\right)}}{n+1}-\frac{y^{\frac{2}{n+1}-1}\log{\left(1-y\right)}}{n+2}\right)dy$$

$$=\frac{n+3}{2(n+2)}+\frac{1}{n+1}\left[\frac{\mathfrak{B}\left(\frac{1}{n+1},1\right)\left(\psi^{\left(0\right)}\left(1\right)-\psi^{\left(0\right)}\left(1+\frac{1}{n+1}\right)\right)}{n+1}-\frac{\mathfrak{B}\left(\frac{2}{n+1},1\right)\left(\psi^{\left(0\right)}\left(1\right)-\psi^{\left(0\right)}\left(1+\frac{2}{n+1}\right)\right)}{n+2}\right]$$

$$=\frac{n+3}{2(n+2)}+\frac{\psi^{\left(0\right)}\left(1+\frac{2}{n+1}\right)-\psi^{\left(0\right)}\left(1+\frac{1}{n+1}\right)}{n+1}=\frac{1}{2\left(n+2\right)}+\frac{\psi^{\left(0\right)}\left(\frac{2}{n+1}\right)-\psi^{\left(0\right)}\left(\frac{1}{n+1}\right)}{n+1}$$

Therefore: $$I_n=\int_{0}^{1}\frac{dx}{1+x+x^2+\ldots+x^n}=\frac{1}{2\left(n+2\right)}+\frac{\psi^{\left(0\right)}\left(\frac{2}{n+1}\right)-\psi^{\left(0\right)}\left(\frac{1}{n+1}\right)}{n+1}$$ Notes: $$\mathfrak{B}(x,y)$$ stands for the Beta Function and $$\psi^{(0)}(z)$$ stands for the Digamma Function.

Decompose the integrand as

$$\frac{1}{1+x+x^2+...+x^n}=\sum_{k=1}^{n}\frac{a_k}{x-x_k},\>\>\>\>\> a_k=\frac{x_k(x_k-1)}{n+1}$$ where $$x_k= e^{i \frac{2\pi k}{n+1}},\> k=1,2...n$$. Then

\begin{align} I_n&=\int_0^1\frac{dx}{1+x+x^2+...+x^n}\\ &=\int_0^1 \sum_{k=1}^{n}\frac{a_k}{x-x_k}dx =\frac1{n+1}\sum_{k=1}^{n} x_k(x_k-1)\ln\left(1-\frac1{x_k}\right) \end{align} Substitute $$x_k= e^{i \frac{2\pi k}{n+1}}$$ into above summation to derive the close-form $$\color{blue}{I_n = \frac\pi{2(n+1)} \csc\frac{2\pi}{n+1}-\frac4{n+1}\sum_{k=1}^{[\frac n2]} \sin\frac{\pi k}{n+1}\sin\frac{3\pi k}{n+1}\ln\left(\sin\frac{\pi k}{n+1}\right)}$$ Listed below are some sample results \begin{align} I_2 &= \frac{\pi}{3\sqrt3}\\ I_3 &= \frac\pi8 +\frac14\ln2\\ I_4 &= \frac\pi{10}\csc\frac{2\pi}{5}+\frac1{\sqrt5}\ln\left(2\cos\frac\pi5\right)\\ I_5 &= \frac{\pi}{6\sqrt3}+\frac13\ln2\\ I_7 &= \frac{\pi}{8\sqrt2}+\frac18\ln2 + \frac{1}{8\sqrt2}\ln \frac{\sqrt2+1}{\sqrt2-1}\\ I_9 &= \frac\pi{20}\csc\frac{\pi}{5}+\frac15\ln2 +\frac1{2\sqrt5}\ln\left(2\cos\frac\pi5\right)\\ \end{align} \begin{align} I_6 &=\frac\pi{14}\csc\frac{2\pi}{7}-\frac1{2\sqrt7}\bigg( \frac{\ln\sin\frac\pi7}{\sin\frac{2\pi}7} +\frac{\ln\sin\frac{2\pi}7}{\sin\frac{3\pi}7}-\frac{\ln\sin\frac{3\pi}7}{\sin\frac{\pi}7}\bigg) \\ \end{align}

\begin{align} I_8 &= \frac\pi{18}\csc\frac{2\pi}{9}+\frac{2}{3\sqrt3} \bigg(\frac{\ln\csc\frac\pi9}{\csc\frac{\pi}9} +\frac{\ln\csc\frac{2\pi}9}{\csc\frac{2\pi}9}-\frac{\ln\csc\frac{4\pi}9}{\csc\frac{4\pi}9}\bigg) \\ \end{align}

• Great answer, The values seem to come out nice at first but get really ugly really quickly Dec 24, 2020 at 18:09

Computing the Integral \begin{align} &\int_0^1\frac{1-x}{1-x^{n+1}}\,\mathrm{d}x\\ &=\int_0^1\sum_{k=0}^\infty\left[x^{(n+1)k}-x^{(n+1)k+1}\right]\tag1\\ &=\sum_{k=0}^\infty\left(\frac1{(n+1)k+1}-\frac1{(n+1)k+2}\right)\tag2\\ &=\frac12+\sum_{k=1}^\infty\left(\frac1{(n+1)k+1}-\frac1{(n+1)k+2}\right)\tag3\\ &=\frac12+\frac1{n+1}\sum_{k=1}^\infty{\scriptsize\left(\frac1k-\frac1{k+\frac2{n+1}}\right)}-\frac1{n+1}\sum_{k=1}^\infty{\scriptsize\left(\frac1k-\frac1{k+\frac1{n+1}}\right)}\tag4\\[3pt] &=\frac12+\frac1{n+1}\left(H\!\left(\frac2{n+1}\right)-H\!\left(\frac1{n+1}\right)\right)\tag5\\[3pt] &=\frac1{n+1}\sum_{k=1}^n\log\left(2\sin\left(\frac{\pi k}{n+1}\right)\right)\left(\cos\left(\frac{4\pi k}{n+1}\right)-\cos\left(\frac{2\pi k}{n+1}\right)\right)\\ &+\frac1{n+1}\sum_{k=1}^n\left(\frac{\pi}2-\frac{\pi k}{n+1}\right)\left(\sin\left(\frac{2\pi k}{n+1}\right)-\sin\left(\frac{4\pi k}{n+1}\right)\right)\tag6 \end{align} Explanation:
$$(1)$$: expand the Taylor series
$$(2)$$: integrate
$$(3)$$: pull the $$k=0$$ term out front
$$(4)$$: rearrange into two series
$$(5)$$: Write as extended Harmonic numbers
$$(6)$$: apply $$(7)$$ from this answer

Although $$(5)$$ is always valid, since $$(7)$$ from this answer requires $$p\le q$$, $$(6)$$ is only valid for $$n\gt0$$. For $$n=0$$, the integral is $$1$$.

Mathematica Implementation

Here is a Mathematica implementation of $$(6)$$:

how[n_]:=1/(n + 1)Sum[
Log[2 Sin[Pi k/(n+1)]](Cos[4 Pi k/(n+1)]-Cos[2 Pi k/(n+1)])
+ (Pi/2-Pi k/(n+1))(Sin[2 Pi k/(n+1)]-Sin[4 Pi k/(n+1)]),
{k,1,n}]


If you wanna find a closed form for that integral then you must do some partial fractions.

Let $$n\in\mathbb{N}^{*}$$,

\begin{aligned}\frac{x-1}{x^{n}-1}=\frac{1}{\prod\limits_{k=1}^{n-1}\left(x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{n}}\right)}=\frac{2\mathrm{i}}{n}\sum_{k=1}^{n-1}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{n}}\sin{\left(\frac{k\pi}{n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{n}}}}\end{aligned}

If working with an even integer :

\begin{aligned}\small\frac{x-1}{x^{2n}-1}=\frac{\mathrm{i}}{n}\sum_{k=1}^{2n-1}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n}}\sin{\left(\frac{k\pi}{2n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{k\pi}{n}}}}&\small=\frac{\mathrm{i}}{n}\left(\sum_{k=1}^{n-1}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n}}\sin{\left(\frac{k\pi}{2n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{k\pi}{n}}}}-\frac{\mathrm{i}}{x+1}+\sum_{k=n+1}^{2n-1}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n}}\sin{\left(\frac{k\pi}{2n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{k\pi}{n}}}}\right)\\ &\small=\frac{\mathrm{i}}{n}\left(\sum_{k=1}^{n-1}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n}}\sin{\left(\frac{k\pi}{2n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{k\pi}{n}}}}-\frac{\mathrm{i}}{x+1}+\sum_{k=1}^{n-1}{\frac{\mathrm{e}^{\mathrm{i}\frac{3\left(2n-k\right)\pi}{2n}}\sin{\left(\frac{\left(2n-k\right)\pi}{2n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{\left(2n-k\right)\pi}{n}}}}\right)\\ &\small=\frac{1}{n\left(x+1\right)}+\frac{\mathrm{i}}{n}\sum_{k=1}^{n-1}{\left(\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n}}\sin{\left(\frac{k\pi}{2n}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{k\pi}{n}}}-\frac{\mathrm{e}^{-\mathrm{i}\frac{3k\pi}{2n}}\sin{\left(\frac{k\pi}{2n}\right)}}{x-\mathrm{e}^{-\mathrm{i}\frac{k\pi}{n}}}\right)}\\ \small\frac{x-1}{x^{2n}-1}&\small=\frac{1}{n\left(x+1\right)}+\frac{2}{n}\sum_{k=1}^{n-1}{\frac{\sin{\left(\frac{k\pi}{2n}\right)}-x\sin{\left(\frac{3k\pi}{2n}\right)}}{x^{2}-2x\cos{\left(\frac{k\pi}{n}\right)}+1}\sin{\left(\frac{k\pi}{2n}\right)}}\end{aligned}

If our integer is odd :

\begin{aligned}\small\frac{x-1}{x^{2n+1}-1}=\frac{2\mathrm{i}}{2n+1}\sum_{k=1}^{2n}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n+1}}\sin{\left(\frac{k\pi}{2n+1}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{2n+1}}}}&\small=\frac{2\mathrm{i}}{2n+1}\left(\sum_{k=1}^{n}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n+1}}\sin{\left(\frac{k\pi}{2n+1}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{2n+1}}}}+\sum_{k=n+1}^{2n}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n+1}}\sin{\left(\frac{k\pi}{2n+1}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{2n+1}}}}\right)\\ &\small=\frac{2\mathrm{i}}{2n+1}\left(\sum_{k=1}^{n}{\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n+1}}\sin{\left(\frac{k\pi}{2n+1}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{2n+1}}}}+\sum_{k=1}^{n}{\frac{\mathrm{e}^{\mathrm{i}\frac{3\left(2n+1-k\right)\pi}{2n+1}}\sin{\left(\frac{\left(2n+1-k\right)\pi}{2n+1}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2\left(2n+1-k\right)\pi}{2n+1}}}}\right)\\ &\small=\frac{2\mathrm{i}}{2n+1}\sum_{k=1}^{n}{\left(\frac{\mathrm{e}^{\mathrm{i}\frac{3k\pi}{2n+1}}\sin{\left(\frac{k\pi}{2n+1}\right)}}{x-\mathrm{e}^{\mathrm{i}\frac{2k\pi}{2n+1}}}-\frac{\mathrm{e}^{-\mathrm{i}\frac{3k\pi}{2n+1}}\sin{\left(\frac{k\pi}{2n+1}\right)}}{x-\mathrm{e}^{-\mathrm{i}\frac{2k\pi}{2n+1}}}\right)}\\ \small\frac{x-1}{x^{2n+1}-1}&\small=\frac{4}{2n+1}\sum_{k=1}^{n}{\frac{\sin{\left(\frac{k\pi}{2n+1}\right)}-x\sin{\left(\frac{3k\pi}{2n+1}\right)}}{x^{2}-2x\cos{\left(\frac{2k\pi}{2n+1}\right)}+1}\sin{\left(\frac{k\pi}{2n+1}\right)}}\end{aligned}

Thus, we have in general : $$\fbox{\begin{array}{rcl}\displaystyle\frac{x-1}{x^{n}-1}=\frac{1+\left(-1\right)^{n}}{n\left(x+1\right)}+\frac{4}{n}\sum_{k=1}^{\left\lfloor\frac{n-1}{2}\right\rfloor}{\frac{\sin{\left(\frac{k\pi}{n}\right)}-x\sin{\left(\frac{3k\pi}{n}\right)}}{x^{2}-2x\cos{\left(\frac{2k\pi}{n}\right)}+1}\sin{\left(\frac{k\pi}{n}\right)}}\end{array}}$$

If you know how to solve an integral like $$\int{\frac{cx+d}{x^{2}-ax+1}\,\mathrm{d}x}$$, then it would be simple to figure out what the closed form would be.

If you just want to find the limit, then we have for any $$n\in\mathbb{N}$$ : $$\int_{0}^{1}{\frac{1-x}{1-x^{n}}\,\mathrm{d}x}=\frac{1}{2}+\int_{0}^{1}{\frac{x^{n}\left(1-x\right)}{1-x^{n}}\,\mathrm{d}x}=\frac{1}{2}+\frac{1}{n}\int_{0}^{1}{\frac{x^{\frac{1}{n}}\left(1-x^{\frac{1}{n}}\right)}{1-x}\,\mathrm{d}x}$$

Since : $$\left|\frac{1}{n}\int_{0}^{1}{\frac{x^{\frac{1}{n}}\left(1-x^{\frac{1}{n}}\right)}{1-x}\,\mathrm{d}x}\right|\leq\frac{1}{n}\int_{0}^{1}{\frac{x^{\frac{1}{n}}\left(1-x\right)}{1-x}\,\mathrm{d}x}=\frac{1}{n+1}\underset{n\to +\infty}{\longrightarrow}0$$

The limit would be $$1/2$$.

• $\int_{0}^{1}{\frac{x^{n}\left(1-x\right)}{1-x^{n}}\mathrm{d}x}=\int_{0}^{1} \frac{x^n}{1+x+\cdots+x^{n-1}}\mathrm dx<\int_{0}^{1}x^n\mathrm dx\to 0.$ Feb 5, 2021 at 13:47
• Actuelly, when $0\leq x\leq 1\implies0\leq x\leq x^{\frac{1}{n}}\leq 1\implies0\leq1-x^{\frac{1}{n}}\leq 1-x\leq 1$, so your last inequality is not tur, it should be $|\cdots|\leq\frac{1}{n}\int_{0}^{1}x^{\frac{1}{n}}dx=\frac{1}{n+1}.$ Feb 5, 2021 at 13:56
• @Riemann True. I'll fix it. Nice proof btw. Feb 5, 2021 at 14:10

Making the problem more general $$I_n=\int_0^t \frac {dx}{\sum_{k=0}^n x^k}=\int_0^t \frac {1-x}{1-x^{n+1}}\,dx$$ $$x=y^{\frac{1}{n+1}} \quad \implies \quad I_n=\frac 1{n+1}\int_0^{t^{n+1}} \frac{y^{-\frac{n}{n+1}}-y^{-\frac{n-1}{n+1}}} {1-y} \,dy$$ Using $$\int \frac {y^a}{1-y}\,dy=\frac{y^{a+1} }{a+1}\,\, _2F_1(1,a+1;a+2;y)$$ $$\int_0^s \frac {y^a}{1-y}\,dy=B_s(a+1,0) \qquad \text{if} \qquad s<1\land a>-1$$ $$I_n=\frac 1{n+1}\Bigg[B_{t^{n+1}}\left(\frac{1}{n+1},0\right)-B_{t^{n+1}}\left(\frac{2}{n+1},0\right) \Bigg]$$

For the specific case where $$t=1$$, $$I_n=\frac{\psi \left(\frac{2}{n+1}\right)-\psi \left(\frac{1}{n+1}\right)}{n+1}=\frac{H_{-\frac{n-1}{n+1}}-H_{-\frac{n}{n+1}}}{n+1}$$ If $$n$$ is large $$I_n=\frac{1}{2}+\frac{\pi ^2}{6 n^2}-\frac{9 \zeta (3)+\pi^2 }{3n^3}+\frac{810 \zeta (3)+45 \pi ^2+7 \pi ^4}{90 n^4}+O\left(\frac{1}{n^5}\right)$$