We determine the extrema of $z(x,y)=5x-x^2-y^2+xy$.
- $z'_x(x,y)=5-2x+y$,
- $z'_y(x,y)=-2y+x$.
$z'_y(x,y)=0$ gives $x=2y$. We plug this into $z'(x,y)=0$, which gives $5-2(2y)+y=5-3y=0$. Hence, $y=\frac{5}{3}$ and $x=2y=2\frac{5}{3}=\frac{10}{3}$.
Hence, the stationary point is $(x,y)=(\frac{10}{3},\frac{5}{3})$.
- $z''_{xx}=-2$,
- $z''_{yy}=-2$,
- $z''_{xy}=1$.
Hence, $C(x,y)=-2\cdot -2 -1^2=3$. Since $C(\frac{10}{3},\frac{5}{3})=3>0$ and $z''_{xx}=-2<0$ it holds that $z(\frac{10}{3},\frac{5}{3})=8\frac{1}{3}$ is a maximum.