Probability function for difference between two i.i.d. Exponential r.v.s My answer is completely off. Can you please tell me where did my logic go wrong.
Donald Trump and Tori Black are to meet at a specific time and both will be late by $ \sim Exponential(\lambda), i.i.d. $.  What is the cdf of the arrival time difference.
Let $ X, Y$ be the late time and difference be $Z = X - Y$. Cases are $z \geq 0$ and $z < 0 $.
First, for $ z \geq 0$,
$ F_Z(z) = P(Z\leq z) = P(X-Y \leq z) = 1 - P(X-Y > z) = 1 - P(X>Z+Y)$
Z $\geq 0$, so $X \geq 0 $ for all $Y$.
$$\begin{align} F_Z(z) & = 1 - \int_0^\infty(\int_{z+y}^\infty f_{X,Y}(x,y)dx) dy \\& = 1 - \int_0^\infty(\int_{z+y}^\infty \lambda e^{-\lambda y}\cdot\lambda e^{-\lambda x}dx) dy \\& = 1 - \int_0^\infty\lambda e^{-\lambda y}(-e^{-\lambda x}|_{z+y}^\infty) dy \\& = 1 - \int_0^\infty\lambda e^{-2\lambda y}e^{-\lambda z}dy \\& = 1 - e^{-\lambda z}\int_0^\infty \lambda e^{-2\lambda y} \\& = 1 - \frac{1}{2}e^{-\lambda z}\end{align}$$

Now, for $z < 0$, where my calculation went very wrong.
Similarly, $F_Z(z) = 1 - P(X-Y > z) = 1 - P(X>Z+Y) $
$Z < 0$, so  for $X \geq 0$, $Y$ should be $Y \geq -Z$, so I do:
$$\begin{align}F_Z(z) & = 1 - \int_{-z}^\infty(\int_{z+y}^\infty \lambda e^{-\lambda y}\cdot\lambda e^{-\lambda x}dx) dy \\& = 1- \int_{-z}^\infty \lambda e^{-\lambda y}\cdot e^{-\lambda (z+y)}dy \\& = 1 - e^{- \lambda z}\int_{-z}^\infty \lambda e^{-2\lambda y}dy \\& = 1 - e^{-\lambda z}\cdot \frac{1}{2}e ^{2\lambda z} \\& = 1 - \frac{1}{2}e^{\lambda z}.\end{align}$$
Hence, my answers for both cases are the same except the $z$ sign.
The correct CDFs are given in textbook as
$F_Z(z) = 1 - \frac{1}{2}e^{-\lambda z}$ for $z\geq 0$ and $\frac{1}{2}e^{\lambda z}$ for $z<0$.

I forgot to integrate $Y$ over $\int_0^{-z}$ for $z<0$, which when included gives the textbook answer.
 A: Your integral limits are not correct. If you draw the region of integration, it'll be in the first quadrant and to the right of the line $X-Y=z$. It'll be easier to integrate if the order of integration is $dy dx$. Otherwise, you'd need to calculate two different ranges: $0\leq y \leq -z$ and $-z<y<\infty$. In your integral, you just calculate the second interval.
$$\begin{align}P(X>z+Y)&=\int_0^\infty \int_0^{x-z}\lambda e^{-\lambda x}\lambda e^{-\lambda y}dydx\\&=\int_0^\infty \lambda e^{-\lambda x}(1-e^{-\lambda(x-z)})dx\\&=1-e^{\lambda z}\int_0^\infty \lambda e^{-2\lambda x}dx\\&=1-e^{\lambda z}/2\end{align}$$
This yields $F_Z(z)=e^{\lambda z}/2$
A: I will not answer the OP's question as to where his analysis for the case $z<0$ went wrong but instead point out an easier way of getting to the correct answer once the value of $F_Z(z)$ has been determined to be $1-\frac 12 \exp(-\lambda z)$ when $z > 0$.
Since $X$ and $Y$ are i.i.d. random variables, the density of $Z = X-Y$ must be the same as the density of $-Z = Y-X$, that is, the density must be an even function. One consequence of this is that $P(Z>\alpha) = P(Z<-\alpha)$ and so we immediately get
\begin{align} P(Z > z) &= \frac 12 \exp(-\lambda z), &z > 0,\\
&{\big \Downarrow}\\ 
P(Z < -z) &= \frac 12 \exp(-\lambda z), &z > 0,\\
&{\big \Downarrow}\\ 
P(Z < z) &= \frac 12 \exp(\lambda z), &z < 0,\\
\end{align}
and so,  $$F_Z(z) = P(Z \leq z) = P(Z < z) = \frac 12 \exp(\lambda z), \,\,\,\ z < 0.$$
A: In fact, this problem can be solved without computing any integrals at all if you start from the knowledge that the exponential distribution is the only continuous distribution which has no memory. That means if a random variable $X\sim\text{Expon}(\lambda)$ then also $X-a|X>a\sim\text{Expon}(\lambda)$ for any $a>0$. In other words, if $X$ is the time until Donald Trump arrives and he has not arrived after, say, 10 minutes, then time until he arrives beyond those 10 minutes is also distributed as $X$. This may seem counterintuitive but is easy to prove.
Now if $X,Y$ are iid $\text{Expon}(\lambda)$ and the arrival time of Donald and Tori respectively, then Donald will be the first to arrive with probability 0.5: $\text{Prob}(Y>X)=0.5$. More importantly in that case however, the memoryless property of $Y$ tells us that $Y-X|Y>X \sim\text{Expon}(\lambda)$ whatever the value of $X$ and therefore $-Z|Y>X$ is $\text{Expon}(\lambda)$. Likewise, if Tori arrives first, with probability $\text{Prob}[X>Y]=0.5$, then $Z|X>Y$ is also $\text{Expon}(\lambda)$. Bringing together the two cases gives you the symmetrical  result for $F_Z(z)$ that was obtained before.
A: I asked for cdf but if it were for pdf.
For $z\geq 0, 0\leq z\leq x <\infty$,
$$\begin{align}
f_Z(z) &= \int_z^\infty f_X(x)\cdot f_y(x-z)dx \\
& = \lambda^2 e^{\lambda z}\int_z^\infty e^{-2\lambda x}dx \\
&= \frac{\lambda}{2}e^{-\lambda z}
\end{align}$$
For $z<0, z< 0\leq x <\infty$,
$$\begin{align}
f_Z(z) &= \int_0^\infty f_X(x)\cdot f_y(x-z)dx \\
& = \lambda^2 e^{\lambda z}\int_0^\infty e^{-2\lambda x}dx \\
&= \frac{\lambda}{2}e^{\lambda z}
\end{align}$$
