Skip to content

Tensor-product ordering is the convention that says which subsystem is first, which basis vectors appear first in a coordinate column, how local operators are embedded into the full space, and which array axes are contracted in a partial trace.

The abstract Hilbert spaces HA⊗HB\mathcal H_A\otimes\mathcal H_B and HB⊗HA\mathcal H_B\otimes\mathcal H_A are naturally isomorphic when the factors have been identified. Their coordinate representations are not the same object until an ordering convention has been chosen. An ordering mismatch can turn an operation on A into an apparent operation on B or contract the wrong indices in a reduced state.

Helpful background. Product Bases explains how paired labels become coefficients; Operators on Composite Systems explains which factor an operator acts on.

Always declare the ordered tensor product before using compact labels. For a bipartite system the default convention is

HAB=HA⊗HB.\mathcal H_{AB} = \mathcal H_A\otimes\mathcal H_B.

For three factors the default convention is

HABC=HA⊗HB⊗HC.\mathcal H_{ABC} = \mathcal H_A\otimes\mathcal H_B\otimes\mathcal H_C.

Then the compact ket

∣ijk⟩ABC\lvert i j k\rangle_{ABC}

means

∣i⟩A⊗∣j⟩B⊗∣k⟩C.\lvert i\rangle_A \otimes \lvert j\rangle_B \otimes \lvert k\rangle_C.

The subscript is not decoration. It records the order in which the slots are being read. If one writes ∣ij⟩AB\lvert ij\rangle_{AB} and later writes ∣ji⟩BA\lvert ji\rangle_{BA}, the labels are being read in different ordered tensor products.

Parentheses do not usually carry physical information in finite tensor products:

(HA⊗HB)⊗HC≃HA⊗(HB⊗HC).(\mathcal H_A\otimes\mathcal H_B)\otimes\mathcal H_C \simeq \mathcal H_A\otimes(\mathcal H_B\otimes\mathcal H_C).

Ordering does carry information for coordinates, matrices, and software arrays.

For two qubits ordered as A,BA,B, the default computational basis order is

∣00⟩,∣01⟩,∣10⟩,∣11⟩.\lvert00\rangle,\quad \lvert01\rangle,\quad \lvert10\rangle,\quad \lvert11\rangle.

This is the order used for coordinate columns and matrix rows unless a page states otherwise. In this convention,

Array index Basis state Bit values
0 ∣00⟩\lvert00\rangle a=0, b=0a=0,\ b=0
1 ∣01⟩\lvert01\rangle a=0, b=1a=0,\ b=1
2 ∣10⟩\lvert10\rangle a=1, b=0a=1,\ b=0
3 ∣11⟩\lvert11\rangle a=1, b=1a=1,\ b=1

Thus a state

∣Ψ⟩=c00∣00⟩+c01∣01⟩+c10∣10⟩+c11∣11⟩\lvert\Psi\rangle = c_{00}\lvert00\rangle +c_{01}\lvert01\rangle +c_{10}\lvert10\rangle +c_{11}\lvert11\rangle

has coordinate column

(c00c01c10c11).\begin{pmatrix} c_{00}\\ c_{01}\\ c_{10}\\ c_{11} \end{pmatrix}.

Equivalently, for a,b∈{0,1}a,b\in\{0,1\},

index⁡(ab)=2a+b.\operatorname{index}(ab) = 2a+b.

For nn qubits ordered as 1,2,…,n1,2,\ldots,n, the displayed bit string is read left to right:

index⁡(a1a2⋯an)=∑r=1nar 2n−r.\operatorname{index}(a_1a_2\cdots a_n) = \sum_{r=1}^{n} a_r\,2^{n-r}.

This is a big-endian convention for displayed bit strings. Other conventions are common in quantum information software and circuit diagrams, so the convention must be stated whenever a calculation depends on array indices.

Coordinate Columns Are Convention Dependent

Section titled “Coordinate Columns Are Convention Dependent”

The same abstract vector can have different coordinate columns under different orderings. Conversely, the same column vector can represent different physical states if the ordering convention changes.

For example, in the default ABAB order,

(0100)AB\begin{pmatrix} 0\\ 1\\ 0\\ 0 \end{pmatrix}_{AB}

represents ∣01⟩AB\lvert01\rangle_{AB}, meaning

∣0⟩A⊗∣1⟩B.\lvert0\rangle_A\otimes\lvert1\rangle_B.

If a calculation silently changes to the BABA order, the same displayed column would be read as ∣01⟩BA\lvert01\rangle_{BA}, meaning

∣0⟩B⊗∣1⟩A.\lvert0\rangle_B\otimes\lvert1\rangle_A.

Those are not the same statement about the subsystems.

The swap map makes the distinction explicit. Define

SAB:HA⊗HB⟶HB⊗HAS_{AB} : \mathcal H_A\otimes\mathcal H_B \longrightarrow \mathcal H_B\otimes\mathcal H_A

