How can I solve this problem?
A point $P = (X, Y)$ of the unit square $(0,1) \times (0,1)$ is chosen at random. Let $\theta$ be the angle formed between the $x-$axis and the segment joining the origin and $P$. Find the density of $\theta$.
I know for example that $\theta=\tan^{-1}\left( \frac{Y}{X}\right)$ and since that $0<x<1$ and $0<y<1$ so $X\sim \textbf{U}(0,1)$ and $Y\sim \textbf{U}(0,1)$ and $X$ and $Y$ are independent random variables. But, I don't know how can I continue. In fact I don't quite understand the problem.
In my attempt, I think I could use the Jacobian transformation theorem, but I don't know how to approach the problem that way.
First of all you can calculate the distribution of $Z=\frac{Y}{X}$
Without integrals, but only with a simple drawing you get
$$ F_Z(z) = \begin{cases} 0, & \text{if $z<0$ } \\ \frac{z}{2}, & \text{if $0\leq z<1$ } \\ 1-\frac{1}{2z}, & \text{if $z\geq 1$} \end{cases}$$
Then easy find the distribution of $\theta=arctan(Z)$ with the fundamental transformation theorem
$$ f_\Theta(\theta) = \begin{cases} \frac{1}{2}+\frac{tan^2\theta}{2}, & \text{if $0\leq \theta<\frac{\pi}{4}$ } \\ \frac{1}{2}+\frac{1}{2 tan^2\theta}, & \text{if $\frac{\pi}{4}\leq\theta\leq\frac{\pi}{2}$} \\ 0, & \text{elsewhere} \end{cases}$$
Solution details & explanation
How to derivate $F_Z(z)$?
Frist of all observe that $Z \in [0;\infty)$.
Using the definition we have
$$F_Z(z)=\mathbb{P}[Z\leq z]=\mathbb{P}[Y\leq zX]$$
Let's do a drawing:
Immeditately find $f_Z(z)$ derivating F
and also easy find the density of $\Theta=tan^{-1}(Z)$ simply applying the known formula
$$f_Y(y)=f_X[g^{-1}(y)]\Bigg|\frac{d}{dy}g^{-1}(y)\Bigg|$$