# What is the best way to produce a symmetric semi-definite matrix using as few variables as possible?

As we know, there are only $\frac{n(n+1)}{2}$ variables in a symmetric $n$-dimensional semi-definite matrix. Is it possible to produce a $n$-dimensional semi-definite matrix whose trace is $1$ using only $\frac{n(n+1)}{2}-1$ variables, $\frac{n(n+1)}{2}$ from symmetry and one from the trace constraint?

If so, what is the best way?

Till now, I can produce a $n$-dimensional semi-definite matrix $\rho$ whose trace is $1$ in the way

t = ({
{a, b, c, d},
{e, f, g, h},
{i, j, k, l},
{m, n, o, p}
});
ρ = t.t\[Transpose]/Total[Flatten[t]^2];


but I need $n^2$ variables and sometimes Total[Flatten[t]^2] may be zero because of semi-definiteness. Any help or suggestions will be appreciated.

• Here is a possible approach. (1) Pick the elements above the main diagonal. (2) Symmetrize (so the main diagonal is zeros). (3) Now pick the main diagonal elements to be at least as large as the sums of absolute values of the rest of elements on their respective rows. (4) Normalize (divide the matrix by the sun of the main diagonal elements). This will give pos semidef matrices although by no means will it give all such matrices. Aug 16, 2013 at 15:18
• Possibly related: Constructing a symbolic Hermitian matrix. But usually positive semi-definiteness means that the eigenvalues have to be non-negative. Is that what you're actually after? Does the parametrization have to produce just some such matrices or all of them?
– Jens
Aug 16, 2013 at 19:37
• @Daniel Lichtblau All of them. Thanks! Aug 17, 2013 at 2:32
• @Jens All of them, thanks! Aug 17, 2013 at 2:32

Use a lower-triangular t:

t = {
{a, 0, 0, 0},
{b, c, 0, 0},
{d, e, f, 0},
{g, h, i, j}};
p = # / Tr@# & [t.Transpose@t];

• Thanks a lot! Since this is not the direct way, it may be not so fast. Aug 17, 2013 at 2:36
• @EdenHarder It seems very fast to me. What do you mean by "not direct?"
– Jens
Aug 17, 2013 at 6:53
• @Jens 'Direct' means we produce it without any other matrice, for example, 't' here. Aug 17, 2013 at 7:24