# Trace of density matrix

Hi friends of Mathematica, i´m a physics student and try to calculate Tr[rho^4] for a general two qubit system analytically. Since this is a very long calculation, the probability of making mistakes is almost 1. Therefore i wanted to double check my calculation with the help of Mathematica, but unfortunately it gives me no helpful result. Here is my code:

Id = IdentityMatrix[2];
sig[0] = SparseArray[PauliMatrix[0]];
sig[1] = SparseArray[PauliMatrix[1]];
sig[2] = SparseArray[PauliMatrix[2]];
sig[3] = SparseArray[PauliMatrix[3]];
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}};

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

Tr[rho.rho.rho.rho]


I want my result to depend only on the matrix cM and the vectors v1 and w1. But it yields some sparse array notifications. It seems as if the calculation is to complicated for Mathematica, although i doubt this highly, since it is my task to do it with pen and paper :) Has someone any suggestions how to obtain a useful result?

• Oh its a typo, but only here in the forum. In my original code its a dot :) Commented Mar 26, 2020 at 15:05

Maybe you want this?

rho = 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[rho.rho.rho.rho] // Simplify


Most importantly, you must not use [ ] to group mathematical expression, use ( ) instead.

• Thanks,a lot, this seems to work :D Commented Mar 26, 2020 at 15:16
• Nice. Here's how I'd do the sum: Total[Normal[Outer[KroneckerProduct, Array[sig, 3], Array[sig, 3], 1] cM], 2]. Additionally, Tr[MatrixPower[rho, 4]] is much more compact. Commented Mar 26, 2020 at 15:25