
# Complex Vector Spaces

> A quantum state is a vector. Not a metaphor — literally a unit vector in a complex vector space.
> Before we can say what a qubit *is*, we need to be precise about the space it lives in: $\mathbb{C}^n$,
> the complex vector space. You know real vector spaces; the upgrade to $\mathbb{C}$ is small in
> definition but consequential in physics, because complex phases are where quantum interference lives.

## Learning Objectives

After this lesson you will be able to:

1. State the axioms of a vector space over a field and verify them for $\mathbb{C}^n$.
2. Explain why quantum mechanics requires $\mathbb{C}$, not $\mathbb{R}$, as its scalar field.
3. Determine whether a set of complex vectors is **linearly independent** and compute the **dimension** of its span.
4. Identify **subspaces** and produce a **basis** for one.
5. Represent and manipulate complex vectors and bases in NumPy.

---

## Intuition

A vector space is a setting where two operations make sense and play nicely together: you can **add**
two vectors, and you can **scale** a vector by a number (a *scalar*). That's it. Everything else —
bases, dimension, linear maps — is built from those two operations.

In high-school physics the scalars were real numbers and vectors were arrows in space. In quantum
mechanics the scalars are **complex numbers** and the "vectors" are abstract lists of complex
amplitudes. Why complex? Because a quantum amplitude carries a **phase** as well as a magnitude, and
relative phases between components are physically observable — they produce interference, the engine
of quantum speedups. A real-amplitude theory cannot reproduce the observed physics (you'll prove a
sharp version of this when we hit the Bloch sphere and interference in
[Term 1](../../term-1-quantum-mechanics/c02-qubits-bloch/01-the-qubit.md)).

For now: think "lists of complex numbers you can add and scale."

---

## Theory

### Fields

The scalars of a vector space form a **field**: a set $\mathbb{F}$ with addition and multiplication
that are associative, commutative, distributive, have identities $0$ and $1$, and admit additive
inverses and (for nonzero elements) multiplicative inverses. We care about two fields:

- $\mathbb{R}$, the real numbers.
- $\mathbb{C} = \{\,a + bi : a,b \in \mathbb{R}\,\}$ with $i^2 = -1$, the **complex numbers**.

We review $\mathbb{C}$ thoroughly in
[0.3.1 Complex Numbers & Functions](../c03-fourier-methods/01-complex-numbers-functions.md); here we
need only that it is a field and that every complex number $z = a+bi$ has a **conjugate** $z^* = a - bi$
and a **modulus** $|z| = \sqrt{a^2+b^2} = \sqrt{z^* z}$.

### Definition: vector space over a field

A **vector space** over a field $\mathbb{F}$ is a set $V$ with two operations — vector addition
$+ : V \times V \to V$ and scalar multiplication $\cdot : \mathbb{F} \times V \to V$ — satisfying,
for all $u, v, w \in V$ and $a, b \in \mathbb{F}$:

$$
\begin{aligned}
&\textbf{(A1) associativity:} && (u + v) + w = u + (v + w) \\
&\textbf{(A2) commutativity:} && u + v = v + u \\
&\textbf{(A3) zero vector:} && \exists\, 0 \in V \text{ s.t. } v + 0 = v \\
&\textbf{(A4) additive inverse:} && \exists\, (-v) \text{ s.t. } v + (-v) = 0 \\
&\textbf{(M1) compatibility:} && a(bv) = (ab)v \\
&\textbf{(M2) scalar identity:} && 1\,v = v \\
&\textbf{(D1) distributivity over }V: && a(u+v) = au + av \\
&\textbf{(D2) distributivity over }\mathbb{F}: && (a+b)v = av + bv
\end{aligned}
$$

Elements of $V$ are **vectors**; elements of $\mathbb{F}$ are **scalars**. When $\mathbb{F} = \mathbb{C}$
we call $V$ a **complex vector space**.

### The space $\mathbb{C}^n$

The central example for us is

$$
\mathbb{C}^n = \left\{\, \begin{pmatrix} z_1 \\ z_2 \\ \vdots \\ z_n \end{pmatrix} : z_k \in \mathbb{C} \,\right\},
$$

with componentwise addition and scalar multiplication:

$$
\begin{pmatrix} z_1 \\ \vdots \\ z_n \end{pmatrix} + \begin{pmatrix} w_1 \\ \vdots \\ w_n \end{pmatrix}
= \begin{pmatrix} z_1 + w_1 \\ \vdots \\ z_n + w_n \end{pmatrix},
\qquad
a \begin{pmatrix} z_1 \\ \vdots \\ z_n \end{pmatrix} = \begin{pmatrix} a z_1 \\ \vdots \\ a z_n \end{pmatrix}.
$$

