# density of $X^2$ when $X$ has uniform $[-1, 2]$ distribution

Suppose $X$ has uniform $[-1,2]$ distribution. I am trying to find the density of $Z=X^2$.

Here is what I have done thus far:

Range($Z$)$=[0,4]$. I began computing the distribution of $Z$ for $z \in [0,4]$ as follows:

\begin{align*} P(Z \le z) &= P(X^2 \le z)\\ &= P(X \in [-\sqrt z, \sqrt z]) \end{align*}

I am note sure what to do from here. Any help is greatly appreciated. Once I unravel the distribution of $Z$, I can obtain the density of $Z$ by taking the derivative of its distribution function with respect to $z$.

$$\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}$$

• I am trying to understand this line: $$F_X(x)=\chi_{x\in(2,\infty)}+\frac{1}{3}(x+1)\chi_{x\in[-1,2]}.$$ I'm assuming $\chi$ is the indicator function. Where do $1/3$, x+1, and $\chi_{x\in (2, \infty)}$ come from? – Marcialo Nov 16 '15 at 8:48
• Since the range of $X$ is $[-1,2]$, thus $\mathbb{P}(X\leq x)=1$, if $x\geq2$. Generally, the uniform distribution on $(a,b)$ has density function $$\frac{x-a}{b-x}\chi_{x\in[a,b]}+\chi_{x>b}$$ As it has uniform density on the interval $[a,b]$, the CDF must be linear, and $\mathbb{P}(X\leq a)=0$ and $\mathbb{P}(X\leq b)=1$. – Ákos Somogyi Nov 16 '15 at 8:51

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).

$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.