Bounds on joint distribution $X$ and $Y$ are distributed according to the joint PDF
$$ f_{X,Y} (x,y) = \{
     \begin{array}{lr}
       \frac{3}{7}x & :  1 \leq x \leq 2,  0 \leq y \leq x\\
       0 & : otherwise
     \end{array}
$$
The random variable $Z$ is defined by $Z = Y - X$. Determine the PDF $f_{Z}(z)$. 
The solution to this problem first determines the CDF then differentiates to determine the PDF. We are given that 
$$
f_{X,Y} (x,y) =  \{
     \begin{array}{lr}\\
       \int_{x = -z}^{x=0} \int_{y=0}^{y=x+z} \frac{3}{7}x  dy dx & :  -2 \leq z \leq -1\\
       \int_{x = -z}^{x=1} \int_{y=0}^{y=x+z} \frac{3}{7}x  dy dx & : -1 < z \leq 0
     \end{array}
$$
I have a few questions. 


*

*Why is my integration bound not y=0 to y=1. I suspect this has to do with the values of z and also some bound of integration concept. I should know this, but could someone provide some intuition as to why this is? 

*I understand intuitively that $Z$ is dependent on values $X,Y$ which is the reason we want to consider the joint PDF $f_{X,Y}(x,y)$. I can see why we want to use the CDF then differentiate to find PDF approach. However, I'm so lost as to how we get our bounds for our integrals. Could I bother someone to step through the thought process of how I should attack this problem? Thanks. 
Geez, this problem has seriously been bothering me for days!
 A: You will need to draw at least one picture. First we identify the part $L$ of the plane where the joint density function of $X$ and $Y$ "lives."
Draw the vertical lines $x=1$ and $x=2$. Draw the line $y=x$. The joint density lives on the part $L$  of the first quadrant that is between $x=1$ and $x=2$, and below $y=x$. This region $L$ is a trapezoid with corners $(1,0)$, $(2,0)$, $(2,2)$, and $(1,1)$.
Let $Z=Y-X$. We want the cdf $F_Z(z)$ of $Z$, that is, $\Pr(Z\le z)$. So we want $\Pr(Y\le X+z)$.  We want the probability that $(X,Y)$ lands in the part $D$ of $L$ that lies below the line $y=x+w$. 
For fixed $z$, we will draw the line $y=x+z$. The only interesting values of $z$ are between $-2$ and $0$. Note that the line $y=x+z$ is always parallel to the line $y=x$.
The geometry is different for small negative $z$ than for large negative $z$. For if $z$ is small negative, the region $D$ below $y=x+z$ but in $L$ is a trapezoid.
At the value of $z$ for which the line $y=x+z$ passes through $(1,0)$, the part $D$ of $L$ below $y=x+z$ turns into a triangle. This happens when $z=-1$.
Now we can calculate. For $-1\lt z\le 0$, we integrate first with respect to $y$, $y=0$ to $y=x+z$, and then with respect to $x$, from $1$ to $2$. So we have
$$F_Z(z)=\int_{x=1}^2\left(\int_{y=0}^{x+z}\frac{3}{7}x\,dy                \right)\,dx$$
when $-1\lt z\le 0$. 
For $-2\le z\le -1$, we are integrating over a triangle. Note that the triangle has corners $(-z,0)$, $(2,0)$, and $(2,2+z)$. 
So as before, in the inner integration, $y$ will go from $0$ to $x+z$. Then for the outer integration, $x$ goes from $-z$ to $2$. So 
$$F_Z(z)=\int_{x=-z}^2\left(\int_{y=0}^{x+z}\frac{3}{7}x\,dy                \right)\,dx$$
when $-2\le z\le -1$. 
The rest is mechanical. Compute the integrals, and differentiate to find $f_Z(z)$.  
Remark: There are other ways to solve the problem. One can find the density function of $Z$ directly, by using a variant of the usual convolution procedure. Doing this still requires careful attention to the geometry, to get the limits right. 
