Prove that there exists $\delta>0$ such that for all $(x,y)\in S$, if $\|(x,y)\|<\delta$, then $f(x,y)\le f(0,0)$. I need help with this question:

Let $f,g:\mathbb{R}^2\rightarrow\mathbb{R}$ be two $C^2$ functions, and let $S=${$(x,y)\in\mathbb{R}^2:g(x,y)=0$}. Suppose that $g(0,0)=\frac{\partial g}{\partial x}(0,0)=0$ and $\frac{\partial g}{\partial y}(0,0)\neq0$. Also assume that there exists $\lambda \in \mathbb{R}$ such that $\nabla f(0,0)=\lambda\nabla g(0,0)$ and $\frac{\partial^2f}{\partial x^2}(0,0)<\lambda\frac{\partial^2g}{\partial x^2}(0,0)$.
Prove that there exists $\delta>0$ such that for all $(x,y)\in S$, if $\|(x,y)\|<\delta$, then $f(x,y)\le f(0,0)$.

Please, I can't do it.
 A: We can bring $g$ and $f$ into the form
$$g(x,y)=x^2\,h_1(x,y)+y\,h_2(x,y) \qquad f(x,y)=x^2\,k_1(x,y) + y\, k_2(x,y)+\kappa$$
$\kappa \in \mathbb{R}$. $h_1, h_2, k_1, k_2$ are continuous and satisfy the following conditions:
$$h_2(0,0)=\partial_y g(0,0) \neq 0 \qquad k_2(0,0)=\lambda h_2(0,0)\qquad k_1(0,0)<\lambda h_1(0,0)$$
This comes from the following consideration: If $f(x,y)$ is continuously differentiable then
$$f(x,y)-f(0,0)=\int_0^1 dt \frac{df(tx,ty)}{dt}=\int_0^1 dt(x\partial_x+y \partial_y) f(tx,ty)=x\int_0^1dt\partial_x f+y\int_0^1dt\partial_yf$$
By doing this construction again with $\partial_x f$ we get the functions $k_1, k_2$. The conditions follow from comparison with the conditions in the question.

If we make $\delta$ very small, since $h_1,h_2,k_1,k_2$ are continuous we can assume $h_2\neq0$ and $k_1<\lambda h_1$ to hold on an entire ball $B_\delta(0)$. Solutions of $g(x,y)=0$ in the ball then have the form $y=-x^2\frac{h_1(x,y)}{h_2(x,y)}$.
$f$ at this point evaluates to $x^2(k_1(x,y)-h_1(x,y) \frac{k_2(x,y)}{h_2(x,y)})+\kappa$. From continuity, given any $\epsilon$ we can choose a $\delta$ small enough so that $|\frac{k_2(x,y)}{h_2(x,y)}-\lambda|<\epsilon$ (as the expression is zero at $(0,0)$).
So $f$ is smaller than $x^2(k_1(x,y)-\lambda h_1(x,y))+x^2\epsilon+\kappa$. Since $k_1(x,y)<\lambda h_1(x,y)$ the first term is negative. The negative term goes with $x^2 (k_1(0,0)-\lambda h_1(0,0))$ when $\delta$ is very small, whereas $\epsilon$ term goes with $x^2 \epsilon$. By taking $\epsilon$ to be super small, the sum of these two terms will eventually be negative.
So finally $f$ evaluates at the zeros of $g$ to something smaller than a negative term $+ \kappa$, so to something smaller than $f(0,0)$.
A: Implicit Function Theorem is applicable and provides that there exists an $\varepsilon>0$,
and a $C^2-$function $h:(-\varepsilon,\varepsilon)\to\mathbb R$, such that $h(0)=0$ and $g\big(x,h(x)\big)=0$, for all $x\in(-\varepsilon,\varepsilon)$. Also, there exists an open ball $U\subset\mathbb R^2$, with $0\in U$, such that 
$$
U\cap S=\{(x,y): g(x,y)=0\}\subset \mathrm{Graph}(h).
$$
Differentiating $g\big(x,h(x)\big)=0$ we obtain 
$$
g_x\big(x,h(x)\big)+g_y\big(x,h(x)\big)h'(x)=0, \tag{1}
$$
and at $x=0$, since $g_x(0,0)=0$ and $g_y(0,0)\ne 0$, we have that $h'(0)=0$. Differentiating $(1)$, we obtain
$$
g_{xx}\big(x,h(x)\big)+2g_{xy}\big(x,h(x)\big)h'(x)
+g_{yy}\big(x,h(x)\big)\big(h'(x)\big)^2+g_y\big(x,h(x)\big)h''(x)
$$
and setting $x=0$, we obtain 
$$
g_{xx}(0,0)+g_y(0,0)h''(0)=0 \quad\Longrightarrow\quad h''(0)=-\frac{g_{xx}(0,0)}{g_y(0,0)}.
$$ 
Our problem reduces to proving that $x=0$ is a local maximum of $F(x)=f\big(x,h(x)\big)$. 
First, we observe that $F'(x)=f_x\big(x,h(x)\big)+f_y\big(x,h(x)\big)h'(x)$, and thus 
$$F'(0)=f_x\big(0,h(0)\big)+f_y\big(0,h(0)\big)h'(0)=0.$$
Next, differentiating once more we obtain $$
F''(x)=f_{xx}\big(x,h(x)\big)+2f_{xy}\big(x,h(x)\big)h'(x)
+f_{yy}\big(x,h(x)\big)\big(h'(x)\big)^2+f_y\big(x,h(x)\big)h''(x),
$$
and thus 
$$
F''(0)=f_{xx}(0,0)+f_y(0,0)h''(0)= f_{xx}(0,0)-\lambda g_y(0,0)\frac{g_{xx}(0,0)}{g_y(0,0)}=f_{xx}(0,0)-\lambda g_{xx}(0,0)<0.
$$
Which concludes the proof.
