derivative of the supremum of a set of n functions Let $\mathcal{S} = \{f_1(x),f_2(x),\dots,f_n(x)\}$ be a set composed by $n$ differentiable functions, where $x \in \mathbb{R}^m$.
Let $h(x) = \sup \mathcal{S}$
Is it possible to compute $\frac{\partial h}{\partial x}$ ?
I know that if $n=2$ then $h(x) = \frac{f_1(x) + f_2(x) + |f_1(x) - f_2(x)|}{2}$ that is differentiable assuming $f_1(x)\ne f_2(x)$
but is it possible to generalize this?
 A: Your approach, by expressing the maximum of two functions in terms of an absolute value of their difference, does demonstrate that $h(x) = \sup S(x)$ is differentiable at points $x$ where all the underlying function values $f_1(x),\ldots,f_n(x)$ are distinct.
We can see this by repeatedly applying your expression for two values:
$$ \max \{f_1(x),f_2(x)\} = \frac{f_1(x)+f_2(x)+|f_1(x)-f_2(x)|}{2} $$
to obtain the maximum of several values:
$$ \max \{f_1(x),f_2(x),\ldots,f_n(x)\} = \max \{ f_1(x), \max\{f_2(x),\ldots,f_n(x)\} \} $$
so that if all the $f_i(x)$ are distinct, then at each stage we obtain subexpressions where the absolute value is taken of the difference of unequal values.  Hence the supremum $h(x) = \sup S$ will be differentiable at such $x$.
To illustrate the idea (as well as how cumbersome these formulas become), for $n=3$ we would get this expression:
$$ h(x) = \frac{f_1(x) + \frac{f_2(x) + f_3(x) + |f_2(x) - f_3(x)|}{2} + |f_1(x) - \frac{f_2(x) + f_3(x) + |f_2(x) - f_3(x)|}{2}|}{2} $$
As I tried to sketch out in the Comments, requiring all the $f_i(x)$ to be distinct will exclude some points where $h(x)$ is actually differentiable.  The condition can be weakened to requiring only that some $f_i(x)$ is strictly greater than all the other $f_j(x)$, $j\neq i$.  In that case by continuity there will be an open neighborhood of $x$ in which $h$ agrees identically with $f_i(x)$. Hence:
$$ h'(x) = f_i'(x) $$
Finally we note that $h(x)$ might sometimes be differentiable also at points $x$ where the two greatest function values are equal, and it will be impossible to rule this out without further information.
For example, $h(x) = \sup \{x^3,-x^3\} = |x^3|$ has derivative zero at the "crossover point" $x=0$.
