# Tensor Product Calculator

Created by Anna Szczepanek, PhD
Reviewed by Rijk de Wet
Last updated: Jun 05, 2023

If you have just stumbled upon this bizarre matrix operation called matrix tensor product or Kronecker product of matrices, look for help no further — Omni's tensor product calculator is here to teach you all you need to know about:

• What the Kronecker product is;
• What the main properties of Kronecker product are;
• How to calculate tensor product of 2x2 matrices by hand; and
• What the most general Kronecker product formula looks like.

As a bonus, we'll explain the relationship between the abstract tensor product vs the Kronecker product of two matrices!

⚠️ The Kronecker product is not the same as the usual matrix multiplication! If you're interested in the latter, visit Omni's matrix multiplication calculator. To discover even more matrix products, try our most general matrix calculator.

## What is the tensor product of matrices?

Matrix tensor product, also known as Kronecker product or matrix direct product, is an operation that takes two matrices of arbitrary size and outputs another matrix, which is most often much bigger than either of the input matrices.

Let's say the input matrices are:

• $A$ with $r_A$ rows and $c_A$ columns, and
• $B$ with $r_B$ rows and $c_B$ columns.

The resulting matrix then has $r_A \cdot r_B$ rows and $c_A \cdot c_B$ columns.

🔎 In particular, we can take matrices with one row or one column, i.e., vectors (whether they are a column or a row in shape). In this case, we call this operation the vector tensor product.

## How to calculate the Kronecker product?

Once we have a rough idea of what the tensor product of matrices is, let's discuss in more detail how to compute it. The Kronecker product is defined as the following block matrix:

$\footnotesize A \otimes B = \! \begin{bmatrix} a_{11} {B} & \cdots & a_{1c_A} {B} \\ \vdots &\ddots &\vdots \\a_{r_A1}{B} &\cdots &a_{r_Ac_A}{B} \end{bmatrix}$

Hence, calculating the Kronecker product of two matrices boils down to performing a number-by-matrix multiplication many times. As you surely remember, the idea is to multiply each term of the matrix by this number while keeping the matrix shape intact:

$\footnotesize a_{ij} B =\! \begin{bmatrix} a_{ij} b_{11} & \cdots & a_{ij} b_{1c_B} \\ \vdots &\ddots &\vdots \\a_{ij}b_{r_B1} &\cdots &a_{ij} b_{r_Bc_B} \end{bmatrix}$

## Tensor product of 2x2 matrices

Let's discuss what the Kronecker product is in the case of 2x2 matrices to make sure we really understand everything perfectly. Suppose that

$\footnotesize A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix}\!,\ B = \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix}$

As we saw above, we have:

$\footnotesize A \otimes B = \begin{bmatrix} a_{11} {B} & a_{12} {B} \\a_{21}{B} &a_{22}{B} \end{bmatrix}$

Writing the terms of $B$ explicitly, we obtain:

$\footnotesize A \otimes B = \\ \begin{bmatrix} a_{11} \begin{bmatrix} b_{11} & b_{12} \\b_{21} &b_{22} \end{bmatrix} & a_{12}\begin{bmatrix} b_{11} & b_{12} \\b_{21} &b_{22} \end{bmatrix} \\a_{21}\begin{bmatrix} b_{11} & b_{12} \\b_{21} &b_{22} \end{bmatrix} &a_{22}\begin{bmatrix} b_{11} & b_{12} \\b_{21} &b_{22} \end{bmatrix} \end{bmatrix}$

Performing the number-by-matrix multiplication, we arrive at the final result:

$\footnotesize A \otimes B = \\ \begin{bmatrix} a_{11} b_{11} & a_{11}b_{12} & a_{12} b_{11} & a_{12} b_{12} \\ a_{11}b_{21} & a_{11}b_{22} & a_{12}b_{21} & a_{12}b_{22} \\ a_{21} b_{11} & a_{21}b_{12} & a_{22} b_{11} & a_{22} b_{12} \\ a_{21}b_{21} & a_{21}b_{22} & a_{22} b_{21} & a_{22} b_{22} \end{bmatrix}$

Hence, the tensor product of 2x2 matrices is a 4x4 matrix. It is not hard at all, is it? But you can surely imagine how messy it'd be to explicitly write down the tensor product of much bigger matrices! Fortunately, there's a concise formula for the matrix tensor product — let's discuss it!

## What is the formula for the Kronecker matrix product?

We can compute the element $(A\otimes B)_{ij}$ of the Kronecker product as:

