density of $X^2$ when $X$ has uniform $[-1, 2]$ distribution
Solution 1:
$Z$ is nonnegative so $f_{Z}\left(x\right)=0$ if $x<0$.
For $x\geq0$ we have: $$F_{Z}\left(x\right)=F_{X}\left(\sqrt{x}\right)-F_{X}\left(-\sqrt{x}\right)$$
Consequently: $$f_{Z}\left(x\right)=\frac{1}{2\sqrt{x}}f_{X}\left(\sqrt{x}\right)+\frac{1}{2\sqrt{x}}f_{X}\left(-\sqrt{x}\right)=\frac{1}{6\sqrt{x}}\left(\chi_{\left[-1,2\right]}\left(\sqrt{x}\right)+\chi_{\left[-1,2\right]}\left(-\sqrt{x}\right)\right)$$
It remains to work out the RHS.
I leave that to you.
Solution 2:
$$ \mathbb{P}(X\in[-\sqrt{z},\sqrt{z}])=\mathbb{P}(X<\sqrt{z})-\mathbb{P}(X<-\sqrt{z})=\boxplus $$ Now since $X$ in uniform on $[-1,2],$ the CDF of it is: $$ F_X(x)=\chi_{x\in(2,\infty)}+\frac{1}{3}(x+1)\chi_{x\in[-1,2]}. $$ Thus by taking the range into consideration, we obtain: $$ \boxplus=\chi_{\sqrt{z}\in(2,\infty)}+\frac{1}{3}(\sqrt{z}+1)\chi_{\sqrt{z}\in[0,2]}-\frac{1}{3}(-\sqrt{z}+1)\chi_{-\sqrt{z}\in[-1,0]}= $$ $$ =\chi_{\sqrt{z}\in(2,\infty)}+\frac{1}{3}(\sqrt{z}+1)\chi_{\sqrt{z}\in[1,2]}+\frac{2\sqrt{z}}{3}\chi_{\sqrt{z}\in[0,1]} $$ Basically we handled the cases $z\geq 4$, $z\in[1,4]$, $z\in[0,1]$ and $z<0$ separately. Thus the PDF is: $$ \begin{cases} 0&z\in(-\infty,0)\cup(4,\infty)\\ \frac{1}{3\sqrt{z}}& z\in(0,1]\\ \frac{1}{6\sqrt{z}}& z\in(1,4]\\ \end{cases} $$
Solution 3:
While Ákos Somogyi's answer is correct, this is not the best approach to solve this kind of problem.
There is a transformation of density formula, which says that if $X$ has density $f_X$ and $h$ is piecewise continuously differentiable and piecewise strictly monotone, then $Y$ has the density $$ f_Y(y) = \sum_{x: h(x) = y} \frac{f_X(x)}{|h'(x)|}. \tag{1} $$
Why is it better to use (1)? The cdf approach goes through: finding the cdf of $X$, solving the inequality $h(x) \le y$ to find cdf of $Y$, differentiating it to get the cdf of $X$. To use (1), one should solve the equation $h(x) = y$, which is much easier; moreover, solving the inequality involves solving the equation anyway. And here you don't make some unnecessary extra operations, like finding the cdf of $X$ and then differentiating the cdf of $Y$ (which are kind of inverse operations, so this is pretty pointless).