What is a good way to generate algebraic constraints that ensure matrix be positive definite? Ideally, I'd be able to do something like below
Solve[# \[Element] Reals & /@ Eigenvalues[A]]
However, this doesn't directly work. Practical example below uses this to find the norm of a positive linear operator (related issue). It works, but requires AposDefiniteConstraints
to be specified manually which I'd like to avoid.
(also tried Thread[Eigenvalues[X] > 0]
suggestion from Find minimum with matrix positive-definiteness constraint but I get Maximize
returning unevaluated)
(* Find norm of a positive transformation of a positive definite \
d-by-d matrix *)
SeedRandom[1];
d = 2;
symmetricMatrix[d_] := Array[a[Min[#1, #2], Max[#1, #2]] &, {d, d}];
extractVars[mat_] := DeleteDuplicates@Cases[Flatten@A, _a];
(* using built-in Norm/Simplify too slow, use this helper instead *)
norm[A_] :=
Max[x /. # & /@ Solve[CharacteristicPolynomial[A, x] == 0, x]];
A = symmetricMatrix[d];
Avars = extractVars[A];
B = Mean[#\[Transpose].A.# & /@
Table[RandomReal[{-1, 1}, {d,
d}], {d^2}]]; (* random positive transformation of A *)
normA =
norm[A];
normB = norm[B];
AposDefiniteConstraints =
a[1, 1]^2 + 4 a[1, 2]^2 - 2 a[1, 1] a[2, 2] + a[2, 2]^2 >= 0 &&
a[1, 1]^2 + 4 a[1, 2]^2 - 2 a[1, 1] a[2, 2] + a[2, 2]^2 >= 0;
Maximize[{normB, normA < 1,
AposDefiniteConstraints}, Avars] (* => {0.7853700810760375`,{a[1,1]\
\[Rule]0.999855037823971`,a[1,2]\[Rule]0.00017274783320670866`,a[2,2]\
\[Rule]0.9997941436806035`}} *)
```
(Tr[M]^2/Tr[MatrixPower[M, 2]] > n - 1 ) && Tr[M] > 0
$\endgroup$norm
looks redundant - it's just the same asMax[Eigenvalues[A]]
. $\endgroup$