I have an absolute value term in equation, which looks like this $$||x| - |y||\text{.}$$
If I remember correct, this term will have 4 variations, depending on values of $x$ and $y$.
- $x > 0\wedge y > 0$
In this case $|x| = x$ and $|y| = y$. Because both of them are positive, the term will look like $$x - y\text{.}$$
- $x > 0 \wedge y < 0$ In this case $|x| = x$ and $|y| = -y$. Because one of them is positive and one negative, the term will look like $$-(x + y) = -x - y\text{.}$$
And so on.
I am doing this right?
There's eight possible cases but four outcomes.
Case 1: x and y both non-negative; x >= y: ||x| - |y|| = |x - y| = x - y
Case 1a: x, y both non-negative; y< x:||x| - |y|| = |x - y| = y - x
Case 2: x< 0; y non-negative; y <= |x|:||x| - |y|| = ||x| - y| = |x| - y = -x - y
Case 2a: x< 0; y non-negative; y > |x|:||x| - |y|| = ||x| - y| = y - |x| = y + x
Case 3: x non-negative: y < 0; |y| <= x: ||x| - |y|| = |x - |y|| = x - |y| = x + y
Case 3a: x non-negative; y < 0; |y| > x:||x| - |y|| = |x - |y|| = |y| - x = -y - x
Case 4: x<0; y<0: x <= y: ||x| - |y|| = |y - x| = y - x
Case 4a: x<0; y<0: x > y: ||x| - |y|| = |y - x| = x - y
===
In other words:
It's $x - y$ or $y - x$ if both are the same sign. It's $x - y$ if x>= y and $y-x$ if y< x.
It's $x + y$ or $-x - y$ if they are different signs.