Finding cdf of difference of two random variables from a joint distribution I have that:
$$f_{X,Y}(x,y) = \begin{cases}
8xy,  & \text{if $0<y<x<1$} \\
0, & \text{otherwise}  \\
\end{cases}
$$
I'm trying to solve for the cdf of a random variable $W$, where $W = X - Y$. I've written down that I'm trying to solve for $F_W(w) = P(W\le w) = P(X - Y\le w)$, which I'm expressing as:
$$\int_0^1 \left(\int_{x-w}^x 8xy \;dy \right) dx $$
I'm pretty certain that my limits are off, but my rationale is that the inner integral is solving over the support of $Y$, while the outer integral is solving over the support of $X$.
 A: This answer has been corrected (again, and again) to respond to comments by @AndréNicolas.
You method is fine, but you're right that one of the limits are wrong (and not both, as I originally wrote).  
The support of the joint distribution is a triangle, with verticies at $\langle 0,0\rangle$, $\langle 1,0\rangle$ and $\langle 1,1\rangle$.  The probability that $X-Y\leq w$ is the (double) integral of the joint pdf except over some smaller triangle where $X-Y$ is large (i.e. where $x-y$ is a long way from the line $y=x$).  The resulting area is a trapezoid: to find the cdf, you just need to find the limits of integration that describe this trapezoid. 
For $w\in [0,1]$, this smaller triangle will be similar to the big triangle: it will be a right angle isosceles triangle with its apex at $\langle 1,0\rangle$.  The hypotenuse of the triangle will lie on the line $x-y=w$, or $y=x-w$.  So, for the trapezoid, the $y$ variable will be integrated from $0$ to $x$ for values of $x$ below $w$ and from $x-w$ to $x$ for values of the $x$ between $w$ and $1$.  The cdf, expressed as an integral is therefore:
$$F_W(w)=\left\{\begin{array}{1cl}
0 & \textrm{if} & w<0 \\
\int_{0}^{1}\int_{\max\{x-w,0\}}^{x}8xy \, \textrm{d}y \, \textrm{d}x & \textrm{if} & 0\leq w \leq 1 \\
1 & \textrm{if} & 1<w
\end{array}\right.$$
As noted in the long comment thread below, it is simpler to avoid that unpleasant "$\max$" operator and take one minus the integral over the triangle instead:
\begin{eqnarray}
& & \int_{0}^{1}\int_{\max\{x-w,0\}}^{x}8xy\,\textrm{d}y\,\textrm{d}x+\int_{w}^{1}\int_{0}^{x-w}8xy\,\textrm{d}y\,\textrm{d}x \\
& =& \int_{0}^{1}\int_{\max\{x-w,0\}}^{x}8xy\,\textrm{d}y\, \textrm{d}x+\int_{0}^{1}\int_{0}^{\max\{x-w,0\}}8xy\, \textrm{d}y\,\textrm{d}x \\
& = & \int_{w}^{1}\int_{0}^{x}8xy \, \textrm{d}y\,\textrm{d}x \\
& = & 1.\end{eqnarray}
A: Here is a solution using automated tools. 
Given: random variables $(X,Y)$ have joint pdf $f(x,y)$:

You seek the cdf of $W=X-Y$, namely $P(W<w) = P(X-Y<w)$:

All done.
Notes


*

*The Prob function used above is from the mathStatica package for Mathematica. As disclosure, I should add that I am one of the authors.

