Assume you have an uniformly distributed random variable $u \in (0,1).$ How can you create a random variable with density
$f(x)=\left\{\begin{matrix} \frac{1}{\pi}\frac{1}{1+x^2}\text{ if }x\geq 0\\ \frac{1}{2}e^x \;\;\;\;\text{ else} \end{matrix}\right. \;\;\;\;$ ?
We first need to know the (cumulative) distribution function of the density function, so we can continue by inverting that distribution function.
The distribution function is $$F(x)=\begin{cases} \frac12e^x & \mbox{if }x < 0 \\ \frac12+\frac1\pi \arctan (x) & \mbox{if } x \ge0 \end{cases}$$
(which is correct because my previous question was about it: Determine the distribution function of this density function).
We are looking for its inverse now (I'm not sure if it's correct like that):
$$i = \frac{1}{2}e^x \Leftrightarrow 2i = e^x \Leftrightarrow x = \ln(2i)$$
$$i=\frac{1}{2}+\frac{1}{\pi} \arctan(x) \Leftrightarrow i-\frac{1}{2}= \frac{1}{\pi}\arctan(x) \Leftrightarrow \pi\left(i-\frac{1}{2}\right)=\arctan(x) \Leftrightarrow \\ \Leftrightarrow x = \tan\left(\pi\left(i-\frac{1}{2}\right)\right)$$
Thus the inverse of the distribution function is $$F^{-1}(i)=\begin{cases} \ln(2i) & \mbox{if }i > 0 \\ \tan\left(\pi\left(i-\frac{1}{2}\right)\right) & \mbox{if } i \le0 \end{cases}$$
Assuming this is correct, how would you get the random variable by this? Is it the maximum possible $i$?
Observe that if $F(x) = y$ then $y \in [0,1]$. Also, in your case, $F(0) = 1/2$. Therefore, $$F^{-1}(y) = \left\{\begin{matrix}\ln(2y) & \text{if $0 \le y \le \frac{1}{2}$;}\\ \tan\left(\pi\left(y-\frac{1}{2}\right)\right) & \text{if $\frac{1}{2} \le y \le 1$.}\end{matrix}\right.$$
Now, set $X = F^{-1}(U)$, where $U$ is a uniform random variable that takes on values between $0$ and $1$. It is easy to observe that $$F_X(x) = \Pr(X \le x) = \Pr(F^{-1}(U) \le x) = \Pr(U \le F(x)) = F(x).$$ Here, I have used the fact that $F_U(u) = \Pr(U \le u)= u$ for $u \in [0,1]$.