# Different Optimum for sum of k largest eigenvalues

I would like to hear some comments on the what I got after some experiences on the model. I am not sure this is because of way of writing code or there is another reason. Please let me know your comments.

Let’s suppose we want to know the sum of the two largest eigenvalues of a matrix A \in \cal S^n. the primal and dual pair is known as:

Primal:
\max ~\langle A, X \rangle

$~~~~~~~~~s.t. \langle I, X \rangle = k$

~~~~~~~~~~~~~~~~~~ 0 \preceq X \preceq I

Dual: ~~\min ~\lambda k + Z

~~~~~~~~~~ s.t.~~\lambda I + Z - A \succeq 0

~~~~~~~~~~~~~~~~~Z \succeq 0

Their codes in MATLAB are, respectively:

k = 2;

A = randn(n);

A = A’*A

cvx_begin sdp

variable X(n,n) symmetric
X == semidefinite(n)
I = eye(n);
maximize (trace(A * X))
subject to
trace(I * X) == k;
X <= I;


cvx_end

cvx_begin sdp

variable Z symmetric
Z == semidefinite(n)
variable y
I = eye(n);
minimize (k * y + trace(I * Z))
subject to
y * I + Z >= A


cvx_end

I used the same matrix A (generated by rand() command) for dual and got these answer:

Primal:

Status: Solved

Optimal value (cvx_optval): +35.1233

Dual:

Status: Solved

Optimal value (cvx_optval): +42.9898

Now, my question is that we know the Slater condition is held for both primal and dual, then we would expected to have the same optimum values. But why I have these?

I really appreciate any helps.