About Tensor Product Calculator
This tensor product calculator multiplies every element of tensor A by every element of tensor B and returns the result with its rank, shape and values. It is free, needs no sign-up and runs in your browser, so nothing you enter is uploaded.
The result shape is the shape of A followed by the shape of B, so the ranks add and the element counts multiply. A vector of length 2 and a vector of length 3 give a 2 by 3 matrix. Two 2 by 2 matrices give a rank 4 tensor of shape [2, 2, 2, 2] with 16 elements. For two vectors this is the outer product from linear algebra.
People often mean the Kronecker product when they say tensor product of matrices. Both contain the same products, but the Kronecker product flattens them into a matrix of multiplied sizes. This page computes the first one, and the Kronecker tab next to it computes the second. Entries must be numbers: symbolic and complex tensors are not supported.
How to use Tensor Product Calculator
- Pick a mode: Shape and reshape, Tensor product, Kronecker product, or Einsum.
- Enter tensor A as nested brackets like [[1, 2, 3], [4, 5, 6]], or as a flat list of numbers with a shape such as 2, 3 in the shape box. One shape entry may be -1.
- For the product and einsum modes, enter tensor B the same way.
- In Shape mode, type a target shape to reshape to (for example 3, -1) and optionally an axes order for transpose (for example 1, 0).
- In Einsum mode, write the expression, such as ij,jk->ik, or pick an example chip: matrix product, trace, diagonal, transpose or a three-matrix chain. One box appears for each operand, labelled with its axes.
- Read the rank, shape and element count above each result, and the values below as nested brackets.
Features
- Shape inference from nested brackets, or a flat list plus a shape.
- Reshape with one -1 dimension worked out automatically.
- Transpose with reversed axes by default, or a custom axes order for any rank.
- Tensor (outer) product whose shape is the shape of A followed by the shape of B.
- Kronecker product with NumPy-style padding, so a vector and a matrix can be combined.
- Einsum with one, two or three operands: the trace (ii->), the diagonal (ii->i), the transpose (ij->ji), the matrix product, a three-matrix chain (ij,jk,kl->il), batch products and more, with an implicit output when you leave off the arrow.
- Each tensor box is labelled with the axes the expression gives it, and the expression is shown as a KaTeX formula.
- Shapes and small results are typeset with KaTeX, for example the shape as R with a superscript of 2 by 3 and a matrix as a bracketed array.
- A size guard: an einsum over 10 million multiply-adds is refused with the exact count, and one over 100,000 runs in a Web Worker so the page stays responsive.
- Readable errors for ragged lists, non-numbers, mismatched sizes and bad axes.
- Rank, shape and element count shown for every result, and values printed as nested brackets rounded to nine decimals.
Tensor product
Every entry of A is multiplied by every entry of B, and the axes of A come first.
(A ⊗ B)[i…, j…] = A[i…] × B[j…]
shape = shape(A) + shape(B)Worked examples
A = [1, 2], B = [3, 4, 5] gives [[3, 4, 5], [6, 8, 10]], shape [2, 3], rank 2
A = [[1, 2], [3, 4]], B = [[0, 1], [1, 0]] gives Shape [2, 2, 2, 2], rank 4, 16 elements.
Four numbers times four numbers is sixteen products, kept as a rank 4 tensor.
Privacy: how it works
- All arithmetic is done by TypeScript code in your browser tab. There is no network request when you calculate, no library is downloaded to do it, and nothing is stored.
Tips
- Use -1 in a reshape to let the calculator fill in one dimension. A 24-element tensor reshaped to 4, -1 becomes shape [4, 6].
- If a reshape fails, multiply your target dimensions and compare with the element count shown for tensor A.
- To check an einsum string, try tiny tensors with distinct values, then compare the rank and shape before the values.
- A custom transpose order lists the old axes in their new positions. For shape [2, 3, 4], the order 1, 0, 2 gives shape [3, 2, 4].
Frequently asked questions
Is it really free?
Yes. There is no price, no trial and no credit card. Ulkaa Tool does the work with your own device, so there is no server bill to pass on to you.
Do I need an account?
No. There is no sign-up and no login. Open the page and use it. An Ulkaa account is not needed for anything on this tool.
Does it run in my browser?
Yes. Your values are processed by code running in your browser tab, on your own device.
Is my data uploaded?
No. Your values are never sent to Ulkaa or to anyone else. You can check this yourself by watching the Network tab in your browser developer tools while you use the tool.
What is the shape of a tensor product?
The shape of the first tensor followed by the shape of the second. [2] and [3] give [2, 3], and [2, 2] with [2, 2] gives [2, 2, 2, 2].
Is the tensor product the same as the outer product?
For two vectors, yes. For higher ranks the tensor product generalises the outer product by keeping every axis of both inputs.
Is it commutative?
The values are the same set of products, but the axes are in a different order, so A ⊗ B and B ⊗ A generally have different shapes and layouts.
More Tensor Calculator pages
- Tensor CalculatorCheck shapes, reshape and transpose, and compute tensor products, Kronecker products and einsum contractions.
- Tensor Shape CalculatorShape, rank and element count of a tensor, plus reshape and transpose.
- Einsum CalculatorEvaluate einsum expressions on one to three tensors and check your own.
- Kronecker Product CalculatorThe Kronecker product of two matrices, with block layout.
- Tensor Contraction CalculatorContract two tensors by summing over shared indices.