Solution (source code)

= Solution

Restrict $\varphi$ to an arbitrary <line segment> by defining $q(t)=\varphi((1-t)x+ty)$ for $0\leq t\leq1$. The <chain rule> and the assumed <positive semidefinite matrix> condition on the <Hessian matrix> give
$$
q''(t)=(y-x)^\top D^2\varphi((1-t)x+ty)(y-x)\geq0.
$$
Thus $q'$ is non-decreasing. For $0<t<1$, integrating $q'$ on the two subintervals gives
$$
\frac{q(t)-q(0)}t\leq\frac{q(1)-q(t)}{1-t}.
$$
Rearranging, and including the immediate endpoint cases, yields
$$
\boxed{\varphi((1-t)x+ty)\leq(1-t)\varphi(x)+t\varphi(y)\quad(0\leq t\leq1).}
$$
This is precisely the definition of a <convex function>.