Chapter 0
Introduction: How to Read This Book
A field manual for building quantum information, quantum computing, and quantum machine learning — from a single qubit, with a keyboard under your fingers.
Book 1 of 2 · the via Rust seriesNew here? Start with Quantum Physics via Rust ↗This is Book 2. It re-earns every idea it uses, so you can begin here — but if kets, the Born rule, or entanglement are new, Book 1 builds the physics this book assumes and is the gentler on-ramp.Somewhere in the last few decades, quantum mechanics quietly stopped being only a description of nature and became an engineering discipline. Entanglement turned out to be a currency. Interference turned out to be programmable. Error correction turned out to be possible. And a new question appeared, with the double slit's own strange flavor: if a machine can hold and manipulate amplitudes in a space of dimensions, can it compute or learn something a classical machine cannot?
This is the sequel to Quantum Physics via Rust. That book built the physics — amplitudes, spin, operators, atoms, entanglement — from the double slit up. This one takes the last idea of that book, entanglement, and asks what you can do with it: quantum information (Part I), quantum algorithms (Part II), keeping fragile quanta alive with error correction (Part III), and machine learning rebuilt in Hilbert space (Part IV). You do not need to have read the first book — this one re-earns every idea it uses — but you do need its one habit: nothing on authority. Every claim here is computed, and every computation carries a referee against an exact answer.
The field is spectacular in principle and unforgiving in practice, and it is drowning in hype. This book's antidote is to make you build the thing and measure it: a state-vector simulator, a Shor order-finder, a surface-code decoder, a variational classifier — each one code you can read, run, and break, written in Rust.
0.2The FCP method
F · FormalismC · ConceptsP · PracticeEach chapter interleaves three layers, color-coded throughout. A full pass touches all three:
Formalism. The mathematics, stated precisely and derived completely. If an equation appears, the path to it appears too. No shortcuts, because shortcuts are where confusion hides.
Concepts. The same idea as a live, interactive system: circuits you can rewire, Bloch spheres you can rotate, training curves that descend as you watch. Your visual intuition is a computational device — this layer trains it.
Practice. A Rust lab per chapter. You implement the algorithm or model from scratch, generate its data — measurement statistics, fidelities, decoder success rates, learning curves — and check them against exact results. The browser charts in each chapter are drawn from data these very labs produced.
The order within a chapter varies; the contract does not: nothing is asserted that is not derived; nothing is derived that is not visualized; nothing is visualized that you cannot compute yourself.
Two rules govern the writing, both inherited from Feynman. First, no word before its meaning: a term is never used in a chapter before the chapter that defines it. “Fidelity” waits for channels; “stabilizer” waits for the Pauli group; “barren plateau” waits until you have a gradient to watch flatten. The book is a single staircase, and every step rests on the one below.
Second, an honest scorecard. Quantum computing will not speed up everything, will never replace classical computers, and for many advertised applications the honest verdict is “no known advantage” or “a classical algorithm caught up.” This book states the wins (factoring, simulating quantum systems, certain learning tasks) and the losses (barren plateaus, dequantization) with equal care, because a field worth a decade of your life is one you can see clearly.
0.4The map of the territory
C · ConceptsThe book has four parts, and the route is logical:
Part I builds the machinery: the qubit, the gates, the circuit model, and a state-vector simulator you write yourself; then entanglement as a measurable resource, and the honest mathematics of noise. Part II is the payoff — the algorithms, and a clear account of what each one really buys: interference in the query model, the Fourier family and Shor, Grover and its provable limits, and Feynman's original dream of simulating physics with physics. Part III confronts fragility: how continuous errors become discrete, how codes protect logical qubits, why a threshold exists at all, and what noisy near-term machines can honestly do. Part IV rebuilds machine learning in Hilbert space — feature maps, quantum kernels, variational training — and ends with the field's honest scorecard.
0.5What mathematics you need
F · FormalismHonest prerequisites: linear algebra, complex numbers, and a little probability. Everything else is built on the way. The central object is a qubit — a unit vector in a two-dimensional complex space,
The numbers are probability amplitudes. Measurement returns with probability — the Born rule, a squared length. Two things make this more than fancy probability. Amplitudes can be negative or complex, so they interfere — the engine of every algorithm in Part II. And qubits live not in an -fold copy but in a tensor product of dimension ,
an exponential space whose non-product states are entangled. That exponential is simultaneously the promise of quantum computing (Part II), the reason it is so hard to keep alive (Part III), and the arena machine learning tries to exploit (Part IV). If you are comfortable with equation (0.1), Chapter 1 will feel like coming home.
0.6Why Rust, and the toolchain
P · PracticeCorrectness in this field is not a mood — it is a discipline, and Rust's compiler shares that worldview with the referee ethos of this book. Dimensional slips, aliasing bugs, and accidental copies that silently corrupt a Python notebook simply do not compile here. The crates we use:
num-complex— complex arithmetic, the native language of amplitudesnalgebra— vectors, matrices, eigenproblems for operators and density matricesrand+rand_distr— sampling measurements, noise, and Monte-Carlo error estimatesserde+serde_json— every lab writes its results and referee report as JSON, which this web book's charts read directly
Notably, we build the quantum machinery itself — state vectors, gates, the Fourier transform, decoders — from scratch, with no quantum SDK. The whole point is to see how it works. Install Rust once with rustup, then every lab is cargo run --release inside Rust-QML/<chapter-lab>/. Here is the spirit of the whole enterprise in twenty lines:
1// Your first quantum computation: a qubit is a complex 2-vector, a gate2// is a matrix, a measurement is a squared length. Nothing more — and,3// as the rest of this book shows, nothing less.4use num_complex::Complex64;5type C = Complex64;67fn main() {8 let s = 1.0 / 2.0_f64.sqrt();9 // Start in |0> = (1, 0).10 let psi0 = [C::new(1.0, 0.0), C::new(0.0, 0.0)];11 // The Hadamard gate H = (1/sqrt2) [[1, 1], [1, -1]] builds a12 // superposition: it turns |0> into |+> = (|0> + |1>)/sqrt(2).13 let h = [[C::new(s, 0.0), C::new(s, 0.0)],14 [C::new(s, 0.0), C::new(-s, 0.0)]];15 let psi = [16 h[0][0] * psi0[0] + h[0][1] * psi0[1],17 h[1][0] * psi0[0] + h[1][1] * psi0[1],18 ];19 // Born rule: P(outcome k) = |amplitude_k|^2.20 println!("P(0) = {:.3}, P(1) = {:.3}", psi[0].norm_sqr(), psi[1].norm_sqr());21 // => P(0) = 0.500, P(1) = 0.500. One qubit, one gate, a fair coin22 // made of amplitudes. Every algorithm in this book is this, scaled up.23}
Nine books stand behind these chapters; each chapter's Sources list names the ones it leans on, so you can go deeper at any point.
| Book | What we take from it |
|---|---|
| Nielsen & Chuang, Quantum Computation and Quantum Information | The spine: qubits, circuits, algorithms, and error correction, at the standard reference's rigor |
| Wilde, Quantum Information Theory | Channels, entropies, and the resource theory of entanglement, done carefully |
| Watrous, The Theory of Quantum Information | The precise mathematics of states, channels, and measurements |
| Schuld & Petruccione, Machine Learning with Quantum Computers (2nd ed. of Supervised Learning with Quantum Computers) | The QML backbone: feature maps, kernels, variational classifiers |
| Sutor, Dancing with Qubits | The gentle on-ramp — intuition first, algebra close behind |
| Johnston, Harrigan & Gimeno-Segovia, Programming Quantum Computers | The circuit-builder's view and hands-on gate intuition |
| Scherer, Mathematics of Quantum Computing | The clean linear-algebra derivations behind the gates |
| Schütt et al. (eds.), Machine Learning Meets Quantum Physics | Where learning theory and quantum many-body physics actually meet |
| Jacquier & Kondratyev, Quantum Machine Learning and Optimisation in Finance | The applications frontier: honest limits and open problems |
One warning inherited from all of them: do not ask “but what is the computer really doing?” expecting a classical answer. Nature runs on amplitudes, and a quantum computer is a machine that lets amplitudes interfere on purpose. Our job is to learn that language well enough to calculate, predict, visualize, and build.
The bridge → Chapter 1: Bits to Qubits
Where you stand. You know the method (FCP), the two writing rules (no word before its meaning; an honest scorecard), the toolchain (Rust from scratch), and the map: four parts, from a single qubit to trained quantum models.
The open question. Everything above rests on one object we have only sketched. What exactly is a qubit — how much information does it hold, how is it different from a classical bit, and why is that difference the seed of the whole field?
What comes next. We start from the classical bit and Shannon's measure of information, then let physics force the qubit on us: a unit vector on the Bloch sphere, a continuum of states that nonetheless yields just one bit when measured. We build a single-qubit kit in Rust and measure exactly what a qubit can and cannot store.