# Showing a function is convex by looking at the hessian.

Let $$f: \mathbb{R}^n \rightarrow \mathbb{R}$$ be a function that is twice-differentiable almost everywhere. That is, $$f$$ is differentiable almost everywhere, and its $$\nabla f$$ is also differentiable almost everywhere. Furthermore $$\nabla^2 f = 0$$ where defined, and so the derivatives of $$\nabla f$$ agrees as you approach the non-differential measure zero set from any direction.

My end goal is to show that $$f$$ is convex. The approach I'm taking is showing that the Hessian is PSD. If $$f$$ were twice differentiable everywhere, this would be sufficient. However $$f$$ is not even differentiable everywhere, it is differentiable almost everywhere, and where its Hessian is defined $$\nabla^2 f = 0$$. Does the conclusion that $$f$$ is convex still hold?

• is the Heaviside step function a counterexample? – LinAlg Dec 16 '18 at 3:02
• Isn't $f:x\mapsto -|x|$ a concave non-convex function $\mathbb R\to\mathbb R$ that satisfies your conditions? – kimchi lover Dec 16 '18 at 3:41