Let $XY$ be two uniformly distributed random variables indicating a coordinate on a triangle $T ∶ ((0,1), (1,0), (0, −1))$, how to find both cumulative and probability density function of $|X − Y|$.
My solution to the problem
If $Z = |X-Y|$, \begin{equation*} \begin{split} F(z) &= P{(|X-Y|\le z)} = P(Y\le X-z)\cup P(Y\ge X+z) \\ &= 1-z \text{ (Given the area formula in above linked figure)} \\ %&= \int_0^{\frac{1+z}{2}}\int_{x-z}^{x+z}dydx = \int_{0}^{\frac{1+z}{2}}2zdx \\ %&= z+z^2 \\ P(z) &= \frac{d}{dz}F(z)\\ &= -z \end{split} \end{equation*}