The evaluate_pauli_product
function in the Pauli Algebra module doesn’t simplify by combining terms which have the the same “label” values specified in a different order. If I’m understanding correctly that Pauli symbols with different labels effectively describe tensor products, does it make sense for the simplification to be made?
Background is that I’m trying to model how qubit observables are changed by a quantum CNOT gate. Perhaps I should look more closely at the quantum SymPy module, but I’d like to check my understanding of the more general Pauli Algebra module as well.
from sympy import eye
from sympy.physics.paulialgebra import Pauli, evaluate_pauli_product
from sympy.physics.matrices import msigma
from sympy.physics.quantum import TensorProduct
# Simplifies because both terms have the "a then b" ordering
display(evaluate_pauli_product(
(Pauli(1, label = "a") * Pauli(3, label = "b")) +
(Pauli(1, label = "a") * Pauli(3, label = "b"))
))
# Doesn't simplify because the different ordering of a and b in the terms
# but probably should?
display(evaluate_pauli_product(
(Pauli(1, label = "a") * Pauli(3, label = "b")) +
(Pauli(3, label = "b") * Pauli(1, label = "a"))
))
# Matrix representations as a tensor product of a and b
display(
TensorProduct(msigma(1), msigma(3)) + TensorProduct(msigma(1), msigma(3))
)
display(
TensorProduct(msigma(1), eye(2)) * TensorProduct(eye(2), msigma(3)) +
TensorProduct(msigma(1), eye(2)) * TensorProduct(eye(2), msigma(3))
)