Finding maxima and minima of two dimensional function The procedure for doing this usually goes as follows:


*

*Find the critical points of the function,

*Check which ones are in the region,

*Find critical points of the function on thr boundary,

*Compare the value of the function at each one of these points and choose the largest to be the maximum and smallest to be the minimum.


My question is: why do we claim this method works? It could very well be that the function restricted to the boundary has a minimum, but this point is neither a local minimum nor maximum on the region. Take for example $f(x,y)=y^2+1−\frac{1}{1+x}$on the right half plane. It is obvious that this function will have a minimum on the y-axis, but this point will not be a minimum on the region. 
My question arose from reviewing some multivariable calculus. The problem in question was to find the maxima and minima of $f(x,y)=x^2+y^2+2x+4y-1$ on the closed region above the diagonal $y=-x$. It is easy to find that $\nabla f =0$ at $(-1,-2)$. Since this point is not within the region, we restrict $f$ to the diagonal and find that its minimum over this boundary occurs at $(1/2,-1/2)$. In the answer sheets, the instructor claims this is a minimum for the function over the whole region, however I find this claim rigorously unjustified. How do we know whether or not there is some other point on which $f$ is smaller?
I tried to prove this formally by assuming that such a point, say $\vec x$ exists, then defining a "gradient descent" sequence $S=\{\vec x_n\}$ as follows:
$$ \vec x_0=\vec x$$
$$ \vec x_{n+1}= \vec x_n-\nabla f(x_n)$$
Since $f$ grows to infinity in all directions, it seems intuitive that $S$ should be bounded, at which point the result is proven. 
It is also very possible I am missing something obvious. Any help is appreciated.
 A: If a function $f : D \to \Bbb R$ from a closed and bounded domain $D$ and is everywhere differentiable, then a maxima or minima must occur at a point where $\nabla f = 0$, for if not then for $x$ with $\nabla f(x) \ne 0$ we would have  $f(x + \epsilon \nabla f) = f(x) + \epsilon \nabla f \cdot \nabla f + O(\epsilon^2)$, which is $\ge f(x)$ for sufficiently small $\epsilon$. Thus any minimizer $x$ of $f$ must either satisfy $\nabla f(x) = 0$ or $x$ must be on the boundary. We may thus enumerate the critical points in the region and on the boundary, and since the absolute maxima and minima must be a local maxima or minima, among them is our absolute maximum and minimum.
The problem with rigor comes when the function is defined on a region which is unbounded. In this case, the function is not guaranteed to have an absolute minimum. If it does have an absolute minimum, then the minimizer $x$ must satisfy $\nabla f(x) = 0$ or be on the boundary, as is argued above. If there is no absolute minimum, then this method tells you nothing.
