# Fubini's Theorem and Integral Bounds

In Shao's mathematical statistics, a problem asks to show for r.v. $X$ with cdf $F$, the expectation (provided it exists) can be evaluated as: $$EX=\int_0^\infty[1-F(x)]dx-\int_{-\infty}^0F(x)dx$$ I can't convince myself why the integral bounds change the way they do, once Fubini's theorem is used to swap the order of integration.

Here's the start of his solution: \begin{align*} \int_0^\infty[1-F(x)]dx&=\int_0^\infty\int_x^\infty dF(y)dx\\ &=\int_0^\infty\int_0^ydxdF(y) \end{align*} This might be a basic calc misunderstanding, but hopefully someone could clarify.

If you consider a plane and label the horizontal axis with $x$ and the vertical axis with $y$, then draw the region consisting of points $(x,y)$ satisfying $y \ge x \ge 0$. It is a cone ("infinite triangle") in the first quadrant. By cutting this region into vertical strips or horizontal strips respectively, you can write this set as $$\{(x,y) : y \in [x, \infty)\} \cap \{(x,y) : x \in [0,\infty)\}$$ or $$\{(x,y) : x \in [0,y]\} \cap \{(x,y) : y \in [0,\infty)\}$$ which gives the two different integral bounds.