How to use Lagrange Multipliers, when the constraint surface has a boundary?

The method called Lagrange Multipliers is used to find critical points of $f(x_1,x_2,\ldots,x_n)$, when $f$ is constrained to the level set $S = \{ x\in \mathbb{R}^n \, | \, g(x_1,x_2,\ldots,x_n)=0 \}$. These critical points may be used to locate local minima and maxima.

When $S$ is a compact set, we know that a global max and min of $f$ exist on $S$.

Do we also have to check what happens on the boundary of $S$, in case a boundary exists ?

-
What do you mean by the boundary of $S$? –  gerw Jun 7 '13 at 12:44
Yes. There are simple examples where the global max occurs at a boundary point, and often (even if we extend the critical point method to the closed constraint region) such a global max point is not a critical point of the objective function. –  coffeemath Jun 7 '13 at 12:48

Another example to supplement that of Sharkos: $f(x,y)=x+y$ and $g(x,y)=\sqrt{x}+\sqrt{y}-1.$ Then the only critical point found by LaGrange is at $(1/4,1/4)$ where $f=1/2$, but the max of $f=1$ occurs at both points $(1,0),(0,1)$. The constraint region here is the inwardly bent curve $y=(1-\sqrt{x})^2$ for $0 \le x \le 1$ and has $(1,0),(0,1)$ as its boundary points.

ADDED: Teddy has in a comment noted that when $\nabla g$ is not defined, one considers that to be a critical point. So here is another example, similar to the above, which avoids that issue. Let $f(x,y)=x+y$ and $g(x,y)=x^{3/2}+y^{3/2}-1$. Note that the implicit radicals in the constraint impose that $x,y \ge 0$, and that this means we have $$\nabla g = ((3/2)x^{1/2},(3/2)y^{1/2}),$$ which exists and is nonzero at all points on the constraint curve (it's the zero vector only at the origin, clearly not on the constraint curve).

In this case the constraint curve is the graph of $y=(1-x^{3/2})^{2/3}$ on the interval $[0,1]$, having endpoints at $(1,0),(0,1)$, and the graph bends outward away from the origin. There is now only one critical point at $(x,y)=(a,a)$ where $a=(1/4)^{1/3}$. At that point, $f=2^{1/3}\approx. 1.259$, while at the "boundary of constraint region" points $(1,0),(0,1)$ we have $f=1$. So if we seek the minimum we would have to look at the boundary points of the constraint region, at non-critical points.

-
Thank you for your answer. It seems, however, that the boundary points you mention are critical points, by virtue of the fact that $\nabla g$ is undefined there. (See, e.g. Susan Colley, Vector Calculus 4th ed., p. 280) Hence this does not demonstrate the need to separately check the boundary. –  Teddy Jun 8 '13 at 20:53
@Teddy -- The two gradients are not parallel there, but I see your point, since if one of the gradients doesn't exist it doesn't make sense to check parallelism. I'll try for another example. –  coffeemath Jun 9 '13 at 1:23
@Teddy -- Just added a hopefully better example, where the gradient does exist everywhere on the constraint curve. Of course it doesn't exist in a neighborhood of the boundary points, but that is unavoidable by definition of boundary. –  coffeemath Jun 9 '13 at 2:28

Yes. For example, $f(x,y) = x^2+y^2$ and $g(x,y)=|x|+|y|-1$. Then $S$ is a series of smooth lines joined at sharp corners. The maxima are attained at these corners. You can make a more convoluted $g$ to make these corners just ends.

-