Did Wolfram|Alpha mess up $\int 1 - \frac{1}{1-e^{-x}} \mathrm{d}x$ or did I?

225 Views Asked by At

I want to calculate $$\int 1 - \frac{1}{1-e^{-x}} \mathrm{d}x$$

Provided that $x>0$. Substituting $u=1-e^{-x}$, we get:

$$\int \frac{1 - \frac{1}{u}}{1-u} \mathrm{d}u = -\int \frac{1 - \frac{1}{u}}{u-1} \mathrm{d}u = -\int \frac{1}{u} \mathrm{d}u=-\ln(u)+C=-\ln(1-e^{-x})+C$$

Differentiating the result gives the integrand, so I think it correct.

However Wolfram|Alpha gives the result $x-\ln(1-e^x)$, which is imaginary for $x\geq0$ and doesn't the integrand when differentiated. What is going on?

3

There are 3 best solutions below

4
On BEST ANSWER

$$\displaystyle I = \int \left(1-\frac{1}{1-e^{-x}}\right)dx = -\int\frac{e^{-x}}{1-e^{-x}}dx\;,$$

Now let $$(1-e^{-x}) = t\;,$$ Then $\displaystyle (+e^{-x})dx = dt$

So $$\displaystyle I = -\int\frac{1}{t}dt = \ln\left|1-e^{-x}\right| = -\left[\ln\left(\frac{e^{x}-1}{e^x}\right)\right] = -\ln\left|e^x-1\right|+\ln(e^x)$$

So we get $$\displaystyle I = -\ln\left|e^x-1\right|+x+\mathcal{C}$$

3
On

However Wolfram|Alpha gives the result x−ln(1−ex), which is imaginary for x≥0 and doesn't the integrand when differentiated. What is going on?

Your answer equals $-\log(e^x - 1) + \log(e^x)$ which is Wolfram's form up to some possible weirdness about adding $\log(-1)$ to the constant of integration.

The weirdness disappears when differentiating, and also has to do with where the basepoint $a$ is taken to be if you think of the integral as $\int_a^x (\cdots)$. Switching from positive to negative $a$ is like computing this as a complex contour integral and making half a loop around the singularity at $0$, so picking up half a $2 \pi i$.

Given the above, there must be some consistent algorithm that Alpha follows, and it is working correctly in that the derivative of its answer is the integrand.

It could be that Alpha writes Log(x) in the output but uses Log|x| internally in its calculations. If so then there is no problem with any imaginary terms. But Alpha's output, when following the link in the question, includes this below the answer:

Series expansion of the integral at $x=0$ $$(-\log(x)-i \pi)+x/2-x^2/24+x^4/2880+O(x^6)$$

and another $i \pi$ in the "alternate form for $x>0$".

The explanation in terms of basepoints and contour integrals seems closer to what is happening at the server.

1
On

You could combine the integrand into one fraction and do $$\int\frac{-e^{-x}}{1-e^{-x}}dx=-\ln|1-e^{-x}|+c$$ since this is of the form $$\int\frac{f'(x)}{f(x)}dx$$