Z=X+Y pdf, there is a part I can't understand.

Two independent random variable X,Y which is U(0,1)

what is the pdf of Z=X+Y?

$$F_Z(z)$$ = $$\begin{cases} 0, & \ z\le0 \\ \int_0^z \int_0^{z-y} 1 \,dxdy=z^2/2, & \ 0\lt z\le1 \\ 1-\int_\bbox[yellow]{z-1}^1 \int_{z-y}^1 1 \,dxdy=1-(2-z)^2/2,& \ 1\lt z\le2 \\ 1 & \ z\ge2 \end{cases}$$

I understand I have to differential $$F_z(z)$$

The thing I can't understand is the highlight part.

Why does it starts with z-1?

• By union, did you mean uniform? The usual notation for this distribution is $U(0,\,1)$. – J.G. Jan 5 at 14:25
• @J.G. Thank you I edited it. – yonghankwon0 Jan 6 at 5:01

Let $$X$$ and $$Y$$ be any two independent (real-valued) random variables with densities $$f_X$$ and $$f_Y$$. Define $$Z \equiv X + Y$$. Note that $$F_Z(z) = \mathbb{P}(Z \leq z) = \mathbb{P}(X + Y \leq z) = \int_{-\infty}^{\infty} f_X(x) \mathbb{P}(x + Y \leq z) dx = \int_{-\infty}^{\infty} f_X(x) F_Y(z - x) dx.$$ Differentiating, $$f_Z(z) = \int_{-\infty}^{\infty} f_X(x) f_Y(z - x) dx.$$
If $$X$$ and $$Y$$ are i.i.d. $$U(0,1)$$, then $$f_x = f_Y = \boldsymbol{1}_{(0,1)}$$ where $$\boldsymbol{1}$$ is the indicator function. Plugging this into the integral of the previous section, $$f_Z(z) = \int_0^1 \boldsymbol{1}_{(0,1)}(z - x) dx.$$ Proceeding by cases, $$f_Z(z) = \begin{cases} \int_0^z dx = z & \text{if } 0 \leq z \leq 1 \\ \int_\bbox[yellow]{z-1}^1 dx = 2 - z & \text{if } 1 \leq z \leq 2. \\ \end{cases}$$