Prove that exists $\delta>0$ such that, if $(x,y)\in S$ satisfies $\lVert(x,y) \rVert < \delta$, then $f(x,y) \leq f(0,0)$. This exercise appeared on my Calculus II exam, and I didn't know even how to start doing it. Any hint is appreciated.
Let $\ f, \ g : \mathbb{R^2}\to \mathbb{R}$ two $C^2$functions over the plane. Let
\begin{equation}
S=\{(x,y)\in \mathbb{R^2} : g(x,y)=0\}.
\end{equation} 
We suppose that $g(0,0)=\frac{\partial g}{\partial x}(0,0)=0$, and $\frac{\partial g}{\partial y}\neq 0$. Also we suppose that
\begin{equation}
\nabla f(0,0)=\lambda\nabla g(0,0)\ 
\end{equation}
and
\begin{equation}
\frac{\partial^2 f}{\partial x^2}(0,0)<\lambda \frac{\partial^2 g}{\partial x^2}(0,0).
\end{equation}
Prove that exists $\delta>0$ such that, if $(x,y)\in S$ satisfies $\lVert(x,y) \rVert < \delta$, then $f(x,y) \leq f(0,0)$.
 A: In the neighborhood of $(0,0)$ the manifold $S$ has a bijective parametric representation of the form
$$S:\quad x\mapsto \bigl(x,h(x)\bigr)$$
with $h(0)=h'(0)=0$. Consider any function $p:\>(x,y)\mapsto p(x,y)\in{\mathbb R}$ defined in a neighborhood of $(0,0)$ and its pullback to $S$ defined by
$$\hat p(x):=p\bigl(x, h(x)\bigr)\ .$$
Using the chain rule we have
$$\hat p'(x)=p_{.1}\bigl(x, h(x)\bigr)+p_{.2}\bigl(x, h(x)\bigr)h'(x)\ ,$$
and differentiating once more gives
$$\hat p''(x)=p_{.11}\bigl(x, h(x)\bigr)+2p_{.12}\bigl(x, h(x)\bigr)h'(x)+p_{.22}\bigl(x, h(x)\bigr)h'^2(x)+p_{.2}\bigl(x, h(x)\bigr)h''(x)\ .$$
We now put $x:=0$ here and obtain
$$\hat p''(0)=p_{.11}(0, 0)+p_{.2}(0,0)h''(0)\ .\tag{1}$$
When $p=g$ then by definition of $S$ we have $\hat p(x)\equiv0\ ,$
and $(1)$ gives
$$0=g_{.11}(0,0)+g_{.2}(0,0)h''(0)\ .\tag{2}$$
We now put $p:=f$ in $(1)$ and obtain
$$\hat f''(0)=f_{.11}(0, 0)+f_{.2}(0,0)h''(0)\ .$$
From $\nabla f(0,0)=\lambda \nabla g(0,0)$ and $(2)$ it then follows that
$$\hat f''(0)=f_{.11}(0, 0)-\lambda g_{.11}(0,0)\ .$$
Therefore, if $f_{.11}(0, 0)-\lambda g_{.11}(0,0)<0$ it follows that $\hat f$ has a strict local maximum at $x=0$, which implies that $f\restriction S$ has a strict local maximum there.
