TITLE: Modus Operandi. Formulae for Maximum and Minimum of two numbers with a + b and $|a - b|$
QUESTION [34 upvotes]: I came across the following problem in my self-study of real analysis:

For any real numbers $a$ and $b$, show that $$\max \{a,b \} = \frac{1}{2}(a+b+|a-b|)$$ and $$\min\{a,b \} = \frac{1}{2}(a+b-|a-b|)$$

So $a \geq b$ iff $a-b \ge0$ and $b \ge a$ iff $b-a \ge 0$. At first glance, it seems like an average of distances. For the first case, go to the point $a+b$, add $|a-b|$ and divide by $2$. Similarly with the second case. 
Would you just break it up in cases and verify the formulas? Or do you actually need to come up with the formulas?

REPLY [11 votes]: It is easy once you realize that always
$$a+b = \max(a,b) + \min(a,b) $$
because you are adding the smallest and the largest if you add both and 
$$|a-b| = \max(a,b) - \min(a,b) $$
because you calculate the distance by taking the largest and subtracting the smallest. 
To compute the formula given, you just add or subtract the two equations.