by

SAB(∣i⟩A⊗∣j⟩B)=∣j⟩B⊗∣i⟩A.S_{AB} \bigl( \lvert i\rangle_A\otimes\lvert j\rangle_B \bigr) = \lvert j\rangle_B\otimes\lvert i\rangle_A.

For two qubits, if both spaces use the displayed computational order, the corresponding permutation matrix is

S=(1000001001000001),S = \begin{pmatrix} 1&0&0&0\\ 0&0&1&0\\ 0&1&0&0\\ 0&0&0&1 \end{pmatrix},

so that

S∣00⟩=∣00⟩,S∣01⟩=∣10⟩,S∣10⟩=∣01⟩,S∣11⟩=∣11⟩.S\lvert00\rangle=\lvert00\rangle,\quad S\lvert01\rangle=\lvert10\rangle,\quad S\lvert10\rangle=\lvert01\rangle,\quad S\lvert11\rangle=\lvert11\rangle.

The same two-qubit permutation matrix can describe two different tasks. A physical SWAP exchanges the states of the devices while their labels stay fixed. A coordinate permutation rewrites the same physical situation in BA order. For the latter, transform all arrays together:

ψBA=SψAB,OBA=SOABS†,ρBA=SρABS†.\psi_{BA}=S\psi_{AB},\qquad O_{BA}=SO_{AB}S^\dagger,\qquad \rho_{BA}=S\rho_{AB}S^\dagger.

Then Tr⁡(ρBAOBA)=Tr⁡(ρABOAB)\operatorname{Tr}(\rho_{BA}O_{BA})=\operatorname{Tr}(\rho_{AB}O_{AB}). Moving only the state array generally changes the prediction.

For dimensions dA=2,dB=3d_A=2,d_B=3, AB order uses k=3i+jk=3i+j, whereas BA order uses k′=2j+ik'=2j+i. Thus

ψAB=(c00,c01,c02,c10,c11,c12)T,ψBA=(c00,c10,c01,c11,c02,c12)T.\begin{aligned} \psi_{AB}&=(c_{00},c_{01},c_{02},c_{10},c_{11},c_{12})^T,\\ \psi_{BA}&=(c_{00},c_{10},c_{01},c_{11},c_{02},c_{12})^T. \end{aligned}

The new column reads the old entries in the order 0,3,1,4,2,50,3,1,4,2,5. This permutation is not its own inverse. The return map is SBA=SAB†S_{BA}=S_{AB}^\dagger, with the local dimensions reversed; the familiar two-qubit identity S=S†S=S^\dagger does not apply to every unequal-dimension coordinate permutation.

Operator order follows subsystem order. If

HABC=HA⊗HB⊗HC,\mathcal H_{ABC} = \mathcal H_A\otimes\mathcal H_B\otimes\mathcal H_C,

then an operator acting only on BB is embedded as

IA⊗OB⊗IC.I_A\otimes O_B\otimes I_C.

An operator acting on AA and CC but not BB is embedded as

OACO_{AC}

only after one has explained how it is placed inside the ABCABC ordering. In explicit tensor notation, a product operator on AA and CC has the form

OA⊗IB⊗OC.O_A\otimes I_B\otimes O_C.

A genuinely joint operator on AA and CC with BB as spectator is best described by its matrix elements or by a permutation into adjacent factors, application of the joint operator, and permutation back. The identity on the spectator factor cannot simply be omitted from a matrix implementation.

For two factors,

AB⟨ij∣(A⊗B)∣kl⟩AB=AikBjl.{}_{AB}\langle ij\vert (A\otimes B) \vert kl\rangle_{AB} = A_{ik}B_{jl}.

This equation fixes the matrix convention. The row and column labels are ordered pairs. In the default ABAB basis, the row label ijij is flattened using the same rule as the state-vector index.

Matrix Example: Acting on the Second Qubit

Section titled “Matrix Example: Acting on the Second Qubit”

Let

X=(0110).X = \begin{pmatrix} 0&1\\ 1&0 \end{pmatrix}.

In the default two-qubit ABAB order, the operator that flips the second qubit is

IA⊗XB.I_A\otimes X_B.

Its matrix in the basis ∣00⟩,∣01⟩,∣10⟩,∣11⟩\lvert00\rangle,\lvert01\rangle,\lvert10\rangle,\lvert11\rangle is

I⊗X=(0100100000010010).I\otimes X = \begin{pmatrix} 0&1&0&0\\ 1&0&0&0\\ 0&0&0&1\\ 0&0&1&0 \end{pmatrix}.

The operator that flips the first qubit is

XA⊗IB=(0010000110000100).X_A\otimes I_B = \begin{pmatrix} 0&0&1&0\\ 0&0&0&1\\ 1&0&0&0\\ 0&1&0&0 \end{pmatrix}.

The two matrices are different because they act on different tensor factors. A reliable calculation names the factor, writes the identity factors, and checks the basis order used to flatten the product basis.

