= Solution
Let $C=\operatorname{conv}\{a,b\}$. Maximizing a linear functional over this line segment occurs at an endpoint, so
$$
f(x)=\sigma_C(x)=\sup_{p\in C}\langle p,x\rangle.
$$
This identifies $f$ as a <support function>. Its <convex conjugate> is the <indicator functional> $\delta_C$: if $p\in C$, then $\langle p,x\rangle-\sigma_C(x)\leq0$ for every $x$, with equality at zero; if $p\notin C$, strict separation and positive scaling of the separating vector make the supremum infinite.
For a <convex function>, equality in the <Fenchel–Young inequality> characterizes its <subdifferential>. Hence
$$
p\in\partial f(x)
\iff p\in C\ \text{and}\ \langle p,x\rangle=\sigma_C(x).
$$
This is <support-function subgradients as exposed faces>. In particular a maximizing $p$ really is a <subgradient>, since $\sigma_C(z)\geq\langle p,z\rangle=f(x)+\langle p,z-x\rangle$ for every $z$.
Writing $p=ta+(1-t)b$, with $0\leq t\leq1$, now gives
$$
\boxed{\partial f(x)=
\begin{cases}
\{a\},&a^Tx>b^Tx,\\
\{b\},&b^Tx>a^Tx,\\
\operatorname{conv}\{a,b\},&a^Tx=b^Tx.
\end{cases}}
$$
If $a=b$, the last line is the singleton $\{a\}$, so the formula includes that case.
Back to article page