What is a tensor product?
The state of a coin can be defined by a vector
How can we define the combined state of a system comprising of
Mathematically, composite systems are represented by the following relation:
Therefore, the state of the above system becomes
Tensor product
In linear algebra, this can be done by computing the tensor product of two vectors. For two vectors
Here,
If
Note: Tensor products are defined on both vectors and matrices.
Code example
In NumPy, the tensor product of two arrays can be evaluated using the kron() function. Let's evaluate the tensor product of the two coin states under consideration:
# Import numpyimport numpy as np# Define the vectorscoin_1 = np.array([0.7, 0.3])coin_2 = np.array([0.4, 0.6])# Evaluate the tensor producttensor_product = np.kron(coin_1, coin_2)print(tensor_product)
Here, the kron() function is used for evaluating the tensor product between the two vectors we defined, coin_1 and coin_2.
Free Resources