The p.d.f. of the random variable $X$ is given by $f(x) = \begin{cases} e^{x-2} & \mbox{for $0 \leq x \leq 2$}, \\ e^{-x} & \mbox{for $x > 2$}, \\ 0 & \mbox{otherwise,} \end{cases}$
I need to find $F^{-1}(y)$ to construct a generator for $X$. So I start with calculating the cdf by taking the integral of $f(x)$: $$ F(X)= \begin{cases} \frac{e^x-1}{e^2} & 0 \leq x \leq 2 \\ -e^{-x}+e^{-2} & x \geq 2 \\ 0 & o.w \end{cases} $$ Next, I need to find the inverse of this function: $$y = \frac{e^x-1}{e^2} \implies x= \ln(e^2y+1) \text{ for } y \in [0, 1-e^{-2}]$$
$$y=-e^{-x}+e^{-2} \implies x = -\ln(e^{-2}-y) \text{ for }y \in (0, e^{-2})$$
Now at this point I am confused since the intervals for $F^{-1}(y)$ overlap. How do I break this up into cases? Did I screw up a calculation along the way( I retraced my steps and it seems fine...)?