Convex Sets and Functions I've been trying to hone my calculus skills and i came upon this question that i can't seem to solve:
Let $K\subset\mathbb{R}^n$ be a convex set and $f : K \to \mathbb{R}$ a convex function. Show that every local minimizer of $f$ in $K$ is a global minimizer.
 A: Suppose that $\overline{x}$ is a local minimum which it is not a global minimum. Then:


*

*Exists $\epsilon > 0$ such that, for all $x \in B(x,\epsilon) \cap K, f(\overline{x}) < f(x)$.

*Exists $y \in K$ such that $f(y) < f(\overline{x})$.


Since $K$ is convex, for all $\lambda \in [0,1], z_{\lambda} = \lambda \overline{x} + (1 - \lambda)y \in K$. Also, for all $\lambda \in [0,1),$
$f( z_{\lambda}) = f(\lambda \overline{x} + (1- \lambda)y) \leq \lambda f( \overline{x})  + (1- \lambda)f(y) <  \lambda f( \overline{x})  + (1- \lambda)f(\overline{x}) = f(\overline{x})$.
So, if we take $\lambda$ enought close to 1, we will have $z_{\lambda} \in B(x,\epsilon) \cap K$ and $f( z_{\lambda}) < f( \overline{x})$ which contradicts that $\overline{x}$ is a local minimum.
A: Suppose $x_0$ is a minimum which is not global, and let $x_1$ be the global minimum. What happens then when you use the fact that $f$ is convex?
A: There is a super-easy solution in the case of differentiable $f$. Differentiable convex functions satisfy a property: their graph is always above the supporting hyperplanes to any of its points. Analytically this means that 
$$
f(x+h)\ge f(x)+ \nabla f(x)\cdot h,\qquad \forall x\in K\, \text{such that }x+h\in K.$$
At a local minimizer $x$, necessarily $\nabla f(x)=0$, and so 
$$
f(x+h)\ge f(x).$$ 
Since $K$ is convex, every $y\in K$ can be written as $y=x+h$ for some $h\in\mathbb R^n$. Therefore, this proves that $x$ is a global minimizer.
The advantage of this proof is that it is geometrically very vivid. See this picture found with a net search: the graph of a convex function lies above the hyperplane tangent to any of its points. At a local minimizer, the hyperplane must be horizontal because derivatives vanish at local extremizers: this is Fermat's principle. This means that the graph of the convex function lies above the value that it attains at the local minimizer; otherwise said, the local minimizer is global.

OPTIONAL 
This argument can be extended to non-differentiable convex functions, but it is clearest after the introduction of a new definition. If $f\colon K\to\mathbb R$ is convex, and if $x\in K$, the sub-differential of $f$ at $x$ is the set 
$$
\partial f(x)=\{ v\in \mathbb R^n\ :\ f(x+h)\ge f(x)+v\cdot h,\quad \forall h\in\mathbb R^n\ \text{such that }x + h\in K\}.$$ 
The function $f$ is differentiable at $x$ if and only if $\partial f(x)$ is reduced to a singleton. It is immediate that 
$$
x\text{ is a global minimizer }\Leftrightarrow 0\in \partial f(x).$$ 
So to prove the desired property of convex functions it suffices to show that, if $x$ is a local minimizer, then $0\in \partial f(x)$, which is a generalization of Fermat's principle. In the differentiable case, Fermat's principle is proved by noting that the gradient of $f$ at $x$ only depends on the values of $f$ in a neighbourhood of $x$. The same holds for sub-differentials:
Property. Let $K\subset \mathbb R^n$ be open and convex. Suppose that $f\colon K \to \mathbb R$ is convex. If $B$ is an open ball centered at $x$ then 
$$\partial f(x)=\partial \left(\left.f\right|_B\right)(x).$$
Sketch of proof. By translation we may assume that $x=0, f(0)=0$. It is clear that $\partial f(x)\subset \partial \left(\left.f\right|_B\right)(x),$ so we only need to prove the opposite inclusion. Now, $v\in\partial f(0)|_B$ if and only if 
$$\tag{1}f(h)\ge v\cdot h,\quad \forall h\in B. $$ 
If $k\in K$, we can consider $k=\lambda h$, where $\lambda>0 $ is such that $h\in B$. By convexity of $f$ we have the inequality 
$$f(h)\le \frac1\lambda f(k), $$ 
so we get from (1) 
$$\frac1\lambda f(k)\ge f(h)\ge v\cdot h=\frac{1}{\lambda} v \cdot k.$$
Simplifying $\frac{1}{\lambda}$ we show that $v\in \partial f(0)$, as claimed. $\square$
Once this property has been established, we immediately have that $0\in \partial f(x)$ if $x$ is a local minimizer of $f$, because such a local minimizer is a global one on an appropriate restriction. This proves that local minimizers are global.
