If $X$ is a random variable with cdf $F_X(x)$, then any function of $X, g(X),$ is also a random variable. Let $Y = g(X).$ For any set $A$, \[P(Y \in A) = P(g(X) \in A)\]
If we write $y = g(x)$, the function $g(x)$ defines a mapping from the original sample space of $X, \mathcal{X},$ to a new sample space $\mathcal{Y}.$ That is, \[g(x) : \mathcal{X} \rightarrow \mathcal{Y}\]
We associate with $g$ an inverse mapping, denoted $g^{-1},$ which is a mapping from subsets of $\mathcal{Y}$ to subsets of $\mathcal{X},$ and is defined by \[g^{-1}(A) = \{x\in \mathcal{X} : g(x) = y \}.\]
\[\begin{equation} \label{eq:sample-space} \mathcal{X} = \{x : f_X(x) > 0\} \;\; \text{and} \;\; \mathcal{Y} = \{y : y = g(x) \text{ for some } x \in \mathcal{X}\}. \end{equation}\]
a.) If $g$ is an increasing function on $\mathcal{X}, F_Y(y) = F_X(g^{-1}(y))$ for $y\in \mathcal{Y}.$
b.) If $g$ is a decreasing function on $\mathcal{X}$ and $X$ is a continuous random variable, $F_Y(y) = 1 - F_X(g^{-1}(y))$ for $y\in \mathcal{Y}.$
i.) $g(x) = g_i(x),$ for $x\in A_i,$
ii.) $g_i(x)$ is monotone on $A_i,$
iii.) The set $\mathcal{Y} = \{y : g_i(x) \text{ for some } x \in A_i\}$ is the same for each $i=1,\ldots, k,$ and
iv.) $g_i^{-1}(y)$ has a continuous derivative on $\mathcal{Y}$, for each $i=1,\ldots,k.$
Then \[f_Y(y) = \begin{cases} \sum_{i=1}^{k} f_X(g_i^{-1}(y))\left\vert\dfrac{d}{dy}g_i^{-1}(y)\right\vert & y \in \mathcal{Y} \\ 0 & \text{otherwise.} \end{cases}\]