[Math] Hessian to show convexity – check the approach please

convex-analysismatricespartial derivative

I need to check the convexity of $f(x)$ for these two questions, using the Hessian matrix. I am aware the function can be said to be convex if over the domain of $f$ the hessian is defined and is positive semidefinite.

First question: $$f(x) = \begin{cases}
x_1x_2 & x\in \mathbb{R}^n_+ \\
+\infty & otherwise
\end{cases}
$$
then the hessian:
$$H = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} $$

So this has eigenvalues $$\lambda_1 = \lambda_2 = 0 $$
Does this mean the matrix can be called positive-semidefinite? Can we conclude $f(x)$ is convex?

Second question:
$$f(x) = \begin{cases}
\frac{x_1^2}{x_2} & x\in \mathbb{R} \times \mathbb{R}_{++} \\
+\infty & otherwise
\end{cases}$$

$$H = \begin{pmatrix} \frac{2}{x_2} & \frac{-2x_1}{x_2^2} \\ \frac{-2x_1}{x_2^2} & \frac{2x_1^2}{x_2^3} \end{pmatrix} $$

since $\lambda_1, \lambda_2 >0$ can we conclude $f(x)$ again is convex? I have read my notes and textbooks carefully, but am unsure what specifically is meant by a positive definite matrix, and in regards to question 1, if the eigenvalues are both 0, does this satisfy being positive definite and result in convexity?

Have I approached these questions correctly?

Best Answer

This answer addresses the first question.

A real-valued, symmetric matrix is positive-semidefinite if and only if all its eigenvalues are nonnegative -- $0$ counts, no matter how many times it occurs.

Also, positive-semidefiniteness everywhere of the Hessian is equivalent to convexity; see this Math.SE question. Hessian matrices of real-valued $C^2$ functions are symmetric. So $0$ eigenvalues do count in this equivalence too; if your computation was correct, then the first function would be convex.


However, your first eigenvalue computation is incorrect. Indeed, we see that

$$H \begin{pmatrix} 1 \\ -1 \end{pmatrix} = \begin{pmatrix} -1 \\ 1 \end{pmatrix} = (-1) \begin{pmatrix} 1 \\ -1 \end{pmatrix},$$

so there is an eigenvalue of $-1$. Also, there is an eigenvalue of $1$, since

$$H \begin{pmatrix} 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 \\ 1 \end{pmatrix}.$$

Since the number of eigenvalues is less than or equal to the dimension, we have eigenvalues of $\pm 1$.

[How did I magically create these eigenvectors? Well, I saw that $H^2 = I$, so I figured the constants were nice, and since the matrix looks like a reflection over the axis $x_1 = x_2$ (i.e., changing the roles of $x_1$ and $x_2$), I figured the lines $x_2 = x_1$ and $x_2 = -x_1$ would be relevant.]

Regarding the "usual" method of characteristic polynomial for finding the eigenvalues, I get the equation for $\det (\lambda I - H ) = 0$ of $$\lambda^2 - 1 = 0.$$ Did you make a computational error here?

In any event, with the correct computation, the first function is not convex. [Geometrically, if you are familiar with convexity of one-dimensional functions, if you let $x_2 = -x_1$, you get $g(x_1) \overbrace{=}^{defined} f(x_1, -x_1) = - x_1^2$, which shows a ``concave down'' effect].


P.S. Since for diagonalizable matrices (including real symmetric matrices), the determinant of the matrix is the product of the eigenvalues, and the determinant of your second matrix is 0 (I think), you should have at least one zero eigenvalue. You should double-check that the other eigenvalue is positive.