Continuity of $\max$ function Given continuous functions $f,g: \mathbb{R} \to \mathbb{R}$, in order to prove that $ \max(f(x),g(x))$ is continuous, a standard trick is to rewrite it as a linear combination of continuous functions:
$$
\max(f(x),g(x)) = \frac{1}{2} (f(x) + g(x) + |f(x) - g(x)|   )
$$
Is there any sort of motivation for why one might come up with this particular combination of continuous functions? I can see that it works, but without knowing this fact beforehand , what might lead you to consider writing $ \max(f(x),g(x)  ) $ in the above manner?

I think I'd start by considering the easier case where one of $f$, $g$ was constant and zero. If I've proved that $\max(h(x),0)$ is continuous for all continuous $h$ and want to generalise, I'll see that I can write 
$$\max(f(x),g(x)) = \max (f(x)-g(x), 0) + g(x).$$
This formula breaks the symmetry between $f$ and $g$ that we started with, so it's natural also to write down $$max(f(x), g(x) = \max( g(x)-f(x), 0) + f(x) $$
and we recover the symmetry by adding the two expressions up:
$$2 max (f(x),g(x)) = f(x) + g(x) +\left(\max (f(x)-g(x), 0) + \max( g(x)-f(x), 0)\right).$$
And now the expression inside the bracket looks familiar, being exactly $|f(x)-g(x)|$.
Indeed you really have to break up $|f(x)|$ into these two parts to prove that the absolute value of a continuous function is continuous. So the magic formula doesn't really make for a shortcut in the proof, even if you're told about it without motivation.
