Please correct my answer (Probability)

I have a probability issue that i am dealing with now. Maybe you could
help me a bit 🙂 .

I have to calculate the density function of the random variable
$Y= 1-X^2$, given that: $f(x) = \frac{1}{9}(x+1)^2$, where $-1 < x < 2$.

So I found that the domain of Y is $-3 < Y < 0$.

I found that distribution of $Y$ is: $0$ when $y < -3$ and $1$ when $y >0$.

At $-3<Y<0$ is :

$$\int_{-\sqrt{1-y}}^{\sqrt{1-y}}f(x) dx = \cdots =
[2(1-y)^{\frac{3}{2}} + 6(1-y)^{\frac{1}{2}}]27$$

So, finally the density function of $Y$ is the derivative of $[2(1-y)^{\frac{3}{2}} + 6(1-y)^{\frac{1}{2}}]27 = \cdots = \frac{x-2}{9\sqrt{1-x}}$ at $-3<y<0$, $0$ else.

I think that the general idea is correct, but I am not sure at all for the results, for example maybe my domain is wrong or I might miss a calculation.

Solutions Collecting From Web of "Please correct my answer (Probability)"

From looking at the graph of $Y$ versus $X$
on the given $X$-domain, the open interval $(-1,2)$,

enter image description here

you can see that $Y\in(-3,1]$ (note that the interval
is open at $-3$ but closed at $Y=1$ where $X=0$).
The CDF of $Y$ can then be calculated from the CDF of $X$,
after calculating that from the integral, as follows:
$$
\eqalign{
F_X(x)
&=P(X\le x)=
\int_{-1}^{x}\tfrac19(1+t)^2\,dt
=\tfrac1{27}\left[(1+t)^3\right]_{-1}^{x}
=\tfrac1{27}(1+x)^3
\\\\
F_Y(y)
&=
P(Y\le y)=P(1-X^2\le y)=P(X^2\ge1-y)=P(|X|\ge\sqrt{1-y})
\\\\
&=\left\{\array{
0&y\le-3\\
P\left(X\ge\sqrt{1-y}\right)\qquad&-3\lt y\le0\\
1-P\left(|X|\le\sqrt{1-y}\right)\qquad&0\lt y\le1
\\1&y\ge1
}\right.
\\\\
&=
\left\{\array{
0&y\le-3\\
1-F_X\left(\sqrt{1-y}\right)\qquad&y\in(-3,0]\\
1-F_X\left(\sqrt{1-y}\right)+F_X\left(-\sqrt{1-y}\right)\qquad&y\in(0,1]
\\1&y\ge1
}\right.
\\\\
&=
\left\{\array{
0&y\le-3\\
1-\tfrac1{27}\left(1+\sqrt{1-y}\right)^3\qquad&y\in(-3,0]\\
1-\tfrac1{27}\left[
\left(1+\sqrt{1-y}\right)^3-
\left(1-\sqrt{1-y}\right)^3
\right]\qquad&y\in(0,1]
\\1&y\ge1
}\right.
}
$$
which for $y\in(0,1]$ can also be simplified a bit further
using $(1\pm r)^3=1\pm3r+3r^2\pm r^3$ thus:
$$
(1+r)^3-(1-r)^3=2\,(3r+r^3)=2r\,(3+r^2)\qquad\implies
$$
$$
F_Y(y)=1-\tfrac1{27}2\sqrt{1-y}~(3~+~1-y)=1-\frac{2\sqrt{1-y}\,(4-y)}{27}
\quad\text{for}\quad y\in(0,1]
$$
or differentiated to get the PDF:
$$
\eqalign{
f_Y(y)
&=\left\{\array{
0 & \qquad y\le-3\quad\text{or}\quad y\gt1\\\\
\frac19+\frac{2-y}{18\sqrt{1-y}} & \qquad y\in(-3,0]\\\\
\frac{2-y}{9\sqrt{1-y}} & \qquad y\in(0,1]
}\right.
}
$$
Here is the PDF $f_X(x)$, in red, and CDF $F_X(x)$, in blue, of $X$:

PDF (red) and CDF (blue) of X

and likewise for $Y$ (the PDF $f_Y(y)$ has a vertical asymptote at $1$):

PDF (red) and CDF (blue) of Y

Note that both CDFs are in fact (not only right- but also left-) continuous,
so that it doesn’t matter to which case we assign the transition points $-3$, $0$ and $1$; as @Dilip has pointed out, it could be considered better pedagogy
to use left-closed, right-open intervals to emphasize that (CDF) distributions
must be right-continuous.

The key step in my method is being able to replace the probabilities
with differences of the (cumulative) distribution function for $X$
in the middle bracketed RHS above during the derivation of $F_Y$.
This technique is known as the distribution function method
or method of distribution functions. Alternate methods exist,
for example integrating the product of $f_X$ with the derivative of the transformation function (or for multivariate transformations, the Jacobian). There is also a method using moment generating functions.


Again starting with the graph $Y=1-X^2$ above,
if we approach it from an integral involving the PDF,
as you do, we can still start as I did above,
up to the first bracketed RHS involving probabilities:

$$
\eqalign{
F_Y(y)&=P\left(X\ge\sqrt{1-y}\right)
\qquad\text{for}\qquad-3\lt y\le0\\
&=\int_{\sqrt{1-y}}^2f_X(x)\,dx
=\int_{\sqrt{1-y}}^2\tfrac19(1+x)^2\,dx\\
&=\tfrac1{27}\left[(1+x)^3\right]_{\sqrt{1-y}}^2
=1-\tfrac1{27}\left(1+\sqrt{1-y}\right)^3
}
$$
as above, and similarly for $y\in(-3,0]$.
The key insight is still that
$$
Y=1-X^2 \le y \iff
X^2 \ge 1-y \iff
|X| \ge \sqrt{1-y},
$$
which then must be handled seperately,
depending on the sign of $x$.