kronecker product

13 views
Skip to first unread message

Romuald P.

unread,
Nov 29, 2022, 4:33:33 PM11/29/22
to sympy
Hello everyone
I am trying to use the Kronecker Product, aka the Tensor Product of sympy.physics.quantum:
from sympy.physics.quantum import TensorProduct
from sympy.physics.quantum.pauli import SigmaZ

When applied to the product of an identity matrix with a Pauli Matrix, say sz, I get:
I =sym.eye(2)
SzA = TensorProduct(SigmaZ(),I)
print(SzA)

> SigmaZ()xMatrix([ [1, 0], [0, 1]])

The problem is with the product of I x Sigmaz:
SzB = TensorProduct(I,SigmaZ())
I get an error:
TypeError: Sequence of Matrices expected, got: (Matrix([ [1, 0], [0, 1]]), SigmaZ())

I can however get out of this issue by using the represent function
from sympy.physics.quantum import represent
I =sym.eye(2)
SzA = TensorProduct(represent(SigmaZ()),I)
SzB = TensorProduct(I,represent(SigmaZ()))

But I would like to understand why the second product (TensorProduct(I,SigmaZ())) is not allowed - or conversely why the first product (TensorProduct(SigmaZ(),I)) does not yield an error.


Thank for your help
Romuald
Reply all
Reply to author
Forward
0 new messages