# Thread: Simplifying an expression containing absolute values

1. ## Simplifying an expression containing absolute values

Hi all,

I've been told that the expression $| (|a+b| - |a| - |b|) |$ can be simplified by removing at least one pair of absolute value signs. So, first of all I simplified the expression down by looking at the four different cases, which are:

a > 0, b > 0: The expression evaluates to zero
a < 0, b < 0: The expression evaluates to zero
a < 0, b > 0, a+b > 0: Simplified to -2a
a < 0, b > 0, a+b < 0: Simplified to 2b
(There are two other cases which are just the same as the third and fourth with the variables swapped. I have ignored these)

Now, I have to start removing different combinations of abs signs and see which ones simplify to the same expressions for each case. However, I count at least 15 different combinations to evaluate. They are:

|a+b|-|a|-|b|
|a+b|-a-|b|
|a+b|-|a|-b
|a+b|-a-b
a+b-|a|-|b|
a+b-a-|b|
a+b-|a|-b
a+b-a-b
||a+b|-a-|b||
||a+b|-|a|-b|
||a+b|-a-b|
|a+b-|a|-|b||
|a+b-a-|b||
|a+b-|a|-b|
|a+b-a-b|

This means checking every one of these 15 variations for all four cases, which is 60 cases!

So, the question is, is there a better, faster way of doing this? Or do I have really have to just work through these cases and see which ones are equivalent?

2. ## No

The simple answer is no.
If a>0, b>0 or a<0, b<0, the equation will always equate to 0, no matter how you put the absolute signs.

Also, note that for all a and b, |a+b| $\leqslant$ |a| + |b| (the Triangle Inequality)
So |a+b| - |a| - |b| $\leqslant$ 0
So you have to keep the outer absolute signs.

That should leave 12 cases.

3. Im not familiar with the results above, so sorry if this is a mistake.

can we note that
$a + b \leq |a + b|$

using this with the result in the previous post:
$|a + b| - |a| - |b| \leq 0 \Rightarrow a + b - |a| - |b| \leq 0$

and hence
$|(|a + b| - |a| - |b|)| = |(a + b - |a| - |b| \leq 0 )|$

Just my thinking, no promise of accuracy!

4. Afraid not.

Set a = 0, b = -1
|( |0-1| - |0| - |-1| )| = 0
|( 0 - 1 - |0| - |-1| )| = -2

To be honest, I doubt a solution exists.
I may be wrong, but consider this;

Let a = -b.
Then the equation simplifies to |a| + |b|
Now, we cannot remove either of the absolute signs, as we don't know which of a or b is negative.
The counter-example above shows you need |a+b|, and I've already shown you need the outermost signs.
So you seem to need all of the absolute signs present in the original.

5. $||a+b| - |a| - |b|| = |(|a+b| - |a| - |b|)*-1 | = |(|a| + |b| - |a+b|) |$

