PDF of a joint probability function with transformation $X = Y_1 - Y_2$ I'm trying to compute the joint CDF for the following PDF,
$$
f(y_1, y_2) = 
\begin{cases}
e^{-y_1}, &\quad 0 \leq y_2 \leq y_1 < +\infty \\
0, &\quad \text{otherwise}
\end{cases}
$$
with the following the $X = Y_1 - Y_2$.
I compute,
\begin{align}
P(X \leq x) 
  &= \int \int_{\{y_1, y_2: X \leq x\}} f(y_1, y_2) dy_1 dy_2 \\
  &= \int \int_{\{y_1, y_2: Y_1 \leq x + y_2\}} f(y_1, y_2) dy_1 dy_2 \\
  &= \int_{y_1 = y_2}^{y_1 = x + y_2} \int_{y_2 = 0}^{y_2 = y_2} e^{-y_1} dy_1 dy_2
\end{align}
However it seems like the second integral should go until $y_2 = +\infty$ but I don't understand why as the definition of the CDF is,
$$
P(Z \leq z) := \int_{0}^{z} f(z)dz
$$
for any random variable $Z$.
 A: You have the integral trees backwards.
Using your notation, you should have.
$$\begin{align}\mathsf P(X\leq x) &= \int_{y_2=0}^{y_2\to\infty}\left.\int_{y_1=y_2}^{y_1=y_2+x}\mathrm e^{-y_1}\,\mathrm d y_1\right.\,\mathrm d y_2\end{align}$$
We are integrating over all supported values for $y_2$, and inside that we are integrating over the conditionally supported values for $y_1$ where $y_1-y_2\leq x$.$$0\leq y_2~\leq y_1\leq y_2+x $$
Note: $y_1$ cannot be mentioned inside the domain for the outer integral, because it is bound inside the scope of the inner integral.

However it seems like the second integral should go until y2=+∞ but I don't understand why as the definition of the CDF is,

$$\begin{align}\mathsf P(X\leq x) &=\int_{s\leq x} f_{X}(s)\,\mathrm d s\\&= \int_{s\leq x} f_{Y_1-Y_2}(s)\,\mathrm d s\\&=\iint_{s\leq x} f_{Y_1-Y_2,Y_2}(s,y_2)\,\mathrm d s\,\mathrm d y_2\\&=\iint_{s\leq x} f_{Y_1,Y_2}(s+y_2,y_2)\,\mathrm d s\,\mathrm d y_2\\&=\iint_{y_1\leq y_2+x} f_{Y_1,Y_2}(y_1,y_2)\,\mathrm d y_1\,\mathrm d y_2\\&=\iint_{0\leq y_2\leq y_1\leq y_2+x} \mathrm e^{-y_1}\,\mathrm d y_1\,\mathrm d y_2\\&=\int_{0\leq y_2}\int_{y_2\leq y_1\leq y_2+x}\mathrm e^{-y_1}\,\mathrm d y_1\,\mathrm d y_2\\&=\int_{y_2=0}^{y_2\to\infty}\int_{y_1=y_2}^{y_1=y_2+x}\mathrm e^{-y_1}\,\mathrm d y_1\,\mathrm d y_2\end{align}$$
In short: The domain of integration must cover the region where $y_1-y_2\leq x$ and $0\leq y_2\leq y_1<\infty$ .
