Tensor Product

Abstract tensor product.

class sympy.physics.quantum.tensorproduct.TensorProduct(*args)[source]

The tensor product of two or more arguments.

For matrices, this uses matrix_tensor_product to compute the Kronecker or tensor product matrix. For other objects a symbolic TensorProduct instance is returned. The tensor product is a non-commutative multiplication that is used primarily with operators and states in quantum mechanics.

Currently, the tensor product distinguishes between commutative and non-commutative arguments. Commutative arguments are assumed to be scalars and are pulled out in front of the TensorProduct. Non-commutative arguments remain in the resulting TensorProduct.

Parameters:

args : tuple

A sequence of the objects to take the tensor product of.

Examples

Start with a simple tensor product of SymPy matrices:

>>> from sympy import Matrix
>>> from sympy.physics.quantum import TensorProduct

>>> m1 = Matrix([[1,2],[3,4]])
>>> m2 = Matrix([[1,0],[0,1]])
>>> TensorProduct(m1, m2)
Matrix([
[1, 0, 2, 0],
[0, 1, 0, 2],
[3, 0, 4, 0],
[0, 3, 0, 4]])
>>> TensorProduct(m2, m1)
Matrix([
[1, 2, 0, 0],
[3, 4, 0, 0],
[0, 0, 1, 2],
[0, 0, 3, 4]])

We can also construct tensor products of non-commutative symbols:

>>> from sympy import Symbol
>>> A = Symbol('A',commutative=False)
>>> B = Symbol('B',commutative=False)
>>> tp = TensorProduct(A, B)
>>> tp
AxB

We can take the dagger of a tensor product (note the order does NOT reverse like the dagger of a normal product):

>>> from sympy.physics.quantum import Dagger
>>> Dagger(tp)
Dagger(A)xDagger(B)

Expand can be used to distribute a tensor product across addition:

>>> C = Symbol('C',commutative=False)
>>> tp = TensorProduct(A+B,C)
>>> tp
(A + B)xC
>>> tp.expand(tensorproduct=True)
AxC + BxC
property kind

Calculate the kind of a tensor product by looking at its children.

sympy.physics.quantum.tensorproduct.tensor_product_simp(e, **hints)[source]

Try to simplify and combine tensor products.

Deprecated since version 1.14.: The transformations applied by this function are not done automatically when tensor products are combined.

Originally, this function tried to pull expressions inside of TensorProducts. It only worked for relatively simple cases where the products have only scalars, raw TensorProducts, not Add, Pow, Commutators of TensorProducts.