
# Multi-Qubit States

> One qubit lives in $\mathbb{C}^2$. Two qubits do **not** live in $\mathbb{C}^2\times\mathbb{C}^2$ —
> they live in the *tensor product* $\mathbb{C}^2\otimes\mathbb{C}^2=\mathbb{C}^4$, and that single
> fact is where the entire mystery of quantum computing begins. This lesson assembles the
> $n$-qubit state space, pins down the big-endian computational basis you will see in every Braket
> bit-string, and gives you a sharp, runnable test for the question that drives the rest of the
> course: *is this state entangled?*

## Learning Objectives

After this lesson you will be able to:

1. Construct the $n$-qubit state space $(\mathbb{C}^2)^{\otimes n}=\mathbb{C}^{2^n}$ and write its
   **computational basis** $\{|q_0\cdots q_{n-1}\rangle\}$ with correct **big-endian** indexing.
2. Distinguish **product (separable)** states from **entangled** states, and prove a given state is
   one or the other.
3. Express **local** operations as tensor products $A\otimes B$ and contrast them with **global**
   (entangling) operations.
4. Apply the **coefficient-matrix / Schmidt-rank** separability test to a bipartite pure state.
5. Build multi-qubit states in NumPy and decide separability numerically via matrix rank.

---

## Intuition

A single qubit is a unit vector $\alpha|0\rangle+\beta|1\rangle$ in $\mathbb{C}^2$. The naïve guess
for two qubits is "a pair of qubits," $(\mathbb{C}^2,\mathbb{C}^2)$ — four real parameters. That guess
is **wrong**, and the reason is the whole story. Quantum mechanics says the joint system can be in any
*superposition* of the four joint configurations $|00\rangle,|01\rangle,|10\rangle,|11\rangle$, so its
state space is the $4$-dimensional span of those configurations: $\mathbb{C}^4$, not a pair of
$\mathbb{C}^2$'s. The extra room — four complex amplitudes instead of two pairs — is exactly the room
where **entanglement** hides.

The headline consequence is exponential: $n$ qubits need $2^n$ complex amplitudes. Most of those
states do **not** factor into "a state of qubit 0" times "a state of qubit 1" times … . A factorable
state is *separable* (boring, classical-ish); a non-factorable one is *entangled* (the resource behind
teleportation, dense coding, and quantum speedups — Term 2). Our job here is to make "factorable"
precise and testable, because everything downstream is a refinement of that distinction.

---

## Theory

### The $n$-qubit state space

By the composite-systems postulate ([1.1.4](../c01-postulates/04-composite-systems-postulate.md)), the
state space of a system built from parts is the **tensor product** of the parts' spaces
([0.1.7](../../term-0-foundations/c01-linear-algebra/07-tensor-products.md)). For $n$ qubits,

$$
\mathcal{H}_n = \underbrace{\mathbb{C}^2\otimes\mathbb{C}^2\otimes\cdots\otimes\mathbb{C}^2}_{n\text{ factors}}
= (\mathbb{C}^2)^{\otimes n} = \mathbb{C}^{2^n},
\qquad \dim\mathcal{H}_n = 2^n .
$$

The dimension **multiplies** ($2\cdot2\cdots = 2^n$), it does not add — this is the single most
important difference between quantum and classical state spaces, and the origin of the simulation wall
at $\sim 50$ qubits.

### The computational basis and big-endian indexing

An orthonormal basis of $\mathcal{H}_n$ is obtained by tensoring the single-qubit basis kets in all
$2^n$ ways:

$$
|q_0 q_1\cdots q_{n-1}\rangle := |q_0\rangle\otimes|q_1\rangle\otimes\cdots\otimes|q_{n-1}\rangle,
\qquad q_k\in\{0,1\}.
$$

We use **big-endian** ordering ([Appendix C](../../appendix/C-notation-glossary.md)): **qubit 0 is
leftmost / most significant**. The bit-string $q_0 q_1\cdots q_{n-1}$ is read as a binary integer that
fixes the basis ket's position in the $2^n$-vector:

$$
\operatorname{index}(|q_0\cdots q_{n-1}\rangle) = \sum_{k=0}^{n-1} q_k\, 2^{\,n-1-k}.
$$

For two qubits this gives $|00\rangle\to 0$, $|01\rangle\to 1$, $|10\rangle\to 2$, $|11\rangle\to 3$, so

