Tensor Products

4 hours ~6 min read

Tensor Products

How do we describe two qubits? Not as a pair of separate vectors — as a single vector in a larger space, the tensor product. This one construction explains the exponential dimension of quantum state spaces (2n2^n, not 2n2n), is the precise origin of entanglement, and is the reason simulating quantum systems is hard classically. It is the capstone of Course 0.1 and the direct gateway to multi-qubit quantum mechanics.

Learning Objectives

After this lesson you will be able to:

  1. Construct the tensor product HAHB\mathcal{H}_A\otimes\mathcal{H}_B and its basis, and explain why dim\dim multiplies.
  2. Compute tensor products of vectors and operators via the Kronecker product.
  3. Apply the mixed-product identity (AB)(CD)=ACBD(A\otimes B)(C\otimes D) = AC\otimes BD.
  4. Distinguish product (separable) from entangled states.
  5. Map all of this to multi-qubit registers in NumPy and (preview) AWS Braket, respecting big-endian ordering.

Intuition

If system AA can be in any of dAd_A basis states and system BB in any of dBd_B, the joint system can be in any combination iAjB|i\rangle_A|j\rangle_B — there are dAdBd_A\cdot d_B such combinations, and the joint state space is their span. Crucially, the joint space contains not just the "both definite" combinations but all superpositions of them, including ones that cannot be pulled apart into "a state of AA" times "a state of BB." Those inseparable states are entangled — the resource behind teleportation, dense coding, and quantum speedups. The tensor product is the machinery that makes "all superpositions of joint configurations" precise.

The dimension count is the headline: nn qubits ⇒ dim=2n\dim = 2^n. Ten qubits already need a 10241024-dimensional complex vector; fifty qubits exceed the memory of any classical computer. That exponential is both the promise and the simulation difficulty of quantum computing.


Theory

Definition

Given finite-dimensional spaces HA\mathcal{H}_A (dim dAd_A, basis {i}\{|i\rangle\}) and HB\mathcal{H}_B (dim dBd_B, basis {j}\{|j\rangle\}), the tensor product HAHB\mathcal{H}_A\otimes\mathcal{H}_B is the dAdBd_A d_B-dimensional space with basis the formal symbols

{ij}i,j,also written ij or ij. \{\, |i\rangle\otimes|j\rangle \,\}_{i,j}, \quad\text{also written } |i\rangle|j\rangle \text{ or } |ij\rangle .

The product \otimes is bilinear:

(ai+bi)j=aij+bij, (a|i\rangle + b|i'\rangle)\otimes|j\rangle = a\,|i\rangle\otimes|j\rangle + b\,|i'\rangle\otimes|j\rangle,

and likewise in the second slot. A general element is i,jcijij\sum_{i,j} c_{ij}\,|i\rangle\otimes|j\rangle — note the coefficients form a matrix cijc_{ij}, not two separate vectors. Hence

dim(HAHB)=dAdB(not dA+dB). \dim(\mathcal{H}_A\otimes\mathcal{H}_B) = d_A\cdot d_B \quad(\text{not } d_A + d_B).

For nn qubits, H=(C2)n=C2n\mathcal{H} = (\mathbb{C}^2)^{\otimes n} = \mathbb{C}^{2^n}.

Inner product on the tensor product

Inner products factor on product vectors and extend bilinearly:

(ab)(cd)=acbd. \big(\langle a|\otimes\langle b|\big)\big(|c\rangle\otimes|d\rangle\big) = \langle a|c\rangle\,\langle b|d\rangle .

So {ij}\{|i\rangle\otimes|j\rangle\} is orthonormal when each factor basis is: $\langle i j| i' j'\rangle = \delta_{ii'}\delta_{jj'}.Thismakes. This makes \mathcal{H}_A\otimes\mathcal{H}_B$ a Hilbert space.

The Kronecker product (coordinates)

In coordinates the tensor product is the Kronecker product. For vectors,

(a1a2)(b1b2)=(a1b1a1b2a2b1a2b2), \begin{pmatrix}a_1\\a_2\end{pmatrix}\otimes\begin{pmatrix}b_1\\b_2\end{pmatrix} = \begin{pmatrix} a_1 b_1\\ a_1 b_2\\ a_2 b_1\\ a_2 b_2\end{pmatrix},

i.e. "scale the whole second vector by each component of the first, stacked." For the qubit basis (our big-endian convention, qubit 0 first — Appendix C):

00=00=(1,0,0,0)T,01=(0,1,0,0)T,10=(0,0,1,0)T,11=(0,0,0,1)T. |00\rangle = |0\rangle\otimes|0\rangle = (1,0,0,0)^T,\quad |01\rangle = (0,1,0,0)^T,\quad |10\rangle = (0,0,1,0)^T,\quad |11\rangle = (0,0,0,1)^T.

The index of q0q1qn1|q_0 q_1\cdots q_{n-1}\rangle is the integer whose binary digits are q0q1q_0 q_1\cdots — exactly how Braket labels amplitudes and reports bit-strings.

Tensor products of operators

If AA acts on HA\mathcal{H}_A and BB on HB\mathcal{H}_B, then ABA\otimes B acts on the product space by

(AB)(ψϕ)=(Aψ)(Bϕ), (A\otimes B)\big(|\psi\rangle\otimes|\phi\rangle\big) = (A|\psi\rangle)\otimes(B|\phi\rangle),

with matrix the Kronecker product of the matrices. "Local" operations are tensor products: applying gate AA to qubit 0 and leaving qubit 1 alone is AIA\otimes I. The single most useful algebra rule:

(AB)(CD)=(AC)(BD)(mixed-product identity), \boxed{\,(A\otimes B)(C\otimes D) = (AC)\otimes(BD)\,}\qquad(\textbf{mixed-product identity}),

proved by acting on product vectors: both sides send ψϕ|\psi\rangle\otimes|\phi\rangle to (ACψ)(BDϕ)(AC|\psi\rangle)\otimes(BD|\phi\rangle), and linearity extends it to all vectors. Consequences: (AB)=AB(A\otimes B)^\dagger = A^\dagger\otimes B^\dagger; tensor of unitaries is unitary; eigenvalues multiply (if Au=auA|u\rangle = a|u\rangle, Bv=bvB|v\rangle = b|v\rangle then $(A\otimes B)(|u\rangle\otimes|v\rangle) = ab,|u\rangle\otimes|v\rangle);and); and \operatorname{Tr}(A\otimes B) = \operatorname{Tr}(A)\operatorname{Tr}(B)$.

