# Simple SDP using Hermitian matrices

I would like to run the following semidefinite program $$\textrm{Minimize}\,\, \textrm{tr}\big({AX}\big)\\ \textrm{subject to}\,\, X \geq B_1\,, X \geq B_2\,,$$ where $$A$$, $$B_1$$ and $$B_2$$ are fixed $$2 \times 2$$ Hermitian positive-semidefinite matrices and the variable $$X$$ is also a $$2 \times 2$$ Hermitian positive-semidefinite matrix. The following is my attempt so far.

MinimizeProblem[A_, B1_, B2_] :=
Return[SemidefiniteOptimization[Tr[A. X],
VectorGreaterEqual[{X - B1, 0}, {"SemidefiniteCone", 2}] &&
VectorGreaterEqual[{X - B2, 0}, {"SemidefiniteCone", 2}] &&
VectorGreaterEqual[{X, 0}, {"SemidefiniteCone", 2}],
X \[Element] Matrices[{2, 2}, Complexes], {"PrimalMinimumValue",
"PrimalMinimizer"}]];


This returns no result, but it doesn't give me a specific error either. I suspect the problem comes from using complex matrices, as this seems to be the main way that my problem differs from other SDP examples on this site e.g. MaxCut SDP primal in mathematica, but I'm not sure. In my attempts, I used the following for $$A$$, $$B_1$$ and $$B_2$$, $$A= \begin{pmatrix} 0.7 & 0 \\ 0 & 0.3\\ \end{pmatrix}\,, \qquad B_1= \frac{1}{2}\begin{pmatrix} 1 & 1 \\ 1 & 1\\ \end{pmatrix}\,, \qquad B_2= \frac{1}{2}\begin{pmatrix} 1 & -1 \\ -1 & 1\\ \end{pmatrix}\,.$$ Any help is appreciated.

Edit: If $$A$$ and $$X$$ are both positive semi-definite then they can be expanded in their eigenbases as $$A=\sum_{i}\lambda_i|u_i \rangle\langle u_i|$$ and $$X=\sum_{j}\gamma_j|v_j \rangle\langle v_j|$$, where every eigenvalue $$\lambda_i$$ and $$\gamma_j$$ is real and non-negative. Then $$\textrm{tr}\big(AX \big)=\sum_{i, j}\lambda_{i}\gamma_{j}|\langle v_j | u_i \rangle|^2$$ is real and non-negative.

• You seem to attempt to minimize a complex-valued function. If $A$ and $X$ are complex-valued matrices, what does guarantee that $\mathrm{tr}(A X)$ is a real number? Maybe you meant to take Frobenius inner product? Then you have to apply Re. Commented Mar 8, 2023 at 14:31
• @HenrikSchumacher I have edited my question to add a proof that $\textrm{tr} \big( AX\big)$ is real and non-negative if $A$ and $X$ are both positive-semidefinite. Commented Mar 8, 2023 at 15:13
• I see. Anyways, Mathematica does not know about this and refuses to minimize complex-valued functions. So wrapping it with Re might help anyways. Commented Mar 8, 2023 at 15:56

The problem here is that Mathematica interprets the sum X - B1 entrywise before doing anything at all. So for your data X - B1 is

{{X-1/2,X-1/2},{X-1/2,X-1/2}}

which is not what you want. In this simple case,

SemidefiniteOptimization[
Tr[A . X],
VectorGreaterEqual[{X, B1}, {"SemidefiniteCone", 2}] &&
VectorGreaterEqual[{X, B2}, {"SemidefiniteCone", 2}] &&
VectorGreaterEqual[{X, 0}, {"SemidefiniteCone", 2}],
X \[Element] Matrices[2, Complexes],
{"PrimalMinimumValue", "PrimalMinimizer"}]


does the job.

P.S. #1: By the way, for real data, the answer is always real.

P.S. #2: This one also runs :)

SemidefiniteOptimization[
Tr[A . X],
VectorGreaterEqual[{X - B1, 0}, {"SemidefiniteCone", 4}] &&
VectorGreaterEqual[{X, 0}, {"SemidefiniteCone", 2}],
X \[Element] Matrices[2, Complexes],
{"PrimalMinimumValue", "PrimalMinimizer"}]