CDF and PDF of absolute difference of two exponential random variables.
Solution 1:
Sadly, your answer cannot be correct because the random variable $Y$ remains in your CDF and PDF. The CDF of $Z$ should be only a function of $z$ and the parameters.
Your initial approach is sound, however. Let's see how to complete it.
$$\Pr[Z \le z] = \Pr[X \le Y + z] - \Pr[X \le Y - z]$$ is correct. Now, let's see how to attack each term on the right. We have $$\Pr[X \le Y + z] = \int_{y=0}^\infty \Pr[X \le y + z] f_Y(y) \, dy,$$ by the law of total probability. This in turn yields $$\Pr[X \le Y + z] = \int_{y=0}^\infty (1 - e^{-(y+z)}) e^{-y} \, dy = 1 - e^{-z}/2.$$ Similarly, $$\Pr[X \le Y - z] = \int_{y=0}^\infty \Pr[X \le y - z]f_Y(y) \, dy.$$ However, you must be careful here. Whereas in the first case we had no issues with $y + z < 0$, since $y$ and $z$ must both be nonnegative, in this situation we could have $0 \le y < z$, in which case $\Pr[X \le y-z] = 0$, because $X$ cannot be negative. Consequently, we can write this as $$\Pr[X \le Y - z] = \int_{y=z}^\infty \Pr[X \le y-z] f_Y(y) \, dy,$$ noting that the lower limit of integration can begin at $y = z$, since on the interval $y \in [0,z)$, the integrand is zero.
I have left the remaining calculations as an exercise. What is your result? Is it surprising? If so, how might you go about verifying it?
Solution 2:
Since $Z > 0$ a.s. we can assume that $z > 0$ in $P(Z \leq z)$. Then you get $P(X \leq Y +z) - P(X \leq Y -z)$. Since $X$ and $Y$ are exponentialy distributed they are a.s. positive, so $Y + z > 0$ therefore part $P(X \leq Y+z)$ is fine. On the other hand we must be careful with $P(X \leq Y-z)$. Since total probability rule \begin{align} P(X \leq Y-z) & = P(X \leq Y-z |Y \leq z)P(Y\leq z) + P(X \leq Y-z |Y> z)P(Y>z) \\ & = P(X\leq Y-z|Y > z)P(Y>z) \end{align} But what is $P(X \leq Y-z)$? It is some number between 0 an 1 dependent only on parameter $z$. But it involves two random variables, so just as in one dimensional case where you integrate density over subcpace of real line to get $P(X \leq z)$, here we must integrate joint densities of both random variables over some subspace of plane (since $X$ and $Y$ are independent we can take product of their densities instead). So \begin{align} P(X \leq Y -z) & = \int_z^{\infty} \int_0^{y-z} e^{-y}e^{-x}dx dy \\ & = -\left(\frac{e^{-z}}{2}-e^{-z}\right) \end{align}
In same way, only that we integrate over different region, we get $P(X \leq Y+z) = -\left(\frac{1}{2}e^{-z}-1\right)$. Then when you take in account that $P(Y > z ) = e^{-z}$ everything else is just elementary computation.
To get PDF you must of course differentiate CDF of $Z$ (in fact $Z$ must be absolutely continuous but in this, as in most cases, it is). But again CDF and PDF respectively must be functions of only $z$.