How do I prove that $\max(x,\max(y,z)) = \max(\max(x,y),z))$ using an algebraic formula? The maximum of two numbers can be expressed by
$$\max(x,y) = \frac12\left(x+y+|x-y|\right)$$
Consequently, we can write
$$\max(x,\max(y,z))=\frac{1}{4}\left(2x+y+z+|y-z|+|2x-y-z-|y-z||\right)$$
$$\max(\max(x,y),z)=\frac{1}{4}\left(x+y+2z+|x-y|+|-x-y+2z-|x-y||\right)$$
Since we know the values on the left are equal, the expressions on the right should be, too. However, I don't know how to show that those expressions are the same.
 A: In case that you want to work with the right sides, only, and intentionally ignore what you already know about the $\max$ function, you have to make a distinction of $6$ cases. Those $6$ cases must cover each possible order of the numbers $x,$ $y$ and $z.$ Now replace all absolute values $|u|$ with $u$ if $u\geq 0.$ Replace it with $-u$ if $u\leq 0.$ Example:
Case 1: $x\leq y\leq z$
$$
\frac{1}{4}(2x+y+z+|y-z|+|2x-y-z-|y-z||) \\
=\frac{1}{4}(2x+y+z-(y-z)+|2x-y-z+(y-z)|) \\
=\frac{1}{4}(2x+2z+|2x-2z|) \\
=\frac{1}{4}(2x+2z-(2x-2z)) \\
=\frac{1}{4}(4z) \\
=z
$$
In the first step, I used $y\leq z$ and hence $(y-z)\leq 0.$ Therefore, $|y-z|$ must be replaced with $-(y-z).$ In the third step, I used $x\leq z$ which means $2x-2z\leq 0.$
A: From
$$\max(x,\max(y,z))=\frac{1}{4}\left(2x+y+z+|y-z|+|2x-y-z-|y-z||\right)$$
$$\max(\max(x,y),z)=\frac{1}{4}\left(x+y+2z+|x-y|+|-x-y+2z-|x-y||\right)$$
Let $y-z=a, x-y=b$, so $z=y-a, x=y+b, x-z=a+b$.
Then
$$\frac{1}{4}\left(x+2y+z+b+|a|+|2x-y-z-|y-z||\right)$$
$$\frac{1}{4}\left(x+2y+z-a+|b|+|-x-y+2z-|x-y||\right)$$
and
$$\frac{1}{4}\left(x+2y+z+b+|a|+|2x-y-z-|a||\right)$$
$$\frac{1}{4}\left(x+2y+z-a+|b|+|-x-y+2z-|b||\right)$$
and
$$\frac{1}{4}\left(x+2y+z+b+|a|+|a+2b-|a||\right)$$
$$\frac{1}{4}\left(x+2y+z-a+|b|+|-2a-b-|b||\right)$$
and using $|x|=x, x\gt0, |x|=-x, x\lt0$ we evaluate the last absolute term of the first and second equations independently for the four cases of the signs of $a$ and $b$ 
\begin{array}{|c|c|c|}
\hline
\frac{a}{b}&-&+\\
\hline
-&2|a+b|,2|a|&2|b|,2|a|\\
\hline
+&2|a+b|,2|a+b|&2|b|,2|a+b|\\
\hline
\end{array}
with the first entry in a cell being relevant to the first equation, etc..
For example if $a\gt0, b\lt0$ eqn 1 reads
$$|a+2b-|a||=|a+2b-a|=|2b|=2|b|$$
and eqn 2
$$|-2a-b-|b||=|-2a-b+b|=|-2a|=2|a|$$
as $-|b|=b$.
Replacing each last term with the associated cell, the equations match.
If $a,b$ are the same sign, $|a+b|=|a|+|b|$, otherwise they cancel as a whole.
For example $a\lt0,b\gt0$
$$b+|a|+|a+2b-|a||=b+|a|+2|a+b|$$
$$-a+|b|+|-2a-b-|b||=-a+|b|+2|a+b|$$
As  $a\lt0, -a=|a|$ and as $b\gt0, |b|=b$
so we get
$$=b+|a|+2|a+b|$$
$$=|a|+b+2|a+b|$$
which are equal.
