TITLE: Is the max of two differentiable functions piecewise-differentiable?
QUESTION [11 upvotes]: The question here asks:

Given that $f$ and $g$ are two real functions and both are differentiable, is it true to say that $h=max(f,g)$ is differentiable too?

Convincing arguments have been presented there that the answer is No.
So, how about a slightly weaker question:  Given that $f$ and $g$ are two real, differentiable functions, is it always true that $h=max(f,g)$ is piecewise-differentiable?
(For the purposes of this question, 'piecewise' is to be taken as user86418 defined it in a comment: "The domain can be divided into subintervals so that the set of endpoints is discrete", i.e., "each endpoint is isolated in the set of endpoints."  Further, the set of endpoints may or may not be finite.)

REPLY [3 votes]: Suppose $f,g : \mathbb {R}\to \mathbb {R}$ are differentiable and $E$ is the set of points where $\max(f,g)$ is not differentiable. Then every point in $E$ is isolated in $E.$ In particular, $E$ is countable. Furthermore, the right derivative and left derivative of $\max(f,g)$ exist at every point of $E$ (hence at every point of $\mathbb {R}$).
Proof: Let's go through some cases. Suppose $f(a)\ne g(a).$ WLOG, $f(a)< g(a).$ Then by continuity, $f<g$ in a neighborhood of $a.$ Thus $\max (f,g)=g$ in a neighborhood of $a,$ which implies $\max (f,g)$ is differentiable in a neighborhood of $a.$ So such an $a$ is not in $E.$
Now suppose $f(a)= g(a).$ Two subcases: (i) $f'(a)\ne g'(a).$ WLOG, $f'(a)< g'(a).$ Then $g\ge f$ in $[a,a+\delta)$ for some $\delta > 0.$ That implies $\max (f,g)=g$ in that interval, hence $\max (f,g)$ is differentiable in $[a,a+\delta),$ with the right derivative at $a$ equal to $g'(a).$ Similarly, $\max (f,g)=f$ in some $(a-\delta,a],$ hence $\max (f,g)$ is differentiable there, with the left derivative at $a$ equal to $f'(a).$ Since the right and left derivatives at $a$ disagree, $a\in E,$ but $\max(f,g)$ is differentiable elsewhere in $(a-\delta,a+\delta).$
The other subcase is $f(a)= g(a), f'(a)= g'(a).$ Here we have a common tangent line, let's call it $l(x).$ By definition of a derivative, near $a$ we have
$$f(x) = l(x) + r(x)(x-a), g(x) = l(x) + s(x)(x-a),$$
where both $r(x), s(x) \to 0$ as $x\to a.$ It follows that 
$$l(x) - |x-a|(|r(x)| + |s(x)|) \le \max (f,g)(x) \le l(x) + |x-a|(|r(x)| + |s(x)|)$$ near $a.$ This shows $\max(f,g)'(a)$ exists, so this $a\not \in E.$
Put all this together to get the claims made at the beginning of this post.