# Why is it insufficient to say that a symmetric matrix A is positive semidefinite if it has non-negative diagonals?

Say we have a symmetric matrix $$A \in R^{n\times n}$$ with all non-negative diagonals.

Then, to my understanding, $$\operatorname{trace}(A) = \sum_{i=1}^n A_{ii} = \sum_{i=1}^n \lambda_i \ge 0$$

Because $$A$$ is symmetric, by the spectral decomposition theorem it can be written as $$A = UDU^T$$ where U is an orthogonal matrix with the eigenvectors of A as columns and $$D = \operatorname{diag}(\lambda_1, \lambda_2, ... , \lambda_n)$$.

We know that the condition for $$A$$ to be PSD is $$x^TAx\ge0$$ for any $$x\in R^n$$. Then $$x^TUDU^Tx \ge 0$$

If we define vector $$y=U^Tx$$, this becomes $$y^TDy\ge0$$ or $$x^TAx=\sum_{i=1}^n\lambda_iy_i^2$$

Because we established above that $$\sum_{i=1}^n\lambda_i\ge0$$ and we know that $$y_i^2\ge0$$ for all $$i=1,\ldots,n$$, we know that the above expression for $$x^TAx$$ must be $$\ge0$$ and thus matrix A is PSD.

What am I missing? Why isn't this sufficient to show that $$A$$ is PSD?

Thank you so much.

• You only know that the sum of the eigenvalues is non-negative, but not the individual eigenvalues. Take, for example, $A=\begin{pmatrix}1&2\\2&1\end{pmatrix}$. The sum of the eigenvalues is $1+1=2$, but the product of the eigenvalues, the determinant, is $-3$. For this matrix, if you take $x=(-1,1)^T$, then $Ax=-x$, then $x^TAx=-\|x\|^2=-2<0$.
– user752802
Feb 25, 2020 at 18:46

Suppose that $$\lambda_1=-1$$ and that $$\lambda_2=2$$. Then $$\lambda_1+\lambda_2=1\geqslant 0$$. However,$$\lambda_1\times3^2+\lambda_2\times1^2=-1<0.$$So, no, it doesn't follow from $$\lambda_1+\lambda_2+\cdots+\lambda_n\geqslant0$$ that you always have$$\lambda_1y_1^{\,2}+\lambda_2y_2^{\,2}+\cdots+\lambda_ny_n^{\,2}\geqslant0$$