<s>[INST] Please show detailed steps of double integration of absolute difference Please show detailed steps of integration
$$\int_0^2 \int_0^1 0.5|x-y| dxdy$$
$$=\frac{1}{2}\int_0^2\int_0^y(y-x)dxdy + \frac{1}{2}\int_0^2\int_y^1(x-y)dxdy$$
$$=\frac{1}{2}\int_0^2\{y\int_0^ydx - \int_0^yxdx\}dy + \frac{1}{2}\int_0^2\{\int_y^1xdx - y\int_y^1dx\}dy$$
$$=\frac{1}{2}\int_0^2\frac{1}{2}y^2dy + \frac{1}{2}\int_0^2\frac{1}{2} -y + \frac{1}{2}y^2dy$$
$$
=2/3 + 1/6 = 5/6
$$
I can't get the $\frac{2}{3}$ solution.
 [/INST] The region of integration, $0\le y\le 2$ and $0\le x\le 1$,  is a rectangle in the xy-plane.  y> x, so |y- x|= y- x above the line form the lower left corner, (0, 0), to the upper right corner, (1, 2) and y< x, so |y- x|= x- y below it.  That line is given by y= 2x so the integral is $\int_{x= 0}^1 \int_{y= 0}^{2x} (x- y) dydx+ \int_{x= 0}^1\int_{y= 2x}^2 (y- x) dx$.
</s>