KroneckerProduct[m1,m2,…]
constructs the Kronecker product of the arrays mi.
KroneckerProduct
KroneckerProduct[m1,m2,…]
constructs the Kronecker product of the arrays mi.
Details
- KroneckerProduct works on vectors, matrices, or in general, full arrays of any depth.
- For matrices, KroneckerProduct gives the matrix direct product.
- KroneckerProduct can be used on SparseArray objects, returning a SparseArray object when possible. »
Examples
open all close allBasic Examples (2)
av = Array[Subscript[a, ##]&, {2}];
bv = Array[Subscript[b, ##]&, {2}];KroneckerProduct[av, bv]//MatrixFormKronecker product of matrices:
am = Array[Subscript[a, ##]&, {2, 2}];
bm = Array[Subscript[b, ##]&, {2, 2}];KroneckerProduct[am, bm]//MatrixFormScope (2)
a and b are matrices with exact entries:
a = {{0, 1}, {-1, 0}};
b = {{1, 2}, {3, 4}};Use exact arithmetic to compute the Kronecker product:
MatrixForm[KroneckerProduct[a, b]]MatrixForm[KroneckerProduct[N[a], N[b]]]Use 20-digit precision arithmetic:
MatrixForm[KroneckerProduct[N[a, 20], N[b, 20]]]s = SparseArray[{i_, i_} -> i, {3, 3}];
t = SparseArray[{{i_, j_} /; Abs[i - j] == 1 -> i - j}, {4, 4}];Compute the sparse Kronecker product:
KroneckerProduct[s, t]MatrixForm[%]Applications (5)
Solve the general linear matrix equation a1.x.b1+⋯+am.x.bm=c for matrix
by using the flattening (vectorizing) relation Flatten[a.x.b]=(ab).Flatten[x]:
{Subscript[a, 1], Subscript[a, 2], Subscript[b, 1], Subscript[b, 2], c} = RandomReal[1, {5, 2, 2}];x = Partition[LinearSolve[KroneckerProduct[Subscript[a, 1], Subscript[b, 1]] + KroneckerProduct[Subscript[a, 2], Subscript[b, 2]], Flatten[c]], 2]Subscript[a, 1].x.Subscript[b, 1] + Subscript[a, 2].x.Subscript[b, 2] - c//ChopDefine the vec-permutation matrix, also called the commutation matrix:
vecPermutationMatrix[p_, q_] := PermutationMatrix[Flatten[Partition[Range[p q], p], {{2, 1}}]]Visualize the vec-permutation matrix:
p = 5;q = 3;
ArrayPlot[vecPermutationMatrix[p, q]]The vec-permutation matrix can be expressed as a sum of Kronecker products of an identity matrix with unit vectors:
vecPermutationMatrix[p, q] == Underoverscript[∑, k = 1, p]KroneckerProduct[UnitVector[p, k], IdentityMatrix[q], UnitVector[p, k]]Generate two symbolic matrices:
p = 6;q = 5;
MatrixForm[m1 = Array[, {p, q}]]r = 4;s = 3;
MatrixForm[m2 = Array[, {r, s}]]The vec-permutation matrix can be used to express the relationship between the Kronecker product of two given matrices and the Kronecker product of the same matrices in reverse order:
KroneckerProduct[m1, m2].vecPermutationMatrix[q, s] == vecPermutationMatrix[p, r].KroneckerProduct[m2, m1]s is a differentiation matrix approximating the second derivative in 1 dimension:
n = 4;
s = SparseArray[{Band[{2, 1}] -> 1, Band[{1, 1}] -> -2, Band[{1, 2}] -> 1}, {n, n}]s.Array[Subscript[u, #]&, n]The identity matrix as a sparse array:
sid = IdentityMatrix[n, SparseArray, WorkingPrecision -> MachinePrecision]A two-dimensional array of values:
MatrixForm[v = Array[Subscript[u, ##]&, {n, n}]]A matrix that differentiates in the first dimension only:
m1 = KroneckerProduct[s, sid]Partition[m1.Flatten[v], n][[2 ;; -2, 2 ;; -2]]//MatrixFormA matrix that approximates the Laplacian (the Kronecker sum of the differentiation matrix with itself):
lap = KroneckerProduct[s, sid] + KroneckerProduct[sid, s]Partition[lap.Flatten[v], n][[2 ;; -2, 2 ;; -2]]//MatrixFormDefine the n×n "butterfly" matrix for even n:
Subscript[b, n_] := Module[{h = Quotient[n, 2], id, w},
id = IdentityMatrix[h];
w = DiagonalMatrix[Exp[-π I Range[0, h - 1] / h]];
ArrayFlatten[{{id, w}, {id, -w}}]
]Define the n×n "bit reversal" permutation matrix for n a power of 2:
Subscript[p, n_] := PermutationMatrix[IntegerReverse[Range[0, n - 1], 2, BitLength[n] - 1] + 1]A compact notation for the identity matrix of size n:
Subscript[i, n_] := IdentityMatrix[n];A compact notation for the Kronecker product:
a_⊗b_ := KroneckerProduct[a, b]Form the discrete Fourier transform matrix for length 16 from the Cooley–Tukey factorization:
Subscript[f, 16] = Subscript[b, 16].(Subscript[i, 2]⊗ Subscript[b, 8]).(Subscript[i, 4]⊗ Subscript[b, 4]).(Subscript[i, 8]⊗ Subscript[b, 2]).Subscript[p, 16];This is equivalent to the result of FourierMatrix:
Subscript[f, 16] == FourierMatrix[16, FourierParameters -> {1, -1}]r is a random vector of length 16:
r = RandomReal[1, 16]The discrete Fourier transform of r:
N[Subscript[f, 16].r]Fourier is fast because it effectively composes the factorization for a particular vector:
Fourier[r, FourierParameters -> {1, -1}]KroneckerSum[a_ ? SquareMatrixQ, b_ ? SquareMatrixQ] :=
KroneckerProduct[a, IdentityMatrix[Length[b], If[SparseArrayQ[a], SparseArray, List]]] +
KroneckerProduct[IdentityMatrix[Length[a], If[SparseArrayQ[b], SparseArray, List]], b]Try it on general symbolic matrices:
am = Array[Subscript[a, ##]&, {2, 2}];bm = Array[Subscript[b, ##]&, {2, 2}];KroneckerSum[am, bm]//MatrixFormVerify the identity MatrixExp[a⊕b]=MatrixExp[a]⊗MatrixExp[b]:
{a, b} = RandomReal[1, {2, 3, 3}];MatrixExp[KroneckerSum[a, b]] == KroneckerProduct[MatrixExp[a], MatrixExp[b]]Verify the identity Eigenvalues[a⊕b]={λi+μj|λi∈Eigenvalues[a],μj∈Eigenvalues[b]}:
λa = Eigenvalues[a];
λb = Eigenvalues[b];
λab = Eigenvalues[KroneckerSum[a, b]];Sort[λab] == Sort[Flatten@Outer[Plus, λa, λb]]Properties & Relations (11)
KroneckerProduct is multi-linear (linear in each argument)
:
{a, b, c} = RandomInteger[5, {3, 2, 4}];
{λ, μ} = {3, 4};KroneckerProduct[λ a + μ b, c] ==
λ KroneckerProduct[a, c] + μ KroneckerProduct[b, c]KroneckerProduct[a, λ b + μ c] ==
λ KroneckerProduct[a, b] + μ KroneckerProduct[a, c]KroneckerProduct[KroneckerProduct[a, b], c] ==
KroneckerProduct[a, KroneckerProduct[b, c]]KroneckerProduct[a, b] == KroneckerProduct[b, a]KroneckerProduct satisfies the mixed product property
:
{a, b, c, d} = RandomInteger[5, {4, 3, 3}];KroneckerProduct[a, b].KroneckerProduct[c, d] ==
KroneckerProduct[a.c, b.d]Transpose distributes over it
:
KroneckerProduct[a, b] == KroneckerProduct[a, b]ConjugateTranspose distributes over it
:
KroneckerProduct[a, b] == KroneckerProduct[a, b]Inverse distributes over it
(iff
and
are invertible):
a = {{1, 2}, {0, 1}}; b = {{2, 1}, {0, 3}};Inverse[KroneckerProduct[a, b]] == KroneckerProduct[Inverse[a], Inverse[b]]PseudoInverse distributes over it PseudoInverse[ab]=PseudoInverse[a]PseudoInverse[b]:
a = {{1, 2}, {0, 0}}; b = {{0, 1}, {0, 3}};PseudoInverse[KroneckerProduct[a, b]] == KroneckerProduct[PseudoInverse[a], PseudoInverse[b]]The trace Tr for a Kronecker product satisfies Tr[ab]=Tr[a]Tr[b]:
a = RandomInteger[10, {3, 3}];b = RandomInteger[10, {4, 4}];Tr[KroneckerProduct[a, b]] == Tr[a]Tr[b]The determinant Det satisfies
where a∈Matrices[{m,m}] and b∈Matrices[{n,n}]:
Det[KroneckerProduct[a, b]] == Det[a]^4Det[b]^3Eigenvalues satisfies Eigenvalues[ab]={λiμj|λi∈Eigenvalues[a],μj∈Eigenvalues[b]}:
a = RandomReal[1, {3, 3}];b = RandomReal[1, {4, 4}];λa = Eigenvalues[a];
λb = Eigenvalues[b];
λab = Eigenvalues[KroneckerProduct[a, b]];Sort[λab] == Sort[Flatten@Outer[Times, λa, λb]]SingularValueList satisfies the same relation:
σa = SingularValueList[a];
σb = SingularValueList[b];
σab = SingularValueList[KroneckerProduct[a, b]];Sort[σab] == Sort[Flatten@Outer[Times, σa, σb]]MatrixRank satisfies MatrixRank[ab]=MatrixRank[a]MatrixRank[b]:
MatrixRank[KroneckerProduct[a, b]] == MatrixRank[a]MatrixRank[b]KroneckerProduct for matrices is a flattened block matrix with blocks
:
am = {{1, 2}, {3, 4}};bm = {{5, 6}, {7, 8}, {9, 10}};KroneckerProduct[am, bm] ==
ArrayFlatten@Table[am[[i, j]] * bm, {i, 2}, {j, 2}]KroneckerProduct of vectors is related to Dot of the corresponding column matrices:
av = {1, 2, 3}; bv = {4, 5};
am = {av}; bm = {bv};The dot product of a column and row matrix is usually also called an outer product:
KroneckerProduct[av, bv] == am.bmKroneckerProduct of vectors is equivalent to TensorProduct:
av = {1, 2, 3}; bv = {4, 5};KroneckerProduct[av, bv] == TensorProduct[av, bv]For matrices it is a flattened tensor product:
am = {{1, 2}, {3, 4}};bm = {{5, 6}, {7, 8}, {9, 10}};KroneckerProduct[am, bm] == ArrayFlatten[TensorProduct[am, bm]]KroneckerProduct of vectors is a special case of Outer:
av = {1, 2, 3}; bv = {4, 5};KroneckerProduct[av, bv] == Outer[Times, av, bv]For matrices it is a flattened outer product:
am = {{1, 2}, {3, 4}};bm = {{5, 6}, {7, 8}, {9, 10}};KroneckerProduct[am, bm] == ArrayFlatten[Outer[Times, am, bm]]The Kronecker product of a diagonal matrix and a general matrix is block diagonal:
dm = DiagonalMatrix[Array[Subscript[d, #]&, 2]];
bm = Array[Subscript[b, ##]&, {2, 2}];BlockDiagonalMatrix[KroneckerProduct[dm, bm]]MatrixForm[%]The Kronecker product of a lower triangular matrix and a general matrix is block lower triangular:
lm = LowerTriangularMatrix[LowerTriangularize[Array[Subscript[ℓ, #]&, {2, 2}]]];
bm = Array[Subscript[b, ##]&, {2, 2}];KroneckerProduct[lm, bm]MatrixForm[%]The Kronecker product of an upper triangular matrix and a general matrix is block upper triangular:
um = UpperTriangularMatrix[UpperTriangularize[Array[Subscript[u, #]&, {2, 2}]]];
bm = Array[Subscript[b, ##]&, {2, 2}];KroneckerProduct[um, bm]MatrixForm[%]See Also
Function Repository: NearestKroneckerProductSum KhatriRaoProduct
Tech Notes
Related Guides
History
Text
Wolfram Research (2007), KroneckerProduct, Wolfram Language function, https://reference.wolfram.com/language/ref/KroneckerProduct.html.
CMS
Wolfram Language. 2007. "KroneckerProduct." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/KroneckerProduct.html.
APA
Wolfram Language. (2007). KroneckerProduct. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KroneckerProduct.html
BibTeX
@misc{reference.wolfram_2026_kroneckerproduct, author="Wolfram Research", title="{KroneckerProduct}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/KroneckerProduct.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_kroneckerproduct, organization={Wolfram Research}, title={KroneckerProduct}, year={2007}, url={https://reference.wolfram.com/language/ref/KroneckerProduct.html}, note=[Accessed: 13-June-2026]}