# Integrating Joint Random Variable Distributions i don't understand how to take the Integration Intervals

Have this problem, two random variables $X \sim Un(0,1)$ and $Y\sim Un(0,1)$. Need to find the distribution function of $Z= \frac{(X)}{(X+Y)}$, i have the solution as well, but i don't understand why it divides the figure before in a triangle and after in a trapeze, i also do not understand how i have to take the integration intervals. Thanks in advance for the help.

I'll assume $X,Y$ are independent. It's clear that we must have $0\leq Z\leq 1$. So, with $0\leq z\leq 1$, the distribution function for $Z$ is
If $0\leq z\leq 1/2,\;$ then $\frac{1-z}{z}\geq 1$ and the above probability is the area of the shaded triangle in picture 1.
If, instead, $1/2\leq z\leq 1,\;$ then $\frac{1-z}{z}\lt 1$ and the above probability is the area of the shaded trapezium in picture 2.
\begin{eqnarray*} \therefore\quad F_Z(z) &=& \begin{cases} \dfrac{z}{2(1-z)}, & \text{if $0\leq z\leq 1/2$} \\ \dfrac{3z-1}{2z}, & \text{if $1/2\leq z\leq 1$} \end{cases} \end{eqnarray*}