# Finding the difference of two random variables

Give that $X_1$ and $X_2$ are random variables and the joint of $$f_{x_1x_2}(x_1,x_2) = e^{-x_1},\quad 0\le x_2\le x_1\le \infty$$

Given that $Y=X_1-X_2$ Find the pdf for Y. So far I have. $$P(Y \le y)=\iint_D e^{-x_1}\,dx_1\,dx_2.$$ $$P(Y \le y)=\int_{0} ^{\infty}\int_{0} ^{y+x_2} e^{-x_1}\,dx_1\,dx_2.$$ After I evaluate the integral I get $$e^{-y-x_2}+x_2$$ which if I try to evaluate from 0 to infinity it diverges and that doesn't seem right.

• There is a typo in the problem. Commented Apr 10, 2014 at 1:06
• Yeah. I typed the $x_1$ and $x_2$ in the wrong order in the inequality. But that doesn't change that it diverges which doesn't make sense since it's asking for the expectation in the next part. Commented Apr 10, 2014 at 1:37

We will use $X$ instead of $X_1$, and $Y$ instead of $X_2$. So we need a new letter for what you called $Y$. Let $W=X-Y$.
Take $w\ge 0$. We have $W\le w$ if $X\le Y+w$. Thus $$\Pr(W\le w)=\iint_D e^{-x}\,dx\,dy,$$ where $D$ is the part of the first quadrant between the lines $y=x-w$ and $y=x$. This strip is slightly unpleasant to integrate over. It is easier to note that $$\Pr(W\le w)=1-\Pr(X\gt Y+w)=1-\iint_E e^{-x}\,dx\,dy,$$ where $E$ is the part of the first quadrant below the line $y=x-w$. We have $$\iint_E e^{-x}\,dx\,dy=\int_{x=w}^\infty \left(\int_{y=0}^{x-w} 1\,dy\right)e^{-x}\,dx.$$ Integrate. The inner integral is $x-w$, so we end up with $\int_w^\infty (x-w)e^{-x}\,dx$, which is $e^{-w}$.
It follows that (for $w\gt 0$), we have $F_W(w)=1-e^{-w}$.
Added: There is a poor choice of order of integration above, which resulted in an integration by parts for the outer integral. It is better to note that $$\iint_E e^{-x}\,dx\,dy=\int_{y=0}^\infty \left(\int_{x=y+w}^{\infty} e^{-x}\,dx\right)\,dy.$$