Find the pdf of Y when pdf of X is given $$
f_{X}(x) = \frac{3}{8}(x+1)^{2} ,\ -1 < x < 1
$$
$$Y = \begin{cases} 1 - X^{2}  & X \leq 0,\\
1- X, & X > 0.\end{cases}$$
I started with :
$$
F_{Y}(y) = 1 - P(Y \leq y) 
$$
$$
         = 1 - [P(-(1-y)^\frac {1}{2} < X < (1-y)]
$$
From here, I can get $F_{Y}(y)$, and differentiating it will give me $f_{x}(x)$.
But the answer I am getting for pdf is not the desired answer. Am I doing anything wrong?
Thanks for your help.
 A: The probability density function of $Y$ can be found by:
$$
f_{Y}(y)=\sum_{i}f_{X}(g_{i}^{-1}(y))\left|\frac{dg_{i}^{-1}(y)}{dy}\right|,\quad \mathrm{for}\; y \in \mathcal{S}_{Y}
$$
where $g_{i}^{-1}$ denotes the inverse of the transformation function and $\mathcal{S}_{Y}$ the support of $Y$. Let's denote our two transformation functions
$$
\begin{align}
     g_{1}(X) &= 1-X^{2}, & X\leq 0\\
     g_{2}(X) &= 1-X, & X>0\\
\end{align}
$$
The support of $Y$ is the set $\mathcal{S}_{Y}=\{y=g(x):x\in\mathcal{S}_{X}\}$ where $\mathcal{S}_{X}$ denotes the support set of $X$. Hence, the support of $Y$ is $y \in (0,1]$. Further, we need the inverse transformations $g_{1}^{-1}(y)$ and $g_{2}^{-1}(y)$. They are given by:
$$
\begin{align}
     g_{1}^{-1}(y) &= -\sqrt{1-y}\\
     g_{2}^{-1}(y) &= 1-y \\
\end{align}
$$
In the first inverse, we need only the negative signed function because $x\leq 0$. The derivatives are:
$$
\begin{align}
     \left|\frac{dg_{1}^{-1}(y)}{dy} g_{1}^{-1}(y)\right| &=\frac{1}{2\sqrt{1-y}}\\
     \left|\frac{dg_{2}^{-1}(y)}{dy} g_{2}^{-1}(y)\right| &= \left|-1\right| = 1 \\
\end{align}
$$
So the PDF of $Y$ is given by:
$$
\begin{align}
f_{Y}(y) &= f_{X}(-\sqrt{1-y})\cdot \frac{1}{2\sqrt{1-y}} + f_{X}(1-y)\cdot 1 \\
&= \frac{3}{8}(1-\sqrt{1-y})^{2}\cdot \frac{1}{2\sqrt{1-y}} + \frac{3}{8}(2-y)^{2}\cdot 1 \\
&= \begin{cases}
\frac{3}{16}\left(6+\frac{2}{\sqrt{1-y}}+y\cdot\left(2y-\frac{1}{\sqrt{1-y}}-8\right)\right), & 0 < y \leq 1\\
0, &\mathrm{otherwise}
\end{cases}
\end{align}
$$
