Kronecker Products & Ordering Conventions
Endianness, qubit ordering and getting the matrices right.
The tensor product is canonical; its matrices are not. Turning into arrays of numbers requires an ordered basis, and two incompatible orderings are in daily use. This lesson makes every choice explicit and gives the exact permutations that translate between them.
What you’ll learn
- State and prove the main Kronecker-product identities: mixed product, trace, rank, spectrum, determinant and norms.
- Translate states and operators between big-endian and little-endian conventions with permutation matrices.
- Use the reshaping identity to compute local actions, overlaps and partial traces.
- Explain why "control" and "target" are basis-dependent notions.
From abstract tensors to Kronecker matrices
No basis appears in this definition. Matrices appear only once you choose orthonormal bases of and of and order the product basis. Lexicographic order, , identifies with , and then operators become Kronecker products:
For subsystems of dimensions , the basis state gets the mixed-radix index , with most significant. This is big-endian, or row-major, order.
Endianness and permutations
Two conventions dominate for qubits:
- Big-endian: qubit 0 is the leftmost tensor factor and the most significant bit, so has index . This course, Nielsen & Chuang and most physics texts use it, and so does
np.kronif you list qubit 0 first. - Little-endian: qubit 0 is the least significant bit, with index . Qiskit uses this, and prints bit strings with qubit 0 on the right.
The two are related by a permutation of tensor factors.
permutes the orthonormal product basis, so it is unitary with :
Apply the left-hand side to a product vector. After , slot holds , which then acts on:
moves the factor in slot into slot :
Product vectors span the space, so the two operators agree. Since every operator is a sum of tensor products, is " with its tensor slots relabelled" for every .
For endianness the relevant permutation is bit reversal, . It is an involution, so its matrix satisfies , and every state and operator translates as
For two qubits is the SWAP matrix. The same physical gate, a CNOT with control and target , therefore has two different matrices:
| Convention | Basis order | CNOT, control , target |
|---|---|---|
| Big-endian (this course) | : | |
| Little-endian (Qiskit) | : |
In Qiskit, a 3-qubit circuit applies to qubit 0 only and is then measured. Which bit string labels the outcome?
100010001110
Show the answer
C. 001
Little-endian strings put qubit 0 on the right: 001 means and . In this course's big-endian notation the same state is .
Reshaping: states as matrices
A vector is the same data as an coefficient matrix , with . In big-endian order, is the row-major reshape of the amplitude vector, psi.reshape(m, p) in NumPy. Bipartite computations then become ordinary matrix algebra:
Expand the action of a local operator:
The bracket is . Note the transpose, not the adjoint: local operators act linearly.
Overlaps are Hilbert–Schmidt inner products of coefficient matrices ( is the matrix of ):
Partial traces are matrix products. Their common nonzero spectrum is the set of squared singular values of : the Schmidt decomposition in disguise.
With column-major storage (Fortran, MATLAB, Julia) the reshape of is , and the identity takes its textbook form with the Kronecker factors in the opposite order. Same mathematics, one more place where conventions bite.
import numpy as np
def apply_1q(psi, U, k, n):
"""Apply the 2x2 matrix U to qubit k of an n-qubit state (big-endian: qubit 0 leftmost)."""
t = psi.reshape([2] * n) # one axis per qubit; axis k is qubit k
t = np.tensordot(U, t, axes=([1], [k])) # contract U's column index with axis k
t = np.moveaxis(t, 0, k) # move the new index back into slot k
return t.reshape(-1)
def reverse_qubits(psi, n):
"""Big-endian <-> little-endian: apply the bit-reversal permutation R."""
return psi.reshape([2] * n).transpose(list(reversed(range(n)))).reshape(-1)A state-vector simulator never builds . It reshapes and contracts one axis, which costs operations per single-qubit gate instead of the of a dense matrix–vector product.
Control and target are basis-dependent
Even "which qubit is the control" is a statement about the computational basis. The controlled-, , is symmetric under exchanging the qubits, and conjugating its target by gives a CNOT: . Hence:
Think first Is there any basis-independent sense in which CNOT acts "from" one qubit "onto" the other?
No direction is invariant, but the nonlocal content is. , and are all equal up to local unitaries, have operator Schmidt rank 2, and turn a product input into at most one ebit. Two-qubit gates up to local unitaries are classified by the Cartan (KAK) decomposition ; CNOT corresponds to .
Key takeaways
- The tensor product is basis-free; a Kronecker matrix requires an ordered product basis. Lexicographic order gives the mixed-radix index .
- Kronecker identities: mixed products, traces, ranks and spectra multiply, and .
- Reordering qubits is conjugation by a permutation unitary; big- and little-endian are related by bit reversal, .
- Reshaping a bipartite state into its coefficient matrix turns into and partial traces into and .
- Control and target are basis-dependent: conjugation by reverses a CNOT.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Qubits . What is the basis index in big-endian and in little-endian order, respectively?
- and
- and
- and
- and
Show the answer
C. and
Big-endian: . Little-endian: . Bit reversal maps .
is with , and is with . What is ?
Show the answer
B.
: each determinant is raised to the dimension of the other factor.
With (row-major coefficient matrix), which matrix represents ?
Show the answer
D.
.
Which gate equals ?
- SWAP
Show the answer
A.
With and , the product is : a CNOT with control qubit 1 and target qubit 0.
Further reading
- R. A. Horn & C. R. Johnson, Topics in Matrix Analysis, ch. 4 (Cambridge, 1991).
- C. F. Van Loan, "The ubiquitous Kronecker product", J. Comput. Appl. Math. 123, 85 (2000).
- J. R. Magnus & H. Neudecker, "The commutation matrix: some properties and applications", Ann. Statist. 7, 381 (1979).
- B. Coecke & A. Kissinger, Picturing Quantum Processes (Cambridge, 2017).
- S. B. Bravyi & A. Yu. Kitaev, "Fermionic quantum computation", Ann. Phys. 298, 210 (2002).