# Proving Max and Min Formula

1. Jul 20, 2013

### Seydlitz

1. The problem statement, all variables and given/known data
The function max will return which number is the largest between the two parameters x and y. The function min will return the smallest number between the two. If the numbers are the same they will give out that same value.

Prove that

$$max(x,y) = \frac{x+y+|y-x|}{2} \\ min(x,y) =\frac{x+y-|y-x|}{2}$$
2. Relevant equations

None

3. The attempt at a solution

Suppose $x=y=0$
$$max(0,0) = \\ \frac{0+0+|0-0|}{2} = 0$$
Suppose $x = a+1$ and $y = a$
\begin{align*} max((a+1),a) &= \frac{(a+1)+a+|a-(a+1)|}{2}\\ &=\frac{a+1+a+1}{2}\\ &=\frac{2a+2}{2} \\ &=(a+1) \\ \end{align*}
Where $x>y$

The similar reasoning can be applied to the case where $y>x$ and to $min(x,y)$ function.

Is this done or enough? I'm not sure if this is already enough for the purpose, to prove a formula. To what extent should we go so that it's correct?

Thank You

2. Jul 20, 2013

### jbunniii

Your special cases, $x = y = 0$ and $x = a+1, y = a$ aren't going to do much for you.

Instead, try considering these two cases: $x \geq y$ and $x < y$.

3. Jul 20, 2013

### Seydlitz

Ok considering the given cases, then it is certain that the prove rest on the inequality $|y-x|$ and what happens with it when $x\geq y$ and $x<y$. I think I can do the symbolic manipulation to prove that it is indeed true.

Though my question is why I've to prove the formula using those cases? What is the difference logically with my a+1 case? (It rests with the fact that $x>y$) Is it that because they are more general, rather than when a+1?

4. Jul 20, 2013

### jbunniii

Note that I suggested considering these two cases because (1) they are the only possibilities, and (2) the expression $|y-x|$ can be simplified in both cases (try rewriting it without the absolute value).
Yes. Your solution does not cover, for example, the case where $x = 1$ and $y = 1/2$.

5. Jul 20, 2013

### Seydlitz

Yes the final simplified statement match with the original case once the inequality is changed, say $|y-x|$ to $(y-x)$ if $x<y$. Thanks for your help.

Ah yes! I really didn't think of that.