Need to find pdf of $ |X-Y| $ .I little confused and not getting answer after taking below limits. As it is symmetrical I have taken one part of triangle. Considering lower triangle limits I have taken is x from $ y+z $ to $ a $ and outer limit : y from $ 0 $ to $ a-z $ Not getting expected answer. Could any help.
Answer: $f_{z}(z)=\frac{2}{a}(1-\frac{z}{a})$
Since $X$ and $Y$ are identically distributed, $P(X-Y\le z,X\ge Y)=P(Y-X\le z,Y\ge X)$
So for $0< z<a$,
\begin{align} P(|X-Y|\le z)&=2\times P(X-Y\le z,X\ge Y) \\&=2 \int P(X-y\le z,X\ge y\mid Y=y)f_Y(y)\,dy \\&=2\int P(y\le X\le z+y)\frac{\mathbf1_{0<y<a}}{a}\,dy \\&=\frac{2}{a}\int_0^a \int_y^{\min(z+y\,,\,a)}\frac{1}{a}\,dx\,dy \\&=\frac{2}{a^2}\left[\int_0^{a-z}\int_y^{z+y}\,dx\,dy+\int_{a-z}^a\int_y^a\,dx\,dy\right] \\&=\frac{2}{a^2}\left(az-\frac{z^2}{2}\right) \end{align}
Hence the pdf of $Z=|X-Y|$ is
$$f_Z(z)=\frac{2}{a^2}(a-z)\mathbf1_{0<z<a}$$
Needless to say, the above algebra for the CDF is not as simple as drawing a picture of the region $\{(x,y)\in[0,a]^2:|x-y|\le z\}$ and finding its area.
Here is a picture for $z=0.6$ and $a=3$: (Also see the case $a=1$ discussed in this post)