Let $U_1,U_2 = \operatorname{Uniform}[0,1]$ and independent. Find the CDF of $Z=\frac{U_1}{U_2+1}$.
My attempt:
$P(Z\le z)=P(U_1\le (U_2+1)z, U_2+1> 0)+P(U_1\ge (U_2+1)z, U_2+1<0)$. The last term will be equal to $0$, since $U_2$ is never less than $-1$. This results in: $$ F_Z(z)=\int_0^1du_2\int_0^{(u_2+1)z}du_1=z\int_0^1(u_2+1)du_2=\frac32z.$$ This holds only if $0\le (u_2+1)z\le 1$ and since $2\ge u_2+1>0$, we get $0\le z\le \frac12.$
So, my answer would be $$ F_Z(z)=\begin{cases} 0 & \text{if }\quad z<0 \\ \frac32z&\text{if }\quad 0\le z\le\frac12\\1&\text{if }\quad z>\frac12\end{cases}.$$
However, in the solutions, there is an extra component: $2-\frac{1}{2z}-\frac{z}2$ if $\frac12\le z\le 1$. I don't see where this one comes from.
Thanks.
The actual bound for the variable $U_1$ is $min((u_2+1)z , 1)$, since $U_1$ is always less than $1$. Hence you need to compute
$$\int_0^1 \int_0^{min((u_2+1)z , 1)} du_1du_2 = \int_0^1 min((u_2+1)z , 1) du_2$$ We see that $(u_2+1)z \leq 1$ exactly when $u_2 \leq \frac1z -1$, hence for $z\in (1/2,1)$ we get, that $$\int_0^1 min((u_2+1)z , 1) du_2=\int_0^{1/z-1}(u_2+1)zdu_2+\int_{1/z-1}^1du_2 = 2-\frac{1}{2z}-\frac{z}{2}$$