# Proving function of random variable is a random variable?

For information on the question, see This question:

I wanted to add a more measure-theoretic answer (I still do, but I can just link this question there if this is answered well). However, when proving the question I confused myself, so I want someone to tell me if this is correct, or how to better prove that $Y=X^2$ is a random variable when $X$ is a random variable.

Here is my attempt, and the bolded part is where I got confused.

$X$ is a random variable means that $X$ is an $\mathscr{F}$-measurable function $X:\Omega\to \mathbb{R}$ (we have some probability space in the background $(\Omega,\mathscr{F},P))$. $X$ being $\mathscr{F}$-measurable means the inverse image of any borel set under $X$ is in $\mathscr{F}$. In other words, $$\text{given and } B\in\mathscr{B}(\mathbb{R}) \text{ (the borel set )}, X^{-1}B \in \mathscr{F}$$

The following is where I am confused If $Y=X^2$, then $Y:\Omega\to\mathbb{R}$, clearly (since it must take the same inputs as $X$, only the outputs are different). Also, we must show that $Y$ is $\mathscr{F}$-measurable. Take any $B \in \mathscr{B}(\mathbb{R})$. $$Y^{-1}B = \{ a \in \Omega : X(a)^2 \in B\} =\{ a\in \Omega : X(a) \in \sqrt{B}\} \in \mathscr{F}$$

Since $\sqrt{B}$ is a borel set (not sure I can say this or even if it makes sense). Basically, I am confused on showing that $Y^{-1}B \in \mathscr{F}$, because I don't know if $\sqrt{B}$ is really a borel set, or if I can even take the square root of a set...? (If I think of an open interval than I think I would take the square root of everything in the interval, but the borel set also contains unions of intervals...)

If the above is correct,then $Y$ satisfies both conditions to be a random variable, and is thus a random variable.

Another way I was considering going (and a more general way) would be to say that $Y= f\circ X$ with $f:\mathbb{R}\to\mathbb{R}$, and then saying that $Y^{-1} = X^{-1}\circ f^{-1}$ which is $\mathscr{F}$ measurable. Would this approach be correct?

Thanks.

2. Any continuous function $f:X\to \mathbb R$ is measurable if we take the Borel set on $\mathbb R$ and $X$.