# Prove $|x|=\max\{x,-x\}$

first time poster here, so please excuse my noobiness

I'm going through some basic first year college math exercises, because i found out i still can't do some of the proofs, and I've encountered this

the absolute value of x is defined as

$$|x|=\begin{cases}x& \text{ if } x\geq 0\\ -x& \text{ if } x< 0 \end{cases}$$

prove that $|x|=\max\{x,-x\}$

i honestly have no idea on what is required from me/how should i start

can someone please help me out with a hint, or just something what would get me on the right track? thx

• Break it into two cases. Case 1: $x\geq 0$. Case 2: $x<0$. In each case, show that both definitions agree. – JMoravitz Jul 11 '16 at 18:51
• i think i still don't understand completely. Should i show that 1)$|x|\leq x$ and 2) $|x|\leq -x$ ? – strangeattractor Jul 11 '16 at 19:05
• When $x> 0$ which is bigger? $x$ or $-x$? What then is $max\{x,-x\}$? What is $|x|$ in that case? Ask the same questions in the case $x <0$. Remember that negative times negative is positive and positive is always bigger than negative. Also remember $-x=-1\cdot x$. Did the expressions agree in both cases? – JMoravitz Jul 11 '16 at 19:20
• so the way i think about it now is x=0 then |0| = max{0,0} so 0 = 0. x=1 then 1=max{1,-1}=1 x=-1 and so on. But i still cant figure out how to prove it in general – strangeattractor Jul 11 '16 at 19:21

## 4 Answers

Welp, when asked do...

$|x|$ is defined conditionally on whether $x \ge 0$ or not. So we prove it as such.

If $x \ge 0$ then $-x \le 0$ and $x \ge -x$. So $\max(x,-x) = x = |x|$.

If $x < 0$ then $-x > 0$ and $-x > x$. So $\max(x,-x) = -x = |x|$. QED.

Alternatively we could do:

$\max(x,-x) = \begin{cases}x& \text{ if } x\geq -x \iff x \ge 0\\ -x& \text{ if } x < - x \iff x< 0 \end{cases}$ which is the exact same definition as $|x|$.

===

A third way is to note $x = \pm |x|$ (plus if $x \ge 0$; minus if $x < 0$) and $-x = \mp|x|$ (vice versa). $|x| \ge 0 \ge -|x|$ so $\max(x,-x) = \max(|x|, - |x|) = |x|$.

There's so many ways to do it. Basically the definitions are equivalent.

===

Basically both absolute value and max(x,-x) are both conditional identities of the form: $f(x) = x$ if $x$ is "nice". $f(x) = -x$ otherwise. For $|x|$, "nice" means $x \ge 0$. For $\max(x,-x)$, "nice" means $x \ge -x$. As $x \ge 0 \iff x \ge -x$ these are both the same thing.

• oh. so this is all that is required? I seriously thought that it was a lot more comlex than this lol. I guess that's why i was having trouble with it. I guess that after a year of solving fancy integrals and magic with infinite sums, you sometimes forget the basics :D THX – strangeattractor Jul 11 '16 at 19:47
• max and || are both conditional definitions. So to prove this statement is to show they coincide in the same conditions. These are basically both identities: f(x) = x if x is nice, and f(x) = -x if x isn't nice. For |x| "nice" means x ge 0. for max "nice" means x ge -x. As x ge 0 iff x ge -x these are the same. – fleablood Jul 11 '16 at 19:55
• You could say $x=\text{sgn}(x)|x|$. – Simply Beautiful Art Jul 11 '16 at 20:28
• @SimpleArt or |x| = sgn(x)x (a bit more subtle as neg x neg = pos). As pos > neg, |x| $\ge$ -|x| so |x| = max(|x|, -|x|) = max(x, - x). .... 's all good, man. – fleablood Jul 11 '16 at 20:53

First, note that if $x = 0$, them $x = -x$, and so the result is obtained by direct computation. Now, examine the case $x \neq 0$ by separating it into two subcases: (1) $x > 0$ and (2) $x < 0$. If still having difficulty, first try to see if your result holds for specific values of $x$, e.g. $x = 1$ or $x = -2$.

• i think that my problem is that i don't know where should i ''plug in'' those specific values – strangeattractor Jul 11 '16 at 19:11
• Plug a value in for every occurrence of $x$. For example, if $x = -2$, then $|x|$ becomes $|-2|$, and $\{x, -x\}$ becomes $\{ -2, - (-2) \}$. By the way the inequalities you asked about in a comment above are generally incorrect; e.g., $|x| \leq -x$ is false. You can see that by trying $x = -1$. But, there are correct inequalities one can write down. – avs Jul 11 '16 at 19:22
• oh yeah lol that was a typo. I just realized it a bit too late – strangeattractor Jul 11 '16 at 19:32
• Actually, I made a typo myself: I meant trying $x=1$. Anyway, does my last preceding comment address what you were asking? – avs Jul 11 '16 at 19:57
• oh yes of course i think i understand what needed to be done. I basically have a two element set consisting of a real number and its inverse. and i split it into two cases (x>=0 & x<0) and in each case i pick the greater one (according to the definition of max{S} where S is a set) and when i write those two cases simultaneously i'm basically writing down the definition of the absolute value. does that makes sense? – strangeattractor Jul 11 '16 at 20:10

Separate into two cases:

If $x \ge 0$, then $\max (x, -x) = x = |x|$.

If $x < 0$, then $\max(x,\, -x) = -x = |x|$.

Thus in either case we have $\max(x, \, -x) = |x|$.

Alternative Method:
Assuming that one is familiar with the formula, $$\max\{ a,b \}=\dfrac{a+b+|a-b|}{2}.$$ Then it becomes trivial to check that $\max\{x,-x\}$ simplifies to $|x|$.