Finding convolution of exponential and uniform distribution- how to set integral limits?

If $z > 1$, we also require that $0 \le z-y \le 1$, or equivalently, $$z \ge y \ge z-1.$$ Thus your lower limit of integration is not correct: clearly, for a convolution integral of a uniform distribution with width $1$, your interval of integration must also have a width of $1$, and your integral limits do not satisfy this basic property.


Note that you would not be led astray if you expressed the densities in terms of indicator functions: $$f_X(x) = \lambda e^{-\lambda x} \mathbb{1}(x \ge 0), \quad f_Y(y) = \mathbb{1}(0 \le y \le 1).$$ Then our convolution is $$\begin{align*} f_Z(z) &= \int_{x = -\infty}^\infty f_X(x) f_Y(z-x) \, dx \\ &= \int_{x=-\infty}^\infty \lambda e^{-\lambda x} \mathbb{1}(x \ge 0) \mathbb{1}(0 \le z-x \le 1) \, dx \\ &= \int_{x = 0}^\infty \lambda e^{-\lambda x} \mathbb{1}(0 \le z-x \le 1) \, dx \\ &= \int_{x=0}^\infty \lambda e^{-\lambda x} \mathbb{1}(z \ge x \ge z-1) \, dx \\ &= \mathbb{1}(0 \le z \le 1) \int_{x=0}^z \lambda e^{-\lambda x} \, dx + \mathbb{1}(z > 1) \int_{x=z-1}^z \lambda e^{-\lambda x} \, dx . \end{align*}$$

The key point here is that we have a density $f_Y(z-x)$ which is nonzero only when $z-x \in [0,1]$. This is equivalent to saying that $x \in [z-1, z]$. But $x$ must also be nonnegative, because otherwise $f_X(x)$ would be zero. So in order for both densities to be positive, we must require $x \in [0,z]$ if $z \le 1$, and $x \in [z-1, z]$ when $z > 1$. We have to take the lower endpoint to be whichever is the larger of $0$ and $z-1$. This is precisely what the last expression above does. Now it is straightforward to evaluate the integrals to obtain $$\begin{align*} f_Z(z) &= \mathbb{1}(0 \le z \le 1) (1 - e^{-\lambda z}) + \mathbb{1}(z > 1) (e^{-\lambda (z-1)} - e^{-\lambda z}) \\ &= \begin{cases} 0, & z < 0 \\ 1-e^{-\lambda z}, & 0 \le z \le 1 \\ e^{-\lambda z}(e^\lambda-1) & z > 1. \end{cases} \end{align*}$$


I made a youtube video based on this question explaining the concept very thoroughly.

Solution video: https://www.youtube.com/watch?v=f63e7uJeCOw


$$ (f_X * f_Y)(x) = \int_{-\infty}^\infty f_X(y) f_Y(x-y)\,dy = \int_A f_X(y) f_Y(x-y)\,dy $$ where $A$ is the set of values of $y$ for which both $$y\ge0\tag1$$ and $$0\le x-y \le 1.\tag2$$ Rearranging $(2)$ we get $$ y\le x \le y+1 \tag 3 $$ and that is equivalent to $$ x-1\le y \le x \tag 4 $$ since the first inequality in $(4)$ is equivalent to the second inequality in $(3)$ and vice-versa.

But we also need $(1)$, so we have $$ \max\{0,x-1\}\le y \le x. $$

Therefore we have $$ (f_X * f_Y)(x) = \begin{cases} \displaystyle \int_{\max\{0,x-1\}}^x f_X(y) f_Y(x-y)\,dy & \text{if }x\ge0, \\[10pt] 0 & \text{otherwise}, \end{cases} $$ or, if you like $$ (f_X * f_Y)(x) = \begin{cases} \displaystyle \int_{x-1}^x f_X(y) f_Y(x-y)\,dy & \text{if }x\ge1, \\[10pt] \displaystyle\int_0^x f_X(y) f_Y(x-y)\,dy & \text{if }0 < x < 1, \\[10pt] 0 & \text{otherwise}, \end{cases} $$ Since $f_Y(x-y)=1$ whenever $y$ is within those bounds, these can be trivially simplified. And after that, the integrals can easily be computed in closed form.