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?
$$\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}$$