$$f:[-2,2] \rightarrow \Bbb R$$ $$\text {and }f(x)= \begin{cases} -1, & -2 \leq x \leq 0 \\ x-1, & 0 < x \leq 2 \end{cases}$$
And, let $g(x)$ be equal to $|f(x)|+f(|x|)$
We need to find the value of $g(x)$ (define it).
I begin by finding the value of $|f(x)|$ first :
$$|f(x)|=\begin{cases} |-1|, & -2 \leq x \leq 0 \\ |x-1|, & 0 < x \leq 2 \end{cases}=\begin{cases} 1, & -2 \leq x \leq 0 \\ |x-1|, & 0 < x \leq 2\end{cases}$$
Now, to determine what $|x-1|$ would be, we need to determine whether $(x-1)$ is positive or negative or zero.
If $x-1 \geq 0$, $|x-1| = x-1$ and if $x-1 < 0$, then $|x-1| = -(x-1) = 1-x$
If $x-1 \geq 0$, then $x \geq 1$ and if $x - 1 < 0$, then $x < 1$. We can now split the condition $0 < x \leq 2$ from the earlier definition of $|f(x)|$ as $0<x<1$ and $1 \leq x \leq 2$, where $0<x<1 \implies |x-1| = 1-x$ and $1 \leq x \leq 2 \implies |x-1| = x-1$
So, $$ |f(x)| = \begin{cases} 1, & -2 \leq x \leq 0 \\ 1-x, & 0<x<1 \\ x-1, & 1 \leq x \leq 2 \end{cases}$$
Now, we need to define $f(|x|)$. Here's what I do :
$$f(|x|) = \begin{cases} -1, & -2 \leq x \leq 0 \\ |x|-1, & 0<|x| \leq 2 \end{cases}$$
Now, is the next step that I do here correct or even necessary?
Now, $|x|$ can never be negative but can be zero when $x=0$. So, the condition $-2 \leq |x| \leq 0$ can be replaced by $x = 0$ from which we obtain the following definition for $f(|x|)$:
$$f(|x|) = \begin{cases} -1, & x=0 \\ |x|-1, & 0 < x \leq 2 \end{cases} = \begin{cases} |x|-1, & 0 \leq |x| \leq 2 \end{cases}$$
I did the last one because we observe that $0$ is mapped to $-1$ and $|0|-1 = -1$, so it will still be mapped to $-1$ if we put it in the second condition. So, basically, for any value of $x$ that is a part of domain of $f$, $f(|x|) = |x|-1$.
Now, we add $|f(x)|$ and $f(|x|)$ to obtain $g(x)$.
$$g(x) = |f(x)| + f(|x|) = \begin{cases} |x|-1+1, & -2 \leq x \leq 0 \\ |x|-1+1-x, & 0 < x < 1 \\ |x|-1+x-1, & 1 \leq x \leq 2\end{cases}$$.
In the first condition, the value of $x$ is either negative or $0$, so if it is negative, $|x| = -x$ and else, it is 0 which is also equal to $-0$, which means that in the first condition, $|x|$ can be substituted by $-x$. In the second and, the value of $x$ is always positive, so $|x| = x$. So, we can substitute $|x|$ by $x$ in the second and third conditions and arrive at the definition of $g(x)$ that is :
$$g(x) = \begin{cases} -x-1+1, & -2 \leq x \leq 0 \\ x-1+1-x, & 0 < x < 1 \\ x-1+x-1, & 1 \leq x \leq 2 \end{cases} = \begin{cases} -x, & -2 \leq x \leq 0 \\ 0, & 0 < x < 1 \\ 2x-2, & 1 \leq x \leq 2 \end{cases}$$
Now, I want to know if this process is correct and if there is some alternative, better approach to this problem.
Sorry for the long post, I thought that showing my line of reasoning would make the question better.
Thanks





Your final answer appears to be correct (though I have not checked all the steps of your reasoning), however you may try to apply symmetry by dividing into three cases: $x=0$, $-2\leq x<0$, and $0<x\leq 2$. Then it would be easy to see how to get $g(x)$, since $|x|$ for $x$ in the second case implies $|x|$ belongs to the third case. The rest is left to you.