# Testing a (numerical) matrix for positivity

I’ve been testing certain randomly-generated $6 \times 6$ symmetric (and also Hermitian) matrices ($H)$ for positive definiteness, using the command ($n$, of course, being a count variable),

If[Sign[Eigenvalues[H]] == {1, 1, 1, 1, 1, 1}, n = n+1]


I also found some earlier programs of mine in which I used instead

If[Min[Chop[Eigenvalues[H]]]>0, n = n+1]


for presumably the same purpose. (I think my use of the Chop command, then, was motivated by the concern [possibly unfounded] that the eigenvalues might be evaluated as having small imaginary parts, even though theoretically they should be just be real-valued.)

The two sets of results generated seem somewhat slightly, but surprisingly to me different in the proportions of matrices found that satisfy the If conditions. (Since the older set was generated about a year ago, with various intermediate steps being involved, I find it hard at this point to be 100% confident in its full validity, though.) I would be able to specify these differences in the proportions found in both the symmetric and Hermitian cases.

Given the two different If statements indicated, is there any basis for thinking the results generated might tend to be somewhat different (and in what manner)? In any case, would another form of If command be most appropriate for such positivity-testing purposes?

By way of further explanation/background, the matrices $H$ to be tested for their positivity are generated in the following manner. A $6 \times 7$ matrix $J$ of random normal variates

Array[RandomVariate[NormalDistribution[0, 1]] &, { 6, 7}]


is formed. Then, we compute $J.J^{T}$ (“Ginibre ensemble”). This is followed by the transposition in place of the four $3 \times 3$ blocks of $J$ (or, equivalently for positivity testing purposes, interchanging the two-off diagonal $3 \times 3$ blocks). This “partial transposition” operation gives us $H$, the positivity of which we want to assess. (This series of steps pertains to the quantum-information problem of determining the “separability probability” of “re[a]bit”-“re[al]trit” density matrices. The Hermitian counterpart--where the starting matrix $J$ is $6 \times 6$--involves the somewhat more familiar "qubit-qutrit" density matrices.)

Additionally, since I want to estimate the separability probability as effectively as possible, I wonder whether or not I should be increasing the precision of the normal random variates I employ in creating $J$. (I recall there being some such option to do so.) Presumably, if I did so the number of realizations generated of $J$ and $H$ for testing would diminish.

Let me also note that in the $4 \times 4$ (two-rebit/two-qubit) counterparts of these $6 \times 6$ problems, the corresponding separability probabilities have been found--after much intensive investigation-to have simple rational values ($\frac{29}{64}, \frac{8}{33},\ldots$) (https://arxiv.org/abs/1701.01973, to appear in Quant. Info. Proc.). So, of course, it is of interest to determine their higher-dimensional counterparts.

• Have to tried PositiveDefiniteMatrixQ? – Henrik Schumacher Feb 23 '18 at 18:39
• If you do get small complex values, then the first one will not show equality whereas the second one will. For instance: Sign[1 + 0.000000001 I] is not equal to 1. – bill s Feb 23 '18 at 19:06
• Per the comment of Henrik Schumacher--the PositiveDefiniteMatrixQ command (of which I was not immediately) aware and the If[Sign[Eigenvalues[H]] == {1, 1, 1, 1, 1, 1}, n = n+1] seem to be in complete agreement--based on several million matrices generated in both the Hermitian and symmetric cases. Now, I need to check on how this relates to the other If command indicated. – Paul B. Slater Feb 24 '18 at 6:40