Show $\max{\{a,b\}}=\frac1{2}(a+b+|a-b|)$ I am tasked with showing that

If $a,b\in \mathbb{R}$, show that $\max{\{a,b\}}=\frac1{2}(a+b+|a-b|)$

I think I can say "without loss of generality, let $a<b$."  Then $b-a>0$  But also, $$\max{\{a,b\}}=b=\frac1{2}a+\frac1{2}b-\frac1{2}a+\frac1{2}b$$
$$=\frac1{2}(a+b-a+b)$$
$$=\frac1{2}(a+b+(-a+b))$$
$$=\frac1{2}(a+b+|b-a|)$$
$$=\frac1{2}(a+b+|a-b|)$$
Is this valid?  Does the proof (if valid) work the same way for the $\min$ function?
 A: There are $3$ separate cases you must cover. 


*

*$a \lt b$

*$a = b$ and

*$a \gt b$
You've covered (1). But this is just one possibility. You must also show that the equality holds for $a = b$. Again, would not be too difficult. And you can argue that case (3) can be shown pretty much the same way as the first one. 
The fallacy in the logic is this: "Not all real numbers are such that $a \lt b$ and you are required to prove the identity for every real number"
A: Here is another approach:
$\max(x,y)+\min(x,y) = x+y$, and $\max(x,y)-\min(x,y) = |x-y|$.
Adding/subtracting gives
$\max(x,y) = {1 \over 2}(x+y+|x-y|)$, $\min(x,y) = {1 \over 2}(x+y-|x-y|)$
A: The "without loss of generality $a<b$" assumes we know that $|a-b|=|b-a|$.  I would usually skip that, but not if the topic of discussion is the $|\cdot|$ absolute value function itself.
You also need to cover the case $a=b$.
A: $$max(a,b) = \frac 1 2 (a + b + |a - b|)$$
$$\text{if}(a \ge b, a, b) = \frac 1 2 (a + b + \text{if}(a - b \ge 0, a - b, -(a - b))$$
$$\text{if}(a \ge b, a, b) = \frac 1 2 (a + b + \text{if}(a \ge b, a - b, b - a))$$
$$\text{if}(a \ge b, a, b) = \text{if}(a \ge b, \frac 1 2 (a + b + a - b), \frac 1 2 (a + b + b - a))$$
$$\text{if}(a \ge b, a, b) = \text{if}(a \ge b, a, b)$$
