Let $d,n\ge 1$ be fixed integers. Given some compact subset $E\subset \mathbb R^d$, consider the function $f: E^n\ni (x\_1,\ldots, x\_n) \longrightarrow f(x\_1,\ldots, x\_n)\in \mathbb R$ defined by


$$f(x\_1,\ldots, x\_n):= \max\_{(c\_1,\ldots,c\_n)\in\mathbb R^n}\left\{\int\_E \left(\min\_{1\le i\le n}|y-x\_i|^2-c\_i\right)p(y)dy + \sum\_{i=1}^n \alpha\_i c\_i\right\},$$


where $p:E\to \mathbb R\_+$ is a probability density on $E$ and $\alpha\_1,\ldots, \alpha\_n>0$ s.t. $\sum\_{i=1}^n \alpha\_i =1$. Under which conditions (on $E, \rho$) $f$ is differentiable (almost everywhere) on $E^n$?



Differentiability of some function defined as the maximum
Suppose that there is an open subset $U$ of $E$ such that the Lebesgue measure of $E\setminus U$ is $0$. Since $E$ is compact, the function $E^n\ni(x\_1,\dots,x\_n)\mapsto|y-x\_i|^2$ is $L$-Lipschitz for some real $L>0$ and each $i\in\{1,\dots,n\}$ and each $y\in E$. Therefore and because the $\max$, $\min$, and integration (with respect to a probability measure) operations preserve the $L$-Lipschitz condition, $f$ is $L$-Lipschitz.


So, by [Rademacher's theorem](https://en.wikipedia.org/wiki/Rademacher%27s_theorem), $f$ is differentiable almost everywhere (a.e.) on $U^n$ and hence a.e. on $E^n$.