the stuff in brackets is always non-negative (from mert's inequality)

$= |a| + |b| - |a+b|$

again, just my thinking. probably wrong!

6. Originally Posted by SpringFan25
$= |a| + |b| - |a+b|$
I was wondering the same thing. This problem reminded me of something from real analysis, which I haven't done in over two years! I don't remember one being able to just drop brackets, and I checked using R to simulate some positive negative values (two for loops for a and b ranging over -5 to 5 each). I did just about every combination and did not see any way to drop off brackets that worked out in an equality. From my memory of analysis, we could do operations, like you did or by adding and subtracting 1 (i.e., 1 of some other form like +x - x, whatever x we choose). Clearly, though, your move is right:

$||a+b| - |a| - |b|| = |a| + |b| - |a+b|$

To see this, just look at some of the instances in the range I mentioned, where the 3rd column is the left-hand side and the 4th column is the right-hand side:

Code:
g = function(x, y) abs(abs(x + y) - abs(x) - abs(y))
h = function(x, y) abs(x) + abs(y) - abs(x+y)
for(x in -5:5) for(y in -5:5) print(c(x, y, g(x,y), h(x,y)))
[1] -5 -5  0  0
[1] -5 -4  0  0
[1] -5 -3  0  0
[1] -5 -2  0  0
[1] -5 -1  0  0
[1] -5  0  0  0
[1] -5  1  2  2
[1] -5  2  4  4
[1] -5  3  6  6
[1] -5  4  8  8
[1] -5  5 10 10
[1] -4 -5  0  0
[1] -4 -4  0  0
[1] -4 -3  0  0
[1] -4 -2  0  0
[1] -4 -1  0  0
[1] -4  0  0  0
[1] -4  1  2  2
[1] -4  2  4  4
[1] -4  3  6  6
[1] -4  4  8  8
[1] -4  5  8  8
[1] -3 -5  0  0
[1] -3 -4  0  0
[1] -3 -3  0  0
[1] -3 -2  0  0
[1] -3 -1  0  0
[1] -3  0  0  0
[1] -3  1  2  2
[1] -3  2  4  4
[1] -3  3  6  6
[1] -3  4  6  6
[1] -3  5  6  6
[1] -2 -5  0  0
[1] -2 -4  0  0
[1] -2 -3  0  0
[1] -2 -2  0  0
[1] -2 -1  0  0
[1] -2  0  0  0
[1] -2  1  2  2
[1] -2  2  4  4
[1] -2  3  4  4
[1] -2  4  4  4
[1] -2  5  4  4
[1] -1 -5  0  0
[1] -1 -4  0  0
[1] -1 -3  0  0
[1] -1 -2  0  0
[1] -1 -1  0  0
[1] -1  0  0  0
[1] -1  1  2  2
[1] -1  2  2  2
[1] -1  3  2  2
[1] -1  4  2  2
[1] -1  5  2  2
[1]  0 -5  0  0
[1]  0 -4  0  0
[1]  0 -3  0  0
[1]  0 -2  0  0
[1]  0 -1  0  0
[1] 0 0 0 0
[1] 0 1 0 0
[1] 0 2 0 0
[1] 0 3 0 0
[1] 0 4 0 0
[1] 0 5 0 0
[1]  1 -5  2  2
[1]  1 -4  2  2
[1]  1 -3  2  2
[1]  1 -2  2  2
[1]  1 -1  2  2
[1] 1 0 0 0
[1] 1 1 0 0
[1] 1 2 0 0
[1] 1 3 0 0
[1] 1 4 0 0
[1] 1 5 0 0
[1]  2 -5  4  4
[1]  2 -4  4  4
[1]  2 -3  4  4
[1]  2 -2  4  4
[1]  2 -1  2  2
[1] 2 0 0 0
[1] 2 1 0 0
[1] 2 2 0 0
[1] 2 3 0 0
[1] 2 4 0 0
[1] 2 5 0 0
[1]  3 -5  6  6
[1]  3 -4  6  6
[1]  3 -3  6  6
[1]  3 -2  4  4
[1]  3 -1  2  2
[1] 3 0 0 0
[1] 3 1 0 0
[1] 3 2 0 0
[1] 3 3 0 0
[1] 3 4 0 0
[1] 3 5 0 0
[1]  4 -5  8  8
[1]  4 -4  8  8
[1]  4 -3  6  6
[1]  4 -2  4  4
[1]  4 -1  2  2
[1] 4 0 0 0
[1] 4 1 0 0
[1] 4 2 0 0
[1] 4 3 0 0
[1] 4 4 0 0
[1] 4 5 0 0
[1]  5 -5 10 10
[1]  5 -4  8  8
[1]  5 -3  6  6
[1]  5 -2  4  4
[1]  5 -1  2  2
[1] 5 0 0 0
[1] 5 1 0 0
[1] 5 2 0 0
[1] 5 3 0 0
[1] 5 4 0 0
[1] 5 5 0 0

7. I believe the only solution is: | |a+b| - |a| - |b| | = | |a+b| - |a| - b |.

Based on mert's contribution, I threw away the a > b > 0 and the a < b < 0 cases, as they always evaluate to zero. I then threw away the top 8 combinations, as you definitely need the outermost abs signs. This left me with 14 tests: 7 combinations x 2 cases

||a+b|-a-|b||
||a+b|-|a|-b|
||a+b|-a-b|
|a+b-|a|-|b||
|a+b-a-|b||
|a+b-|a|-b|
|a+b-a-b|

We can immediately discard the seventh expression, as this just evaluates to zero.

I tested the first one, and found that it evaluated to zero if a+b > 0, when it should evaluate to -2a. Discarded it.

The second one does work, because it evaluates to -2a when a+b>0, and to 2b when a+b<0. So there is at least one solution.

Given this, I discarded all other cases where the single b term was contained in abs signs, to see if it was possible to remove more. This left me with only the third and sixth expressions. The third case evaluates to zero when a+b>0, so it gets discarded.

The sixth expression only has one test, since we have removed the signs around a+b and therefore do not need to to test when a+b>0 and a+b<0. It evaluates to -2a, which is not a solution since it should evaluate to 2b when a+b<0

Have I got this correct? Or is there an error in my working?

8. Your first statement is false.

$||a+b| - |a| - |b|| \neq ||a+b| - |a| - b|$

For some examples of values (from R):

Code:
f = function(x, y) abs(abs(x + y) - abs(x) - abs(y))  ## ||a+b| - |a| - |b||
g = function(x, y) abs(abs(x+y) - abs(x) - y)         ## ||a+b| - |a| -  b |
for(x in -2:2) for(y in -2:2) print(c(x, y, f(x,y), g(x,y)))
#    a  b  f  g
[1] -2 -2  0  4
[1] -2 -1  0  2
[1] -2  0  0  0
[1] -2  1  2  2
[1] -2  2  4  4
[1] -1 -2  0  4
[1] -1 -1  0  2
[1] -1  0  0  0
[1] -1  1  2  2
[1] -1  2  2  2
[1]  0 -2  0  4
[1]  0 -1  0  2
[1] 0 0 0 0
[1] 0 1 0 0
[1] 0 2 0 0
[1]  1 -2  2  2
[1]  1 -1  2  0
[1] 1 0 0 0
[1] 1 1 0 0
[1] 1 2 0 0
[1]  2 -2  4  0
[1]  2 -1  2  0
[1] 2 0 0 0
[1] 2 1 0 0
[1] 2 2 0 0

9. Hmm, I guess I should have checked it with real numbers...

Well, I must say I am more confused now than when I first started. Does anybody have the answer manual to Michael Spivak's Calculus? I have borrowed this from the library, and cannot afford to buy the answer manual. I would be interested to know if this question has been solved in the answers manual.

10. OK, I'm going to work through this completely, so that hopefully someone can point out any logical fallacies in my work.

The expression $||a+b| - |a| - |b||$ can be evaluated by considering six cases:

Case 1: When $a, b \geqslant 0$
Case 2: When $a, b < 0$
Case 3: When $a < 0, b \geqslant 0, a+b \geqslant 0$
Case 4: When $a < 0, b \geqslant 0, a+b < 0$
Case 5: When $b < 0, a \geqslant 0, a+b \geqslant 0$
Case 6: When $b < 0, a \geqslant 0, a+b < 0$

Of these six cases, we can ignore the fifth and sixth, since they are effectively the same as the third and fourth, with the variables a and b swapped around.

So for the first four cases, I simplify the expression:

CASE 1:
$||a+b| - |a| - |b|| = |a + b - a - b| = 0$

CASE 2:
$||a+b| - |a| - |b|| = |-(a + b) + a + b| = |-a - b + a + b| = 0$

CASE 3:
$||a+b| - |a| - |b|| = |a + b + a - b| = |2a| = -2a$

CASE 4:
$||a+b| - |a| - |b|| = |-(a + b) + a - b| = |-a -b +a -b| = |-2b| = 2b$

Now, I consider each case where I remove one or more abs signs, and check that they evaluate for each of the four cases the same as they do above

There are a total of 15 combinations, but as has been pointed out, $|a + b| \leqslant |a| + |b|$, so $|a+b| - |a| - |b| \leqslant 0$. Because the expression between the outermost abs signs is always negative or zero, it is essential to retain the outermost abs signs. This reduces the number of combinations to seven.

Of the remaining combinations, the expression $|a + b - a - b|$ is obviously invalid, because it is always zero for all a, b. So we discard it.

The remaining candidates that may be equivalent to the original expression are:

Candidate 1: $||a+b|-a-|b||$
Candidate 2: $||a+b|-|a|-b|$
Candidate 3: $||a+b|-a-b|$
Candidate 4: $|a+b-|a|-|b||$
Candidate 5: $|a+b-a-|b||$
Candidate 6: $|a+b-|a|-b|$

Candidate 1, Case 1:
$||a+b| - a - |b|| = |a + b - a - b| = 0$ (Valid)

Candidate 1, Case 2:
$||a+b| - a - |b|| = |-(a + b) - a + b| = |-a - b - a + b| = |-2a| = -2a$ (Invalid, so we can discard this candidate).

Candidate 2, Case 1:
$||a+b| - |a| - b| = |a + b - a - b| = 0$ (Valid)

Candidate 2, Case 2:
$||a+b| - |a| - b| = |-(a + b) + a - b| = |-a - b + a - b| = |-2b| = -2b$ (Invalid, should be zero, so we can discard)

Candidate 3, Case 1:
$||a+b|-a-b| = |a + b - a - b| = 0$ (Valid)

Candidate 3, Case 2:
$||a+b|-a-b| = |-(a + b) - a - b| = |-a - b - a - b| = |-2a - 2b| = -(2a + 2b) or (2a + 2b)$ (Invalid, so we discard)

Candidate 4, Case 1:
$|a+b-|a|-|b|| = |a + b - a - b| = 0$ (Valid)

Candidate 4, Case 2:
$|a+b-|a|-|b|| = |a + b + a + b| = |2a + 2b| = -(2a + 2b)$ (Invalid, so discard)

Candidate 5, Case 1:
$|a+b-a-|b|| = |a + b - a - b| = 0$ (Valid)

Candidate 5, Case 2:
$|a+b-a-|b|| = |a + b - a + b| = |2b| = -2b$ (Invalid, so discard)

Candidate 6, Case 1:
$|a+b-|a|-b| = |a + b - a - b| = 0$ (Valid)

Candidate 6, Case 2:
$|a+b-|a|-b| = |a + b + a - b| = |2a| = -2a$ (Invalid)

So according to my working, there are no valid cases. I can only conclude that my understanding of what the author is asking is flawed, or that this is an error in the book. The second possibility seems unlikely, as the original edition was written in the 60's, I'm sure this would have been corrected by now.

The exact wording of the problem is: "Express each of the following with at least one less pair of absolute value signs", with this problem being the second of five problems (M. Spivak, Calculus, 2006, Ch 1, Problem 9(ii)). I guess it doesn't explicitly state that you cannot rearrange the expression, but to me it's an ambiguous question.

Anyway, I have spent enough time on this, and I assume that we are able to rearrange the expression, as long as there is only three or less pairs of abs signs, so perhaps SpringFan25's solution is the one the author is looking for?

Thanks all for you help.

11. Ugh. That's a lot of cases haha. I'll check it later. I will say, though, if you notice from my output that whenever sign(a) = sign(b) the result is 0. You might want to prove that algebraically, though. I believe this holds true in every manipulation of the absolute values that you do. Therefore, a quick check for counter examples will be to try each of the possible manipulations with differing positive and negative values. I did that in my simulation (not shown) and most of the cases didn't work, but I didn't record which ones I tried. I may have tried them all. I don't think you can just remove absolute signs and get an equivalent statement.

12. Okay. I can't help myself. None of them work. Just check out this script. I'll explain it below.

Code:
f  = function(a,b) abs(abs(a+b) - abs(a) - abs(b)) ## ||a+b| - |a| - |b||
f1 = function(a,b) abs(abs(a+b) - a - abs(b))      ## ||a+b| -  a  - |b||
f2 = function(a,b) abs(abs(a+b) - abs(a) - b)      ## ||a+b| - |a| -  b |
f3 = function(a,b) abs(abs(a+b) - a - b)           ## ||a+b| -  a  -  b |
g  = function(a,b) abs(a+b - abs(a) - abs(b))      ## | a+b  - |a| - |b||
g1 = function(a,b) abs(a+b - a - abs(b))           ## | a+b  -  a  - |b||
g2 = function(a,b) abs(a+b - abs(a) - b)           ## | a+b  - |a| -  b |
g3 = function(a,b) abs(a+b - a - b)                ## | a+b  -  a  -  b |
h  = function(a,b) abs(a+b) - abs(a) - abs(b)      ##  |a+b| - |a| - |b|
h1 = function(a,b) abs(a+b) - a - abs(b)           ##  |a+b| -  a  - |b|
h2 = function(a,b) abs(a+b) - abs(a) - b           ##  |a+b| - |a| -  b
h3 = function(a,b) abs(a+b) - a - b                ##  |a+b| -  a  -  b
j  = function(a,b) a+b - abs(a) - abs(b)           ##   a+b  - |a| - |b|
j1 = function(a,b) a+b - a - abs(b)                ##   a+b  -  a  - |b|
j2 = function(a,b) a+b - abs(a) - b                ##   a+b  - |a| -  b
j3 = function(a,b) a+b - a - b                     ##   a+b  -  a  -  b
P  = function(a,b) {
c(f(a,b), f1(a,b), f2(a,b), f3(a,b),
g(a,b), g1(a,b), g2(a,b), g3(a,b),
h(a,b), h1(a,b), h2(a,b), h3(a,b),
j(a,b), j1(a,b), j2(a,b), j3(a,b))
} ## end P-print function
x <- data.frame(matrix(nrow = 25, ncol = 18))
i <- 1
for(a in -2:2) for(b in -2:2) {x[i, ] <- c(a, b, P(a,b)); i = i+1}
as.numeric( apply(x[-c(1:3)], 2, function(col) all(col == x[[3]])) )
## The output is 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Basically I defined a bunch of functions. See the commented portion to the right that explains them notationally. I believe I exhausted all the cases, no? It should be:

$_4C_2\ \times\ _3C_2\ \times\ _2C_2 = 18$

Those being "choose" functions. There are 18 cases as shown. I then define a "wrapper" function 'P' that concatenates them into a vector given the input. I then do a couple 'for' loops for ranges of inputs (-2 to 2 is sufficient). This gives 25 cases (rows). I store those into a data frame (a type of R object for storing data). I then use a built-in looping type function "apply" that with index "2" it performs the defined function on each column (excluded the first three). I take each column and compare it to the first function 'f' which is the one of interest. I use the "all" function that is true if the vector of logical values comes out all true. I wrap the return value in "as.numeric" to convert it to binary (0 = false; 1 = true). As indicated, the output was all 0. None of the outputs exactly match the function of interest (= 'f'). If you want check for yourself, see the output below. The first two columns are 'a' and 'b', respectively. The rest are the functions in order defined in 'P'.

Spoiler:
Code:
   X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18
1  -2 -2  0  4  4  8  8  4  4   0   0   4   4   8  -8  -4  -4   0
2  -2 -1  0  4  2  6  6  2  4   0   0   4   2   6  -6  -2  -4   0
3  -2  0  0  4  0  4  4  0  4   0   0   4   0   4  -4   0  -4   0
4  -2  1  2  2  2  2  4  0  4   0  -2   2  -2   2  -4   0  -4   0
5  -2  2  4  0  4  0  4  0  4   0  -4   0  -4   0  -4   0  -4   0
6  -1 -2  0  2  4  6  6  4  2   0   0   2   4   6  -6  -4  -2   0
7  -1 -1  0  2  2  4  4  2  2   0   0   2   2   4  -4  -2  -2   0
8  -1  0  0  2  0  2  2  0  2   0   0   2   0   2  -2   0  -2   0
9  -1  1  2  0  2  0  2  0  2   0  -2   0  -2   0  -2   0  -2   0
10 -1  2  2  0  2  0  2  0  2   0  -2   0  -2   0  -2   0  -2   0
11  0 -2  0  0  4  4  4  4  0   0   0   0   4   4  -4  -4   0   0
12  0 -1  0  0  2  2  2  2  0   0   0   0   2   2  -2  -2   0   0
13  0  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
14  0  1  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
15  0  2  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
16  1 -2  2  2  2  2  4  4  0   0  -2  -2   2   2  -4  -4   0   0
17  1 -1  2  2  0  0  2  2  0   0  -2  -2   0   0  -2  -2   0   0
18  1  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
19  1  1  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
20  1  2  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
21  2 -2  4  4  0  0  4  4  0   0  -4  -4   0   0  -4  -4   0   0
22  2 -1  2  2  0  0  2  2  0   0  -2  -2   0   0  -2  -2   0   0
23  2  0  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
24  2  1  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0
25  2  2  0  0  0  0  0  0  0   0   0   0   0   0   0   0   0   0

You'll notice, though, that $h = -f$ (X11 and X3, respectively).

Edit: You would be surprised. I've seen old books with new editions that keep glaring errors sometimes. Nevertheless, I think the author just worded the question very poorly. It should have asked for something like "rearrange the following expressions so they contain one less absolute value," or something to that effect. In that case, as is the case in my real analysis text book (when covering the triangle inequality), the answer provided earlier appears to be what is of interest. And trust me, it does show up sometimes in your proofs.