Determine if function is convex I want to determine if the function
$$f(x,y)=e^x+e^y+x^2-2xy+4y^2+2x+3y-8$$
is convex on $\mathbb{R}^2$. Any ideas on how to prove convexity for two variable functions?
 A: You can show that the hessian is positive semi-definite.
A: Firstly, a convex function plus/minus a linear function is convex. So you just need to check if $e^x+e^y+x^2-2xy+4y^2$ is convex. It is because it equals $e^x+e^y+(x-y)^2+3y^2$ is a summation of 4 convex functions.
A: If $u$ and $v$ are convex, so is $u + \lambda v$ for any positive $\lambda.$ Linear functions, constants (negative constants included) and exponential are all convex, so suffices to show $x^2 -2xy+4y^2 = (x-y)^2+3y^2$ is convex, which is obvious (sum of two convex). Is this enough or want a more detailed explanations?
A: $$f(x,y)=e^x+e^y+x^2-2xy+4y^2+2x+3y-8$$
$$\nabla f=\begin{bmatrix}  e^x+2x-2y+2 \\ e^y-2x+8y+3\end{bmatrix} $$
$$\nabla^2 f=\begin{bmatrix}  e^x+2 & -2 \\ -2 & e^y+8\end{bmatrix} $$
Since
$$e^x+2>0$$
and $$(e^x+2)(e^y+8)-2^2=8e^x+2e^y+16-4=8e^x+2e^y+12>0$$
The function is convex.
Another way to see this is to observe that since
$$\nabla^2 f=\begin{bmatrix}  e^x+2 & -2 \\ -2 & e^y+8\end{bmatrix} =\begin{bmatrix}  e^x & 0 \\ 0 & e^y\end{bmatrix}+ \begin{bmatrix}  2 & -2 \\ -2 & 8\end{bmatrix}.$$
Observe that 
$\begin{bmatrix}  2 & -2 \\ -2 & 8\end{bmatrix}$ is positive semidefinite from Gershgorin circle theorem, the eigenvalues lie between $0$ and $10$.
Also, $\begin{bmatrix}  e^x & 0 \\ 0 & e^y\end{bmatrix}$ is positive definite.
Hence $\nabla^2f$ is positive definite.
