For two standard uniform RVs is there a way to find the $E[|U_1-U_2|]$ using the linearity rule, ie $E[X+Y] =E[X] + E[Y]$? The answer is $\frac{1}{3}$ and I know how to get it by either:


*

*finding $f_{|U_1-U_2|}(a) = 2 -2a$ and doing the expected value formula

*or by calculating $\int \int |x-y| dxdy$
It looks like $E[|U_1-U_2|] \neq E[|U_1|]-E[|U_2|]$ since the LHS is $\frac{1}{3}$ and the RHS is $0$.
My questions


*

*What about the absolute value screws up the linearity of expected values?

*Is there a way to solve this problem using linearity of expectations?
 A: "What about the absolute value screws up the linearity of expected values?" This issue has nothing fundamental to do with expected values at all; it's just a property of how numbers behave, and in particular how absolute values do not play nicely with $+$ or $-$. Note, for instance, that $|5 - 7| \neq |5| - |7|$.
"Is there a way to solve this problem using linearity of expectations?" Not an easy one, no. The best you can do is break this up into cases; consider one case where $U_1 > U_2$, and another where $U_2 > U_1$. You will quickly notice that this strongly resembles your direct calculation via double integral.
It's not the linearity of expected values that's burning you here, as they are indeed always linear; it's the (non)-linearity of absolute values.
A: I'll write $\operatorname{abs}(x)$ for $|x|$ because mixed vertical bars for absolute values and conditional probabilities get rather confusing. We have
\begin{eqnarray*}
E[\operatorname{abs}(U_1-U_2)]
&=&
\frac12E[\operatorname{abs}(U_1-U_2)\mid U_1\gt U_2]
+
\frac12E[\operatorname{abs}(U_1-U_2)\mid U_1\le U_2]
\\
&=&
\frac12E[U_1-U_2\mid U_1\gt U_2]
+
\frac12E[U_2-U_1\mid U_1\le U_2]
\\
&=&
\frac12\left(E[U_1\mid U_1\gt U_2]-E[U_2\mid U_1\gt U_2]\right)
\\&&+
\frac12\left(E[U_2\mid U_1\le U_2]-E[U_1\mid U_1\le U_2]\right)
\;,
\\
&=&
E[U_1\mid U_1\gt U_2]-E[U_2\mid U_1\gt U_2]
\\
&=&
E[U_1\mid U_1\gt U_2]-(1-E[U_1\mid U_1\gt U_2])
\\
&=&
2E[U_1\mid U_1\gt U_2]-1\;,
\end{eqnarray*}
where the equalities are respectively due to the law of total probability, the definition of the absolute value, the linearity of expectation, symmetry considerations, again symmetry consideration, and finally simple algebra.
Now you just need a nice way to find $E[U_1\mid U_1\gt U_2]$ :-)
