I have a problem where I do not know how to find the CDF and the PDF.
Problem:
I have the joint density for two random variables $X$ and $Y$:
$$ p(x,y) = \left\{ \begin{array}{ll} 1 & \quad \textrm{if}{\ } 0 < x < 2,{\ } y < x,{\ } y<2-x \\ 0 & \quad \textrm{otherwise} \end{array} \right. $$
I have found the marginal densities:
$$ f(x) = \left\{ \begin{array}{ll} 1 & \quad \textrm{if}{\ } 0 < x \leq 1\\ 2-x & \quad \textrm{if}{\ } 1 < x <2\\ 0 & \quad \textrm{otherwise} \end{array} \right. $$
$$ g(y) = \left\{ \begin{array}{ll} 2-2y & \quad \textrm{if}{\ } 0 < y < 1\\ 0 & \quad \textrm{otherwise} \end{array} \right. $$
Since the joint PDF is not a product of the marginal PDF's I conclude that the variables are dependent.
It is easy to find the marginal distributions:
$$ F(x) = \left\{ \begin{array}{ll} \frac{1}{2}x^2 & \quad \textrm{if}{\ } 0 < x \leq 1\\ 2x-\frac{1}{2}x^2-1 & \quad \textrm{if}{\ } 1 < x <2\\ 0 & \quad \textrm{if}{\ }x\leq0\\ 1 & \quad \textrm{if}{\ }x\geq2\\ \end{array} \right. $$ And: $$ G(y) = \left\{ \begin{array}{ll} 2y-y^2 & \quad \textrm{if}{\ } 0 < y < 1\\ 0 & \quad \textrm{if}{\ }y\leq0\\ 1 & \quad \textrm{if}{\ }y\geq1\\ \end{array} \right. $$
But I get stuck when I am asked to consider the variable $W=X-Y$ and find it's distribution and the PDF. My idea is:
$$H(w)=P(W\leq{}w)=P(X-Y\leq{}w)=\int_{0}^{2}P(X-Y\leq{}w|X=x)f(x)dx$$
But am not sure how to procede...

$$H(w)=\int_{\mathbb{R^2}}{1_{x-y\leq w}p(x,y)dxdy}$$
Try to draw the surface, it is very intuitive. The surface where $p$ equals $1$ is the triangle with edges $(0,0),(2,0)$ and $(1,1)$
If $w\geq 2$, $H(w)=1$, as we only consider the surface of the above triangle,which is $1$
If $w\leq 0$ $H(w)=0$ as the intersection between the triangle and $\{y>x-w\}$ is empty.
Otherwise, we subtract the surface of the triangle with edges $(w,0),(2,0)$ and $(1+\frac{w}{2},1-\frac{w}{2})$ to the first triangle, which is $\frac{(2-w)^2}{4}$, therefore $$H(w)=1-\frac{(2-w)^2}{4}$$