So I have the following, $f(x,y)=2e^{-y}$. For this x is greater than equal zero and y is greater than or equal to $2x$. $U=Y-X$ is given and I have to derive a pdf for U. Something seems not quite right about my answer so if someone can check it that would be appreciated!
$F(u)=P(U<u)=P(y-x<u)=P(y<u+x)=\int_0^{inf} \int_{2x}^{u+x} 2e^{-y}\space dydx=2e^{-u}$. The work seems logical to me but for my variance I got zero so I feel like I made a mistake with the intial calculation but I can't see it...
The pdf of $(X,Y)$ is $f_{XY}(x,y)=2e^{-y}{\bf 1}_{\{0\leq x, 2x\leq y\}}(x,y)$
Note that $x\in [0,\infty)$ and $y\in [2x,\infty)$ means that $x-y\in (-\infty,0]$.
To see this, we have (i) $0\leq x < \infty$ and (ii) $2x\leq y <\infty$. (i) and (ii) imply (iii) $0\leq 2x\leq y < \infty$. Multiplying (iii) by $-1$ gives (iv) $-\infty < -y \leq -2x \leq 0$. Combining (i) and (iv) gives (v) $-\infty < x-y \leq x-2x = -x \leq 0$. And, (v) indicates that the random variable $U=X-Y$ takes values in $(-\infty,0]$.
Now, recognising that ${\bf 1}_{\{x-y\leq u\}}(x,y)={\bf 1}_{\{x-u\leq y\}}(x,y)$ we get \begin{eqnarray*} F_U(u) &=& P(U\leq u)\\ &=& P(X-Y\leq u)\\ &=& \int_{x=-\infty}^{x=\infty}\int_{y=-\infty}^{y=\infty}2e^{-y}{\bf 1}_{\{0\leq x, 2x\leq y\}}(x,y){\bf 1}_{\{x-y\leq u\}}(x,y)dydx\\ &=& \int_{x=0}^{x=\infty}\int_{y=2x}^{y=\infty}2e^{-y}{\bf 1}_{\{x-u\leq y\}}(x,y)dydx\\ &=& \int_{x=0}^{x=\infty}\int_{y=\max\{2x,x-u\}}^{y=\infty}2e^{-y}dydx\\ &=& \int_{x=0}^{x=-u}\int_{y=x-u}^{y=\infty}2e^{-y}dydx + \int_{x=-u}^{x=\infty}\int_{y=2x}^{y=\infty}2e^{-y}dydx\\ &=& \int_{x=0}^{x=-u}(-2e^{-y})\Big|_{y=x-u}^{y=\infty}dx + \int_{x=-u}^{x=\infty}(-2e^{-y})\Big|_{y=2x}^{y=\infty}dx\\ &=& \int_{x=0}^{x=-u}2e^{-(x-u)}dx + \int_{x=-u}^{x=\infty}2e^{-2x}dx\\ &=& -2e^{-(x-u)}\Big|_{x=0}^{x=-u} -e^{-2x}\Big|_{x=-u}^{x=\infty}\\ &=& -2e^{2u}+2e^{u}+e^{2u}\\ &=& 2e^{u}-e^{2u}\\ \end{eqnarray*}
One sees that $F_U(u=-\infty)=0$ and $F_U(u=0)=1$, as required.
The pdf is given by $f_U(u)=F_U'(u)=2e^u-2e^{2u}$ for $u\leq 0$ and zero for $u>0$.
For the mean and variance of $U$ I get
$E[U]=\int_{-\infty}^0 u(2e^u-2e^{2u})du=-\frac{3}{2}$
and
$E[U^2]=\int_{-\infty}^0 u^2(2e^u-2e^{2u})du=\frac{7}{2}$
so variance is
$Var[U]=E[U^2]-(E[U])^2=\frac{5}{4}$
EDIT
The above calculation was for $U=X-Y$, which was a mistake, but I thought I would leave it in the answer as it might be useful to see. I'll do the correct version now: $U=Y-X$ not $X-Y$!
Note that $x\in [0,\infty)$ and $y\in [2x,\infty)$ means that $y-x\in [0,\infty)$ as $y\geq 2x \geq x$ for all $x\geq 0$. Thus, the random variable $U=Y-X$ takes values in $[0,\infty)$. And, for $u=y-x$ we have $u=y-x\geq 2x-x=x$ and $u+x=y\geq 2x$, which we will need in the integration limits below.
Now, recognising that ${\bf 1}_{\{y-x\leq u\}}(x,y)={\bf 1}_{\{y\leq x+u\}}(x,y)$ we get \begin{eqnarray*} F_U(u) &=& P(U\leq u)\\ &=& P(Y-X\leq u)\\ &=& \int_{x=-\infty}^{x=\infty}\int_{y=-\infty}^{y=\infty}2e^{-y}{\bf 1}_{\{0\leq x, 2x\leq y\}}(x,y){\bf 1}_{\{y-x\leq u\}}(x,y)dydx\\ &=& \int_{x=0}^{x=\infty}\int_{y=2x}^{y=\infty}2e^{-y}{\bf 1}_{\{y\leq x+u\}}(x,y)dydx\\ &=& \int_{x=0}^{x=u}\int_{y=2x}^{y=x+u}2e^{-y}dydx\\ &=& \int_{x=0}^{x=u}(-2e^{-y})\Big|_{y=2x}^{y=x+u}dx\\ &=& \int_{x=0}^{x=u}(-2e^{-(x+u)}+2e^{-2x})dx\\ &=& (2e^{-(x+u)}-e^{-2x})\Big|_{x=0}^{x=u}\\ &=& 2e^{-2u}-e^{-2u}-2e^{-u}+1\\ &=& 1+e^{-2u}-2e^{-u} \end{eqnarray*}
One sees that $F_U(u=0)=0$ and $F_U(u=\infty)=1$, as required.
The pdf is given by $f_U(u)=F_U'(u)=-2e^{-2u}+2e^{-u}$ for $u \geq 0$ and zero for $u<0$.
For the mean and variance of $U$ I get
$E[U]=\int_0^{\infty} u(-2e^{-2u}+2e^{-u})du=\frac{3}{2}$
and
$E[U^2]=\int_0^{\infty} u^2(-2e^{-2u}+2e^{-u})du=\frac{7}{2}$
so variance is
$Var[U]=E[U^2]-(E[U])^2=\frac{5}{4}$