Is it right?
How it is checked
Every simulation is exact or checked against an independent method: a textbook formula, a second numerical method, or numpy, Qiskit and PennyLane in the Python lab. These 213 automated checks (some run once per reference case) run on every change.
Statevector engine 6
Gates, measurement and collapse, classical control, textbook formatting.
- measurement collapses the state with the right probabilities
- measuring one half of a Bell pair fixes the other half
- classically controlled gates only fire on the right bit
- ketOrder lists basis states in reading order
- swap exchanges qubits and the seeded RNG is repeatable
- states are written the way a textbook would
Bloch-sphere geometry 5
Every single-qubit gate as a rotation of the Bloch arrow.
- Bloch vectors of the six cardinal states
- an entangled qubit has a zero-length Bloch vector
- rotationOf recovers axis and angle, and predicts what the gate does to the arrow
- rotationMatrix matches the gate it came from, and any fraction of it
- Bloch angles and global phase removal
Hamiltonian dynamics 5
Exact evolution and Trotter circuits against numpy, scipy and the Qiskit Schwinger Hamiltonian.
- exact and Trotter dynamics match numpy: (each reference case)
- Schwinger preset matches the Qiskit Hamiltonian (particle number and energy)
- parser accepts the documented syntax
- parser rejects malformed input with a readable message
- commuting Hamiltonian has zero Trotter error
Algorithms 5
Deutsch–Jozsa, Bernstein–Vazirani, the QFT, phase estimation and Shor.
- Deutsch-Jozsa: |0...0> has probability 1 for constant and 0 for balanced functions
- Bernstein-Vazirani reads the secret string in one query
- QFT matches the discrete Fourier transform, and the inverse undoes it
- phase estimation: exact binary fractions give a certain answer, others peak nearby
- Shor's algorithm factors 15
Grover’s search 7
The circuit against the closed-form rotation picture.
- gates: H twice is identity, X flips the right qubit, CNOT makes a Bell state
- gates preserve the norm, including complex and controlled ones
- diffuser reflects every amplitude about the average
- success probability after k rounds is sin^2((2k+1) theta)
- optimal rounds reach the first (fewest-queries) peak of the success probability
- the state stays in the Grover plane and rotates by 2 theta per round
- step sequence and sampling
Protocols 4
Teleportation, superdense coding and BB84.
- teleportation delivers the message to Bob for every measurement outcome
- before Bob's correction, his qubit alone carries no information
- superdense coding: Bob always reads the two bits Alice encoded
- BB84: no eavesdropper, no errors; intercept-and-resend causes about 25% errors
Circuit sandbox 5
Link format and every lesson circuit surviving the trip into the sandbox.
- encode and decode round-trip, including angles
- a control dot plus X makes a Bell pair
- controlled swap works and malformed columns produce warnings
- lesson circuits survive the trip into the sandbox
- setCell keeps one cell per wire per column and trims empty columns
Wave mechanics 6
Eigenstates, split-operator evolution, shooting and transmission against exact results.
- FFT matches a direct DFT and inverts
- particle in a box: E_n = n^2 pi^2 / (2 L^2), orthonormal states with n-1 nodes
- harmonic oscillator: E_n = n + 1/2, and the shooting method agrees
- Gaussian packet: minimum uncertainty, then free spreading as sigma(t) = sigma sqrt(1 + (t / 2 sigma^2)^2)
- a coherent state in the oscillator swings like a classical ball without spreading
- transmission matches the exact rectangular-barrier formula, below and above the top
Formula parser 2
The safe V(x) parser, including rejected input.
- formulas evaluate with the usual precedence
- bad formulas give readable errors, and nothing outside the grammar runs
Spin and atoms 9
Stern–Gerlach, magnetic resonance and hydrogen.
- measuring spin along a tilted axis gives cos^2(theta/2)
- Stern-Gerlach chains: z then z keeps everything, z x z brings spin down back
- magnetic resonance: exact rotating-field solution matches direct integration and Rabi
- spin echo: spread-out spins refocus at twice the pulse spacing
- hydrogen radial functions are normalised, orthogonal and give <r> = (3n^2 - l(l+1))/2
- real spherical harmonics are orthonormal on the sphere
- the radial Schrodinger equation, solved numerically, gives E = -1/(2 n^2)
- hydrogen spectrum: energies and the Balmer lines (vacuum wavelengths)
- sampled electron clouds follow |psi|^2
The founding experiments 5
Photoelectric effect, double slit, Mach–Zehnder, bomb tester and Compton scattering.
- photoelectric effect: E = hf, threshold, stopping voltage and Millikan's h/e
- double slit: fringe spacing lambda L / d, marked paths add intensities
- Mach-Zehnder matches the same circuit built from gates: Rx(-pi/2), phase, Rx(-pi/2)
- bomb tester: a live bomb is found without exploding a quarter of the time; Zeno pushes it to 1
- Compton scattering: shift h/mc (1 - cos theta), with energy and momentum both conserved
Nonlocality, noise and error correction 5
CHSH, density matrices, decoherence and the repetition and Shor codes.
- CHSH: classical strategies top out at 3/4, quantum reaches 1/2 + sqrt2/4
- density matrices: Bloch round trip, purity, entropy, partial trace of a Bell pair
- decoherence: each environment qubit multiplies the coherence by cos(angle/2)
- repetition code: 3p^2 - 2p^3, and bigger codes help only below p = 1/2
- Shor's code corrects any single-qubit error, including arbitrary rotations
Many particles and approximations 5
Bands, identical particles, perturbation theory, the variational method and WKB.
- Kronig-Penney bands agree with the levels of a long chain of wells
- identical particles: fermions avoid each other, bosons bunch, same state forbidden for fermions
- perturbation theory: a linear field on the oscillator shifts every level by -F^2/2 at second order
- variational method: exact for the oscillator, an upper bound for the quartic well
- WKB: exact for the oscillator, close for a V-shaped well, and a tunnelling estimate
Linear algebra 3
The Hermitian eigensolver and the SVD behind the new lessons.
- the Hermitian eigensolver gives A v = λ v with orthonormal v
- degenerate eigenvalues are found exactly (the 2-qubit identity plus a projector)
- the SVD reconstructs any real matrix with orthonormal factors
Entanglement measures 6
Entropy, concurrence and negativity against exact values and numpy.
- a Bell pair carries one ebit; a product state none
- cos(t/2)|00> + sin(t/2)|11> has C = sin t and the Schmidt coefficients cos(t/2), sin(t/2)
- Wootters concurrence equals 2|ad - bc| for random pure states, and S(A) = S(B)
- Werner states are entangled only above p = 1/3
- GHZ has no pairwise entanglement; W has C = 2/3 for every pair
- entropies and concurrences match numpy on a random 4-qubit state
Quantum channels 4
Kraus operators, Bloch-ball maps and Stinespring circuits checked against each other.
- every channel is trace preserving: sum of K†K is the identity
- the Bloch-ball maps have their textbook form
- each Stinespring circuit, with the environment traced out, reproduces its channel
- repeated noise flows to the fixed point: the centre, or |0> for amplitude damping
State discrimination 3
Helstrom, unambiguous discrimination and the Neumark dilation.
- the Helstrom measurement reaches ½(1 + √(1 − 4 q0 q1 s²)) for any priors
- the unambiguous POVM is never wrong, is conclusive with probability 1 − s, and is a valid POVM
- Neumark: one projective measurement on qubit + ancilla realises the three-outcome POVM
No-cloning and monogamy 4
The copiers’ fidelities and the CKW inequality.
- the CNOT copier copies |0> and |1> but gives fidelity (1 + z²)/2 in general
- the optimal universal cloner gives both copies Bloch vector (2/3) r, fidelity 5/6, for every input
- CKW monogamy: C²(A,B) + C²(A,C) <= C²(A,BC), with the same three-tangle from every qubit
- GHZ has three-tangle 1 and no pairwise entanglement; W has tangle 0 and C² = 4/9 per pair
Quantum walks 4
Ballistic spreading and the classical limit under noise.
- the quantum walk conserves probability and the symmetric coin gives a symmetric walk
- a quantum walk spreads ballistically: <x²>/t² → 1 − 1/√2, against t for a classical walk
- full coin dephasing turns the quantum walk into the classical random walk exactly
- the density-matrix walk with no noise matches the pure walk, and stays normalised with noise
Probability current 3
Plane waves, packets and the continuity equation.
- a plane wave e^{ikx} carries current j = k (ħ = m = 1) and a real wave carries none
- the total current of a packet is its mean momentum: ∫ j dx = ħk0/m
- continuity: the probability that crosses a gate equals the time integral of j there
Delta potentials 3
Bound states and transmission against the grid solvers.
- the bound state has E = −α²/2, is normalised and has the derivative jump −2α ψ(0)
- transmission is k²/(k² + α²) for attractive and repulsive spikes alike
- the double delta has an even level, and an odd one only when αa > 1/2, matching the grid solver
Particle on a ring 2
Revivals and flux-shifted levels.
- a packet on a ring revives exactly at t = 4πR², and at half that time it sits on the far side
- the ring levels (n − Φ)²/2R² match a finite-difference ring with the flux as a hopping phase
Angular momentum 4
Commutators, Wigner rotations and Clebsch–Gordan coefficients, two ways.
- [Jx, Jy] = i Jz and J² = j(j + 1) for every spin
- the rotation exp(−iβJy) built from eigenvectors equals Wigner’s closed formula
- Clebsch–Gordan: textbook values and orthonormality
- diagonalising J² gives the allowed J values and the Clebsch–Gordan states (up to sign)
Fermi’s golden rule 5
First-order theory, exponential decay, recurrences and the Lorentzian line shape.
- first-order perturbation theory matches the exact evolution while the level is barely depleted
- Fermi’s golden rule: the level decays as e^{−Γt} with Γ = 2πV²/δ
- a finite band gives the probability back at the recurrence time 2π/δ
- a level far outside the band does not decay
- after the decay the band holds a Lorentzian of width Γ (shifted by the band’s self-energy)
Adiabatic evolution 3
Landau–Zener transitions and Berry’s phase.
- a Landau–Zener sweep jumps diabatically with probability exp(−πΔ²/2α)
- a slow sweep follows the ground state (adiabatic theorem); a sudden one stays put
- Berry’s phase: a slow loop adds −Ω/2 on top of the dynamic phase
Quantum statistics 4
Chemical potentials, the Sommerfeld expansion and Bose–Einstein condensation.
- the chemical potential reproduces the particle number for all three statistics
- at high temperature Fermi–Dirac and Bose–Einstein both approach Boltzmann
- Sommerfeld: fermions in a 3D trap have μ ≈ E_F [1 − (π²/3)(T/E_F)²]
- Bose–Einstein condensation in a trap: N0/N → 1 − (T/Tc)³
Stabilizer simulator 5
The tableau simulator against the statevector engine on random Clifford circuits.
- every stabilizer the tableau reports leaves the statevector unchanged (random Clifford circuits)
- measurements: deterministic exactly when the statevector says so, with the same outcome
- Pauli expectations: ±1 for stabilizer elements, 0 otherwise (Bell and GHZ)
- the tableau handles hundreds of qubits: a 300-qubit GHZ state measures all-equal
- the canonical generators describe the same state (each one stabilizes the statevector)
Surface code and decoders 9
Matching weights and logical error rates against PyMatching, with perfect and with noisy measurements; threshold behaviour.
- the rotated surface code has d² − 1 commuting checks and anticommuting logical operators
- both decoders correct every error of weight ≤ (d − 1)/2 (exhaustive for d = 3 and 5)
- minimum-weight matching agrees with PyMatching’s matching weight on random errors
- logical error rates match PyMatching within statistical error, and show a threshold
- with measurement errors (phenomenological noise) the threshold drops to a few per cent
- the threshold lesson’s scan is reproducible, reports progress, and shows Λ > 1 below threshold
- a space-time run lights detection events exactly at the ends of its fault edges
- in space-time, matching corrects every pattern of one or two faults (repetition code, d = 5, 5 rounds)
- with measurement errors, logical error rates match PyMatching (repetition and surface codes)
Steane’s code 2
Every single-qubit error on every position corrected by the full circuit.
- the encoder makes |0_L> an equal superposition of the 8 even codewords
- any single X, Y or Z error on any of the 7 qubits is corrected; the message comes back
Fields on a lattice 3
Chain modes against diagonalisation; two coupled quantum oscillators in a Fock basis against the phonon formula.
- chain normal modes: ω_k² = w₀² + 4 sin²(q_k/2) matches diagonalising the spring matrix, and the modes are orthonormal
- two coupled quantum oscillators in a truncated Fock basis have exactly the phonon spectrum ω₊(n₊ + ½) + ω₋(n₋ + ½)
- zero-point energy and fluctuations: ⟨u²⟩ grows by 1/ω per phonon added to a mode where it is large
Fock space and Jordan–Wigner 4
Commutation and anticommutation on every basis state; Jordan–Wigner matrix elements; qubit chain spectrum and dynamics against free fermions.
- bosons obey [a_i, a†_j] = δ_ij and fermions {c_i, c†_j} = δ_ij, {c_i, c_j} = 0, on every basis state
- Jordan–Wigner: Z strings times σ± reproduce every fermion matrix element on 4 modes
- the qubit chain ½ Σ (XX + YY) has the free-fermion spectrum: sums of −2t cos(kπ/(N+1)) in every particle-number sector
- fermions hopping on qubits spread exactly like free particles (statevector against single-particle orbitals)
Schwinger model 3
Library against the playground preset; flux-free bare vacuum; Lanczos against dense diagonalisation; string-breaking energies against an independent numpy build.
- the Schwinger library equals the playground preset, and its bare vacuum has no particles and no flux
- Lanczos finds the same ground energy as dense diagonalisation
- string breaking: ground energies and particle numbers with static charges match an independent bit-string build (numpy)
Transverse-field Ising 3
Free-fermion energies and gap against dense diagonalisation and Lanczos; the Kibble–Zurek ramp against the statevector and the τ^(−1/2) law; entanglement scaling.
- transverse-field Ising: the free-fermion ground energy and gap equal dense diagonalisation and Lanczos
- Kibble–Zurek: the free-fermion ramp equals the statevector simulation, and long chains follow n ≈ 1/(2π√(2τ_Q)) for slow ramps
- half-chain entanglement grows with size at h = J but saturates in the paramagnet
Matrix product states 4
Complex SVD; MPS round trip and truncation bound; TEBD second-order convergence to exact evolution; area law and Page’s value.
- complex SVD: U S V† rebuilds the matrix, U and V have orthonormal columns
- an MPS rebuilds any state exactly at full bond dimension, and truncation loses at most the discarded weight
- TEBD converges to exact evolution at second order, with the right entanglement
- area law against volume law: a gapped ground state stays flat, a random state reaches Page’s value
Fields on hardware 2
Schwinger CNOT count against a hand count; Trotter infidelity slopes of orders 1 and 2.
- Schwinger gate count per first-order Trotter step equals the hand count 4(N − 1) + (N − 1)(N − 2)
- Trotter infidelity falls as steps⁻² at first order and steps⁻⁴ at second order
Quantum machine learning 11
Classifier values and parameter-shift gradients, Fourier coefficients, ZZ kernel, H₂ VQE and QAOA against PennyLane; amplitude encoding.
- the re-uploading classifier and its parameter-shift gradient equal PennyLane’s
- a 1-qubit model with L re-uploadings is a Fourier series of degree L, with PennyLane’s coefficients
- kernels: the ZZ feature map matches PennyLane; angle encoding gives the product of cos²
- H₂ (STO-3G, PennyLane Hamiltonians): Hartree–Fock and the one-parameter VQE ansatz reach the HF and FCI energies
- QAOA p = 1 MaxCut expectations equal PennyLane’s
- amplitude encoding: the controlled-RY tree prepares exactly the normalised vector
- on its training points a degree-L quantum model never beats the least-squares Fourier series of degree L
- kernel ridge regression solves (K + λI)α = y, and a 2-qubit kernel matrix has rank at most 16
- barren plateaus: with a shallow circuit the global cost’s gradients vanish exponentially, the local cost’s do not
- the H₂ data shipped with the site equal the PennyLane reference
- the classical Fourier surrogate uses exactly the frequencies an L-layer classifier can produce
Amplitude estimation 2
Outcome distribution against the Brassard–Høyer–Mosca–Tapp formula; their error bound; 1/calls against 1/√calls.
- amplitude estimation: the circuit’s outcome distribution equals the Brassard–Høyer–Mosca–Tapp formula
- with probability ≥ 8/π² the estimate is within the Brassard et al. bound; that error falls as 1/calls, sampling as 1/√calls
Simon’s algorithm 2
Two-to-one oracle; outcome distribution uniform on y·s = 0 for every s; GF(2) recovery of s.
- Simon: the oracle is two-to-one with period s, and the circuit outputs only y with y·s = 0, uniformly
- Simon: n − 1 independent outcomes determine s by linear algebra over GF(2)
Trotter and qDRIFT 2
Exact qDRIFT channel against 4000 sampled sequences and Campbell’s bound; convergence orders 1/N², 1/N⁴ and 1/N.
- qDRIFT: the exact channel equals the average over sampled gate sequences, and stays within Campbell’s bound
- Trotter orders 1 and 2 and qDRIFT converge at their expected rates (1/N², 1/N⁴ and 1/N in infidelity)
Adiabatic quantum computing 2
Spectrum end points; sudden limit 1/2ⁿ; success on a large-gap instance and a small-gap one against 1/Δ².
- adiabatic interpolation: the spectrum starts at −ΣX and ends on the sorted cost values
- annealing: the sudden limit gives 1/2ⁿ, slow runs find the answer, and a small gap demands a long run
HHL 2
Postselected state equals A⁻¹b/‖A⁻¹b‖ and success equals C²‖A⁻¹b‖² when the clock holds the eigenvalues exactly; inexact and ill-conditioned cases.
- HHL: with eigenvalues the clock can hold exactly, the postselected state is A⁻¹b/‖A⁻¹b‖ and succeeds with probability C²‖A⁻¹b‖²
- HHL: eigenvalues between clock values give an imperfect answer, and ill-conditioned systems succeed rarely
Transmon 2
Charge-basis and phase-grid solvers agree; charging parabolas without the junction; Koch et al.’s asymptotic frequency, anharmonicity and charge dispersion.
- transmon: the charge basis and a twisted grid in φ give the same levels
- transmon: Koch et al.’s asymptotic frequency, anharmonicity and charge dispersion are approached at large E_J/E_C
Pulses and DRAG 2
Area theorem in the two-level limit; time-step convergence; DRAG leakage and error optima; slower pulses leak less.
- pulses: a two-level system obeys the area theorem for any pulse length, and the time step is converged
- DRAG on a transmon: β ≈ 1 suppresses leakage, β ≈ 0.5 minimises the gate error, and slower pulses leak less
Randomized benchmarking 3
Clifford group closure; twirled parameters in closed form; fitted decay against the exact twirl for depolarizing, damping and coherent noise; SPAM robustness.
- the single-qubit Clifford group has 24 elements and is closed under multiplication
- twirled noise parameters match their closed forms
- randomized benchmarking recovers the twirled decay rate, independent of SPAM errors, even for coherent errors
Error mitigation 3
Density-matrix simulator against the statevector; folding exact without noise; readout inversion exact; ZNE exact under global depolarizing noise and a large improvement under local noise.
- mitigation: the density-matrix simulator equals the statevector engine, and folding is exact without noise
- readout mitigation inverts independent readout errors exactly
- zero-noise extrapolation: exact for global depolarizing noise, a large improvement for local noise
Final review 2
Shor (N = 15) outcome distribution and factoring for every valid a; the nine-qubit Shor code against every single-qubit error.
- Shor (N = 15): counting outcomes are multiples of 2^t / r, and post-processing factors 15 for every valid a
- Shor’s nine-qubit code corrects any single-qubit X, Y, Z or rotation error on any qubit
Real hardware (IBM Quantum) 2
The Bell-test S recomputed from the raw ibm_kingston counts; the Schwinger reference curve against the site’s engine.
- hardware: the Bell-test S on the site is recomputed exactly from the raw IBM counts
- hardware: the Schwinger reference values (Python/Qiskit) equal the site’s own engine
Toric code and anyons 5
Checks, ground state and the −1 braiding phase, on the tableau and on an 18-qubit statevector.
- toric code: stars and plaquettes commute, and 2L² − 2 of them are independent (two logical qubits)
- the prepared ground state has every star and plaquette at +1 and Z̄ = +1 (tableau, and statevector for L = 3)
- strings create anyons only at their ends: Z strings make e pairs, X strings on the dual lattice make m pairs
- braiding: an e carried around one m picks up −1, around both or none +1 (tableau and statevector)
- a loop around the torus flips a logical qubit without creating any anyon
Magic states 5
Distillation’s weight enumerator against MacWilliams, transversal T on the Reed–Muller code, 35p³ against Monte Carlo, and T injection.
- the undetected error patterns are the Hamming [15,11] code: weight enumerator by MacWilliams, 35 of weight 3
- the code states are a valid [[15,1,3]] code, and fifteen T gates act on it as a logical T†
- 15-to-1 distillation: output error → 35p³, acceptance → 1 − 15p, and Monte Carlo agrees
- distillation helps below a break-even error rate, and two rounds compound
- T-gate injection: both measurement outcomes leave T|ψ⟩ (after the S fix), without it outcome 1 gives T†|ψ⟩
Site structure 6
Lesson pages, teaching notes and this page itself.
- no lesson reuses an id owned by the lesson frame
- no lesson declares the same id twice
- every lesson has teaching notes with well-formed questions
- the catalog is consistent with the pages on disk
- the checks page lists every test (run node web/tools/make-checks.mjs)
- every page script and module compiles as an ES module
Python lab: engine 2
Qiskit and PennyLane, against exact diagonalization.
- trotter matches exact for two qubit ising
- trotter accuracy improves with more steps
Python lab: hardware runs 2
Qiskit and PennyLane, against exact diagonalization.
- folding keeps the ideal circuit and scales the two qubit gates
- stored analyses are reproducible from the raw counts
Python lab: schwinger model 5
Qiskit and PennyLane, against exact diagonalization.
- hamiltonian is hermitian for several sizes
- two site matches hand derivation
- vacuum has zero particle number
- particle number operator eigenvalues are zero or one
- bare vacuum is the strong coupling ground state with no flux
Python lab: schwinger model pennylane 1
Qiskit and PennyLane, against exact diagonalization.
- pennylane matches qiskit up to identity shift