Necessary condition for local maximum Let $\Omega\subset \mathbb{R}^n$ open, bounded and let $f:\Omega\to\mathbb{R}$ be a $C^2$-function.
I want to prove: Necessary for a interior maximum $x_0\in\Omega$ is that $D^2f(x_0)$ is negative semidefinite. 
I'm stuck, I want to know how to finish my proof.
First case: Suppose that $x_0\in \Omega$ is a maximum and $D^2f(x_0)$ is positive definite. This means, there is a nonzero vector $v$ such that $v^TD^2f(x_0)v>0$. Consider $g(t)=f(x_0+tv)$. $g$ has local minimum at $t=0$ which is a contradiction that $f$ has a maximum at $x_0$. Therefore $D^2f(x_0)$ can't be positive definite. 
Second Case: Suppose that $x_0\in \Omega$ is a maximum and $D^2f(x_0)$ is indefinite. This means the maximum $x_0$ is a saddle point too,  this is a contradiction.
I'm stuck on the third case. Suppose that $x_0\in \Omega$ is a maximum and $D^2f(x_0)$ is positive semidefinite. How do you get a contradiction here? 
 A: It might be that there is no contradiction in the third case.
Namely, it can happen that $D^2f(x_0)$ is zero and therefore positive semidefinite and positive semidefinite.
You don't really have to work by cases.
A matrix $A$ being negative semidefinite means that for all $v$ you have $v^TAv\leq0$.
If this is not the case, then there is some $v$ for which $v^TAv>0$.
And you know how to get a contradiction from here.
A: You don't even have to argue by contradiction. Start from Taylor's formula at order $2$:
\begin{align*}
f(x_0+h,y_0+k)&=f(x_0,y_0)+Df(x_0,y_0)\cdot (h,k)+ \frac 12D^2f(x_0,y_0)\cdot (h,k)+o\bigl(\bigl\lVert(h,k)\bigr\rVert^2\bigr)\\
&=f(x_0,y_0)+ \frac 12D^2f(x_0,y_0)\cdot (h,k)+o\bigl(\bigl\lVert(h,k)\bigr\rVert^2\bigr)
\end{align*}
since at an interior local extremum, the linear form $Df(x_0,y_0)=0$.
Hence, if the quadratic form $D^2f(x_0,y_0)$ is positive semi-definite, $f(x_0+h,y_0+k)\ge f(x_0,y_0)\;$ in a small neighbourhood of $(x_0,y_0)$, i.e. we have a local minimum.
Similarly, if it is semi-definite negative $f(x_0+h,y_0+k)\le f(x_0,y_0)\;$ we have a local maximum. 
Finally if the quadratic form is not semi-definite, we have a saddle point.
