Solution (source code)

= Solution

The <Hessian criterion for convexity>, in the usual twice-differentiable multivariate setting, is
$$
\boxed{g\text{ is convex on }\mathbb R^d\quad\Longleftrightarrow\quad v^{\mathsf T}H(g)(x)v\ge0\text{ for all }x,v\in\mathbb R^d.}
$$
Thus the <Hessian matrix> must be a <positive semidefinite matrix> everywhere. The criterion follows by applying the <second-derivative criterion for convexity> to each line restriction $t\mapsto g(x+tv)$, whose <second derivative> is $v^{\mathsf T}H(g)(x+tv)v$. Continuous second partials are a sufficient regularity hypothesis for this line-restriction argument.