Appendix D: Mathematical Refresher

The mathematics this book actually uses. It is less than people expect: linear algebra over complex vectors, plus enough statistics to know when a measurement means something.


Complex numbers

$z = a + bi$, $|z|^2 = z^*z = a^2 + b^2$. Euler: $e^{i\theta} = \cos\theta + i\sin\theta$, so $|e^{i\theta}| = 1$ — a pure phase.

Why it matters: amplitudes are complex, and it is the phase that makes quantum computing work. Interference is amplitudes cancelling, and cancellation needs signs.

Vectors and Dirac notation

A qubit state is a unit vector in $\mathbb{C}^2$:

$$|\psi\rangle = \alpha|0\rangle + \beta|1\rangle = \binom{\alpha}{\beta}, \qquad |\alpha|^2 + |\beta|^2 = 1$$

  • $|\psi\rangle$ — a column vector ("ket")
  • $\langle\psi|$ — its conjugate transpose ("bra")
  • $\langle\phi|\psi\rangle$ — inner product, a complex number
  • $|\psi\rangle\langle\phi|$ — outer product, a matrix

The Born rule: measuring $|\psi\rangle$ in the computational basis gives outcome $k$ with probability $|\langle k|\psi\rangle|^2$.

Tensor products

Two qubits live in $\mathbb{C}^2 \otimes \mathbb{C}^2 = \mathbb{C}^4$:

$$\binom{a}{b} \otimes \binom{c}{d} = \begin{pmatrix} ac \\ ad \\ bc \\ bd \end{pmatrix}$$

$n$ qubits need $2^n$ complex amplitudes. This is the exponential everything turns on — and Chapter 26 measured where it stops being simulable, around 30–35 qubits.

A state that cannot be written as a tensor product is entangled:

$$\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle) \neq |\psi_1\rangle \otimes |\psi_2\rangle$$

Matrices and unitaries

A matrix $U$ is unitary if $U^\dagger U = I$, where $U^\dagger$ is the conjugate transpose. Unitary matrices preserve norm, which is why they preserve probability — every quantum gate is unitary, and therefore reversible.

Hermitian: $A^\dagger = A$. Hermitian matrices have real eigenvalues and are what observables are.

For a Hermitian $H$, $e^{-iHt}$ is unitary. This is how Hamiltonians become circuits.

Eigenvalues and eigenvectors

$A|v\rangle = \lambda|v\rangle$. For a Hermitian $A$, eigenvalues are real and eigenvectors form an orthonormal basis.

Why it matters: VQE finds the lowest eigenvalue of a Hamiltonian; phase estimation extracts an eigenvalue's phase. Both of Part IV's headline algorithms are eigenvalue problems.

The Pauli matrices

$$I = \begin{pmatrix}1&0\\0&1\end{pmatrix}\ \ X = \begin{pmatrix}0&1\\1&0\end{pmatrix}\ \ Y = \begin{pmatrix}0&-i\\i&0\end{pmatrix}\ \ Z = \begin{pmatrix}1&0\\0&-1\end{pmatrix}$$

They are Hermitian and unitary, they anticommute pairwise, and $\{I,X,Y,Z\}^{\otimes n}$ spans all $2^n \times 2^n$ Hermitian matrices. Every observable in this book is a sum of Pauli strings — which is why Chapter 36 counts terms rather than qubits.

Expectation values

$$\langle A \rangle = \langle\psi|A|\psi\rangle$$

Estimated from shots: measure in $A$'s eigenbasis, average the eigenvalues you see. For $Z$ that is $P(0) - P(1)$.

Probability and statistics

Binomial sampling. $N$ shots with probability $p$ gives $\hat p$ with standard error

$$\sigma = \sqrt{\frac{p(1-p)}{N}} \le \frac{1}{2\sqrt{N}}$$

★ This is the single most important formula in the book. Precision costs $1/\epsilon^2$ shots, and every cost model in Parts IV–VII traces back to it. Chapter 36's $1.91\times10^{20}$ shots is this formula with a molecule attached.

Confidence intervals. A 95% interval is roughly $\hat p \pm 1.96\sigma$. Chapter 38 used exactly this to show 20 test bits cannot distinguish a fully compromised channel from a clean one.

Significance. A difference is meaningful when it exceeds its uncertainty:

$$\text{significant} \iff |\Delta| > 2\,\text{SE}$$

Chapter 33 measured $+0.0202 \pm 0.0170$ (not significant) and $+0.0626 \pm 0.0067$ (significant at nine standard errors) in the same experiment.

⚠️ A standard error of exactly zero means it was never estimated, not that it is absent. vqelab.claims.significant() refuses it.

Total variation distance. For comparing measured distributions:

$$\mathrm{TVD}(P,Q) = \tfrac{1}{2}\sum_x |P(x) - Q(x)|$$

The shot-noise floor is $\approx 3/\sqrt{N}$ — a test with a tolerance below it is blind, not strict (Chapter 27).

Complexity notation

$\mathcal{O}(f(n))$ — grows no faster than $f$, up to constants.

Growth Example
$\mathcal{O}(1)$ Deutsch–Jozsa queries
$\mathcal{O}(\log n)$ Bravyi–Kitaev Pauli weight
$\mathcal{O}(n)$ Jordan–Wigner Pauli weight
$\mathcal{O}(n^3)$ DFT, SDP solving
$\mathcal{O}(n^4)$ molecular Hamiltonian terms
$\mathcal{O}(n^7)$ CCSD(T)
$\mathcal{O}(\sqrt{N})$ Grover
$\mathcal{O}(2^n)$ state-vector simulation, full CI

★ Constants matter more than this notation admits. Chapter 21 measured a 20-bit Grover search at 229,944 T gates; Chapter 37 measured a 600,000× stack of mitigations failing to close a $10^8$ gap. Asymptotics tell you which curve wins eventually, not which wins at your problem size.

Binary entropy

$$h_2(x) = -x\log_2 x - (1-x)\log_2(1-x)$$

Zero at 0 and 1, maximum 1 at $x = 1/2$. Chapter 38's secret fraction $r = 1 - 2h_2(Q)$ reaches zero at $Q = 0.110028$.

What you do not need

Real analysis, measure theory, group representation theory, and differential geometry all appear in the research literature and in none of this book's code. If you can multiply complex matrices and compute a confidence interval, you can do everything here.


See also: Appendix B (the matrices), Chapter 5 (statistics in practice), Chapter 27 (when a measurement is blind).