I have to prove that if $K \subset \mathbb{R}^n$ is a compact non-empty set, $\operatorname{int} K \ne \emptyset$ and $f:K\to\mathbb{R}$ is a function s.t.
i) $f$ is continuous in $K$
ii) $f$ is differentiable on $\operatorname{int} K$
iii) $f$ is constant on $\partial K$
at least exists one point $x\in \operatorname{int} K$ s.t. $\nabla f(x) = 0$.
I thought that if there is a maximum or a minimum in $\partial K$, since $f$ is constant in $\partial K$ there must be a maximum or a minimum in $\operatorname{int} K$. But then I also thought, what would it mean if we have both maximum and minimum in $\partial K$?
If $K$ is compact then, by continuity, $f$ attains a maximum value at $x_M\in K$ and a minimum value at $x_m\in K$. If $f$ is not identically constant in $K$ (otherwise the gradient of $f$ is identically 0 in $\mbox{int}(K)$) then $f(x_M)>f(x_m)$ because $f$ is identically constant in $\partial k$. Therefore it can't happen that $x_M,x_m\in\partial K$. Hence at least one of them is in $K\setminus\partial K=\mbox{int}(K)\not=\emptyset$. At such point the gradient of $f$ is zero.