# Explain Lagrange multipliers?

I am having serious issues with comprehension of this method. In particular, I don't understand the conditions. Thus far, I think it's something like;

Given an objective $f: A \to \mathbb{R}^1$ and a constraint $g: A \to \mathbb{R}^1$, wherein $C = \{ x \in A | \,\, g = 0 \}$ is the constraint region, such that $f, g$ have continuous partial derivatives in $C$ and if $\nabla g \not= 0$ on $C$, then we have $\nabla f = \lambda \nabla g$ at any local maximum or minimum constrained to $C$.

Now, what I don't understand is how to deal with the problem of global maxima constrained to $C$, or why $C$ has to be compact (and does $A$ need to be compact)?

And, $C$ has to be an open set, correct? As Lagrange multipliers does not give extrema on the boundary $\partial C$?

(An example illustrating this would be helpful).

You are given an open set $\Omega\subset{\mathbb R}^n$, a $C^1$ objective function $f:\>\Omega\to{\mathbb R}$, and a $C^1$ constraint function $g:\>\Omega\to{\mathbb R}$. This $g$ is used to define an $(n-1)$-dimensional hypersurface $$C:=\{x\in\Omega\>|\>g(x)=0\}\subset\Omega\ ,\tag{1}$$ where it is assumed that $\nabla g(x)\ne0$ for all points $x\in C$.
The points $x$ you are interested in form a certain explicitly defined subset $D\subset C$ (which can be all of $C$). You want to know $\max_{x\in D} f(x)$. When $D$ is, e.g., compact you know for sure that this $\max$ is taken at some point $\xi\in D$, in other cases some qualitative argument can make it obvious that such a point $\xi\in D$ exists.
Now comes Lagrange's method: If such a point $\xi$ is in the relative interior of $D$, which means that $(1)$ is the only restriction when moving from $\xi$ to nearby points in $D$, then $\xi$ will be brought to the fore by Lagrange's method. But when $D$ has a boundary $\partial D\subset C$ given by extraneous conditions then a maximum point $\xi$ which happens to lie on $\partial D$ will not be exposed by this method. In fact, it will be necessary to look at $f$ on $\partial D$ in detail, even if you already have found a conditionally stationary point $\xi$ in the relative interior of $D$.