The value halfway between x and y is $$\frac{x+y}{2}.$$ If we want to add something to it to get to $\max \left( x,y \right)$, we would need to add the difference between $\max \left( x,y \right)$ and $\frac{x+y}{2}$. What is that value? well if $\max \left( x,y \right) = y$ then it is $$y- \frac{x+y }{2} = \frac{y-x }{2},$$ and if $\max \left( x,y \right) = x$ then it is $$x- \frac{x+y }{2} = \frac{x-y}{2}.$$
We know 2 things:
- $x-y$ and $y-x$ are the same up to a change of sign.
- the difference between the max and the middle is positive.
So,
$$\left| \frac{x-y}{2} \right|=\left| \frac{y-x}{2} \right|,$$
and whether $\max \left( x,y \right)$ is $x$ or $y$, you can add this amount to the value halfway between $x$ and $y$ to get $\max \left( x,y \right)$.
This gives you the formula:
$$\max \left( x,y \right) = \frac{x+y + \left| x-y \right|}{2}.$$