10

I want to derive (not prove that this is true) the formula

$\max (x,y) = \dfrac{x + y + |y-x|}{2}$

I was reading a proof (which they have the result ahead of time already) that we do cases and then we consider $x + y + |y - x|$. I am not sure how they first came up with $x + y + |y - x|$ in the first place

Lemon
  • 12,664
  • the formalu $max(x,y)=x1_{x\ge y}+y1_{x<y}$, where $1_p=1$ when $p$ is correct, may help deriving it. –  May 06 '13 at 01:40
  • @sizz : you start at the middle (average) and you go up or down as needed. – Stefan Smith May 06 '13 at 01:40
  • @StefanSmith there's no "down". Think of it as starting at the middle, and adding the difference between the middle and the max. – Alex L May 06 '13 at 01:42
  • Sorry guys, I have absolutely no idea what you guys are talking about "up" and "down". Feels like an elevator conversation I am reading – Lemon May 06 '13 at 01:47
  • @Alex L : I'm thinking of the positive direction as up and the negative direction as down, obviously. – Stefan Smith May 06 '13 at 20:44
  • @StefanSmith Yes, but you won't be going in the negative direction to go from the middle to the max. – Alex L May 06 '13 at 20:46

2 Answers2

13

The value halfway between x and y is $$\frac{x+y}{2}.$$ If we want to add something to it to get to $\max \left( x,y \right)$, we would need to add the difference between $\max \left( x,y \right)$ and $\frac{x+y}{2}$. What is that value? well if $\max \left( x,y \right) = y$ then it is $$y- \frac{x+y }{2} = \frac{y-x }{2},$$ and if $\max \left( x,y \right) = x$ then it is $$x- \frac{x+y }{2} = \frac{x-y}{2}.$$

We know 2 things:

  1. $x-y$ and $y-x$ are the same up to a change of sign.
  2. the difference between the max and the middle is positive.

So,

$$\left| \frac{x-y}{2} \right|=\left| \frac{y-x}{2} \right|,$$

and whether $\max \left( x,y \right)$ is $x$ or $y$, you can add this amount to the value halfway between $x$ and $y$ to get $\max \left( x,y \right)$.

This gives you the formula:

$$\max \left( x,y \right) = \frac{x+y + \left| x-y \right|}{2}.$$

Alex L
  • 590
  • 6
  • 13
  • 1
    Crazy question, but why do we start with "half way"? Why not consider (x + y)/3 or 2(x + y)/3 – Lemon May 26 '13 at 03:08
  • @sidht i want to know too. –  Mar 07 '14 at 15:49
  • 1
    @TuckerRapu If you start halfway, then the amount you need to add is the same whichever of $x$ or $y$ is the max. If you don't start halfway, then the amount you need to add depends on $\max(x,y)$. – Alex L Mar 09 '14 at 10:29
  • @AlexL +Upvote yesterday. thank you. please add this to your answer? –  Mar 09 '14 at 14:52
-1

I expatiate on how this begets the formula for $\min(x,y) = -\max (-x,-y)$.

(http://math.berkeley.edu/~borisp/MA104/MA104solutions2.pdf)

The smaller of the two numbers f and g is bigger when you reverse the sign. To recover the original number, one must again reverse the sign.

Videlicet, posit $y < x$. Ergo $\color{seagreen}{min(y, x) = y}$.
Modus operandi. Want $min(y, x) = y$ as a functin of $max(x,y)$.

$y < x \iff -y > -x$ ergo $-y$ is bigger. Ergo $max(-x, -y) = -y$.
To return to $\color{seagreen}{min(y, x) = y}$, reverse sign: $\color{magenta}{-}max(-x, -y) = \color{magenta}{-}-y$