$\footnotesize a_{\lceil i/r_B\rceil ,\lceil j/c_B\rceil } \cdot b_{\left((i-1)\% r_B+1\right),\left((j-1)\% c_B+1\right)}$

where $\lceil x \rceil$ is the ceiling function (i.e., it's the smallest integer that is greater than $x$) and $\%$ denotes the modulo operation. Recall also that $r_B$ and $c_B$ stand for the number of rows and columns of $B$, respectively.

We have discussed two methods of computing tensor matrix product. There's a third method, and it is our favorite one — just use Omni's tensor product calculator!

## How to use this tensor product calculator?

To compute the Kronecker product of two matrices with the help of our tool, just pick the sizes of your matrices and enter the coefficients in the respective fields.

🙋 Oops, you've messed up the order of matrices? No worries — our tensor product calculator allows you to choose whether you want to multiply $A \otimes B$ or $B \otimes A$. Enjoy!

## Properties of the Kronecker product

#### Associativity

Tensor matrix product is associative, i.e., for every $A, B, C$ we have

$\footnotesize ({A} \otimes {B} )\otimes {C} ={A} \otimes ({B} \otimes {C})$

#### Bilinearity

Tensor matrix product is also bilinear, i.e., it is linear in each argument separately:

$\footnotesize (A + B)\otimes C =A \otimes C +B \otimes C, \\[0.5em] (x{A}) \otimes {B} = x({A} \otimes {B} )$

and

$\footnotesize {A} \otimes ({B} +{C} ) ={A} \otimes {B} +{A} \otimes {C}, \\[0.5em] {A} \otimes (x{B} )= x({A} \otimes {B} )$

where $A,B,C$ are matrices and $x$ is a scalar.

#### (Conjugate) transposition

The transposition of the Kronecker product coincides with the Kronecker products of transposed matrices:

$\footnotesize (A\otimes B)^{T}=A^{T}\otimes B^{T}.$

The same is true for the conjugate transposition (i.e., adjoint matrices):

$\footnotesize (A\otimes B)^{*}=A^{*}\otimes B^{*}.$

#### Singular values and rank

💡 Don't worry if you're not yet familiar with the concept of singular values - feel free to skip this section or go to the singular values calculator.

If $\sigma_1, \ldots, \sigma_{p_A}$ are non-zero singular values of $A$ and $s_1, \ldots, s_{p_B}$ are non-zero singular values of $B$, then the non-zero singular values of $A \otimes B$ are $\sigma_{i}s_j$ with $i=1, \ldots, p_{A}$ and $j=1, \ldots, p_{B}$.

Recall that the number of non-zero singular values of a matrix is equal to the rank of this matrix. In consequence, we obtain the rank formula:

$\footnotesize \operatorname{rank}(A \otimes B) = \operatorname{rank}(A) \cdot \operatorname{rank}(B)$

#### Inverse of tensor product

For the rest of this section, we assume that $A$ and $B$ are square matrices of size $m$ and $n$, respectively.

If $A$ and $B$ are both invertible, then $A\otimes B$ is invertible as well and

$\footnotesize (A\otimes B)^{-1}=A^{-1}\otimes B^{-1}.$

#### Eigenvalues, trace, determinant

💡 Finding eigenvalues is yet another advanced topic. If you need a refresher, visit our eigenvalue and eigenvector calculator.

If $\alpha_1, \ldots, \alpha_m$ and $\beta_1, \ldots, \beta_n$ are the eigenvalues of $A$ and $B$ (listed with multiplicities) respectively, then the eigenvalues of $A \otimes B$ are of the form
$\alpha_{i}\beta_{j}$ with $i=1,\ldots ,m$ and $j=1,\ldots ,n$.

Since the determinant corresponds to the product of eigenvalues and the trace to their sum, we have just derived the following relationships:

$\footnotesize \det(A \otimes B) = \det(A)^n \det (B)^m$
$\footnotesize \operatorname{trace}(A \otimes B) = \operatorname{trace}(A) \operatorname{trace}(B)$

## FAQ

### Is the Kronecker product associative?

Yes, the Kronecker matrix product is associative: (A ⊗ B) ⊗ C = A ⊗ (B ⊗ C) for all matrices A, B, C.

### Is the Kronecker product commutative?

No, the Kronecker matrix product is not commutative: A ⊗ B ≠ B ⊗ A for some matrices A, B.

### Is tensor product the same as Kronecker product?

The tensor product is a more general notion, but if we deal with finite-dimensional linear spaces, the matrix of the tensor product of two linear operators (with respect to the basis which is the tensor product of the initial bases) is given exactly by the Kronecker product of the matrices of these operators with respect to the initial bases.