Understanding the tensor product calculator — concept and principle
This calculator computes the Kronecker (tensor) product A ⊗ B of two matrices, and also B ⊗ A to show that the order matters. It gives the size of the result and the number of entries. Use it for quantum computing (combining qubit states and gates), linear algebra, vectorising matrix equations, and signal and image processing.
How it is calculated
For an m × n matrix A and a p × q matrix B, A ⊗ B is the mp × nq block matrix
[a₁₁B a₁₂B …; a₂₁B a₂₂B …; …]
Each entry aᵢⱼ is replaced by aᵢⱼ times a full copy of B. Entry by entry, the element in row p(i − 1) + k and column q(j − 1) + l equals aᵢⱼ·bₖₗ. Any sizes can be combined. Inputs are limited to 4 × 4 each so the result stays readable.
The principle
The Kronecker product builds a matrix that acts on pairs of things at once. If A transforms one vector x and B transforms another y, then A ⊗ B transforms their combined vector x ⊗ y exactly as (Ax) ⊗ (By). In quantum computing, a two-qubit state is the tensor product of single-qubit states, and applying gates to each qubit separately is the Kronecker product of the gates. The product is not commutative: B ⊗ A contains the same numbers in a different arrangement, related to A ⊗ B by reordering rows and columns.
Worked example
Default: A = [1 2; 3 4], B = [0 5; 6 7].
- Top-left block 1·B = [0 5; 6 7]; top-right 2·B = [0 10; 12 14].
- Bottom-left 3·B = [0 15; 18 21]; bottom-right 4·B = [0 20; 24 28].
- A ⊗ B = [0 5 0 10; 6 7 12 14; 0 15 0 20; 18 21 24 28].
- Size 4 × 4, 16 entries.
- B ⊗ A = [0 0 5 10; 0 0 15 20; 6 12 7 14; 18 24 21 28], different from A ⊗ B.
How to read the result
The result is organised in blocks, one for each entry of A. Useful properties: (A ⊗ B)(C ⊗ D) = AC ⊗ BD when the sizes fit; (A ⊗ B)ᵀ = Aᵀ ⊗ Bᵀ; and for square matrices, det(A ⊗ B) = det(A)^p·det(B)^n, with n and p the sizes of A and B. The eigenvalues of A ⊗ B are all products of an eigenvalue of A and one of B.
Common mistakes
- Confusing the Kronecker product with ordinary matrix multiplication, which needs matching inner sizes.
- Expecting A ⊗ B = B ⊗ A.
- Confusing it with the element-wise (Hadamard) product, which needs equal sizes.
- Getting the block order wrong: blocks follow the layout of A, and each block is a copy of B.
Frequently asked questions
Is the tensor product the same as the Kronecker product?
For matrices in standard bases, the Kronecker product is the matrix of the tensor product of the two linear maps.
How is it used in quantum computing?
Multi-qubit states and gates acting on separate qubits are built with Kronecker products.
What size is A ⊗ B?
If A is m × n and B is p × q, the result is mp × nq.
Sources: Wolfram MathWorld, "Kronecker Product"