Most efficient way to find the "solution intervals" / "case conditions"? (problem regarding a function with absolute value notation): I am trying to write the function $f(x) = |x^2-1|+|x|-1$ without the notation for the absolute value. "||"
It makes logical sense to consider four cases, because each term in the absolute value notation can either be positive or negative.
Therefore, we get:

*

*Case 1 (positive, positive):  $f(x) = x^2-1+x-1 = (x-1)(x+2)$

*Case 2 (positive, negative):  $f(x) = x^2-1-x-1 = (x+1)(x-2)$

*Case 3 (negative, positive):  $f(x) = -x^2+1+x-1 = -x(x-1)$

*Case 4 (negative, negative):  $f(x) = -x^2+1-x-1 = -x(x+1)$
To use the piecewise function notation, I need the intervals for which each term is correct.
$$
  f(x) = \cases{        term       & $condition\ $ \cr
                 term       & $condition\ $ \cr
                        term       & $condition\ $ \cr
term       & $condition\ $ \cr}
$$
What is the most efficient way to find the case conditions (in this particular example, and generally speaking)?
(I have tried putting the term of each case equal to zero to find the roots. However, doing this, I get $5$ roots. Our expression is of order $3$, therefore something has to be wrong/I overlooked something while trying this.)
I am thankful for any input/ideas! Thank you!
 A: Since the terms inside the absolute value bars are continuous, they can only change sign where they are equal to zero.  Since $x^2 - 1 = 0$ when $x = 1$ or $x = -1$ and $x = 0$ when $x = 0$, you should consider the behavior of $f$ in the intervals $(-\infty, -1)$, $[-1, 0)$, $[0, 1)$, and $[1, \infty)$.
If $x \geq 1$, then $|x^2 - 1| = x^2 - 1$ and $|x| = x$.
If $0 \leq x < 1$, then $|x^2 - 1| = -x^2 + 1$ and $|x| = x$.
If $-1 \leq x < 0$, then $|x^2 - 1| = -x^2 + 1$ and $|x| = -x$.
If $x < -1$, then $|x^2 - 1| = x^2 - 1$ and $|x| = -x$.
Hence,
\begin{align*}
f(x) & = |x^2 - 1| + |x| - 1\\
     & = \begin{cases} 
         x^2 - 1 - x - 1 & \text{if $x < -1$}\\
         -x^2 + 1 - x - 1 & \text{if $-1 \leq x < 0$}\\
         -x^2 + 1 + x - 1 & \text{if $0 \leq x < 1$}\\
         x^2 - 1 + x - 1 & \text{if $x \geq 1$}\\
         \end{cases}\\
     & = \begin{cases} 
         x^2 - x - 2 & \text{if $x < -1$}\\
         -x^2 - x & \text{if $-1 \leq x < 0$}\\
         -x^2 + x & \text{if $0 \leq x < 1$}\\
         x^2 + x - 2 & \text{if $x \geq 1$}\\
         \end{cases}
\end{align*}
