Lagrange multiplier. What happen when gradient of boundaries is null Suppose that you have to maximize the function $f(x)$ ($f : \mathbb{R} \rightarrow \mathbb{R}$), continuous and differentiable for each $x \in A = \left\{ x  |g(x) =c \right\}$, where $g : \mathbb{R} \rightarrow \mathbb{R}$) is continuous and differentiable.
Suppose now that $x^* \in A$ such that $f(x^*)$ is maximum. From the theory, I know that there exists a $\lambda^*$ such that $(x^*, \lambda^*)$ is a stationary point of the following function:
$$\Lambda(x,\lambda) = f(x) + \lambda\left(g(x) - c\right)$$
$(x^*, \lambda^*)$ is a stationary point of $\Lambda(x,\lambda) $ when the followings are satisfied:
$$\left\{ \begin{array}{l}\frac{\partial \Lambda}{\partial x} = 0 \\ \frac{\partial \Lambda}{\partial \lambda} = 0\end{array}\right. \Rightarrow \left\{ \begin{array}{l}f'(x) + \lambda g'(x) = 0 \\ g(x) - c = 0\end{array}\right.$$
What happen when $f'(x^*) \neq 0$ and $g'(x^*) = 0$? It seems that $(x^*, \lambda^*)$ is not a stationary point since:
$$f'(x^*) + \lambda \cdot 0 = 0 \Rightarrow f'(x^*) = 0 $$
but this is a contradiction!
This situation can be found using $f(x) = x+1$ , $g(x) = x^2$ and $c = 0$.
In this case, the feasible set $A$ is $A = \{0\}$ and $x^* = 0$. But $g'(x^*) = 2x^* = 0$, while $f'(x^*) = 1 \neq 0$.
I think that I'm missing some hypotheses.
 A: First, it's sort of crazy to apply Lagrange multipliers in dimension $1$. But, yes, the hypothesis you're missing is that $\nabla g(x)\ne 0$ (here $g'(x)\ne 0$) for all $x$ in the constraint set. (In general, if there are $m$ constraints $g_1(x)=c_1$, $\dots$, $g_m(x)=c_m$, the hypothesis is that $\nabla g_i(x)$, $i=1,\dots,m$, are all linearly independent for $x$ in the constraint set.)
A: As I'm sure you know, the method of Lagrange multipliers is usually applied for studying functions of many variables, restricted of course to submanifolds.  But you are right to investigate the situation where $f$ and $g$ are each functions of a single variable.  In this case, various things can happen:
(0) Generically, the set $A$ will then consist of isolated points, each of which is then automatically a local extremum of $f|_A$.
(1) A point $x^*\in A$ at which $g'(x^*) = 0$ might be an accumulation point of $A$; if so, a necessary condition for it to be a local extremum of $f$ is that $f'(x^*) = 0$.
(2) Your case concerns a border-line situation between these two.  You are correct that, set theoretically, the set $A=\{x|x^2=0\}$ consists of the unique point $x=0$, which therefore extremizes any function.  But a "better" understanding of $A$ is something more like "two points on top of each other" or "a point with an infinitesimal amount of fuzz around it".  These words can be made precise in various ways, including but not limited to the theory of schemes and the theory of generalized manifolds.  In these settings, the point $x=0$ is not a critical point of $f|_{\{x|x^2=0\}}$ if $f$ is the function $x \mapsto x+1$, since in $A$ "it's possible to move a little bit left or right".
In scheme/generalized manifold/etc theory, situations (1) and (2) would both be ruled out if you demand that "the set $A$ consists of isolated points".  A fairly common requirement in higher dimensions is that "the set $A = \{\vec x|g(\vec x)=c\}$ is a submanifold".  If interpreted in any reasonable generalized framework, this requirement would rule out both cases (1) and (2).  Here are some words that impose this condition.  Let the domain of $f,g$ be $\mathbb R^n$ (so in your case $n=1$); then the set $A$ can be understood as the intersection in $\mathbb R^{n+1}$ of the two embeddings $\mathbb R^n \hookrightarrow \mathbb R^{n+1}$ given by $\vec x\mapsto (\vec x,c)$ and $\vec x \mapsto (\vec x,g(\vec x))$.  In scheme theory, one can require that this be a complete intersection.  In manifold theory, one can require that the intersection is clean.
Of course, these conditions rule out interesting cases.  For example, one might care about the set $A = \{(x,y) | xy = 0\} \subseteq \mathbb R^2$, and critical points thereon.  Note that the point $(0,0)$ has something interesting about it.
So the best answer is probably simply to interpret the method of Lagrange multipliers in one of these generalized frameworks.
