[proofplan]
We prove both implications. If $f$ is convex, we restrict $f$ to the line segment from $x$ to $y$ and compare the convexity inequality with the directional derivative at $x$. Conversely, assuming the first-order inequality, we apply it at a convex combination $z = (1-\lambda)x + \lambda y$ toward both endpoints and take the corresponding convex combination of the two inequalities; the linear terms cancel exactly.
[/proofplan]
[step:Derive the supporting hyperplane inequality from convexity]
Assume that $f$ is convex on $U$. Fix $x,y \in U$. If $x = y$, then
\begin{align*}
f(y) = f(x) = f(x) + \nabla f(x)\cdot (y - x),
\end{align*}
so the desired inequality holds.
Assume now that $x \neq y$, and define the vector $v \in \mathbb{R}^n$ by $v := y - x$. Since $U$ is open and $x \in U$, there exists $\delta > 0$ such that $B(x,\delta) \subset U$. Define
\begin{align*}
\varepsilon := \min\left\{1, \frac{\delta}{2|v|}\right\}.
\end{align*}
For every $t \in (0,\varepsilon)$, the point $x + tv$ belongs to $U$, and also
\begin{align*}
x + tv = (1-t)x + ty.
\end{align*}
Since $U$ is convex and $f$ is convex on $U$, convexity gives
\begin{align*}
f(x + tv) \leq (1-t)f(x) + t f(y).
\end{align*}
Subtracting $f(x)$ from both sides and dividing by $t > 0$ gives
\begin{align*}
\frac{f(x + tv) - f(x)}{t} \leq f(y) - f(x).
\end{align*}
Because $f$ is differentiable at $x$, the directional derivative of $f$ at $x$ in the direction $v$ exists and is
\begin{align*}
\lim_{t \downarrow 0} \frac{f(x + tv) - f(x)}{t} = \nabla f(x)\cdot v.
\end{align*}
Taking the limit as $t \downarrow 0$ in the preceding inequality yields
\begin{align*}
\nabla f(x)\cdot (y - x) \leq f(y) - f(x).
\end{align*}
Rearranging gives
\begin{align*}
f(y) \geq f(x) + \nabla f(x)\cdot (y - x).
\end{align*}
[guided]
Assume that $f$ is convex on $U$, and fix two points $x,y \in U$. The goal is to prove that the tangent affine function at $x$ lies below $f$ at the point $y$.
If $x = y$, then the assertion is immediate from the identity
\begin{align*}
f(y) = f(x) = f(x) + \nabla f(x)\cdot (y - x),
\end{align*}
because $y-x = 0$.
Now suppose $x \neq y$. Define $v \in \mathbb{R}^n$ by $v := y - x$. We want to approach $x$ from the direction of $y$, so we consider points of the form $x + tv$ for small positive $t$. Since $U$ is open and $x \in U$, there exists $\delta > 0$ such that the open Euclidean ball $B(x,\delta)$ is contained in $U$. Define
\begin{align*}
\varepsilon := \min\left\{1, \frac{\delta}{2|v|}\right\}.
\end{align*}
Then for every $t \in (0,\varepsilon)$,
\begin{align*}
|x + tv - x| = t|v| < \delta,
\end{align*}
so $x + tv \in B(x,\delta) \subset U$.
The reason for choosing points of the form $x + tv$ is that they are convex combinations of $x$ and $y$:
\begin{align*}
x + tv = x + t(y-x) = (1-t)x + ty.
\end{align*}
Since $0 < t < 1$, convexity of $f$ gives
\begin{align*}
f(x + tv) \leq (1-t)f(x) + t f(y).
\end{align*}
Subtract $f(x)$ from both sides:
\begin{align*}
f(x + tv) - f(x) \leq t(f(y)-f(x)).
\end{align*}
Because $t > 0$, division by $t$ preserves the inequality:
\begin{align*}
\frac{f(x + tv) - f(x)}{t} \leq f(y)-f(x).
\end{align*}
Now differentiability at $x$ converts the left-hand side into the directional derivative in the direction $v$. Since $f$ is differentiable at $x$, its directional derivative along $v$ exists and equals the dot product with the gradient:
\begin{align*}
\lim_{t \downarrow 0} \frac{f(x + tv) - f(x)}{t} = \nabla f(x)\cdot v.
\end{align*}
Taking the limit as $t \downarrow 0$ in the inequality therefore gives
\begin{align*}
\nabla f(x)\cdot v \leq f(y)-f(x).
\end{align*}
Finally substitute back $v = y-x$ and rearrange:
\begin{align*}
f(y) \geq f(x) + \nabla f(x)\cdot (y-x).
\end{align*}
This proves the first-order inequality from convexity.
[/guided]
[/step]
[step:Recover convexity from the first-order inequality]
Assume that, for every $a,b \in U$,
\begin{align*}
f(b) \geq f(a) + \nabla f(a)\cdot (b-a).
\end{align*}
We prove that $f$ is convex. Fix $x,y \in U$ and $\lambda \in [0,1]$. Define the point $z \in U$ by
\begin{align*}
z := (1-\lambda)x + \lambda y.
\end{align*}
The membership $z \in U$ follows from the convexity of $U$.
Apply the assumed first-order inequality with $a=z$ and $b=x$:
\begin{align*}
f(x) \geq f(z) + \nabla f(z)\cdot (x-z).
\end{align*}
Apply it again with $a=z$ and $b=y$:
\begin{align*}
f(y) \geq f(z) + \nabla f(z)\cdot (y-z).
\end{align*}
Multiplying the [first inequality](/theorems/2897) by $1-\lambda \geq 0$, multiplying the second by $\lambda \geq 0$, and adding, we obtain
\begin{align*}
(1-\lambda)f(x) + \lambda f(y) \geq f(z) + \nabla f(z)\cdot\big((1-\lambda)(x-z) + \lambda(y-z)\big).
\end{align*}
By the definition of $z$,
\begin{align*}
(1-\lambda)(x-z) + \lambda(y-z) = (1-\lambda)x + \lambda y - z = 0.
\end{align*}
Hence
\begin{align*}
(1-\lambda)f(x) + \lambda f(y) \geq f(z).
\end{align*}
Substituting $z = (1-\lambda)x + \lambda y$ gives
\begin{align*}
f((1-\lambda)x + \lambda y) \leq (1-\lambda)f(x) + \lambda f(y).
\end{align*}
Since $x,y \in U$ and $\lambda \in [0,1]$ were arbitrary, $f$ is convex on $U$.
[/step]