0
$\begingroup$

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$.

  1. $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{.}$$

  1. $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?

$\endgroup$
  • 3
    $\begingroup$ If $x, y > 0$ then $||x| - |y|| = |x - y|$, but this is $x - y$ or $y - x$, depending on whether $x$ or $y$ is larger. $\endgroup$ – Travis Oct 7 '15 at 18:18
  • $\begingroup$ @Travis and concerning the second point on my list? Do values of |x| and |y| affect the value in determining ||x| - |y||? $\endgroup$ – Accelerate to the Infinity Oct 7 '15 at 18:21
  • $\begingroup$ @Travis thank you, I guess I got it. $\endgroup$ – Accelerate to the Infinity Oct 7 '15 at 18:27
  • 1
    $\begingroup$ You're welcome, I hope you found my comment useful. $\endgroup$ – Travis Oct 7 '15 at 18:41
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.