Soon I will have my final exam for probability theory. Unfortunately, my university doesn't have a lot of past papers available due to a change of lecturer. Hence I decided to make some exercises on the internet, but some of them don't have answers. I think that this exercise looks quite easy, however I am not sure if I did it right, and it would be nice if someone could verify for me whether I am on the right track or not.
Let $X$ be a continuous random variable with pdf:
$\begin{equation} f_X(x) = \begin{cases} |x|,& -1\leqslant x \leqslant 1 \\ 0,& \text{otherwise} \end{cases} \end{equation}$
I need to compute the density function of $Y:= g(X) = X^2$.
For this I decided to use the following theorem:
"Given that $g$ is differentiable and either strictly decreasing or strictly increasing,
$f_Y(y) = f_X(g^{-1}(y)) |\frac{d}{dy}g^{-1}(y)|$"
In our case $g$ is differentiable, strictly decreasing on $-1 \leq x < 0$, and strictly inceasing on $0 \leq x < 1$. So my idea was just to apply this theorem over those two intervals.
Computing the inverse of $g$ gives us $g^{-1}(y) = \sqrt{y}$.
Then, filling this into our formula gives us
$\begin{aligned}f_Y(y) &= f_X(g^{-1}(y)) |\frac{d}{dy}g^{-1}(y)|\\ &= |\sqrt{y}||\frac{1}{2\sqrt{y}}|\\ &= |\frac{\sqrt{y}}{2\sqrt{y}}|\\ &= |\frac{1}{2}|\\ &= \frac{1}{2} \end{aligned}$
We can observe that $f_Y(y)$ will be the same on both intervals, and also, squaring the range of $x$ gives us that the range of $y$ will be $0 \leq y \leq 1$. Hence $\begin{equation*} f_Y(y) = \begin{cases} \frac{1}{2},& 0\leqslant y \leqslant 1 \\ 0,& \text{otherwise} \end{cases} \end{equation*}$
Can someone verify for me if this is right? Actually I dont even know if it is okay to use the formula $f_Y(y) = f_X(g^{-1}(y)) |\frac{d}{dy}g^{-1}(y)|$, since over the total interval our function is first decreasing and after increasing.
Thanks in advance!
Note 1: $\dfrac{\mathrm d \sqrt y}{\mathrm d ~y~~}=\dfrac{1}{2\sqrt y}$
Note 2: $x\mapsto x^2$ folds $[-1;1]$ onto $[0;1]$, so it effectively has two "inverse" functions.
These are $y\mapsto +\surd y$ and $y\mapsto -\surd y$, mapping $[0;1]$ to $[0;1]$ and $[-1;0]$ respectively.
Thusly:
$$f_Y(y)=f_X({+}\surd y)\cdot\left\lvert\dfrac{\mathrm d ({+}\surd y)}{\mathrm d~y~}\right\rvert~\mathbf 1_{y\in[0;1]}+ f_X({-}\surd y)\cdot\left\lvert\dfrac{\mathrm d ({-}\surd y)}{\mathrm d~y~}\right\rvert~\mathbf 1_{y\in[0;1]}$$