Consider the following function $f:(-\infty,e]\rightarrow \mathbb{R}, f(x) = \begin{cases} 1 & ,\text{if } x=e \\ \ln(x) & ,\text{if } x \in(0,e)\\ -x & , \text{if} \, x\leq 0 \end{cases} $
I am trying to show it is a measurable function by showing $\{x\colon f(x)<a\}$ for all $a\in\Bbb R$.
Now, I will consider cases for $a$:
Case I: If $a\leq 0$, then $f^{-1}(-\infty,a)=(0,e^a).$
Case II: If $0<a<1$, then $f^{-1}(0,a)=(-a,0)\cup(1,e^a)$
Case III: If $a\geq 1$, then $f^{-1}(1,a)=(-a,1)$
Another way to do it, let $g_1(x)=\begin{cases} 1 & ,\text{if } x=e \\ 0 & ,\text{if} \, x\in\Bbb R\setminus\{e\}\\ \end{cases} $ , $g_2(x)=\begin{cases} 1 & ,\text{if } x\in(0,e) \\ 0 & ,\text{if} \, x\in\Bbb R\setminus(0,e)\\ \end{cases} $ , $g_3(x)=\begin{cases} 1 & ,\text{if } x\in(-\infty,0] \\ 0 & ,\text{if} \, x\in\Bbb R\setminus(-\infty,0]\\ \end{cases} $
Now, $f(x)=g_1(x)+\ln(x)g_2-xg_3(x).$ Clearly, $f$ is a measurable function.
Is that right?