What's the explanation behind the identity $\frac{x+y}{2} +\frac{\vert x-y\vert}{2}=\mathrm{max}(x,y)$? I'm supposed to get the maximum of two unknown numbers.
I used this equation to do this task:
$${x+y\over 2} + {\vert x-y\vert\over 2} $$
Let's get the maximum by substituting any two values e.g. $$x = 5$$ and  $$y = 10$$
So:  
$${5+10\over 2} + {\vert 5-10\vert\over 2} = 7.5 + 2.5 = 10 $$ 
 
My questions are: 


*

*What's the mathematical explanation behind this?

*How can I simplify this equation? 
I can't simplify it because absolute value is confusing.

 A: You are adding two values together
$${x+y\over 2} + {\vert (x-y)\vert\over 2}$$
The first is the average which gives you the midpoint.
The second part is half the total distance between $x$ and $y.$
What happens if you start at the midpoint and add half the distance to that?
You get to the larger one.
If you subtract the half distance you get to the smaller one. 
Thus you can also find the minimum by changing the plus sign to a minus sign. 
$${x+y\over 2} -{\vert (x-y)\vert\over 2}$$
A: It helps to keep in mind that $\,\max(x,y), \min(x,y)\,$ are just the same numbers $\,x,y\,$, but possibly in a different order. Then it follows from definitions that:
$$
\begin{cases}
\begin{align}
x + y &= \max(x,y)+\min(x,y) \\
|x - y| &= \max(x,y)-\min(x,y) \\
\end{align}
\end{cases}
$$
Adding the two identities above gives the posted relation, while subtracting them gives its dual: $\;\dfrac{x+y}{2} - \dfrac{|x-y|}{2} = \min(x,y)\,$.
A: Hint: You can find the secret by considering two cases if $x \geq y$ and $x < y$.
If $x \geq y$ means $\max(x,y)= x$:
$$\frac{x+y}{2} + \frac{x-y}{2} = x$$
If $x < y$ means $\max(x,y)= y$:
$$\frac{x+y}{2} + \frac{y-x}{2} = y$$
Indeed maximum changes the sign of the abs, and the minimum value will be removed in the summation.
A: The first term of the sum is just the average value of the two given inputs.  To get the max input out of the sum, it follows that the second term of the sum gives you the difference between the average and the max (or min) input.  The formula does this by finding the difference between the two inputs (using absolute values to avoid negative values) and dividing that value by two to give the “length” of the distance between the max and the average.