The axioms (A1)–(D2) follow directly from the field axioms of $\mathbb{C}$ applied componentwise. A
single qubit's state space is $\mathbb{C}^2$; $n$ qubits live in $\mathbb{C}^{2^n}$ (we'll see *why*
the dimension is $2^n$, not $2n$, in [0.1.7 Tensor Products](07-tensor-products.md)).

> **Note on dimension counting.** As a *real* vector space, $\mathbb{C}^n$ has dimension $2n$ (each
> complex component contributes a real and imaginary part). As a *complex* vector space it has
> dimension $n$. Unless stated otherwise, "dimension" means the complex dimension.

### Linear combinations, span, independence

Let $v_1, \dots, v_m \in V$.

- A **linear combination** is any $\sum_{k=1}^m a_k v_k$ with $a_k \in \mathbb{F}$.
- Their **span** $\operatorname{span}\{v_1,\dots,v_m\}$ is the set of *all* such linear combinations.
  It is always a subspace (see below).
- The set is **linearly independent** if the only solution to

$$
\sum_{k=1}^m a_k v_k = 0 \quad\text{is}\quad a_1 = a_2 = \cdots = a_m = 0.
$$

  Otherwise it is **linearly dependent**: some vector is a linear combination of the others.

### Basis and dimension

A **basis** of $V$ is a linearly independent set that spans $V$. Two foundational facts (proved in
any linear algebra text, e.g. [Axl]):

- **Every basis of a finite-dimensional space has the same number of elements.** That number is the
  **dimension** $\dim V$.
- **Unique representation:** if $\{e_1, \dots, e_n\}$ is a basis, every $v \in V$ has a *unique*
  expansion $v = \sum_k c_k e_k$. The $c_k$ are the **coordinates** of $v$ in that basis.

The **standard (computational) basis** of $\mathbb{C}^n$ is

$$
e_1 = \begin{pmatrix}1\\0\\\vdots\\0\end{pmatrix},\ \
e_2 = \begin{pmatrix}0\\1\\\vdots\\0\end{pmatrix},\ \dots,\
e_n = \begin{pmatrix}0\\0\\\vdots\\1\end{pmatrix}.
$$

For $\mathbb{C}^2$ we rename these $|0\rangle = e_1$ and $|1\rangle = e_2$ — the computational basis
of a qubit. (That bra–ket notation is the subject of [0.1.3 Dirac Notation](03-dirac-notation.md);
we adopt it as soon as inner products are in hand.)

### Subspaces

A subset $W \subseteq V$ is a **subspace** if it is itself a vector space under the inherited
operations. Equivalently (the **subspace test**), $W$ is a subspace iff:

1. $0 \in W$;
2. $W$ is closed under addition: $u, w \in W \Rightarrow u + w \in W$;
3. $W$ is closed under scalar multiplication: $a \in \mathbb{F},\, w \in W \Rightarrow a w \in W$.

Spans are the prototypical subspaces. Subspaces matter physically: a measurement outcome corresponds
to projecting a state onto a subspace (the eigenspace of an observable), which we develop in
[Term 1.3](../../term-1-quantum-mechanics/c03-measurement/01-projective-measurement.md).

---

## Worked Examples

### Example 1 — Verifying linear independence in $\mathbb{C}^2$

Are $v_1 = \begin{pmatrix} 1 \\ i \end{pmatrix}$ and $v_2 = \begin{pmatrix} i \\ -1 \end{pmatrix}$
linearly independent over $\mathbb{C}$?

Set $a v_1 + b v_2 = 0$:

$$
a\begin{pmatrix}1\\i\end{pmatrix} + b\begin{pmatrix}i\\-1\end{pmatrix}
= \begin{pmatrix} a + bi \\ ai - b \end{pmatrix} = \begin{pmatrix}0\\0\end{pmatrix}.
$$

From the top: $a = -bi$. Substitute into the bottom: $(-bi)i - b = -b i^2 - b = b - b = 0$, which holds
for *every* $b$. So a nonzero solution exists (e.g. $b = 1,\ a = -i$): the vectors are **linearly
dependent**. Indeed $v_2 = i\,v_1$ — multiplying by $i$ is a legal complex scaling, so over $\mathbb{C}$
these are the "same direction." (Over $\mathbb{R}$, treating $i$ as a forbidden scalar, they would
look independent — a concrete reminder that the scalar field matters.)

### Example 2 — A basis for a subspace

