Calculate the following integral: double integral over 0
Calculate the following integral: $$ \iint_{\substack{0\leqslant x\leqslant1\\0\leqslant y\leqslant1}} |x-y|\,dx\,dy. $$
Explanation of Method
The diagonal $x=y$ splits the unit square into two congruent triangles, on which $|x-y|$ equals $x-y$ and $y-x$ respectively. By the symmetry $x\leftrightarrow y$, both triangles contribute equally, so it suffices to compute one and double it.
- Split the square along the diagonal $x=y$.
- Integrate $x-y$ over the triangle $x\geqslant y$.
- Double the result by symmetry.
Step 1 · Split the region
On the triangle $x\geqslant y$ (vertices $(0,0)$, $(1,0)$, $(1,1)$), $|x-y|=x-y$; on the triangle $x\leqslant y$ (vertices $(0,0)$, $(0,1)$, $(1,1)$), $|x-y|=y-x$. By the symmetry $x\leftrightarrow y$, both integrals are equal, so $I=2I_1$ where $I_1$ is the integral over $x\geqslant y$.
Step 2 · Set up and integrate $I_1$
$$ I_1 = \int_0^1\int_0^x (x-y)\,dy\,dx = \int_0^1\left[xy-\frac{y^2}{2}\right]_0^x dx = \int_0^1\frac{x^2}{2}\,dx = \frac16. $$
Step 3 · Combine the results
$$ I = 2I_1 = 2\cdot\frac16 = \frac13. $$
Additional Notes
- This is a standard result: the mean absolute difference of two independent uniform$(0,1)$ random variables is $\frac13$.
Result
The solution to the integral is: