# Are all second partial derivatives of $f(x,y)$ nonpositive at local maximum at $x$ when $f$ is $C^2$?

Let $f$ be a real-valued $C^2$ function in $\mathbb{R}^2.$ By Second partial derivatives, we know that if the Hessian is negative definite (equivalently, has all eigenvalues negative) at a, then $f$ attains a local maximum at a.

My question is about necessary condition for local maximum.

One of necessary conditions for local maximums is that its Hessian is negative semidefinite.

I was wondering if the following is true:

If $f$ is $C^2$ and has a local maximum at $x,$ then all second partial derivatives at $x$ are nonpositive.

Please let me know if you have any comment of it. Thanks in advance!

No, this is not correct. If $f(x,y)=2xy-x^2-y^2$, then $f(x,y)\leq f(0,0)$ for all $x,y$, but $\frac{\partial^2f}{\partial x\partial y}(0,0)=2>0$.