34
$\begingroup$

Show that the $\max{ \{ x,y \} }= \dfrac{x+y+|x-y|}{2}$.

I do not understand how to go about completing this problem or even where to start.

$\endgroup$
6
  • 21
    $\begingroup$ It may help to note that $|x| = \max(x,-x)$. $\endgroup$
    – copper.hat
    Jun 26, 2013 at 3:09
  • 4
    $\begingroup$ I would start by convincing yourself that the proof is meaningful with several concrete examples. Set x=1, y=-3, for example, and try to get an intuition that it's true (before you try to prove why it's true). Then many of the comments above should be helpful. $\endgroup$
    – Dave B.
    Jun 26, 2013 at 4:23
  • 4
    $\begingroup$ Just do a case-by-case analysis: Evaluate both sides once for the case $x\leq y$ and once for $y\leq x$. $\endgroup$ Jun 26, 2013 at 6:23
  • $\begingroup$ possible duplicate of Proof the maximum function $\max(x,y) = \frac {x +y +|x-y|} {2}$ $\endgroup$
    – user53259
    Mar 7, 2014 at 13:43
  • 6
    $\begingroup$ @TuckerRapu: IIRC, here and in a couple of other places you've marked an older question as a duplicate of a newer question. $\endgroup$ Mar 7, 2014 at 14:52

7 Answers 7

61
$\begingroup$

Here is another way of looking at it:

We have $|x| = \max(x,-x)$. Also, $\max(a,b)+c = \max(a+c,b+c)$, and if $c \geq 0$, then $c \max(a,b) = \max(ac,bc)$.

Hence \begin{eqnarray} \frac{1}{2}(x+y+|x-y|) &=& \frac{1}{2}(x+y+\max(x-y,y-x)) \\ &=& \frac{1}{2}(\max(x-y+x+y,y-x+x+y)) \\ &=& \frac{1}{2}(\max(2x,2y)) \\ &=& \max(x,y) \end{eqnarray}

$\endgroup$
6
  • $\begingroup$ +1 it would be nice, if you noted the $\text{min}(x,y)$ for the OP as well. :) $\endgroup$
    – Mikasa
    Jun 26, 2013 at 5:00
  • 2
    $\begingroup$ @BabakS.: Thanks! The $\min$ result follows immediately from $\max(x,y)+\min(x,y) = x+y$. $\endgroup$
    – copper.hat
    Jun 26, 2013 at 5:40
  • 2
    $\begingroup$ Great! This should be accepted! $\endgroup$ Jun 26, 2013 at 12:57
  • $\begingroup$ on the first line why is it max(x-y,y-x) and not max(x-y,-x-y)? $\endgroup$
    – AGarza
    Oct 21, 2021 at 0:27
  • 1
    $\begingroup$ @AGarza Because $|z|=\max(z,-z)$. Now let $z=x-y$. $\endgroup$
    – copper.hat
    Oct 21, 2021 at 0:32
38
$\begingroup$

This probably isn't as rigorous as it should be, but I think it's intuitive enough.

Hmm... We don't know which of $x$ or $y$ is bigger, but we do know one thing: their average. If we call the average $z$, then $z=\frac{x+y}{2}$. Now, the distance between $x$ and $y$ is $|x-y|$, so the distance from $z$ to both $x$ and $y$ is $\frac{|x-y|}{2}$.

So if we imagine a number line, the distance from $0$ to $z$ is $\frac{x+y}{2}$, and the distance from $z$ to max(x, y) is $\frac{|x-y|}{2}$. Thus, the total distance from $0$ to max(x, y) is $\frac{|x-y|}{2}$ + $\frac{x+y}{2}$, as desired.

$\endgroup$
1
  • 2
    $\begingroup$ I like this answer. If not as rigorous, this is exactly how one would come up with the expression in the first place. Also, one can easily come up with similar expression for $\operatorname{min}$ in this manner. $\endgroup$
    – Ennar
    Oct 3, 2015 at 19:23
30
$\begingroup$

Hint: If $x\ge y$ then $|x-y|=x-y$. If $x\lt y$ then $|x-y|=-(x-y)=y-x$.

We have used the fact that in general $|w|=w$ if $w\ge 0$ and $|w|=-w$ if $w\lt 0$.

$\endgroup$
2
  • 4
    $\begingroup$ +1 This is the most straightforward one here. Also @user71925 it should also be noted that $\min\{x,y\} = \frac{1}{2}(x+y-|x-y|)$. $\endgroup$
    – chs21259
    May 20, 2014 at 18:40
  • $\begingroup$ I think I mistakenly hit the downvote button here but it won't let me undo it. My apologies, entirely unintended. $\endgroup$
    – copper.hat
    Oct 19 at 13:25
4
$\begingroup$

$$ \max\{x,y\} =\frac{x+y+|x-y|}{2} $$ $$ => 2.\max\{x,y\} =x+y+|x-y| $$ there are two possible situation :
1. $ y>x $, i.e $\max\{x,y\}=y$ then $y-x=|x-y|$, this equation is true because we assume that
$ y>x$
2. $x>y$, or $\max\{x,y\}=x$, then $x-y=|x-y|$, which is true if $x>y$

$\endgroup$
0
1
$\begingroup$

Conceptually, focus on $|x-y|$ as the absolute difference of the two numbers.

Without loss of generality, assume $x > y$. Then $y + |x - y| = x$. This can be understood as representing that if we add the difference between two numbers to the smaller, we get the larger.

The specific equation will naturally fall out with this observation.

$\endgroup$
0
$\begingroup$

Without loss of generality, let $y=x+k$ for some nonnegative number $k$. Then,

$$ \frac{x+(x+k)+|x-(x+k)|}{2} = \frac{2x+2k}{2} = x+k = y $$

which is equal to $\max(x,y)$ by the assumption.

$\endgroup$
0
$\begingroup$

For another approach we can do as follows:

$$max(x, y) - max(-x, -y) = x + y$$ and, $$max(x, y) + max(-x, -y) = |x - y|$$

Adding those together yeilds: $$2\times max(x, y) = x + y + |x - y|$$ Dividing by two, gives us what we want.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .