Let $E \in \mathbb{R}^n$ be compact. For simplicity, let's say $E$ is a closed ball. Let $f$ be a smooth function $f: \mathbb{R}^n \rightarrow \mathbb{R}$. We know that global maximum exists in $E$, and it is either on $\partial E$ or in $E^o$. Then, is the following true?
If global maximum takes place at $p \in E^o$, then $p$ must be a critical point, i.e. $Df(p) = 0$.
I think this is false as I've seen some examples that a function with a unique local extrema (wlog take min) with unique critical point fails to attain global minimum at this point, given that the function is defined in open set. (Unique critical point does not imply global maximum/global minimum) Things get really rough in $\mathbb{R}^n$, and I would appreciate if you all can provide some insight!