Let $W = \{ (z_1, z_2, z_3) \in \mathbb{C}^3 : z_1 + z_2 + z_3 = 0 \}$. Is $W$ a subspace, and what is
$\dim W$?

**Subspace check.** $0$ satisfies the constraint. If $u, w \in W$ then $(u+w)$'s components sum to
$0 + 0 = 0$, and $a w$'s components sum to $a \cdot 0 = 0$. All three conditions hold, so $W$ is a
subspace.

**Basis.** The constraint $z_3 = -z_1 - z_2$ leaves $z_1, z_2$ free. Write a general element as

$$
\begin{pmatrix} z_1 \\ z_2 \\ -z_1 - z_2 \end{pmatrix}
= z_1 \begin{pmatrix} 1 \\ 0 \\ -1 \end{pmatrix} + z_2 \begin{pmatrix} 0 \\ 1 \\ -1 \end{pmatrix}.
$$

These two vectors span $W$ and are independent (neither is a scalar multiple of the other), so they
form a basis and $\dim W = 2$. One linear constraint dropped the dimension from $3$ to $2$.

---

## Hands-on (Python)

We make these abstractions concrete with NumPy. Recall from
[Appendix B](../../appendix/B-python-numpy-refresher.md): **always use `dtype=complex`** for states.

```python
import numpy as np

# The computational basis of C^2 (a single qubit).
ket0 = np.array([1, 0], dtype=complex)   # |0>
ket1 = np.array([0, 1], dtype=complex)   # |1>

# A linear combination (a superposition): (3 + 4i)|0> + (1 - 2i)|1>
v = (3 + 4j) * ket0 + (1 - 2j) * ket1
print(v)                                  # [3.+4.j 1.-2.j]

def is_independent(*vectors):
    """A set of vectors is independent iff the matrix with them as columns has full column rank."""
    M = np.column_stack(vectors)          # shape (n, m)
    return np.linalg.matrix_rank(M) == M.shape[1]

v1 = np.array([1, 1j], dtype=complex)
v2 = np.array([1j, -1], dtype=complex)
print(is_independent(v1, v2))             # False  -> v2 = i*v1 (Example 1)

# A genuinely independent pair:
print(is_independent(ket0, ket1))         # True
```

```python
# Coordinates in the standard basis are just the components themselves.
# Expansion v = sum_k c_k e_k is recovered trivially for the standard basis:
coords = v                                 # [3+4j, 1-2j] are the coordinates of v
reconstructed = coords[0] * ket0 + coords[1] * ket1
print(np.allclose(reconstructed, v))       # True

# Dimension of a span = rank of the matrix of spanning vectors.
W_basis = [np.array([1, 0, -1], dtype=complex),
           np.array([0, 1, -1], dtype=complex)]
print(np.linalg.matrix_rank(np.column_stack(W_basis)))   # 2  (Example 2)
```

> Computing coordinates in a *non-standard* basis requires solving a linear system or inverting the
> basis matrix — we'll do that systematically once we have the inner product in
> [0.1.2](02-inner-products-norms.md), where for orthonormal bases it collapses to a simple projection.

---

## Exercises

> Attempt before expanding. Solutions use the conventions of this lesson.

**E1 (easy).** Verify axiom (D2), $(a+b)v = av + bv$, explicitly for $\mathbb{C}^2$ with
$a = 1+i$, $b = 2$, $v = (i, 1)^T$.

<details><summary>Solution</summary>

$(a+b) = 3 + i$, so $(a+b)v = (3+i)(i,\,1)^T = ((3+i)i,\ 3+i)^T = (-1+3i,\ 3+i)^T$.
Separately, $av = (1+i)(i,1)^T = (i + i^2,\ 1+i)^T = (-1+i,\ 1+i)^T$ and $bv = 2(i,1)^T = (2i, 2)^T$.
Then $av + bv = (-1+i+2i,\ 1+i+2)^T = (-1+3i,\ 3+i)^T$. They match. ∎
</details>

**E2 (easy).** Show that $\{(1,1)^T, (1,-1)^T\}$ is a basis of $\mathbb{C}^2$ and find the coordinates
of $(0,1)^T$ in it.

<details><summary>Solution</summary>

Independence: $a(1,1)^T + b(1,-1)^T = (a+b,\ a-b)^T = 0$ forces $a+b=0$ and $a-b=0$, hence $a=b=0$.
Two independent vectors in a 2-dimensional space form a basis. For coordinates solve
$a+b = 0,\ a-b = 1 \Rightarrow a = \tfrac12,\ b = -\tfrac12$. So
$(0,1)^T = \tfrac12(1,1)^T - \tfrac12(1,-1)^T$. (Up to normalization these are $|+\rangle, |-\rangle$.)
</details>

