b2KIT

Tensor Operations Calculator

Perform tensor products, contractions, and index manipulations on rank-2 and rank-3 tensors with visual component grids.

Tested tool guide Tested browser tools Checked August 16, 2026

What Tensor Operations Calculator does, with a checked example

Fill in the components of a rank-2 or rank-3 tensor as grids of numbers, choose an operation, and the tool returns the result as a new component grid. Tensor products pair every component of one grid with every component of the other and raise the rank; contractions sum over a chosen index pair and lower it. The surprise is that the ordinary matrix product is itself a contraction - a sum over the shared index - so 'product' here does not multiply components one by one. Everything is computed in the browser from the grids you enter.

Worked example

A concrete input and expected output from the current implementation.

Input

A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]] as rank-2 grids; operation: contract the shared index (matrix product A_ij B_jk)

Expected output

A 2x2 grid with rows [19, 22] and [43, 50].

Contraction sums over the repeated index j: (AB)_ik = A_i1 B_1k + A_i2 B_2k. Entry (AB)_11 = 1x5 + 2x7 = 19; the other entries are 1x6 + 2x8 = 22, 3x5 + 4x7 = 43, and 3x6 + 4x8 = 50. Two free indices remain, so the output keeps the same 2x2 shape.

How the result is produced

1

Grids and index order

A rank-2 tensor is entered as a two-dimensional grid and a rank-3 tensor as a stack of component grids, with rows and columns standing for the first and second index. The tool carries that layout through the computation, so the returned grid has one axis per free (unsummed) index. That is why identical numbers can give different results when entered transposed.

2

Products multiply, contractions sum

A tensor product multiplies every component of one grid by every component of the other, so two 2x2 grids combine into 16 components. A contraction instead selects one index on each factor (or two indices of one tensor), sums over them, and drops the summed axes. Contracting the shared index of two 2x2 grids is exactly matrix multiplication; contracting a single 2x2 grid over both indices is its trace.

Good uses

  • Verify a hand computation: enter two matrices as grids, contract the shared index, and compare each entry of the result grid with the matrix product or trace you calculated yourself.
  • Work through rank-3 tensors from elasticity or continuum mechanics, where objects such as the stress tensor have 27 components: enter the slices, contract one index, and read off the resulting matrix instead of trusting a formula.
  • Settle which index pairing your problem needs: compute a contraction with the indices paired one way, then the other (for example A_ij B_jk versus A_ij B_ki), and compare the two result grids.

Limits and checks

  • A contraction is a sum, not a product. If you expected componentwise multiplication and the tool summed over an index instead, the output looks just as plausible. Read the operation label before comparing against your own numbers.
  • Index order changes the answer. Entering a matrix transposed, or contracting a different index pair, yields a different tensor. If the result surprises you, check the orientation of the input grids and which indices the contraction pairs.
  • Output size encodes the rank. A tensor product of two 2x2 grids has 16 components; a contraction of the same grids has 4. If the output grid is larger or smaller than expected, an index was kept free or summed that you meant the other way.

Common questions

Is the tensor product the same as the matrix product?

No. Mathematically, the tensor product of two rank-2 tensors has rank 4 and 16 components for 2x2 inputs, while the matrix product contracts the shared index to a rank-2 grid, (AB)_ik = A_ij B_jk. In this tool they are separate operations with different output sizes, so choose by what rank you want back.

What rank is the result of contracting a rank-3 tensor?

A contraction sums over one pair of indices, so a single contraction of a rank-3 tensor leaves one free index: the result is a rank-1 tensor, shown as a one-dimensional grid. There are three pairs of indices you can sum, and they generally give three different vectors. Contracting twice would need two index pairs, which a rank-3 tensor does not have.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools