# Differentiability of some function defined as the maximum

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$$?

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, $$f$$ is differentiable almost everywhere (a.e.) on $$U^n$$ and hence a.e. on $$E^n$$.

• Thanks for the answer. Do you think there is some way to compute its gradient? Commented Nov 3, 2022 at 16:33
• @Fawen90 : I think there should be a way to compute the gradient where it exists. However, that would be a different, much more difficult question -- in particular, that would require an explicit determination of the points where the gradient exists (which would probably depend on the density $p$). As your posted question has been answered, you may want to post additional questions separately. Commented Nov 3, 2022 at 16:47
• Of course. Will post it in an alternative one. Thanks again for your help. Commented Nov 4, 2022 at 8:01