$$
|00\rangle=(1,0,0,0)^T,\ \ |01\rangle=(0,1,0,0)^T,\ \ |10\rangle=(0,0,1,0)^T,\ \ |11\rangle=(0,0,0,1)^T,
$$

exactly the Kronecker-product coordinates of [0.1.7](../../term-0-foundations/c01-linear-algebra/07-tensor-products.md).
This is also precisely how Braket's `measurement_counts` keys read (qubit 0 first), so the convention
costs us nothing later. A general $n$-qubit pure state is

$$
|\Psi\rangle = \sum_{x\in\{0,1\}^n} c_x\,|x\rangle, \qquad \sum_x |c_x|^2 = 1, \quad c_x\in\mathbb{C}.
$$

### Local vs global operations

An operation acting on each qubit **independently** is a tensor product of single-qubit operators. To
apply $A$ to qubit 0 and $B$ to qubit 1 of a two-qubit register,

$$
(A\otimes B)\big(|\psi\rangle\otimes|\phi\rangle\big) = (A|\psi\rangle)\otimes(B|\phi\rangle),
$$

and "do nothing to qubit 1" is just $A\otimes I$. These are **local** operations. By the mixed-product
identity ([Appendix E](../../appendix/E-math-identities.md)),
$(A\otimes B)(C\otimes D)=(AC)\otimes(BD)$ — local operations compose factor-by-factor and therefore
**can never produce entanglement** (we prove the relevant direction below). A **global** operation is
any unitary on $\mathcal{H}_n$ that is *not* of the product form $A\otimes B$; the canonical example is
$\mathrm{CNOT}$ (Term 2.1), the entangling two-qubit gate.

### Product (separable) vs entangled states

A bipartite pure state $|\Psi\rangle\in\mathcal{H}_A\otimes\mathcal{H}_B$ is a **product (separable)**
state if it factors,

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

and **entangled** otherwise. (For $n>2$ qubits "separable" usually means *fully* separable,
$|\psi_0\rangle\otimes\cdots\otimes|\psi_{n-1}\rangle$; one may also speak of separability across a
particular bipartition $A\,|\,B$. We treat the bipartite case as the fundamental one.)

**Local operations preserve separability.** If $|\Psi\rangle=|\psi\rangle\otimes|\phi\rangle$ then
$(A\otimes B)|\Psi\rangle=(A|\psi\rangle)\otimes(B|\phi\rangle)$ is again a product. So no amount of
single-qubit gates, applied in parallel, can entangle initially unentangled qubits — you need a global
gate. ∎

### The separability / Schmidt-rank test

We need a *decidable* criterion, not "stare at it and try to factor." Arrange the amplitudes of a
bipartite state into a matrix. Writing the basis of $\mathcal{H}_A$ as $\{|i\rangle\}$ ($d_A$ of them)
and of $\mathcal{H}_B$ as $\{|j\rangle\}$ ($d_B$ of them),

$$
|\Psi\rangle = \sum_{i=0}^{d_A-1}\sum_{j=0}^{d_B-1} c_{ij}\,|i\rangle_A\otimes|j\rangle_B,
\qquad C := (c_{ij}) \in \mathbb{C}^{d_A\times d_B}.
$$

$C$ is the **coefficient matrix**. The criterion is:

$$
\boxed{\ |\Psi\rangle \text{ is a product state} \iff \operatorname{rank}(C) = 1.\ }
$$

**Proof.** ($\Rightarrow$) 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$, i.e.
$C = a\,b^{\top}$ is an outer product of nonzero vectors, which has rank $1$.

($\Leftarrow$) If $\operatorname{rank}(C)=1$, then $C=a\,b^{\top}$ for some nonzero $a\in\mathbb{C}^{d_A}$,
$b\in\mathbb{C}^{d_B}$ (every rank-$1$ matrix is an outer product). Then $c_{ij}=a_i b_j$ and

$$
|\Psi\rangle=\sum_{ij}a_i b_j|i\rangle|j\rangle = \Big(\sum_i a_i|i\rangle\Big)\otimes\Big(\sum_j b_j|j\rangle\Big),
$$

a product state. ∎

