As a routine exercise, I am trying to find the distribution of $\sqrt{X^2+Y^2}$ where $X$ and $Y$ are independent $ U(0,1)$ random variables.
The joint density of $(X,Y)$ is $$f_{X,Y}(x,y)=\mathbf 1_{0<x,y<1}$$
Transforming to polar coordinates $(X,Y)\to(Z,\Theta)$ such that $$X=Z\cos\Theta\qquad\text{ and }\qquad Y=Z\sin\Theta$$
So, $z=\sqrt{x^2+y^2}$ and $0< x,y<1\implies0< z<\sqrt 2$.
When $0< z<1$, we have $0< \cos\theta<1,\,0<\sin\theta<1$ so that $0<\theta<\frac{\pi}{2}$.
When $1< z<\sqrt 2$, we have $z\cos\theta<\implies\theta>\cos^{-1}\left(\frac{1}{z}\right)$, as $\cos\theta$ is decreasing on $\theta\in\left[0,\frac{\pi}{2}\right]$; and $z\sin\theta<1\implies\theta<\sin^{-1}\left(\frac{1}{z}\right)$, as $\sin\theta$ is increasing on $\theta\in\left[0,\frac{\pi}{2}\right]$.
So, for $1< z<\sqrt 2$, we have $\cos^{-1}\left(\frac{1}{z}\right)<\theta<\sin^{-1}\left(\frac{1}{z}\right)$.
The absolute value of jacobian of transformation is $$|J|=z$$
Thus the joint density of $(Z,\Theta)$ is given by
$$f_{Z,\Theta}(z,\theta)=z\mathbf 1_{\{z\in(0,1),\,\theta\in\left(0,\pi/2\right)\}\bigcup\{z\in(1,\sqrt2),\,\theta\in\left(\cos^{-1}\left(1/z\right),\sin^{-1}\left(1/z\right)\right)\}}$$
Integrating out $\theta$, we obtain the pdf of $Z$ as
$$f_Z(z)=\frac{\pi z}{2}\mathbf 1_{0<z<1}+\left(\frac{\pi z}{2}-2z\cos^{-1}\left(\frac{1}{z}\right)\right)\mathbf 1_{1<z<\sqrt 2}$$
Is my reasoning above correct? In any case, I would like to avoid this method and instead try to find the cdf of $Z$ directly. But I couldn't find the desired areas while evaluating $\mathrm{Pr}(Y\le \sqrt{z^2-X^2})$ geometrically.
EDIT.
I tried finding the distribution function of $Z$ as
\begin{align} F_Z(z)&=\Pr(Z\le z) \\&=\Pr(X^2+Y^2\le z^2) \\&=\iint_{x^2+y^2\le z^2}\mathbf1_{0<x,y<1}\,\mathrm{d}x\,\mathrm{d}y \end{align}
Mathematica says this should reduce to
$$F_Z(z)=\begin{cases}0 &,\text{ if }z<0\\ \frac{\pi z^2}{4} &,\text{ if } 0< z<1\\ \sqrt{z^2-1}+\frac{z^2}{2}\left(\sin^{-1}\left(\frac{1}{z}\right)-\sin^{-1}\left(\frac{\sqrt{z^2-1}}{z}\right)\right) &,\text{ if }1< z<\sqrt 2\\ 1 &,\text{ if }z>\sqrt 2 \end{cases}$$
which looks like the correct expression. Differentiating $F_Z$ for the case $1< z<\sqrt 2$ though brings up an expression which doesn't readily simplify to the pdf I already obtained.
Finally, I think I have the correct pictures for the CDF:
For $0<z<1$ :
And for $1<z<\sqrt 2$ :
Shaded portions are supposed to indicate the area of the region $$\left\{(x,y):0<x,y< 1\,,\,x^2+y^2\le z^2\right\}$$
The picture immediately yields
\begin{align} F_Z(z)&=\Pr\left(-\sqrt{z^2-X^2}\le Y\le\sqrt{z^2-X^2}\right) \\&=\begin{cases}\frac{\pi z^2}{4} &,\text{ if } 0<z<1\\\\ \sqrt{z^2-1}+\int_{\sqrt{z^2-1}}^1 \sqrt{z^2-x^2}\,\mathrm{d}x &,\text{ if }1< z<\sqrt 2 \end{cases} \end{align}
, as I had previously found.
FullSimplify
) they simplify to different formulas in Mathematica. However, they are equivalent. This is easily shown by plotting their difference. Apparently Mathematica doesn't know that $\tan ^{-1}\left(\sqrt{z^2-1}\right)=\sec ^{-1}(z)$ when $1\lt z \lt \sqrt{2}$. $\endgroup$