# Continuous function in a non-empty set

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$?

• Are there any constraints on the type of set $K$ is? – Bernard W Sep 17 '17 at 8:57
• The assertion may not be true. If we set $K$ to be the closed unit ball in $\mathbb{R}^2$ and $f(x,y)=e^{\frac{1}{1-x^2-x^2}} (1>x^2+y^2), f(x,y)=0 (1=x^2+y^2)$ then $f$ meets the requirement yet his derivative never vanishes in the interior points of $K$ – Arundo Donax Sep 17 '17 at 8:58
• I'm sorry I forgot it... K is compact – shot22 Sep 17 '17 at 8:59
• If both maximum and minimum are in $\partial K$, according to the assumptions, the maximum and minimum values of $f$ are the same. – Gribouillis Sep 17 '17 at 9:02
• @ArundoDonax you probably meant $f(x,y) = e^{\frac{1}{1-(x^2+y^2)}}$ and $0$ on the boundary. I get that $\nabla f(0,0) = (0,0)$ though. – Henno Brandsma Sep 17 '17 at 9:37

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.