Find the density function of $Y = X^2 - 1$ for a piecewise-linear r.v. $X$ A density function $f$, of a continuous random variable $X$, is given by:
$$
f(x) = \left\{
        \begin{array}{lc}
            \frac{1}{2} & \quad 0 < x < 1 \\
            \frac{x}{3} & \quad 1 \leq x < 2 \\
            \ 0 & \text{else}
        \end{array}
    \right.
$$
Find the density function of the random variable $Y = X^2 - 1.$
I'm struggling with this problem can someone explain me how to proceed with this kind of problems?

First note that Y can take values between -1 and 3.  If we find the cumulative probability for Y - let's call it $G(y) = p(Y \le y)$ - then its derivative will be the density function.
For $0 < x < 1$, $y = x^2 - 1$, so $-1 < y < 0$.  For $y$ in this range,
$p(Y \le y) = p(X^2 - 1 \le y) = p(X \le \sqrt{y+1}) = \frac12 \sqrt{y+1}$
The last step follows from the observation that $p(X<x) = \frac12x$ for $0 < x <1$
Now consider $1 \le x \lt 2$ where $0 \le y < 3$.
$p(Y \le y) = p(Y \le 0) + p(0 < Y < y)$
We know $p(Y \le 0)$ from the first part, ie $\frac12 \sqrt{0+1} = \frac12$
$p(0 < Y < y) = p(0 < X^2 - 1 < y) = p(1 < X < \sqrt{y+1})$
$$=\int_1^\sqrt{y+1}\frac{x}{3}dx$$
$$=\left[\frac{x^2}{6}\right]_1^\sqrt{y+1}$$
$$=\frac{y}6$$
So $G(y) = \frac12 + \frac{y}6 = \frac {y+3}{6}$
Putting it all together:
$$G(y) = \left\{
        \begin{array}{lc}
            \frac{1}{2}\sqrt{y+1} & \quad -1 < y < 0 \\
            \frac{y+3}{6} & \quad 0 \leq y < 3 \\
            \ 0 & \text{else}
        \end{array}
    \right.$$
If you find the derivative of this function with respect to y, you will have the density function required.