The integer $\operatorname{rank}(C)$ — equivalently the number of nonzero **singular values** of $C$ —
is the **Schmidt rank**. Rank $1$ means separable; rank $\ge 2$ means entangled, and a *larger* rank
(with balanced singular values) means *more* entangled. Computing rank via the singular value
decomposition (SVD) is robust to floating-point noise, which is why the code below uses a tolerance.
The full theory — the Schmidt decomposition itself and entanglement entropy — is
[Lesson 1.4.4](04-schmidt-decomposition.md).

> **Why rank, not "can I factor it"?** Factoring by hand is error-prone and does not scale. The rank
> of $C$ is a single number computable in $O((d_Ad_B)\min(d_A,d_B))$ time, gives a yes/no answer, and
> generalizes immediately to a *quantitative* measure of entanglement. It is the workhorse of this
> whole course.

---

## Worked Examples

### Example 1 — Two ways to read $|10\rangle$, and a local flip

Take the two-qubit basis ket $|10\rangle$. **Big-endian:** qubit 0 is $1$, qubit 1 is $0$, binary $10_2=2$,
so it sits at index $2$: $|10\rangle=(0,0,1,0)^T$. As a tensor product,
$|10\rangle=|1\rangle\otimes|0\rangle=\binom{0}{1}\otimes\binom{1}{0}=(0,0,1,0)^T$ — consistent.

Now apply the **local** operation "flip qubit 1, leave qubit 0," i.e. $I\otimes X$:

$$
(I\otimes X)\,|1\rangle\otimes|0\rangle = (I|1\rangle)\otimes(X|0\rangle) = |1\rangle\otimes|1\rangle = |11\rangle .
$$

A product went to a product, as local operations must.

### Example 2 — Is $\tfrac{1}{\sqrt2}(|00\rangle+|11\rangle)$ entangled?

Its coefficient matrix (rows indexed by qubit 0, columns by qubit 1) is

$$
C = \frac{1}{\sqrt2}\begin{pmatrix} c_{00} & c_{01}\\ c_{10} & c_{11}\end{pmatrix}
= \frac{1}{\sqrt2}\begin{pmatrix} 1 & 0\\ 0 & 1\end{pmatrix}.
$$

$\det C = \tfrac12\neq 0$, so $\operatorname{rank}(C)=2$. By the test, the state is **entangled** — this
is the Bell state $|\Phi^+\rangle$ of [Lesson 1.4.2](02-bell-states.md).

Contrast with $\tfrac12(|00\rangle+|01\rangle+|10\rangle+|11\rangle)$, whose coefficient matrix
$C=\tfrac12\binom{1\ \,1}{1\ \,1}$ has $\det C = 0$ and rank $1$ — **separable**, in fact
$|+\rangle\otimes|+\rangle$.

### Example 3 — A three-qubit state across a bipartition

Consider $|\Psi\rangle=\tfrac{1}{\sqrt2}(|000\rangle+|111\rangle)$ (the GHZ state, Term 2.3). Group it
as qubit $0$ ($A$) versus qubits $1,2$ ($B$). The coefficient matrix has shape $2\times 4$ with the
single nonzero entries $c_{0,\,00}=c_{1,\,11}=\tfrac1{\sqrt2}$:

$$
C=\frac1{\sqrt2}\begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 1\end{pmatrix},\qquad \operatorname{rank}(C)=2.
$$

So $|\Psi\rangle$ is entangled across the cut $A\,|\,B$. The lesson: separability is **relative to a
bipartition**, and the coefficient matrix is reshaped accordingly. We reuse this reshape trick
constantly.

---

