i recently wrote a code which computes the trace of a general 2-qubit density matrix to the fourth power (i´m studying physics :D), in terms of two bloch vectors and a matrix of the correlations. Here is the code:

Id = IdentityMatrix[2];
sigv = Table[PauliMatrix[i], {i, 1, 3}];

v1 = {vx, vy, vz};
w1 = {wx, wy, wz};
cM = {{c11, c12, c13}, {c21, c22, c23}, {c31, c32, c33}};

rho1 = 1/4 (KroneckerProduct[Id, Id] + KroneckerProduct[Id, v1.sigv] +
      KroneckerProduct[w1.sigv, Id] + 
     Sum[cM[[i]][[j]] KroneckerProduct[sig[i], sig[j]], {i, 1, 3}, {j,
        1, 3}]);

Tr[rho1.rho1.rho1.rho1] // Simplify

The code works fine, its just here to help you guys to understand my problem. The final result is a very large polynomial in the matrix- and vector-coefficents and i would like to express this polynomial in terms of the norms of the vectors and matrix, or just generally compactify it (like in the case of the one qubit purity Tr[rho^2]=1/2(1+||v||^2) ). I played around with Collect[] for a long time, but i was not happy with any of the results. About help/suggestions i would be very grateful :D Peace!

  • $\begingroup$ Should sig[i] and sig[j] be sigv[[i]] and sigv[[j]]? $\endgroup$ Mar 26, 2020 at 18:51

1 Answer 1


One possible approach is to write out a list of possible invariants that could be involved in the result, e.g.

v2 = v1.v1
w2 = w1.w1
vw = v1.w1
ctr = Tr[cM]
c2tr = Tr[cM.cM]
vcv = v1.cM.v1

As far as I can tell, your expression only contains terms that are quadratic & quartic in the components of $\bf{v}$, $\bf{w}$, and $\bf{c}$, so there will be a finite number of such terms. Then construct the most general expression of the appropriate order out of these invariants:

ansatz = a[1] + a[2] v2 + a[3] v2^2 + a[4] v2 w2 + ...

Again, there should be a finite number of such terms. (If I had to guess, you'll get a couple dozen or so such terms.)

Finally, apply SolveAlways:

SolveAlways[originalresult == ansatz, {vx, vy, vz, wx, wy, wz, c11, c12, ...}]

This should yield a solution for the coefficients a[i].

The pitfall of this method is that you'll need to be sure that you get all of the possible invariants. If you miss one, Mathematica will find an empty solution.

  • $\begingroup$ Hihi, thanks for your help. I tried ur method, but its too easy to makes mistakes there, especially with the polynom-ansatz. Im still looking for an easier method ... $\endgroup$
    – Jolle
    Mar 28, 2020 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.