Let $X\sim U\left[-2, 1\right]$. I want to calculate $F_{X^2}(t)$, but I don't know how to handle the interval. With, e.g., $\left[-2, 2\right]$, it would be trivial:
$ F_{X^2}(t) = \mathbb{P}\left(X^2 \leq t\right) = \mathbb{P}\left(X \in \left[-\sqrt{t}, \sqrt{t} \right]\right) = \frac{\sqrt{t}-(-\sqrt{t})}{2-(-2)} = \frac{2\sqrt{t}}{4} = \frac{\sqrt{t}}{2} $ for $t\in\left[0, 4\right]$
But I don't think this will work with $\left[-2, 1\right]$. I thought about dividing it into $t\in\left[0,1\right]$ and $t\in\left[1, 4\right]$. I then could treat the first one exactly the same as above. But is this the correct way to handle this?
First of all the cdf of X is
$$F_X(x)=\begin{cases} 0, \ x<-2 \\ \frac13 x+\frac23, \ -2\leq x \leq 1 \\ 1, \ x>1 \end{cases}$$
Now we split it in two cases:
First case: $x\in [-1,1) \Rightarrow y\in [0,1)$
We have $x=y^{1/2} $ for $x\in [0,1)$ and $x=-y^{1/2}$ for $x\in [-1,0)$
Second case: $x\in [-2,-1] \Rightarrow y\in [1,4]$
$\texttt{First case:}$
$$F_Y (y) = P(Y ≤ y) = P(X^2 ≤ y) = P(−y^{1/2} ≤ X ≤y^{1/2})$$
Here you can see symmetry of the limits for X.
$$= P(X ≤ y^{1/2}) − P(X ≤ −y^{1/2}) = F_X(y^{1/2}) − F_X(−y^{1/2})$$.
The cdf of $Y$ is
$$F_Y(y)=F_X\left(y^{1/2}\right)-F_X\left(-y^{1/2}\right)=\frac13y^{1/2}+\frac23-\left(\frac13 (-y^{1/2})+\frac23 \right)=\frac23y^{1/2}$$
$\texttt{Second case:}$
Here $X$ is negative and $Y$ is positive Therefore
$$F_Y(y)=F((-X)^2<y)=F(-X\leq y^{1/2})=P(X\geq -y^{1/2})=1-P(X\leq -y^{1/2})$$
$$F_Y(y)=1-\frac13\cdot \left(-y^{1/2}\right)-\frac23=\frac13\cdot y^{1/2}+\frac13$$
Finally you differentiate to obtain the pdf.