Tensor Product Calculator

Compute the tensor product (outer product) of two vectors and display the result as a matrix or flattened vector.

Enter two vectors as comma-separated or space-separated numbers, choose an output format, and click Calculate.

Tensor Product Calculator
Compute the tensor product (outer product) of two vectors and display the result as a matrix or flattened vector.

About the tensor product calculator

The tensor product, also called the outer product in the context of vectors, is a fundamental operation in linear algebra that takes two vectors and produces a matrix. Given a vector u with m components and a vector v with n components, their tensor product u ⊗ v is an m × n matrix in which the element at row i and column j equals uᵢ multiplied by vⱼ. This is in sharp contrast to the dot product, which reduces two vectors to a single scalar, or the cross product, which applies only to three-dimensional vectors and yields another vector. Mathematically, if u = [u₁, u₂, …, uₘ] and v = [v₁, v₂, …, vₙ], then (u ⊗ v)ᵢⱼ = uᵢvⱼ for every valid pair (i, j). The computation has time complexity O(mn), making it efficient even for moderately large vectors. The tensor product is bilinear — scaling either vector scales the result by the same factor, and it distributes over vector addition. The tensor product is not commutative: u ⊗ v and v ⊗ u are different matrices (one is m × n, the other is n × m) unless m = n and some special relationship holds. The first vector always determines the rows and the second always determines the columns. This asymmetry matters especially when applying the operation in physics or machine learning, where the order carries physical or semantic meaning. In quantum mechanics, tensor products are indispensable for describing composite systems. When two quantum systems are combined, the state space of the composite system is the tensor product of the individual state spaces. For example, a two-qubit system has a 4-dimensional state space that is the tensor product of two 2-dimensional qubit spaces. Quantum entanglement arises precisely when a composite state cannot be written as a simple tensor product of individual states. In machine learning and data science, tensor products (and their higher-order generalisations, called tensors) underlie the attention mechanism in Transformer models, the feature cross operations in recommendation systems, and separable convolutions in image processing. A Gaussian blur kernel, for instance, is the tensor product of a 1-D horizontal Gaussian filter with a 1-D vertical Gaussian filter, enabling efficient separable computation. In signal processing, representing multidimensional filters as tensor products of 1-D filters enables significant computational savings. The flattened vector representation produced by this calculator is particularly useful when feeding the result into a subsequent operation that expects a 1-D input, such as a fully connected neural network layer.

Tensor product examples

Four worked examples showing different vector dimensions and output formats.

VectorsResultNotes
u = [1, 2], v = [3, 4][[3, 4], [6, 8]]2 × 2 matrix. Entry (1,1) = 1×3 = 3; entry (2,2) = 2×4 = 8.
u = [1, 2, 3], v = [4, 5][[4, 5], [8, 10], [12, 15]]3 × 2 matrix showing that the vectors may have different lengths.
u = [1, 0], v = [0, 1][[0, 1], [0, 0]] | flattened: [0, 1, 0, 0]Outer product of standard basis vectors. Non-zero entry appears only at row 1, col 2.
u = [2, 3], v = [1, 4][[2, 8], [3, 12]]General 2 × 2 case. Each row of the result is v scaled by the corresponding component of u.

How to use the tensor product calculator

  1. Enter the components of the first vector u as comma-separated or space-separated numbers, for example: 1, 2, 3.
  2. Enter the components of the second vector v in the same format. The two vectors may have different numbers of components.
  3. Select the output format: 'Matrix Format' shows the result as a grid of rows and columns; 'Flattened Vector' shows all elements in a single row.
  4. Click Calculate. The result matrix (or flattened list) is displayed together with the matrix dimensions.
  5. Click Reset to clear all fields and start a new calculation.

Tensor product calculator FAQ

What is the difference between a tensor product and a dot product?
The dot product takes two vectors of equal length and returns a single number (a scalar) by summing the products of corresponding components. The tensor product takes two vectors of any lengths and returns a matrix: every component of the first vector is multiplied by every component of the second. The tensor product preserves all information from both vectors, while the dot product collapses it to one number.
Do the two vectors have to be the same length?
No. The vectors may have different numbers of components. If u has m components and v has n components, the result is an m × n matrix. This is one of the reasons the tensor product is more general than operations like the dot product, which requires equal lengths.
Is the tensor product commutative?
No. The tensor product u ⊗ v is generally different from v ⊗ u. The first vector always indexes the rows, and the second always indexes the columns, so swapping the order transposes and potentially reshapes the result matrix.
What does the flattened vector format represent?
The flattened vector is simply the m × n result matrix read row by row into a single list of mn numbers. It is useful when you need to pass the tensor product as a 1-D input to another computation, such as a machine learning model that expects a fixed-size feature vector.
How is the tensor product used in quantum computing?
In quantum mechanics, the state of a multi-particle system is described by the tensor product of the individual particle states. For two qubits each in state [a, b] and [c, d], the combined system state is their tensor product, a 4-component vector. This formalism is what gives quantum computers their exponentially growing state space.
What is the connection to the Kronecker product?
The Kronecker product is a generalisation of the tensor product for matrices. When the inputs are vectors (treated as column matrices), the tensor product u ⊗ v equals the Kronecker product of u (column) with vᵀ (row), producing the same m × n matrix. For general matrices the Kronecker product creates a block matrix.