Need help understanding why $\int_0^\infty \int_0^\infty |x-y|e^{-x}e^{-y} \, dx \,dy = 2 \int_0^\infty \int_y^\infty (x-y)e^{-x}e^{-y} \, dx \,dy$

It seems to me that:

$$\int_0^\infty \int_0^\infty |x-y|e^{-x}e^{-y} \, dx \,dy$$

$$= \int_0^\infty e^{-y} \left( \int_y^\infty (x-y)e^{-x} \, dx + \int_0^y (y-x)e^{-x} \, dx \right) \,dy$$

But in the book solution below it just doubles the integral that goes from $$y$$ to infinity. Specifically I'm having problems understanding why

$$2 \int_y^\infty (x-y)e^{-x} \, dx = \int_y^\infty (x-y)e^{-x} \, dx + \int_0^y (y-x)e^{-x} \, dx$$

From the book solution the LHS $$=2e^{-y}$$

and I think the RHS $$= 2e^{-y} + y - 1$$

In the end they both give the same answer after integrating with respect to $$y$$ from zero to infinity.

Can you explain the reasoning why you can double the integral? I'm thinking there is symmetry but I'm having trouble seeing it. Thanks for your help and patience.

Book solution

Note that

$$\tag{*} \int_0^\infty\int_0^\infty |x-y|e^{-x}e^{-y} \, dx\, dy \\ = \int_0^\infty\int_y^\infty (x-y)e^{-x}e^{-y} \, dx\, dy + \int_0^\infty\int_0^y (y-x)e^{-x}e^{-y} \, dx\, dy$$

The second integral on the RHS of (*) can be written using the indicator function as

$$\int_0^\infty\int_0^y (y-x)e^{-x}e^{-y} \, dx\, dy = \int_0^\infty\int_0^\infty (y-x)e^{-x}e^{-y}\mathbf{1}_{\{x \leqslant y\}}(x,y) \, dx\, dy$$

Note that $$\mathbf{1}_{\{x \leqslant y\}}(x,y) = 1$$ if $$x \leqslant y$$ and $$\mathbf{1}_{\{x \leqslant y\}}(x,y) = 0$$ if $$x > y$$.

Applying Fubini's theorem (integrand is absolutely integrable) we get

$$\int_0^\infty\int_0^y (y-x)e^{-x}e^{-y} \, dx\, dy = \int_0^\infty\int_0^\infty (y-x)e^{-x}e^{-y}\mathbf{1}_{\{x \leqslant y\}}(x,y) \, dy\, dx\\ = \int_0^\infty\int_x^\infty (y-x)e^{-x}e^{-y}\, dy\, dx$$

Now switch variable names and this is identical to the first integral on the RHS of (*).

Hence,

$$\int_0^\infty\int_0^\infty |x-y|e^{-x}e^{-y} \, dx\, dy = 2\int_0^\infty\int_y^\infty (x-y)e^{-x}e^{-y} \, dx\, dy$$

• Thanks for your help... I will take some time to digest this. Is this something that you would just know by inspection? For example, any time I see a double integral of $|x-y|$ should I think of this trick? – HJ_beginner Jan 21 at 1:58
• The essential trick is $\int_0^\infty \int_0^x f(x,y) \, dy \, dx = \int_0^\infty \int_y^\infty f(x,y) \, dx \, dy$. Make a graph to see why this works. This will come up many times in problems you may encounter. – RRL Jan 21 at 2:13
• Thanks this was very helpful!! – HJ_beginner Jan 21 at 2:19