Hi everyone :) I'm trying to find my mistake in the following question: Let $X$ be a random variable uniformly distributed over $[a,b]$ and Y exponentially distributed with a $\lambda$ parameter. Assuming $X$ and $Y$ are independent, find the CDF of $Z=Y-X$.
My answer: $F_Z(z)=P(Z\leq z)=P(Y-X\leq z)=P(Y\leq X+z)$. Let's look at the following boundaries:
for $z>-a$: graph a
So the calculation is: $$F_Z(z)=\int\limits _{a}^{b}\int\limits _{0}^{x+z}\frac{\lambda e^{-\lambda s}}{b-a}dtds=\frac{1}{b-a}\left(b+\frac{1}{\lambda}e^{-\lambda\left(z+b\right)}-a-\frac{1}{\lambda}e^{-\lambda\left(z+a\right)}\right)$$
For $-b<z\leq -a$: graph b
So the calculation is: $$F_Z(z)=\int\limits _{z}^{b}\int\limits _{0}^{x+z}\frac{\lambda e^{-\lambda s}}{b-a}dtds=\frac{1}{b-a}\left(b+\frac{1}{\lambda}e^{-\lambda\left(z+b\right)}-z-\frac{1}{\lambda}e^{-2\lambda z}\right)$$
For $z\leq -b$: graph c
So $F_Z(z)=0$
According to my class mates the $z>-a$ case is correct but the $-b<z\leq -a$ is wrong.
I'll be grateful if anyone could help me find my mistake :) Thank you!!!
Your first case is indeed correct.
$$\begin{align*}F_Z(z)&=\int_{x=a}^{x=b}\int_{y=0}^{y=x+z}\frac{\lambda e^{-\lambda y}}{b-a}\,dy\,dx\\&=-\frac1{b-a}\int_a^b\left(e^{-\lambda(x+z)}-1\right)\,dx\\&=\frac1{b-a}\left(b-a+\frac{e^{-\lambda(b+z)}-e^{-\lambda(a+z)}}\lambda\right)\\&=1+\frac{e^{-\lambda(b+z)}-e^{-\lambda(a+z)}}{\lambda(b-a)}\end{align*}$$
Your second case integral contains a small error.
The only change is to the lower limit with respect to $x$. Now $x$ varies from where the line $y=x+z$ meets the $x$-axis $(y=0\implies x=-z)$, up to previous upper limit $x=b$. You should thus have
$$\begin{align*}F_Z(z)&=\int_{x=\color{red}{-z}}^{x=b}\int_{y=0}^{y=x+z}\frac{\lambda e^{-\lambda y}}{b-a}\,dy\,dx\\&=-\frac1{b-a}\int_{-z}^{b}\left(e^{-\lambda(x+z)}-1\right)\,dx\\&=\frac{\color{red}{z}+b}{b-a} + \frac{e^{-\lambda(b+z)}\color{red}{-1}}{\lambda(b-a)} \end{align*}$$