I want to compute a partial trace using formula
$\rho_A=\sum\langle B|\rho_{AB}|B\rangle$ .
Example,
$\rho_{AB}= $$ \begin{pmatrix} a & b & c & d\\ e & f & g & h\\ i & j & k & l\\ m & n & o & p \end{pmatrix} $
I try to evaluate
MatrixForm[
Sum[
TensorProduct[{{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}}, (q*r)],
{1, 2}]]
but Mathematica returns the expression unevaluated.
The output is wrong. I am not sure whether the operator should be TensorProduct or Cross.
I expected to get
$\rho_{A}= $$ \begin{pmatrix} a +f & c+h\\ i+n & k+p\\ \end{pmatrix} $
Answer
Your example can be achieved using Map with a level specification, Partition to generate the sub-matrices and Tr to calculate the traces.
ClearAll[a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p]
r = {{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}};
Map[Tr, Partition[r, {2, 2}], {2}]
{{a + f, c + h}, {i + n, k + p}}
Comments
Post a Comment