Probability distribution and density of Y=g(X) $Y=g(X)$ as shown below. 

Find $f_Y(y)$ and $F_Y(y)$ in function of $f_X(x)$.

I began with writing $Y=g(X)$ as the following piecewise function: $
 Y =
  \begin{cases}
   \ -b &amp; \text{if } x &lt; -a \\
   bx/a       &amp; \text{if } -a \leq x \leq a \\
   b       &amp; \text{if } x &gt; a
  \end{cases}
$

For the middle part I think it's simply $f_Y(y)= f_X(y)$ and $F_Y(y)=F_X(y)$.

For the constant parts of the functions I had the following: $f_Y(y)=\delta(y+b)$ when $x&lt;-a$ and $f_Y(y)=\delta(y-b)$ when $x&gt;a$. Is this correct? And how should I put these parts together to express the overall functions $F_Y(y)$ and $f_Y(y)$?
If $b\leq y$ then $g\left(x\right)\leq y$ is true for every $x$ so
that: $$F_{Y}\left(y\right)=P\left\{ g\left(X\right)\leq y\right\} =1$$

If $-b\leq y&lt;b$ then $g\left(x\right)\leq y\iff x\leq\frac{a}{b}y$
so that: $$F_{Y}\left(y\right)=P\left\{ g\left(X\right)\leq y\right\} =P\left\{ X\leq\frac{a}{b}y\right\} =F_{X}\left(\frac{a}{b}y\right)$$

If $y&lt;-b$ then $g\left(x\right)\leq y$ is not true for any $x$
so that: $$F_{Y}\left(y\right)=P\left\{ g\left(X\right)\leq y\right\} =0$$

It is not sure that $Y$ has a density. For this we need $P\{X\in[-b,b]\}=1$, and in that case: $$f_{Y}\left(y\right)=\frac{a}{b}f_{X}\left(\frac{a}{b}y\right)$$
From the graph, $Y$ cannot be less than $-b$ nor greater than $b$.   $$\Pr(Y&lt;-b)=0\\ \Pr(Y&gt;b)=0$$

However, at the points of inflection, we know $Y$ has a probability mass: $$\Pr(Y=-b)=\Pr(X\leq -a) \\ \Pr(Y=b)=\Pr(X\geq a)$$

In the interval between there is a linear relation between $X$ and $Y$ so $$\Pr(Y\le y)=\Pr(X\le ay/b) , \forall y\in (-b, b)$$

Putting it together, 
$$F_Y(y) = \begin{cases} 0 &amp; y &lt; -b \\ F_X(-a) &amp; y=-b\\ F_X(ay/b) &amp; y\in (-b, b) \\ 1 &amp; y\ge b\end{cases}$$
By derivation,
$$f_Y(y) = \begin{cases} 0 &amp; y &lt; -b \\ F_X(-a)\delta(y+b) &amp; y=-b \\ a f_X(ay/b)/b &amp; y\in (-b, b)\\ (1-F_X(a))\delta(y-b) &amp; y=b \\ 0 &amp; y&gt; b\end{cases}$$
Thus:
 $$f_Y(y) = F_X(-a)\delta(y+b)+(1-F_X(a))\delta(y-b) + \frac{a f_X(ay/b)}{b}\operatorname{\bf 1}_{(-b,b)}(y)$$

$$F_Y(y) = F_X(ay/b)\operatorname{\bf 1}_{[-b,b)}(y)+\operatorname{\bf 1}_{[b,\infty)}(y)$$