**E3 (medium).** Let $W = \{ (z_1, z_2) \in \mathbb{C}^2 : z_1 = \overline{z_2} \}$ (bar = complex
conjugate). Is $W$ a subspace of the *complex* vector space $\mathbb{C}^2$? Is it a subspace of
$\mathbb{C}^2$ viewed as a *real* vector space?

<details><summary>Solution</summary>

Not a complex subspace: take $w = (1,1) \in W$ (since $\overline{1}=1$). Scale by $i$:
$iw = (i, i)$; but $\overline{i} = -i \neq i$, so $iw \notin W$ — closure under complex scaling fails.
It *is* a real subspace: it contains $0$, and is closed under addition and **real** scaling (for real
$a$, $\overline{a z_2} = a\overline{z_2}$). This is the recurring lesson that "subspace" depends on the
scalar field.
</details>

**E4 (medium).** Prove that any list of vectors containing the zero vector is linearly dependent.

<details><summary>Solution</summary>

Suppose $0$ is among $v_1, \dots, v_m$, say $v_1 = 0$. Then $1\cdot v_1 + 0\cdot v_2 + \cdots + 0\cdot v_m = 0$
is a vanishing linear combination with a **nonzero** coefficient ($a_1 = 1$). By definition the list is
linearly dependent. ∎
</details>

**E5 (hard).** Show that $\mathbb{C}$ is a vector space over $\mathbb{R}$ of dimension $2$, but over
$\mathbb{C}$ of dimension $1$. Generalize to state $\dim_\mathbb{R} \mathbb{C}^n$ vs $\dim_\mathbb{C} \mathbb{C}^n$.

<details><summary>Solution</summary>

Over $\mathbb{R}$: $\{1, i\}$ is independent (no real $a,b$ with $a\cdot 1 + b\cdot i = 0$ except
$a=b=0$) and spans (every $z = a + bi$), so $\dim_\mathbb{R}\mathbb{C} = 2$. Over $\mathbb{C}$:
$\{1\}$ spans (every $z = z\cdot 1$) and is independent, so $\dim_\mathbb{C}\mathbb{C} = 1$. In general
$\dim_\mathbb{C}\mathbb{C}^n = n$ while $\dim_\mathbb{R}\mathbb{C}^n = 2n$, because each complex
coordinate contributes two real degrees of freedom. This is why a single qubit, living in $\mathbb{C}^2$,
has $2\cdot 2 = 4$ real parameters before we impose normalization and discard global phase — leaving
the $2$ real parameters of the Bloch sphere (Term 1.2).
</details>

---

## Checkpoint

1. State the eight vector-space axioms from memory (group them: 4 additive, 2 multiplicative, 2 distributive).
2. Why does quantum mechanics use $\mathbb{C}$ rather than $\mathbb{R}$ as its scalar field?
3. What is the difference between a *spanning set*, a *linearly independent set*, and a *basis*?
4. Give the complex and real dimensions of $\mathbb{C}^3$.
5. State the three conditions of the subspace test.

<details><summary>Answers</summary>

1. (A1) associativity, (A2) commutativity, (A3) zero vector, (A4) additive inverses; (M1) scalar-mult
   compatibility, (M2) scalar identity $1v=v$; (D1) distributivity over vector addition, (D2)
   distributivity over scalar addition.
2. Quantum amplitudes carry a relative **phase**; complex scalars encode magnitude *and* phase, and
   relative phases produce interference, which experiment confirms. A real theory cannot reproduce it.
3. A spanning set reaches every vector by linear combinations; an independent set has no redundancy; a
   basis is both at once (minimal spanning set / maximal independent set).
4. $\dim_\mathbb{C}\mathbb{C}^3 = 3$; $\dim_\mathbb{R}\mathbb{C}^3 = 6$.
5. Contains $0$; closed under vector addition; closed under scalar multiplication.

</details>

---

## Further Reading

- **[Axl]** Axler, *Linear Algebra Done Right*, Ch. 1–2 — vector spaces, span, independence, bases.
- **[NC]** Nielsen & Chuang, §2.1.1 — bases and linear independence in the QC context.
- **[Pre]** Preskill, *Ph219*, Ch. 2 — the linear-algebra setup as physicists use it.

---

← Prev: [Term 0 Overview](../README.md) · Up: [Term 0](../README.md) · Next: [Inner Products & Norms](02-inner-products-norms.md) →
