Is there an idea that resolves nested value expressions into several separate expressions each using a single absolute value? Something similar like resolving the max function using the absolute value.
More concretely, I am looking for a way to rewrite the expression $$||x-y|-z|$$ in a way that does not use expressions of nested absolutes.
I already did a case study, and this is what I've got so far
- For $x<y$ and $(y-x) < z$, we have: $||x-y|-z| = x - y + z$
- For $x<y$ and $(y-x) > z$, we have: $||x-y|-z| = -x + y - z$
- For $x>y$ and $(x-y) < z$, we have: $||x-y|-z| = -x + y + z$
- For $x>y$ and $(x-y) > z$, we have: $||x-y|-z| = x - y - z$
But I can't seem to find a pattern to rewrite it.
If it helps, we can assume that all variables $x$, $y$ and $z$ are non-negative.