Gradient of a convex function on $\mathbb{R}^d$, maximum on hypercubes bounded by values in corners? Let $f : \mathbb{R}^d \rightarrow \mathbb{R}$ be infinitely often continuously differentiable and convex.
For $d = 1$, we know that for any interval $[a, b]$, it holds for $x, y \in [a, b]$ that
$$
(f'(y) - f'(x))(y-x) \leq (f'(b) - f'(a))(b-a),
$$
which directly follows by monotonicity of the derivative $f'$. I am looking for a suitable generalization to $d > 1$ and hypercubes $[a, b]$ with $a, b \in \mathbb{R}^d$.
In particular, I am wondering whether for $d=2$, it holds for all $x, y \in [0, 1]^2$ that
\begin{align}
\langle \nabla f(y) - \nabla f(x), y-x\rangle \leq &\langle \nabla f(1, 0) - \nabla f(0, 0), (1, 0)\rangle \\
+ &\langle \nabla f(0, 1) - \nabla f(0, 0), (0, 1)\rangle \\
+ &\langle \nabla f(1, 1) - \nabla f(0, 1), (1, 0)\rangle \\
+ &\langle \nabla f(1, 1) - \nabla f(1, 0), (0, 1)\rangle
\end{align}
Answering the above question for $d=2$ would already be a complete answer for me, but I am also happy for pointers to other generalizations of the one-dimensional case. Hereby it is important to me to only use the corners, and not the whole boundary.
 A: $\newcommand{\ep}{\varepsilon}$There is a smooth convex function $f\colon \mathbb{R}^2 \rightarrow \mathbb{R}$ such that the inequality
\begin{equation}
    \begin{aligned}
\langle \nabla f(y) - \nabla f(x), y-x\rangle \leq 
&\langle \nabla f(1, 0) - \nabla f(0,0), (1, 0)\rangle \\
+ &\langle \nabla f(0, 1) - \nabla f(0, 0), (0, 1)\rangle \\
+ &\langle \nabla f(1, 1) - \nabla f(0, 1), (1, 0)\rangle \\
+ &\langle \nabla f(1, 1) - \nabla f(1, 0), (0, 1)\rangle
\end{aligned}
\tag{1}\label{1}
\end{equation}
fails to hold for some $x,y$ in $[0,1]^2$.
Indeed, for real $\ep>0$, let
\begin{equation}
    f_\ep(x):=\max (-4 \ep t,4 \ep (t-1),-\ep-s,-\ep+s-1)
\end{equation}
for $x=(s,t)\in\mathbb R^2$. The function $f_\ep \colon \mathbb{R}^2 \rightarrow \mathbb{R}$ is convex.
However, letting $\ep\downarrow0$, we see that,
for $x=(0,1/2)$ and $y=(1,1/2)$, the left-hand side of \eqref{1} goes to $2$ while the right-hand side of \eqref{1} goes to $0$.
This follows because, if $\ep>0$ is small enough, then $f_\ep(x)$ equals

*

*$-4 \ep t$ in small enough neighborhhoods of the points $(0,0)$ and $(1,0)$;


*$4 \ep (t-1)$ in small enough neighborhhoods of the points $(0,1)$ and $(1,1)$;


*$-\ep-s$ in a small enough neighborhhood of the point $(0,1/2)$ ;


*$-\ep+s-1$ in a small enough neighborhhood of the point $(1,1/2)$.
So, if $\ep>0$ is small enough, then $\nabla f_\ep(0,0)=\nabla f_\ep(1,0)=(0,-4\ep)$, $\nabla f_\ep(0,1)=\nabla f_\ep(1,1)=(0,4\ep)$, $\nabla f_\ep(0,1/2)=(-1,0)$, $\nabla f_\ep(1,1/2)=(1,0)$.
So, \eqref{1} fails to hold for the convex function $f:=f_\ep$, $x=(0,1/2)$, and $y=(1,1/2)$, provided that $\ep>0$ is small enough.
Moreover, convolving such a function $f_\ep$ with (say) a symmetric mollifier supported on a small enough disk centered at the origin, one gets a smooth convex function with the values of the function and of its gradient at the vertices of the unit square and at the points $x=(0,1/2)$ and $y=(1,1/2)$ that are the same as the corresponding values for $f_\ep$.
Thus, \eqref{1} will fail to hold for some smooth convex function $f$, $x=(0,1/2)$, and $y=(1,1/2)$.

Here is the graph $\{(s,t,f_\ep(s,t))\colon s\in[0,1],t\in[0,1]\}$ for $\ep=1/5$:

