# probability - Distribution for squared random variable

I came across the following question:

What is the mean distance between two points in the unit square?

Disclaimer: I would very much appreciate not getting hints regarding how to solve this problem, but rather I would like to get help with the path I chose.

It is easy to solve this problem numerically. Either with Monte Carlo, or by integrating $$\int_0^1 \int_0^1 \int_0^1 \int_0^1 \sqrt{(x_1-x_2)^2+(y_1-y_2)^2} dx_1 dx_2 dy_1 dy_2$$ The result for the mean distance then becomes $\approx 0.52$. However, I don't like this approach is I consider this somehow to be cheating.

So here is what I came up with: We have $x_1,x_2,y_1,y_2 \sim \mathcal{U}[0,1]$. I can then compute the distribution for $d_x= x_1-x_2$ to be $f_{d_x}(s) = 2-2s$. I would now like to compute the distribution for $d_x^2$. Using that distribution, I would then like to compute the distribution for $d_x^2+d_y^2$ and then try to compute the distribution for $\sqrt{d_x^2+d_y^2}$. However, I'm stuck with computing the distribution for $d_x^2$. I came across the Wikipedia article for the product distribution, stating for $Z=XY$ the distribution is $$f_z(s) = \int f_X(s') f_y(s/s')\frac{1}{|s'|} ds'$$ which I cannot really follow. For my understanding, I would only need to compute $$f_z(s) = \int f_X(s') f_y(s/s') ds'$$ Furthermore, my situation is different, as $Y$ and $X$ are not independent, since they are the same. With some educated guesses, it seems to me, that the distribution for $d_x^2$ could be given by $$f_{d_x^2}(s) = \frac{2-\sqrt{s}}{s}$$ I came to this result, by comparing a histogram with some functions I constructed. But: This function is not a pdf, since it is not integrable on $[0,1]$.

So here is my question:

Given a distribution $f_x$ of a random variable $x$, where $f_x:[0,1]\rightarrow \mathbb{R}$ and $\int_0^1 f_x(x)dx=1$, how can I compute the distribution $f_{x^2}$.

Which would be the general setting. Or more concrete

Given a distribution $f_x$ of a random variable $x$, where $f_x(s) = 2-2s$, how can I compute the distribution $f_{x^2}$.

1. Let $$X = X_2-X_1$$ denote the difference of two standard Uniform random variables, which is well-known to be a symmetric Triangular distribution on (-1,1). Similarly, let $$Y = Y_2-Y_1$$. By independence, the joint pdf of $$(X,Y)$$, say $$f(x,y)$$, is then:
where I am using the Expect function from the mathStatica package for Mathematica to do the nitty gritties, ArcSinh denotes $$\sinh^{-1}(1)$$, and the answer to the first few decimal places is 0.521405 ...
P.S. The pdf of $$U = X^2$$ will be say $$g(u) = \frac{1}{\sqrt{u}}-1$$ defined on (0,1), but it is questionable as to whether making this transformation makes the integration any easier.