Product vs entangled states

A joint pure state is a product (separable) state if it factors:

Ψ=ψAϕB. |\Psi\rangle = |\psi\rangle_A\otimes|\phi\rangle_B .

Otherwise it is entangled. The canonical example is the Bell state

Φ+=12(00+11), |\Phi^+\rangle = \tfrac{1}{\sqrt2}\big(|00\rangle + |11\rangle\big),

which cannot be written as (α0+β1)(γ0+δ1)(\alpha|0\rangle + \beta|1\rangle)\otimes(\gamma|0\rangle + \delta|1\rangle). Proof of inseparability. Expanding the product gives coefficients $\alpha\gamma,|00\rangle + \alpha\delta,|01\rangle + \beta\gamma,|10\rangle + \beta\delta,|11\rangle.Matching. Matching |\Phi^+\rangle$ requires αδ=0\alpha\delta = 0 and βγ=0\beta\gamma = 0 (no 01,10|01\rangle,|10\rangle) but $\alpha\gamma = \beta\delta = \tfrac1{\sqrt2}\neq0.From. From \alpha\delta = 0,either, either \alpha=0(killing (killing \alpha\gamma$) or δ=0\delta=0 (killing βδ\beta\delta) — contradiction either way. So no factorization exists. ∎

Separability test via the coefficient matrix. Write Ψ=ijcijij|\Psi\rangle = \sum_{ij}c_{ij}|i\rangle|j\rangle and form the matrix C=(cij)C = (c_{ij}). The state is a product state iff rank(C)=1\operatorname{rank}(C) = 1. The number of nonzero singular values of CC (the Schmidt rank) quantifies entanglement — developed in Term 1.4 · Schmidt Decomposition. For Φ+|\Phi^+\rangle, C=12IC = \tfrac1{\sqrt2}I has rank 22 ⇒ entangled.

Partial trace (preview)

To describe just subsystem AA of a joint state, we "trace out" BB with the partial trace ρA=TrB(ρAB)\rho_A = \operatorname{Tr}_B(\rho_{AB}), defined by $\operatorname{Tr}_B(|a\rangle\langle a'|\otimes |b\rangle\langle b'|) = |a\rangle\langle a'|,\langle b'|b\rangle$ and linear extension. For an entangled pure state this yields a mixed ρA\rho_A — the signature of entanglement. We make this precise in Term 1.5 · Partial Trace; it's flagged here so you know where \otimes leads.


Worked Examples

Example 1 — Building a two-qubit state and applying a local gate

Prepare +0|+\rangle\otimes|0\rangle and then apply XX to qubit 1 (i.e. IXI\otimes X).

+0=12(0+1)0=12(00+10). |+\rangle\otimes|0\rangle = \tfrac1{\sqrt2}(|0\rangle+|1\rangle)\otimes|0\rangle = \tfrac1{\sqrt2}(|00\rangle + |10\rangle).

Apply IXI\otimes X (flip qubit 1): X0=1X|0\rangle = |1\rangle, so each ket's second slot flips:

(IX)12(00+10)=12(01+11)=+1. (I\otimes X)\,\tfrac1{\sqrt2}(|00\rangle + |10\rangle) = \tfrac1{\sqrt2}(|01\rangle + |11\rangle) = |+\rangle\otimes|1\rangle .

Still a product state — local gates never create entanglement; you need a genuinely two-qubit gate like CNOT (Term 2.1) for that.

Example 2 — CNOT turns a product state into a Bell state

Recall CNOT (control = qubit 0) acts as a,ba,ab|a,b\rangle\mapsto|a,\,a\oplus b\rangle. Start from +0=12(00+10)|+\rangle\otimes|0\rangle = \tfrac1{\sqrt2}(|00\rangle + |10\rangle):

CNOT12(00+10)=12(00+11)=Φ+. \text{CNOT}\,\tfrac1{\sqrt2}(|00\rangle + |10\rangle) = \tfrac1{\sqrt2}(|00\rangle + |11\rangle) = |\Phi^+\rangle .

The input was separable; the output is the maximally entangled Bell state (we proved it's non-factorable above). This two-line computation is the heart of Bell-state preparation, which you'll run on Braket in Term 2.


Hands-on (Python)

import numpy as np
from functools import reduce

ket0 = np.array([1, 0], dtype=complex)
ket1 = np.array([0, 1], dtype=complex)

def tensor(*ops):
    """Kronecker product of any number of vectors/operators (big-endian: first arg = qubit 0)."""
    return reduce(np.kron, ops)

# Two-qubit basis states:
ket00 = tensor(ket0, ket0)        # [1,0,0,0]
ket11 = tensor(ket1, ket1)        # [0,0,0,1]
print(ket00, ket11)

# Local gate on qubit 1 of a 2-qubit register is I ⊗ X:
I = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)
plus = (ket0 + ket1) / np.sqrt(2)
state = tensor(plus, ket0)
print(np.round(tensor(I, X) @ state, 3))    # |+>|1> = (|01>+|11>)/√2
# CNOT (control=qubit 0) and Bell-state creation:
CNOT = np.array([[1, 0, 0, 0],
                 [0, 1, 0, 0],
                 [0, 0, 0, 1],
                 [0, 0, 1, 0]], dtype=complex)
bell = CNOT @ tensor(plus, ket0)
print(np.round(bell, 3))                      # [0.707, 0, 0, 0.707] = |Φ+>

# Mixed-product identity (A⊗B)(C⊗D) = AC⊗BD:
A, B, C, D = X, I, I, X
lhs = tensor(A, B) @ tensor(C, D)
rhs = tensor(A @ C, B @ D)
print(np.allclose(lhs, rhs))                  # True
# Separability test via the coefficient matrix's rank (Schmidt rank):
def schmidt_rank(state_2q):
    C = state_2q.reshape(2, 2)                # c_{ij} for a 2-qubit state
    return np.linalg.matrix_rank(C, tol=1e-9)

print(schmidt_rank(tensor(plus, ket0)))       # 1 -> product (separable)
print(schmidt_rank(bell))                     # 2 -> entangled

Braket preview. In Term 2 you'll write Circuit().h(0).cnot(0, 1) and the simulator returns a length-2n2^n amplitude vector indexed exactly as tensor(...) produces here (big-endian). Everything a multi-qubit simulator does is Kronecker products and matrix–vector multiplication on this space.


Exercises

E1 (easy). Compute 1+|1\rangle\otimes|+\rangle as a 4-vector and identify which computational basis kets appear.

Solution

$|1\rangle\otimes\tfrac1{\sqrt2}(|0\rangle+|1\rangle) = \tfrac1{\sqrt2}(|10\rangle + |11\rangle) = \tfrac1{\sqrt2}(0,0,1,1)^T.Basiskets. Basis kets |10\rangleand and |11\rangle$ appear, each with amplitude 1/21/\sqrt2.

E2 (easy). Show dim\dim of nn qubits is 2n2^n and compute it for n=1,10,50n = 1,10,50. Why does this make classical simulation hard?

Solution

Each qubit contributes a factor of 22, so dim=2n\dim = 2^n: 22, 10241024, 1.13×1015\approx 1.13\times10^{15}. Storing a 50-qubit complex state vector needs 250×16\sim 2^{50}\times 16 bytes 18\approx 18 PB — infeasible. The exponential dimension is why classical simulation blows up (and motivates tensor-network methods like Braket's TN1 for structured cases — Term 5.2).

E3 (medium). Prove the mixed-product identity (AB)(CD)=ACBD(A\otimes B)(C\otimes D) = AC\otimes BD by acting on an arbitrary product vector, then argue it holds on all vectors.

Solution

On a product vector: $(A\otimes B)(C\otimes D)(|\psi\rangle\otimes|\phi\rangle) = (A\otimes B)(C|\psi\rangle\otimes D|\phi\rangle) = AC|\psi\rangle\otimes BD|\phi\rangle = (AC\otimes BD)(|\psi\rangle\otimes|\phi\rangle)$. Product vectors {ij}\{|i\rangle\otimes|j\rangle\} form a basis, and both sides are linear operators agreeing on a basis, so they are equal everywhere. ∎

E4 (medium). Determine whether 12(00+01+10+11)\tfrac12(|00\rangle + |01\rangle + |10\rangle + |11\rangle) is entangled. Factor it if separable.

Solution

Coefficient matrix C = \tfrac12\begin{psmallmatrix}1&1\\1&1\end{psmallmatrix} has rank 11 ⇒ separable. Factor: 12(0+1)(0+1)=++\tfrac12(|0\rangle+|1\rangle)(|0\rangle+|1\rangle) = |+\rangle\otimes|+\rangle. (Equal superposition over all bit-strings is just +n|+\rangle^{\otimes n} — not entangled.)

E5 (hard). Prove the separability ⟺ rank-1 coefficient matrix criterion for a bipartite pure state Ψ=ijcijij|\Psi\rangle = \sum_{ij}c_{ij}|i\rangle|j\rangle.

Solution

(⇒) If Ψ=ψϕ|\Psi\rangle = |\psi\rangle\otimes|\phi\rangle with ψ=iaii|\psi\rangle = \sum_i a_i|i\rangle, ϕ=jbjj|\phi\rangle = \sum_j b_j|j\rangle, then cij=aibjc_{ij} = a_i b_j, so C=abC = a b^\top is an outer product — rank 11. (⇐) If rank(C)=1\operatorname{rank}(C) = 1, write C=abC = a b^\top for some vectors a,ba,b; then cij=aibjc_{ij} = a_i b_j and Ψ=(iaii)(jbjj)|\Psi\rangle = (\sum_i a_i|i\rangle)\otimes(\sum_j b_j|j\rangle) — separable. More generally, the SVD C=kσkukvkC = \sum_{k}\sigma_k u_k v_k^\dagger gives the Schmidt decomposition Ψ=kσkukvk|\Psi\rangle = \sum_k\sigma_k|u_k\rangle|v_k\rangle, and the count of nonzero σk\sigma_k (Schmidt rank) =1=1 iff separable. ∎ (Full treatment: Term 1.4.)


Checkpoint

  1. Why does dim(HAHB)=dAdB\dim(\mathcal{H}_A\otimes\mathcal{H}_B) = d_A d_B rather than dA+dBd_A + d_B?
  2. Write the Kronecker product of (a1,a2)T(a_1,a_2)^T and (b1,b2)T(b_1,b_2)^T, and state the big-endian index rule.
  3. State the mixed-product identity and one consequence.
  4. Define a product state vs. an entangled state; give the rank test.
  5. What operation gives the state of one subsystem alone, and what's notable about it for entangled states?
Answers
  1. A joint state is a superposition over all pairs (i,j)(i,j) of basis states — there are dAdBd_A d_B of them — and its coefficients form a dA×dBd_A\times d_B matrix.
  2. (a1b1,a1b2,a2b1,a2b2)T(a_1 b_1, a_1 b_2, a_2 b_1, a_2 b_2)^T; q0qn1|q_0\cdots q_{n-1}\rangle sits at the index equal to the binary number q0qn1q_0\cdots q_{n-1} (qubit 0 most significant).
  3. (AB)(CD)=ACBD(A\otimes B)(C\otimes D) = AC\otimes BD; e.g. tensor products of unitaries are unitary, eigenvalues multiply.
  4. Product: ψϕ|\psi\rangle\otimes|\phi\rangle; entangled: not factorable. Separable iff the coefficient matrix has rank 11 (Schmidt rank 11).
  5. The partial trace TrB\operatorname{Tr}_B; for an entangled pure state it yields a mixed reduced state.

Further Reading

  • [NC] Nielsen & Chuang, §2.1.7 (tensor products) and §2.2.8 / §2.5 (entanglement, Schmidt decomposition).
  • [Pre] Preskill, Ph219, Ch. 2–4 — tensor products and bipartite entanglement.
  • [Wat] Watrous, Theory of Quantum Information, Ch. 2 — rigorous tensor-product formalism.

← Prev: Special Operators · Up: Term 0 · Next: 0.2.1 Probability Spaces

Ready to measure your state?

5 exercises · 10 checkpoint questions

Start the quiz