# Failure to justify switching common integral

I wanted to evaluate $$\int_0^\infty \frac{xe^{-x}}{1+e^{-x}} \, dx$$ and found this answer where it is shown

$$\int_0^\infty \frac{xe^{-x}}{1+e^{-x}} \, dx = \int_0^\infty \sum_{k=0}^\infty(-1)^kxe^{-(k+1)x}\, dx = \sum_{k=0}^\infty(-1)^k\int_0^\infty xe^{-(k+1)x}\, dx$$

In the last step, switching the sum and integral is justified by answerer "because the sum and integral converge." There are many examples where changing the order of a convergent infinite series and convergent infinite integral is not allowed.

How is this justified here? Monotone convergence does not help.

• Dominated convergence. Take the absolute value of each term, then you still get a convergent sum. Commented Jul 27, 2020 at 18:41

In this case we can be brutal, taking the absolute value of each term still leads to a convergent sum and integral because the factor $$x$$ cancels the pole of $$\frac{1}{e^x-1}$$ at $$0$$ if we do so. Thus changing the order is justified by the dominated convergence theorem.
We can be more conservative too, if we wish (and if we considered the integral of $$\frac{1}{e^x+1}$$ instead of $$\frac{x}{e^x+1}$$ we would have to be). The series is alternating, with the terms decreasing in absolute value (except at $$0$$, where all terms have absolute value $$1$$), thus $$0 \leqslant \sum_{k = 0}^{N} (-1)^ke^{-(k+1)x} \leqslant e^{-x}$$ on $$[0, +\infty)$$ for every $$N \in \mathbb{N}$$, and we can appeal to the dominated convergence theorem with dominating function $$xe^{-x}$$. This works for $$\int_0^{+\infty} \frac{f(x)}{e^x+1}\,dx$$ whenever $$f(x)e^{-x}$$ is Lebesgue-integrable on $$[0,+\infty)$$. (Whether it helps determining the value of the integral is a different question.)