
# 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 ($2^n$, not $2n$), 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** $\mathcal{H}_A\otimes\mathcal{H}_B$ and its basis, and explain why
   $\dim$ multiplies.
2. Compute tensor products of vectors and operators via the **Kronecker product**.
3. Apply the mixed-product identity $(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 $A$ can be in any of $d_A$ basis states and system $B$ in any of $d_B$, the *joint* system
can be in any combination $|i\rangle_A|j\rangle_B$ — there are $d_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 $A$" times "a state of $B$." 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: $n$ qubits ⇒ $\dim = 2^n$. Ten qubits already need a
$1024$-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 $\mathcal{H}_A$ (dim $d_A$, basis $\{|i\rangle\}$) and $\mathcal{H}_B$
(dim $d_B$, basis $\{|j\rangle\}$), the **tensor product** $\mathcal{H}_A\otimes\mathcal{H}_B$ is the
$d_A d_B$-dimensional space with basis the formal symbols

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

The product $\otimes$ is **bilinear**:

$$
(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 $\sum_{i,j} c_{ij}\,|i\rangle\otimes|j\rangle$ —
note the coefficients form a *matrix* $c_{ij}$, not two separate vectors. Hence

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

For $n$ qubits, $\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:

$$
\big(\langle a|\otimes\langle b|\big)\big(|c\rangle\otimes|d\rangle\big) = \langle a|c\rangle\,\langle b|d\rangle .
$$

So $\{|i\rangle\otimes|j\rangle\}$ is orthonormal when each factor basis is: $\langle i j| i' j'\rangle =
\delta_{ii'}\delta_{jj'}$. 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,

$$
\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](../../appendix/C-notation-glossary.md)):

$$
|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 $|q_0 q_1\cdots q_{n-1}\rangle$ is the integer whose binary digits are $q_0 q_1\cdots$ —
exactly how Braket labels amplitudes and reports bit-strings.

### Tensor products of operators

If $A$ acts on $\mathcal{H}_A$ and $B$ on $\mathcal{H}_B$, then $A\otimes B$ acts on the product space by

$$
(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 $A$ to qubit 0 and leaving qubit 1 alone is $A\otimes I$. The single most useful algebra rule:

$$
\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|\psi\rangle)\otimes(BD|\phi\rangle)$, and linearity extends it to all vectors. Consequences:
$(A\otimes B)^\dagger = A^\dagger\otimes B^\dagger$; tensor of unitaries is unitary; eigenvalues
multiply (if $A|u\rangle = a|u\rangle$, $B|v\rangle = b|v\rangle$ then $(A\otimes B)(|u\rangle\otimes|v\rangle)
= ab\,|u\rangle\otimes|v\rangle$); 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:

$$
|\Psi\rangle = |\psi\rangle_A\otimes|\phi\rangle_B .
$$

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

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

which **cannot** be written as $(\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 $|\Phi^+\rangle$
requires $\alpha\delta = 0$ and $\beta\gamma = 0$ (no $|01\rangle,|10\rangle$) but $\alpha\gamma =
\beta\delta = \tfrac1{\sqrt2}\neq0$. From $\alpha\delta = 0$, either $\alpha=0$ (killing $\alpha\gamma$)
or $\delta=0$ (killing $\beta\delta$) — contradiction either way. So no factorization exists. ∎

> **Separability test via the coefficient matrix.** Write $|\Psi\rangle = \sum_{ij}c_{ij}|i\rangle|j\rangle$
> and form the matrix $C = (c_{ij})$. The state is a product state **iff** $\operatorname{rank}(C) = 1$.
> The number of nonzero singular values of $C$ (the **Schmidt rank**) quantifies entanglement — developed
> in [Term 1.4 · Schmidt Decomposition](../../term-1-quantum-mechanics/c04-entanglement/04-schmidt-decomposition.md).
> For $|\Phi^+\rangle$, $C = \tfrac1{\sqrt2}I$ has rank $2$ ⇒ entangled.

### Partial trace (preview)

To describe just subsystem $A$ of a joint state, we "trace out" $B$ with the **partial trace**
$\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* $\rho_A$ — the signature of entanglement. We make this precise in
[Term 1.5 · Partial Trace](../../term-1-quantum-mechanics/c05-density-matrices/02-partial-trace-reduced-states.md);
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 $|+\rangle\otimes|0\rangle$ and then apply $X$ to qubit 1 (i.e. $I\otimes X$).

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

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

$$
(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,b\rangle\mapsto|a,\,a\oplus b\rangle$. Start from
$|+\rangle\otimes|0\rangle = \tfrac1{\sqrt2}(|00\rangle + |10\rangle)$:

$$
\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)

```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
```

```python
# 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
```

```python
# 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-$2^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\rangle\otimes|+\rangle$ as a 4-vector and identify which computational basis
kets appear.

<details><summary>Solution</summary>

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

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

<details><summary>Solution</summary>

Each qubit contributes a factor of $2$, so $\dim = 2^n$: $2$, $1024$, $\approx 1.13\times10^{15}$. Storing
a 50-qubit complex state vector needs $\sim 2^{50}\times 16$ bytes $\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).
</details>

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

<details><summary>Solution</summary>

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
$\{|i\rangle\otimes|j\rangle\}$ form a basis, and both sides are linear operators agreeing on a basis,
so they are equal everywhere. ∎
</details>

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

<details><summary>Solution</summary>

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

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

<details><summary>Solution</summary>

(⇒) If $|\Psi\rangle = |\psi\rangle\otimes|\phi\rangle$ with $|\psi\rangle = \sum_i a_i|i\rangle$,
$|\phi\rangle = \sum_j b_j|j\rangle$, then $c_{ij} = a_i b_j$, so $C = a b^\top$ is an outer product —
rank $1$. (⇐) If $\operatorname{rank}(C) = 1$, write $C = a b^\top$ for some vectors $a,b$; then
$c_{ij} = a_i b_j$ and $|\Psi\rangle = (\sum_i a_i|i\rangle)\otimes(\sum_j b_j|j\rangle)$ — separable.
More generally, the SVD $C = \sum_{k}\sigma_k u_k v_k^\dagger$ gives the Schmidt decomposition
$|\Psi\rangle = \sum_k\sigma_k|u_k\rangle|v_k\rangle$, and the count of nonzero $\sigma_k$ (Schmidt rank)
$=1$ iff separable. ∎ (Full treatment: [Term 1.4](../../term-1-quantum-mechanics/c04-entanglement/04-schmidt-decomposition.md).)
</details>

---

## Checkpoint

1. Why does $\dim(\mathcal{H}_A\otimes\mathcal{H}_B) = d_A d_B$ rather than $d_A + d_B$?
2. Write the Kronecker product of $(a_1,a_2)^T$ and $(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?

<details><summary>Answers</summary>

1. A joint state is a superposition over *all pairs* $(i,j)$ of basis states — there are $d_A d_B$ of
   them — and its coefficients form a $d_A\times d_B$ matrix.
2. $(a_1 b_1, a_1 b_2, a_2 b_1, a_2 b_2)^T$; $|q_0\cdots q_{n-1}\rangle$ sits at the index equal to the
   binary number $q_0\cdots q_{n-1}$ (qubit 0 most significant).
3. $(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 $1$ (Schmidt rank $1$).
5. The partial trace $\operatorname{Tr}_B$; for an entangled pure state it yields a mixed reduced state.

</details>

---

## 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](06-special-operators.md) · Up: [Term 0](../README.md) · Next: [0.2.1 Probability Spaces](../c02-probability-information/01-probability-spaces.md) →