Partial trace is basis independent as an operator operation, but array formulas require a basis order. For

HAB=HA⊗HB,\mathcal H_{AB} = \mathcal H_A\otimes\mathcal H_B,

write a matrix element of ρAB\rho_{AB} as

ρab,a′b′.\rho_{a b,a' b'}.

The reduced state on AA is obtained by setting the BB bra and ket labels equal and summing:

(ρA)aa′=∑bρab,a′b.(\rho_A)_{a a'} = \sum_b \rho_{a b,a' b}.

The reduced state on BB is

(ρB)bb′=∑aρab,ab′.(\rho_B)_{b b'} = \sum_a \rho_{a b,a b'}.

For three factors ordered as A,B,CA,B,C, a density matrix has labels

ρabc,a′b′c′.\rho_{a b c,a' b' c'}.

Tracing out BB gives an operator on HA⊗HC\mathcal H_A\otimes\mathcal H_C:

(ρAC)ac,a′c′=∑bρabc,a′bc′.(\rho_{AC})_{a c,a' c'} = \sum_b \rho_{a b c,a' b c'}.

In code this is an axis contraction. The axis labels should be named before the contraction is performed. For a density matrix reshaped as

ρ[a,b,c,a′,b′,c′],\rho[a,b,c,a',b',c'],

tracing out BB contracts the second and fifth axes. It does not contract the first and fourth axes, and it does not depend merely on which subsystem has dimension two.

Array memory layout and subsystem order are distinct choices. For example, if a row-major reshape turns a matrix into axes (a,b,a′,b′)(a,b,a',b'), tracing B means contracting the second and fourth axes. A column-major reshape generally needs a different axis interpretation. Label the axes before taking a trace.

A compact description is enough:

The factor order is AB, array indices are k=a dB+bk=a\,d_B+b, and the density-matrix axes are (a,b,a′,b′)(a,b,a',b'). Tracing B contracts the two B axes.

If a library numbers displayed bits differently, first map its qubit labels to A, B, and so on. The computational examples provide checks using unequal dimensions, which are better at exposing an accidental axis exchange than symmetric Bell states.

Identical arrays can mean different states. The column with its second entry equal to one denotes ∣01⟩|01\rangle only after the basis order is known.

Partial trace follows labels, not dimensions. Several subsystems may have the same dimension. Contract the named row/column pair, not whichever two axes happen to have equal length.

Coordinate changes also act on operators. Use the same permutation on both sides of a density matrix or observable. A permutation of amplitudes alone is a different physical prediction unless the observable is invariant.

  • M. A. Nielsen and I. L. Chuang, Quantum Computation and Quantum Information, 10th anniversary ed., Cambridge University Press, 2010, section 2.1.
  • J. Watrous, The Theory of Quantum Information, Cambridge University Press, 2018, chapter 1. Author manuscript.
  1. In the default two-qubit basis order, what coordinate column represents ∣10⟩AB\lvert10\rangle_{AB}?
Solution

The default order is

∣00⟩,∣01⟩,∣10⟩,∣11⟩.\lvert00\rangle,\quad \lvert01\rangle,\quad \lvert10\rangle,\quad \lvert11\rangle.

Therefore ∣10⟩AB\lvert10\rangle_{AB} is the third basis vector:

(0010).\begin{pmatrix} 0\\ 0\\ 1\\ 0 \end{pmatrix}.
  1. For a three-qubit register ordered as A,B,CA,B,C, write the operator that applies ZZ to BB only.
Solution

The operator is

IA⊗ZB⊗IC.I_A\otimes Z_B\otimes I_C.

The identity factors specify that AA and CC are spectators.

  1. Let ρABC\rho_{ABC} have components ρabc,a′b′c′\rho_{a b c,a' b' c'} in the A,B,CA,B,C order. Write the component formula for tracing out BB.
Solution

Tracing out BB sets the BB row and column labels equal and sums over them:

(ρAC)ac,a′c′=∑bρabc,a′bc′.(\rho_{AC})_{a c,a' c'} = \sum_b \rho_{a b c,a' b c'}.

The remaining operator acts on HA⊗HC\mathcal H_A\otimes\mathcal H_C in the induced A,CA,C order.

  1. For the qubit–qutrit system above, ZA⊗IBZ_A\otimes I_B has diagonal entries (1,1,1,−1,−1,−1)(1,1,1,-1,-1,-1) in AB order. Find its diagonal in BA order. Check the eigenvalue on the physical state ∣1⟩A∣0⟩B|1\rangle_A|0\rangle_B in both descriptions.
Solution

Permuting rows and columns together gives (1,−1,1,−1,1,−1)(1,-1,1,-1,1,-1), the diagonal of IB⊗ZAI_B\otimes Z_A. The state occupies AB array index 3 and BA array index 1. Both corresponding diagonal entries equal −1-1, so the physical result is unchanged.