Weak Hessian of the distance function If $\Omega\subset\mathbf{R}^d$ has a smooth boundary it is known that the distance function $\mathrm{d}_\Omega:x\mapsto \mathrm{d}(x,\partial\Omega)$ is smooth on a neighborhood of $\partial\Omega$. My question is about the hessian of $\mathrm{d}_\Omega$ outside that neighborhood : does it exists in a weaker sense ? I am thinking of Sobolev regularity, for instance. Since $\mathrm{d}_\Omega$ is lipschitz, we know that it belongs to $\mathrm{W}_{\mathrm{loc}}^{1,\infty}(\mathbf{R}^d)$ and my hope is that those distance functions enjoy more regularity (in the whole space) than mere $\mathrm{W}^{1,\infty}_{\mathrm{loc}}(\mathbf{R}^d)$.
 A: The following result is due to Asplund [A, p.235].

Theorem. If $\varnothing\neq E\subset\mathbb{R}^n$ is closed, and $d(x)=\operatorname{dist}(x,E)$, then $f:\mathbb{R}^n\to\mathbb{R}$ defined by
$f(x)=|x|^2-d(x)^2$ is convex.

Proof. The proof is very easy, but clever. We have
$$
f(x)=|x|^2-\inf_{y\in E}|x-y|^2=|x|^2+\sup_{y\in E}(-|x-y|^2)=\sup_{y\in E} \big(2\langle x,y\rangle -|y|^2\big).
$$
Therefore,
$f$ is a supremum of a family of affine functions,
and hence it is convex. $\Box$
That means $d^2$ has in some sense the same regularity properties as a convex function and that translates into properties of the distance function.
The Hessian of a convex function is a positive definite Radon measure and that says something about the Hessian of $d$ when we are at a positive distance to $E$.
If $d>0$, then $|x|^2-f(x)>0$ and hence $d(x)=\sqrt{|x|^2-f(x)}$ is a composition of a function which is the difference of two convex functions with a smooth function $0<y\mapsto\sqrt{y}$ so smoothness properties of convex functions translate into similar properties of $d$. In particular it is known that a convex function conincides with a $C^2$ function outiside a set of small measure (for references see the proof of Theorem 1(b) in [H]) and hence as a corollary we obtain:

Corollary. If $\varnothing\neq E\subset\mathbb{R}^n$ is closed, then for any $\varepsilon>0$ there is a function $g\in C^2(\mathbb{R}^n\setminus E)$ such that
$$
|\{x\in\mathbb{R}^n\setminus E:\, f(x)\neq g(x)\}|<\varepsilon.
$$

[A] E. Asplund,
Cebyvsev sets in Hilbert space.
Trans. Amer. Math. Soc. 144 (1969), 235-240.
[H] P. Hajłasz,
On an old theorem of Erdős about ambiguous locus.
Colloq. Math. 168 (2022), 249–256.