## 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 kets/operators.
    Big-endian: the FIRST argument is qubit 0 (most significant)."""
    return reduce(np.kron, ops)

def basis_ket(bits):
    """Build a computational-basis ket from a bit-string like '101'."""
    return tensor(*[ket0 if b == '0' else ket1 for b in bits])

# Big-endian indexing: |10> sits at integer index 2 = binary 10.
print(np.real(basis_ket('10')))          # [0. 0. 1. 0.]
print(int('10', 2))                       # 2  -> the position of the lone 1
```

```python
# Local (product) operations are tensor products; e.g. I ⊗ X flips qubit 1 only.
I = np.eye(2, dtype=complex)
X = np.array([[0, 1], [1, 0]], dtype=complex)

state = basis_ket('10')                   # |10>
flipped = tensor(I, X) @ state            # apply X to qubit 1
print(np.real(flipped))                   # [0. 0. 0. 1.] = |11>
```

```python
def coefficient_matrix(state, dA, dB):
    """Reshape a bipartite state vector into its coefficient matrix C (dA x dB)."""
    return state.reshape(dA, dB)

def schmidt_rank(state, dA, dB, tol=1e-9):
    """Number of nonzero singular values of C = the Schmidt rank.
    rank 1  -> product (separable);  rank >= 2 -> entangled (across the A|B cut)."""
    C = coefficient_matrix(state, dA, dB)
    s = np.linalg.svd(C, compute_uv=False)    # singular values, descending
    return int(np.sum(s > tol))

# Product state |+>|0>: expect rank 1.
plus = (ket0 + ket1) / np.sqrt(2)
print(schmidt_rank(tensor(plus, ket0), 2, 2))           # 1  -> separable

# Bell state (|00>+|11>)/√2: expect rank 2.
bell = (basis_ket('00') + basis_ket('11')) / np.sqrt(2)
print(schmidt_rank(bell, 2, 2))                         # 2  -> entangled

# Equal superposition |+>|+> over 2 qubits: separable despite "looking" mixed.
equal = 0.5 * (basis_ket('00') + basis_ket('01')
               + basis_ket('10') + basis_ket('11'))
print(schmidt_rank(equal, 2, 2))                        # 1  -> separable
```

```python
# Separability is RELATIVE to a bipartition. GHZ = (|000>+|111>)/√2,
# cut qubit 0 (dim 2) vs qubits 1,2 (dim 4):
ghz = (basis_ket('000') + basis_ket('111')) / np.sqrt(2)
print(schmidt_rank(ghz, 2, 4))                          # 2  -> entangled across 0|12
```

> **Floating-point note.** Never test singular values for exact zero. Use a tolerance (here `1e-9`);
> simulator amplitudes and any non-trivial preparation accumulate rounding error. This mirrors how the
> real Schmidt-decomposition code in [Lesson 1.4.4](04-schmidt-decomposition.md) treats tiny singular
> values as numerical zeros.

---

## Exercises

**E1 (easy).** Write the four-qubit basis ket $|1011\rangle$ as a $16$-vector index, and as a tensor
product of single-qubit kets.

<details><summary>Solution</summary>

Binary $1011_2 = 8+0+2+1 = 11$, so $|1011\rangle$ is the unit vector with a $1$ at index $11$ (and $0$
elsewhere). As a tensor product, $|1011\rangle=|1\rangle\otimes|0\rangle\otimes|1\rangle\otimes|1\rangle$
(qubit 0 leftmost).
</details>

**E2 (easy).** How many *real* parameters does a normalized $n$-qubit pure state have, after removing
the global phase? Evaluate for $n=1,2,3$.

<details><summary>Solution</summary>

A state has $2^n$ complex amplitudes $= 2\cdot 2^n$ real numbers. Normalization removes $1$; the
irrelevant global phase removes another $1$. So $2^{n+1}-2$ real parameters: $n=1\Rightarrow 2$ (the
Bloch sphere), $n=2\Rightarrow 6$, $n=3\Rightarrow 14$.
</details>

**E3 (medium).** Show that $|\psi\rangle=\tfrac{1}{\sqrt2}(|00\rangle+|10\rangle)$ is separable by
factoring it, then confirm $\operatorname{rank}(C)=1$.

<details><summary>Solution</summary>

$\tfrac1{\sqrt2}(|00\rangle+|10\rangle)=\tfrac1{\sqrt2}(|0\rangle+|1\rangle)\otimes|0\rangle
=|+\rangle\otimes|0\rangle$. Coefficient matrix $C=\tfrac1{\sqrt2}\binom{1\ \,0}{1\ \,0}$ has identical
nonzero structure only in its first column, so its columns are linearly dependent ⇒ rank $1$. Separable. ✓
</details>

**E4 (medium).** The state $\tfrac{1}{\sqrt3}(|00\rangle+|01\rangle+|10\rangle)$ — is it entangled?
Justify with the rank test.

<details><summary>Solution</summary>

$C=\tfrac1{\sqrt3}\begin{psmallmatrix}1&1\\1&0\end{psmallmatrix}$. $\det C=\tfrac13(1\cdot0-1\cdot1)
=-\tfrac13\neq0$, so $\operatorname{rank}(C)=2$ ⇒ **entangled**. (It cannot be written as a single
product; there is no way to get $|00\rangle,|01\rangle,|10\rangle$ but not $|11\rangle$ from a product.)
</details>

**E5 (hard).** Prove that a single-qubit-on-each-side local unitary $U_A\otimes U_B$ leaves the
**Schmidt rank** of any bipartite pure state unchanged. (Hence local operations cannot change *whether*
a state is entangled.)

<details><summary>Solution</summary>

Let $|\Psi\rangle$ have coefficient matrix $C$. Acting with $U_A\otimes U_B$ sends $c_{ij}\mapsto
\sum_{kl}(U_A)_{ik}(U_B)_{jl}c_{kl}$, i.e. $C\mapsto U_A\,C\,U_B^{\top}$. Multiplying by the invertible
matrices $U_A$ (left) and $U_B^{\top}$ (right) is multiplication by full-rank matrices, which preserves
matrix rank: $\operatorname{rank}(U_A C U_B^{\top})=\operatorname{rank}(C)$. So the Schmidt rank — hence
separable-vs-entangled — is invariant under local unitaries. ∎
</details>

**E6 (hard).** Generalize the rank test to detect whether an $n$-qubit state is entangled across the
bipartition "qubit $0$ vs the rest." Describe the reshape and the rank you'd compute, and what rank
range is possible.

<details><summary>Solution</summary>

Reshape the $2^n$-vector into a $2\times 2^{n-1}$ matrix $C$ (rows = qubit 0's basis, columns = the
other $n-1$ qubits' joint basis). Compute $\operatorname{rank}(C)$ (equivalently the number of nonzero
singular values). Since $C$ has $2$ rows, the rank is $1$ or $2$: rank $1$ ⇒ qubit 0 is unentangled
from the rest; rank $2$ ⇒ entangled across that cut. (For a balanced cut into $k$ and $n-k$ qubits, the
matrix is $2^k\times 2^{n-k}$ and the rank can be up to $\min(2^k,2^{n-k})$.)
</details>

---

## Checkpoint

1. Why is the two-qubit state space $\mathbb{C}^4$ and not "two copies of $\mathbb{C}^2$"? What is
   $\dim$ for $n$ qubits?
2. Give the big-endian index of $|110\rangle$.
3. What is the difference between a local and a global operation? Why can't a local operation create
   entanglement?
4. State the coefficient-matrix separability test and the meaning of Schmidt rank.
5. Is separability an absolute property of a multi-qubit state, or relative to something?

<details><summary>Answers</summary>

1. The composite postulate uses the *tensor product*, whose dimension multiplies: $2\cdot2=4$ for two
   qubits and $2^n$ for $n$. The joint system can be in any superposition of the $4$ (resp. $2^n$) joint
   configurations.
2. $110_2 = 6$, so $|110\rangle$ is at index $6$.
3. Local $=A\otimes B$ (acts factor-wise); global $=$ any unitary not of product form (e.g. CNOT).
   Local ops send products to products: $(A\otimes B)(|\psi\rangle\otimes|\phi\rangle)
   =(A|\psi\rangle)\otimes(B|\phi\rangle)$, so they can't entangle initially unentangled qubits.
4. Form $C=(c_{ij})$ from $|\Psi\rangle=\sum c_{ij}|i\rangle|j\rangle$; the state is a product iff
   $\operatorname{rank}(C)=1$. The Schmidt rank is $\operatorname{rank}(C)=$ number of nonzero singular
   values; $1$ = separable, $\ge 2$ = entangled.
5. Relative to a **bipartition** $A\,|\,B$ (and for $n>2$, "fully separable" means it factors across
   every qubit). The coefficient matrix is reshaped to match the chosen cut.

</details>

---

## Further Reading

- **[NC]** Nielsen & Chuang, §2.2.8 (composite systems) and §2.5 (the Schmidt decomposition).
- **[Pre]** Preskill, *Ph219*, Ch. 2 — bipartite systems and the meaning of separability.
- **[Wat]** Watrous, *Theory of Quantum Information*, Ch. 2 — rigorous tensor-product formalism.
- [0.1.7 Tensor Products](../../term-0-foundations/c01-linear-algebra/07-tensor-products.md) — the
  construction this lesson builds on, including the Kronecker product in coordinates.

---

← Prev: [POVMs & Generalized Measurement](../c03-measurement/03-povm-generalized.md) · Up: [Term 1](../README.md) · Next: [Bell States](02-bell-states.md) →
