Question: I have the problem following :

Let's say we have random variable with density function $f\_x=\begin{cases} \frac{x+1}{2} &for \; x \in[-1,1] \newline 0 & for \; x \in(-\infty,1)\cup(1,+\infty)
\end{cases}$

And we want to derive density function of $X^2$

**My work so far**

My first guees was to derive CDF of $X$ : $$F\_X=\begin{cases} 0 & for \; x \in (-\infty,-1) \newline \frac{x^2}{4}+\frac{x}{2}+\frac{1}{4} & for \; x\in[-1,1] \newline 1&for\; x \in (1,+\infty)\end{cases}$$

After that I wanted to derive CDF of $X^2$ :

$P(X^2 \le t)=0$ for $t<0$, so we can now consider our formula only for $t>0$

$P(X^2 \le t)=P(X \le \sqrt{t})=\frac{t}{4}+\frac{\sqrt{t}}{2}+\frac{1}{4}$ for $t \in [0,1]$

And $P(X^2 \le t)=1$ for $t>1$.

And finally I calculated PDF of X^2 $$f\_{X^2}=\begin{cases} 0 & for \; x \notin [0,1] \newline 
\frac{1}{4}+\frac{1}{4\sqrt{x}} & for \; x \in [0,1]
 \end{cases}$$

And my problem is that $\int\_{R}f\_{X^2}=\frac{3}{4} \neq 1$

Can you please help me spot the mistake ?

Thank you in advance!

Answer: 
**Hint:** Note that $P(X^2\le t) = P\left(-\sqrt{t}\le X \le \sqrt{t}\right)$ (you forgot to consider negative values of $X$ here).
If $\phi(X)$ was defined as
$$
Y = \Bigg\{
\begin{align}
X^2 && x \geq0 \\
0 && \text{otherwise}
\end{align}
$$
Then your approach would be correct. In your case though, your suggestion $P(X^2<0)=0$ (which is correct) is not equivalent to the correct probability $P(-\sqrt{y} \leq X \leq 0$), because the set $A=\{X^2 \leq y\} = \{-\sqrt{y} \leq X \leq \sqrt{y}\}$ includes the subset for negative $x$. So, when you consider 'formula only for $y>0$', it also includes negative values for $X$.

It is also more convenient in your case to derive the CDF of Y first:
$$
P(Y \leq y) = P(\phi(X) \leq y) = P(X \leq \phi^{-1}(y)) = P(-\sqrt{y} \leq X \leq \sqrt{y}) = \int\_{-\sqrt{y}}^{\sqrt{y}}f = \sqrt{y}, \ y >0
$$
After differentiation, you get PDF of $Y$:
$$
f(y) = \frac{1}{2\sqrt{y}}, y >0
$$