Why is it that
$$\max(x, x') = \frac{1}{2}( x + x' + |x - x'|)$$
is true? Is it supposed to be obvious? Because it seems to come out of thin air for me. Anyway, I've verified this by plotting it in matlab, so it works, but its hardly a satisfying proof/justification.
I've actually have been shown a proof but I am unable to internalize and understand it properly. I will provide it below:
$$\begin{align*} \max(x, x') &= \max\left(x - \frac{1}{2}(x + x'),\; x' - \frac{1}{2}(x + x')\right) + \frac{1}{2}(x + x')\\\\ &=\max\left(\frac{1}{2}(x - x'), \frac{1}{2}(x' - x)\right) + \frac{1}{2}(x + x')\\\\ &=\max\left(\frac{1}{2}(x' - x), \frac{1}{2}(x - x')\right) + \frac{1}{2}(x + x')\\\\ &=\max\left(-\frac{1}{2}(x - x'), \frac{1}{2}(x - x')\right) + \frac{1}{2}(x + x')\\\\ &=\left| \frac{1}{2}(x - x')\right| + \frac{1}{2}(x + x') \\\\ &= \frac{1}{2}( x + x' + |x -x'| ) \end{align*}$$
The only line that remains a mystery for me is actually the first line.
$$ \max(x, x') = \max\left(x - \frac{1}{2}(x + x'),\; x' - \frac{1}{2}(x + x')\right) + \frac{1}{2}(x + x') $$
After that everything seems to be simple algebra manipulations, except for the cool use of the identity $$\left| \frac{1}{2}(x - x')\right| = \max\left(-\frac{1}{2}(x - x'), \frac{1}{2}(x - x')\right)$$ which makes sense to me.
If anyone has a good explanation of why that step is true, I'd be very thankful. Also, and maybe more importantly, that first step seems like magic to me, I have no idea where it came from and if someone has a good explanation for that too, that would be awesome. I'd like to understand this not only to see why its correct, but also to understand how one would have come up with such a result.
You should visualize things on the real number line (Wikipedia link). The average of $x$ and $x'$, that is, the number $$\frac{x+x'}{2}$$ is exactly halfway between $x$ and $x'$. The distance between $x$ and $x'$ on the number line is $$|x-x'|$$ (regardless of which of $x$ and $x'$ is larger). Therefore, to get to the larger of the numbers $x$ and $x'$ – in other words, $\max(x,x')$ – we start at the midpoint of $x$ and $x'$ and then move "up" exactly half of the total distance between $x$ and $x'$: $$\frac{x+x'}{2}+\frac{|x-x'|}{2}=\frac{1}{2}\left(x+x'+|x-x'|\right)$$ Similarly, if we instead moved "down" exactly half of the total distance between $x$ and $x'$, we'd arrive at the smaller of the two numbers, which explains why $$\min(x,x')=\frac{1}{2}\left(x+x'-|x-x'|\right)$$
As for the first step in the proof you cited, what's being used is $$\max(x,x')=\max(x+y,x'+y)-y$$ for any number $y$. Here's how I'd explain it: if I want to find the height of the taller of two people, I can either
measure their heights and take the larger number, or
have them both stand on boxes of height $y$, measure their total heights with the boxes, take the larger of those two numbers, and then subtract the height of the box