Let $Y_1$ and $Y_2$ by independent and uniformly distributed over the interval (0, 1). Find the probability density for $U = Y_1/Y_2$:
Solution:
$F_U(u) = P(U \le u) = P(Y_1/Y_2 \le u)$. Looking at the figure:
we can see that there are two regions: $0 \le u \le 1$ and $u \gt 1$. Because $tan(\alpha) = \frac{1}{u} = \frac{y_2}{y_1}$ we see that $u = y_1$, so either can say that $F_U(u) = \frac{y_1 y_2}{2} = \frac{u y_2}{2}$, because $y_2 = 1$, then $F_U(u) = \frac{u}{2}$ for $0 \le u \le 1$. So, $f_U(u) = \frac{d[F_U(u)]}{du} = \frac{1}{2}$ on this range.
Next, we need to find $f_U(u)$ when $u \gt 1$. To do it we need to find integral:
$$F_U(u) = \int_0^1 \int_0^{y_1/u}{\frac{1}{(\theta_2 - \theta_1)^2}dy_2 dy_1} = \frac{1}{2u}$$
because $\theta_2 = 1$ and $\theta_1 = 0$. So, differentiating this, gives negative result $f_U(u) = \frac{-1}{2u^2}$. This looks explainable, because $\frac{1}{2u}$ is a hyperbola and on $u \gt 1$ it's decreasing one, so derivative is negative, but from definition of density function it cannot be negative, obviously.
Answers for this are:
$$f_U(u) = \frac{1}{2}, 0 \le u \le 1$$
and
$$f_U(u) = \frac{1}{2u^2}, u \gt 1$$
I can't understand how $f_U(u)$ turned to be positive, please, help.