Learning Path 0 / 8

Math Prerequisites

The minimum math you need to read the rest of the lab. No proofs — just the notation and the rules of the game. If you've seen complex numbers and matrix multiplication, you already know almost everything here.

1 · Vectors — column form & Dirac notation

A quantum state is just a list of complex numbers (a vector). For a single qubit the list has length 2.

|ψ⟩ =
αβ
= α|0⟩ + β|1⟩

The "ket" |ψ⟩ is a column vector. Its conjugate-transpose is the "bra" ⟨ψ| = (α*, β*). The inner product ⟨φ|ψ⟩ is a single complex number. A state is normalised when ⟨ψ|ψ⟩ = |α|² + |β|² = 1.

⟨ψ|ψ⟩ = α*·α + β*·β = |α|² + |β|² = 1

2 · Complex numbers

A complex number is z = a + bi where i² = −1. We use them because quantum amplitudes carry a phase as well as a magnitude.

Conjugate
z* = a − bi
Modulus²
|z|² = z·z* = a² + b²
Polar form
z = r·e = r(cos θ + i sin θ)
Multiplication
e·e = ei(α+β)

Born-rule probabilities use |amplitude|², so an overall phase e on a state is unobservable — only relative phases matter.

3 · Operators & matrices

An operator is a linear map that takes a vector and returns another vector. On a single qubit it is a 2×2 matrix.

A|ψ⟩ =
abcd
·
αβ
=
aα + bβcα + dβ

Composition is just matrix multiplication. A·B means "apply B first, then A". Order matters: in general AB ≠ BA.

4 · Hermitian operators & eigenvalues

The adjoint A ("A-dagger") is the conjugate-transpose. A matrix is Hermitian when A = A. Hermitian operators represent every observable in QM (energy, spin, position, …).

Eigenvalue equation
A|v⟩ = λ|v⟩
Hermitian property
A = A  ⇒  eigenvalues λ are real

Example. The Pauli-Z operator is Hermitian. Its eigenvalues are ±1; its eigenvectors are |0⟩ (eigenvalue +1) and |1⟩ (eigenvalue −1). Measuring "Z" returns one of those two real numbers — never anything else.

5 · Unitary operators

A matrix U is unitary when UU = I. Geometrically, U preserves lengths: ⟨Uψ|Uψ⟩ = ⟨ψ|ψ⟩. So unitary evolution always keeps a normalised state normalised — total probability stays 1.

Defining property
UU = U·U = I
Reversible
U⁻¹ = U

Every quantum gate (X, Y, Z, H, CNOT, …) is unitary. That's why quantum computation is reversible — the only step that isn't is measurement.

The Five Postulates of Quantum Mechanics

The whole edifice of QM rests on five short rules. Everything that follows in this lab — superposition, entanglement, measurement, gates, algorithms — is just these postulates being applied carefully.

① State vector lives in a Hilbert space

The complete state of an isolated quantum system is described by a unit vector |ψ⟩ in a complex Hilbert space ℋ (a complex inner-product space that's closed under limits).

|ψ⟩ ∈ ℋ   with   ⟨ψ|ψ⟩ = 1

For one qubit, ℋ = ℂ² (two complex amplitudes). For n qubits, ℋ = ℂ²ⁿ — the Hilbert space grows exponentially in qubit count. That exponential room is the resource quantum computers exploit.

② Time evolution is unitary

An isolated (no-measurement) quantum system evolves through a unitary operator U. Discretely:

|ψ(t₁)⟩ = U·|ψ(t₀)⟩,  with   UU = I

Continuously, the Schrödinger equation:

i ℏ  d|ψ⟩/dt  =  H |ψ⟩

Here H is the system's Hamiltonian (a Hermitian operator — the observable for energy). Quantum gates are nothing more than carefully chosen unitary U's applied for finite time.

③ Observables are Hermitian operators

Every physically measurable quantity (energy, position, spin, …) is represented by a Hermitian operator A on ℋ. The only possible outcomes of a measurement are the eigenvalues ai of A.

A |ai⟩ = ai |ai⟩,  ai ∈ ℝ

Example: measuring "spin along Z" uses the Pauli-Z operator with eigenvalues ±1 and eigenvectors |0⟩, |1⟩ — these are the only readings the apparatus can ever produce.

④ Born rule

The probability of measuring outcome ai on state |ψ⟩ is the squared modulus of the projection of |ψ⟩ onto the corresponding eigenvector:

P(ai) = |⟨ai|ψ⟩|²

Probabilities of all possible outcomes sum to 1 because |ψ⟩ is normalised. This is the only non-deterministic ingredient in QM — everything else (states, gates, evolution) is fully deterministic.

⑤ Collapse — projective measurement

Immediately after a measurement that returned outcome ai, the system's state collapses to the corresponding (normalised) eigenvector:

|ψ⟩  ⟶  |ai

A second measurement of the same observable will return ai with certainty (probability 1) — the random part is "spent". Collapse is what makes quantum mechanics non-reversible at the moment of measurement, and it's exactly the rule that lets entanglement look like spooky action at a distance.

Putting it together

Every demo in this lab is some combination of these five rules: ① pick a state, ② apply unitary gates, ③ ④ measure an observable to get an eigenvalue with Born-rule probability, ⑤ the state collapses to that eigenvector. Everything else — entanglement, interference, teleportation, error correction — emerges from how those five steps interact.

Density Matrix

The state-vector |ψ⟩ formalism is elegant but limited: it only describes pure states with perfect knowledge. Real quantum systems are often mixed — entangled with an unknown environment, prepared from a probabilistic ensemble, or partial views of larger systems. The density operator ρ generalises |ψ⟩ to handle pure and mixed states uniformly, and lets us reformulate all five QM postulates in a more powerful language.

Definition

For an ensemble where the system is in pure state |ψᵢ⟩ with probability pᵢ:

ρ  =  Σᵢ pᵢ |ψᵢ⟩⟨ψᵢ|
Properties
Hermitian
ρ = ρ
Trace 1
Tr(ρ) = 1
Positive semi-definite
⟨φ|ρ|φ⟩ ≥ 0   ∀ |φ⟩
Pure vs mixed test
Tr(ρ²) = 1 (pure)   ⇔   Tr(ρ²) < 1 (mixed)
Pure state special case

A pure state |ψ⟩ has density matrix:

ρ = |ψ⟩⟨ψ|   (a rank-1 projector)
Bloch-sphere representation (single qubit)

Any single-qubit density matrix can be written as:

ρ = ½ ( I + r⃗ · σ⃗ ),   r⃗ = (rx, ry, rz),   |r⃗| ≤ 1

where σ⃗ = (X, Y, Z) are the Pauli matrices. |r⃗| = 1 → pure state on the Bloch-sphere surface; |r⃗| < 1 → mixed state inside the ball; r⃗ = 0 → maximally mixed ρ = I/2 (no information).

① State postulate (reformulated)

The state of an isolated quantum system is described by a density operator ρ on Hilbert space ℋ, satisfying:

ρ = ρ,   ρ ≥ 0,   Tr(ρ) = 1

Generalises the pure-state postulate (|ψ⟩ ∈ ℋ with ⟨ψ|ψ⟩ = 1) by allowing classical mixtures and entanglement-induced mixedness. Pure states are the special case where ρ has rank 1.

② Evolution postulate (reformulated)

The density operator of an isolated system evolves by unitary conjugation:

ρ(t₁)  =  U·ρ(t₀)·U

Continuously, the von Neumann equation — the density-matrix analog of Schrödinger's equation:

i ℏ  dρ/dt  =  [ Ĥ, ρ ]

For a pure state ρ = |ψ⟩⟨ψ|, this reduces to the standard Schrödinger evolution. The von Neumann equation also extends naturally to open systems (the Lindblad master equation), where dynamics aren't unitary because the system exchanges information with its environment.

③ Observable postulate (reformulated)

Every measurable quantity is represented by a Hermitian operator A with spectral decomposition:

A  =  Σᵢ aᵢ  Pᵢ,   Pᵢ = |aᵢ⟩⟨aᵢ| (eigen-projectors)

Each eigenvalue aᵢ ∈ ℝ is a possible measurement outcome; Pᵢ projects onto the corresponding eigenspace.

Identical to the pure-state version — observables don't depend on how the state is described.

④ Born rule (reformulated)

The probability of measuring outcome aᵢ when the system is in state ρ is given by a trace:

P(aᵢ)  =  Tr( Pᵢ  ρ )

The expectation value of any observable A is:

⟨ A ⟩  =  Tr( A  ρ )

For a pure state, this reproduces the original rule: P(aᵢ) = ⟨ψ|Pᵢ|ψ⟩ = |⟨aᵢ|ψ⟩|² (just unfold ρ = |ψ⟩⟨ψ| and use cyclicity of trace). The trace formula extends linearly to mixed states for free.

⑤ Collapse postulate (reformulated)

If a projective measurement of A returns outcome aᵢ, the post-measurement state is:

ρ'  =  Pᵢ  ρ  Pᵢ   /   Tr( Pᵢ  ρ )

The denominator normalises so that Tr(ρ′) = 1.

For a pure state ρ = |ψ⟩⟨ψ| this reduces to ρ′ = |aᵢ⟩⟨aᵢ| — the familiar collapse to the eigenvector. For a mixed state, only the part of the ensemble consistent with the observed outcome survives. A second measurement of the same observable returns aᵢ with certainty.

Why bother with density matrices?

  • Mixed states. Thermal states, ensembles, partially-known preparations — none have a single |ψ⟩ representation, but they all have a clean ρ.
  • Subsystems via partial trace. If a composite system AB is in a pure entangled state, neither A nor B individually is pure. The reduced state ρA = TrBAB) is a mixed density matrix that correctly predicts every local measurement on A.
  • Open quantum systems. Decoherence is most naturally described by non-unitary evolution of ρ (Kraus operators, Lindblad master equation).
  • Generalised measurements (POVMs). Beyond projective measurements: outcomes characterised by positive operators {Ei} with Σ Ei = I.
  • Information theory. Von Neumann entropy S(ρ) = −Tr(ρ log ρ), channel capacities, quantum error correction — all naturally formulated with ρ.

In modern quantum-computing literature, ρ is the default. The pure-state formalism is a friendly entry point, but every advanced topic — from QEC to quantum information theory to noisy-channel analysis — lives in the density-matrix world.

History of Quantum Mechanics

From a "desperate fix" to the blackbody-radiation puzzle in 1900, to a complete relativistic theory in 1928 — the foundations of quantum mechanics were laid in just three decades. Every name on the timeline below earned a Nobel Prize for this work.

Timeline · 1900 → 1928

1900

Planck — quantization of blackbody radiation

Max Planck · Berlin

To explain the spectrum of light emitted by a hot body, Planck assumed the energy of an oscillator can only take discrete values E = nhν. He called it an "act of desperation" — but it introduced the constant h that would define the quantum world. Nobel Prize 1918.

E = h · ν,   h ≈ 6.626 × 10−34 J·s
1905

Einstein — light quanta & the photoelectric effect

Albert Einstein · Bern

In one of his "annus mirabilis" papers, Einstein argued that light itself comes in discrete packets — photons — to explain why the photoelectric effect depends on a light's frequency, not its intensity. The result earned him the Nobel Prize in 1921 (relativity was still controversial).

Ephoton = h · ν
1906

Einstein — specific heat from quantized oscillators

Albert Einstein · Bern

Classical physics (Dulong–Petit law) predicts a constant specific heat for solids, but real materials drop sharply toward zero at low temperature. Einstein modelled each atom in a crystal as an independent quantized harmonic oscillator with E = nhν. At low T, the oscillators get stuck in the ground state and stop absorbing heat — quantitatively explaining the diamond data. The first time quantum theory crossed from radiation into matter.

⟨E⟩ = h ν / ( ehν / kBT − 1 )
1911

Rutherford — the nuclear atom

Ernest Rutherford · Manchester (gold-foil experiment by Geiger & Marsden, 1909)

Alpha particles fired at thin gold foil mostly passed through, but a few bounced sharply backward. Rutherford concluded the atom is mostly empty space with a tiny dense nucleus. Classically, accelerating electrons in orbit should radiate energy and spiral in — but they don't. The atom was unstable on paper and clearly stable in reality.

1913

Bohr — quantized atomic orbits

Niels Bohr · Copenhagen

Bohr postulated that electrons orbit only at specific, quantized energies and emit/absorb a photon when jumping between levels. The model predicted hydrogen's spectral lines exactly. The first explicit "quantum jump". Nobel Prize 1922.

L = nℏ,    En = − 13.6 eV / n²  (hydrogen)
1922

Stern–Gerlach — discovery of spin

Otto Stern & Walther Gerlach · Frankfurt

A beam of silver atoms passed through an inhomogeneous magnetic field split into exactly two beams — direct evidence that angular momentum is quantized in two values. Later understood as electron spin ±ℏ/2 — there is no classical analogue. Stern: Nobel 1943.

1924

de Broglie — matter waves

Louis de Broglie · Paris (PhD thesis, "Recherches sur la théorie des quanta")

If light has both wave & particle aspects, why not matter? de Broglie proposed every particle has an associated wavelength λ = h/p. Wave-particle duality applies to electrons too. Confirmed in 1927 by the Davisson–Germer electron-diffraction experiment. Nobel Prize 1929.

λ = h / p
1925
June

Heisenberg — the Helgoland "one-man" paper

Werner Heisenberg · Helgoland (recovering from hay fever, alone on the island)

Heisenberg gave up trying to picture electron orbits and worked only with observable quantities — transition amplitudes between energy levels. The mathematics he invented turned out to be matrix multiplication, though he didn't know that yet. Title: "Quantum-theoretical re-interpretation of kinematic and mechanical relations".

1925
Sept

Born & Jordan — the "two-man" paper

Max Born & Pascual Jordan · Göttingen

Born recognised Heisenberg's arrays of numbers as matrices and, with his student Jordan, formalised the theory. They wrote down the canonical commutation relation [x̂, p̂] = iℏ — the algebraic signature of quantum non-commutativity, the heart of the uncertainty principle.

[ x̂, p̂ ] = iℏ
1925
Oct

Uhlenbeck & Goudsmit — electron spin explains Stern–Gerlach

George Uhlenbeck & Samuel Goudsmit · Leiden (graduate students of Ehrenfest)

For three years no one knew what really caused the silver-atom beam to split in two. Uhlenbeck and Goudsmit boldly proposed that the electron itself carries an intrinsic angular momentum of ℏ/2 — what we now call spin — with only two possible projections (±ℏ/2). This retroactively explained Stern–Gerlach AND the anomalous Zeeman effect. Pauli initially mocked the idea (a spinning point particle would need a surface speed faster than light), but the prediction matched experiment too well to ignore.

Sz = ± ℏ / 2,   gs ≈ 2
1925
Nov

Born–Heisenberg–Jordan — the "three-man" paper

Born, Heisenberg, Jordan · Göttingen

The complete matrix-mechanics framework: Zur Quantenmechanik II. The first internally consistent quantum theory. Heisenberg got the Nobel in 1932; Born had to wait until 1954.

1926

Schrödinger — wave mechanics

Erwin Schrödinger · Zurich

Inspired by de Broglie, Schrödinger wrote down a wave equation for the electron. Solving it for hydrogen reproduced Bohr's spectrum naturally, with no quantization assumption. Within months he also proved that his wave mechanics and Heisenberg's matrix mechanics are mathematically equivalent. Nobel Prize 1933 (shared with Dirac).

iℏ · ∂ψ / ∂t = Ĥ ψ
1926

Born — probability interpretation

Max Born · Göttingen

Born proposed that |ψ(x)|² is the probability density for finding a particle at position x. Probabilistic outcomes become a fundamental feature of nature, not a symptom of incomplete knowledge — an idea Einstein never fully accepted ("God does not play dice"). Nobel Prize 1954.

P(x) = | ψ(x) |²
1927

Heisenberg — uncertainty principle

Werner Heisenberg · Copenhagen

A direct consequence of [x̂, p̂] = iℏ: position and momentum can never both be measured to arbitrary precision. The closer you pin one down, the more uncertain the other becomes.

Δx · Δp ≥ ℏ / 2
1927

Dirac — transformation theory unifies wave & matrix mechanics

Paul Dirac · Cambridge

Schrödinger had already shown the two formulations were mathematically equivalent. Dirac went deeper: his transformation theory exhibited both as different "representations" of a single underlying algebraic theory. The modern bra-ket notation (⟨φ|, |ψ⟩) traces back to this work.

1928

Dirac equation — relativistic QM & antimatter

Paul Dirac · Cambridge

By combining quantum mechanics with special relativity, Dirac arrived at a first-order wave equation for the electron. It produced electron spin-½ automatically and predicted negative-energy solutions — interpreted as antimatter. The positron was discovered by Anderson in 1932, confirming the prediction. Nobel Prize 1933 (shared with Schrödinger).

( iℏ γμμ − mc ) ψ = 0

And after the founding era…

  • 1932 — Anderson detects the positron, vindicating Dirac. John von Neumann publishes Mathematical Foundations of Quantum Mechanics, putting QM on rigorous mathematical footing as operators on a Hilbert space with projective measurement — the language used ever since.
  • 1935 — EPR paradox (Einstein, Podolsky, Rosen) and Schrödinger's cat. The interpretation debates begin in earnest.
  • 1948 — Feynman's path-integral formulation.
  • 1964 — Bell's theorem: local hidden variables are testable, and quantum mechanics violates them. (See Bell's Inequality.)
  • 1969CHSH inequality (Clauser, Horne, Shimony & Holt) re-derives Bell's theorem in a form real experiments can actually run: just four correlation measurements on entangled pairs, with the bound |S| ≤ 2 for any local hidden-variable theory.
  • 1972 — Freedman & Clauser perform the first experimental CHSH test using polarization-correlated photons from calcium-atom cascades. The result violates the classical bound — quantum mechanics wins, but several "loopholes" remain.
  • 1981–82 — Alain Aspect's experiments at Orsay close the locality and detection-setting loopholes with switched polarisers, dramatically confirming Bell/CHSH violation.
  • 2015 — First loophole-free Bell tests (Hensen et al., Delft; Giustina et al.; Shalm et al.) — definitively rule out local realism.
  • 1980s+ — Feynman, Deutsch & others propose quantum computers.
  • 1994 — Shor's algorithm. 1996 — Grover's algorithm.
  • 2019 — Google claims "quantum supremacy" with the 53-qubit Sycamore.
  • 2022 — Aspect, Clauser & Zeilinger share the Nobel Prize for their Bell-test experiments.

Qubits — the building block

A classical bit is either 0 or 1. A qubit can be 0, 1, or a blend of both at once — a superposition. Tap the toggle to feel it.

Try it · Bloch sphere toggle

|0⟩
|1⟩

Click a state above.

Mini quiz

Bloch Sphere

The Bloch sphere is the standard 3D picture of a single qubit. Every pure state maps to a unique point on the unit sphere:

|ψ⟩ = cos(θ/2)·|0⟩ + e·sin(θ/2)·|1⟩

θ (polar) is the angle from the |0⟩ pole; φ (azimuth) is the angle around the equator. Drag the sliders or apply gates to watch the state vector rotate.

Spinor twist. Slide θ past 360° and into the 360°–720° range to see one of the strangest features of spin-½ systems: the Bloch vector returns to where it started after a 2π rotation, but the state vector picks up a global −1 phase. Only a 4π (720°) rotation brings the state truly back to itself. That's the spinor property — observable in interferometry experiments with neutrons.

Try it · Rotate the qubit

|0⟩ |1⟩ |+⟩ |−⟩ |+i⟩ |−i⟩
Apply gate:
Preset:

Superposition

Until measured, a qubit can be a mix of |0⟩ and |1⟩. Each outcome has a probability that adds up to 100%. Move the slider to change the balance.

Try it · Probability slider

P(0) = 50%
P(1) = 50%

Mini quiz

Entanglement

Two qubits can be linked so that measuring one instantly tells you about the other — even if they are far apart. This is the magical Bell-state correlation.

Try it · Bell pair

Qubit A
?
Qubit B
?

Press “Measure A” — both will collapse to the same value.

State vector
|Φ⁺⟩ = 1√2·|00⟩ + 1√2·|11⟩
An equal superposition of |00⟩ and |11⟩. The cross-terms |01⟩ and |10⟩ have amplitude 0 — that's the entanglement.

Mini quiz

Bell's Inequality

If the world were ruled by local hidden variables (every qubit secretly carrying its own pre-decided answer), the CHSH quantity |S| could never exceed 2. Real entangled qubits reach up to 2√2 ≈ 2.828. Run the experiment below and watch quantum mechanics break the classical ceiling.

Try it · CHSH experiment

A Bell pair |Φ⁺⟩ is shared between Alice and Bob. Each trial they independently pick a measurement angle at random — Alice from {a₀ = 0°, a₁ = 90°}, Bob from {b₀ = 45°, b₁ = 135°}. We tally same-vs-different outcomes per setting pair and compute the correlation E(aᵢ,bⱼ) = (#same − #diff) / N.

S = E(a₀,b₀) − E(a₀,b₁) + E(a₁,b₀) + E(a₁,b₁)  =  0.000  ·  |S| = 0.000
0 2 classical bound 2√2 quantum bound 4
Press a button to start.

Quantum prediction: |S| → 2√2 ≈ 2.828. Classical max: |S| ≤ 2.

Measurement

Measuring a qubit forces it to choose: 0 or 1. The probabilities decide how often each appears. Run many measurements and watch the pattern emerge.

Try it · Repeated measurement

Counts — zeros: 0   ones: 0

Mini quiz

Quantum Gates Reference

Gates are the building blocks of quantum circuits — small unitary (reversible) operations that rotate qubit states. Each single-qubit gate is a 2×2 matrix; two-qubit gates are 4×4. Hover or scroll the cards below to see each gate's symbol, matrix, effect, and intuition.

Gate library

Quantum Circuits

A circuit is a sequence of gates applied to qubits, executed left to right.

Tips: drag a gate from the palette onto a wire, or click the gate then click a wire. CNOT & CZ are 2-qubit gates — drop them twice, on two different wires (control + target). Right-click a placed Rx/Ry/Rz gate to change its angle. Left-click any placed gate to remove it.

Try it · Circuit builder

2 qubits

Pick a gate, then click a wire to place it.

Probabilities State: |00⟩
Show numeric values
|00⟩  100.00%

Mini quiz

Phase Kickback

One of the most beautiful tricks in quantum computing: a gate that's "controlled by" the control qubit can end up changing the control itself instead of the target. This effect powers Deutsch–Jozsa, phase estimation, and Shor's algorithm.

Rule of thumb: if the target is in an eigenstate |u⟩ of the controlled operation U, with U|u⟩ = e|u⟩, then the phase e "kicks back" onto the control's |1⟩ branch. The target stays put — the control picks up the phase.

Try it · CNOT phase kickback

Setup: control starts in |+⟩ (after H on |0⟩). Pick a target state, then run CNOT. Watch what happens to each qubit.

Before CNOT
|+⟩ ⊗ |−⟩
CNOT ⟶
After CNOT
|−⟩ ⊗ |−⟩

Derivation — phase kickback on an oracle

The identity at the heart of Deutsch–Jozsa, Bernstein–Vazirani, Simon's, and Grover:

U_f |x⟩|−⟩ = (−1)^f(x) |x⟩|−⟩

where the oracle Uf acts on two registers as Uf|x⟩|y⟩ = |x⟩|y ⊕ f(x)⟩ (data register |x⟩ untouched, output qubit XOR-ed with f(x) ∈ {0,1}). Let's derive it line by line.

Step 1 — Expand |−⟩

|−⟩ = (|0⟩ − |1⟩)/√2

Step 2 — Apply Uf by linearity Uf acts on each basis term of the output register separately:

U_f |x⟩|−⟩
  = (1/√2) [ U_f |x⟩|0⟩  −  U_f |x⟩|1⟩ ]
  = (1/√2) [ |x⟩|0 ⊕ f(x)⟩  −  |x⟩|1 ⊕ f(x)⟩ ]
  = |x⟩ ⊗ (1/√2) [ |f(x)⟩  −  |1 ⊕ f(x)⟩ ]

Step 3 — Case split on f(x) The output register is either |0⟩−|1⟩ or |1⟩−|0⟩, depending on f(x):

If f(x) = 0:
   (1/√2) [ |0⟩ − |1⟩ ]   =   +|−⟩

If f(x) = 1:
   (1/√2) [ |1⟩ − |0⟩ ]   = − (1/√2) [ |0⟩ − |1⟩ ]   = −|−⟩

Step 4 — Combine into one formula Both cases collapse into a single sign that depends on f(x):

U_f |x⟩|−⟩  =  (−1)^f(x) |x⟩|−⟩

What just happened The output register |−⟩ never changed. The bit f(x) — which is what Uf was "supposed" to write into the output qubit — instead appears as a ±1 phase attached to the data register |x⟩. That's the kickback: information about f flows backward, from the target into the control.

Why this is a superpower If we feed the data register a superposition (1/√2ⁿ) Σx |x⟩ instead of a single |x⟩:

U_f [ (1/√2ⁿ) Σ_x |x⟩ ] |−⟩
   = (1/√2ⁿ) Σ_x (−1)^f(x) |x⟩  ⊗  |−⟩

One call to Uf writes the entire truth table of f — as ±1 signs — into the amplitudes of the data register. A follow-up H⊗n then interferes those signs into a measurable answer. That single line is the engine inside every H–oracle–H algorithm.

Quantum Information

The marriage of quantum mechanics with Shannon's information theory. Where classical information counts bits, quantum information counts qubits, cbits (classical bits transmitted), and ebits (Bell pairs as a resource) — and asks how they convert into each other.

1 · Bit vs Qubit

A classical bit is one of two definite values. A qubit is a complex unit vector in a 2-dimensional Hilbert space — a continuum of possibilities. But here's the catch: you can only extract one classical bit per qubit measurement.

Classical bitQubit
State space{0, 1} — two valuesS² (Bloch sphere) — continuum
Holds1 bit of info2 real parameters (θ, φ) — but only ~1 cbit accessible
Copyable?Yes (trivially)No — no-cloning theorem
MeasurementReturns its valueProbabilistic; collapses the state
Composition (n)2ⁿ states, n bits2ⁿ-dim Hilbert space, exponentially many amplitudes

Holevo bound (1973). A single qubit transmits at most 1 cbit of classical info. The exponentially-large state space is real, but most of it is inaccessible to a measurement.

2 · Density matrix — the universal state representation

Kets |ψ⟩ describe pure states only — perfectly known wavefunctions. Real systems are often mixed: probabilistic ensembles of pure states (from noise, tracing out an environment, or a partial measurement). The density matrix ρ handles both uniformly.

ρ = Σᵢ pᵢ |ψᵢ⟩⟨ψᵢ|,   Tr(ρ) = 1,   ρ ≥ 0
  • Pure state: ρ = |ψ⟩⟨ψ|,   Tr(ρ²) = 1
  • Mixed state: ρ = Σ pᵢ |ψᵢ⟩⟨ψᵢ|,   Tr(ρ²) < 1
  • Maximally mixed: ρ = I/d,   "no information" — measurements look uniform

For a composite system AB in a joint state ρAB, Alice's local view is obtained by the partial trace ρA = TrBAB). For an entangled pure state ρAB = |ψ⟩⟨ψ|, the partial trace ρA is generally mixed — the entanglement appears as local randomness.

3 · Von Neumann entropy

The quantum analog of Shannon entropy:

S(ρ) = −Tr(ρ log₂ ρ) = −Σᵢ λᵢ log₂ λᵢ

where λᵢ are the eigenvalues of ρ. Properties:

  • Pure state: S(|ψ⟩⟨ψ|) = 0 — perfect knowledge.
  • Maximally mixed: S(I/d) = log₂ d — total ignorance.
  • Bell pair |Φ⁺⟩: S(ρAB) = 0 (joint pure) but S(ρA) = 1 ebit. That gap is the entanglement.
  • Subadditivity: S(ρAB) ≤ S(ρA) + S(ρB) — quantum correlations reduce joint entropy below the sum of parts (the opposite is impossible classically).

3a · Worked example — density matrices & von Neumann entropy

Three states, three density matrices, three entropies. The recipe in each case: build ρ, diagonalise to read off its eigenvalues {λᵢ}, then compute S(ρ) = −Σ λᵢ log₂ λᵢ (using the convention 0·log 0 = 0).

A · Pure state |+⟩ = (|0⟩+|1⟩)/√2

For a pure state, ρ = |ψ⟩⟨ψ|. With α = β = 1/√2:

ρ+ = |+⟩⟨+| = ½
1111

Eigenvalues: λ = {1, 0}.   Tr(ρ²) = 1 → confirms pure.

S(ρ+) = −(1·log₂1 + 0·log₂0) = 0 bits  (perfect knowledge)
B · Classically-mixed state — 50/50 ensemble of |0⟩ and |1⟩

Alice flips a fair coin and prepares |0⟩ or |1⟩ accordingly:

ρmix = ½|0⟩⟨0| + ½|1⟩⟨1| = ½
1001
= I/2

Eigenvalues: λ = {½, ½}.   Tr(ρ²) = ½ < 1 → mixed (in fact, maximally mixed).

S(ρmix) = −(½·log₂½ + ½·log₂½) = 1 bit  (total ignorance)

Same ρ ≠ same preparation. The ensemble ½|+⟩⟨+| + ½|−⟩⟨−| also gives ρ = I/2. Any two preparations with the same ρ are operationally indistinguishable — no measurement can tell them apart.

C · Entangled Bell state |Φ⁺⟩ = (|00⟩+|11⟩)/√2

The joint state is pure, so S(ρAB) = 0. But what does Alice see locally? Trace out Bob:

ρA = TrB(|Φ⁺⟩⟨Φ⁺|) = ½|0⟩⟨0| + ½|1⟩⟨1| = I/2

Eigenvalues of ρA: {½, ½}.   Locally Alice sees the maximally mixed state — even though the joint state is perfectly known.

S(ρAB) = 0  ·  S(ρA) = S(ρB) = 1 bit

The gap S(ρA) − S(ρAB) = 1 bit is the entanglement entropy — quantifies "1 ebit" of shared resource. Classically impossible: a joint distribution can never be more certain than its marginals.

Summary
StateρEigenvaluesTr(ρ²)S(ρ)
Pure |+⟩½[[1,1],[1,1]]{1, 0}1 (pure)0
Mixed ½|0⟩+½|1⟩I/2{½, ½}½ (mixed)1 bit
Bell joint |Φ⁺⟩|Φ⁺⟩⟨Φ⁺|{1,0,0,0}1 (pure)0
Bell reduced ρAI/2{½, ½}½ (mixed)1 bit

4 · No-cloning theorem (Wootters & Zurek, 1982; Dieks, 1982)

There is no unitary operator U on a 2-qubit system that maps |ψ⟩|0⟩ → |ψ⟩|ψ⟩ for every input state |ψ⟩.

∄ U  such that  U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ ∀ |ψ⟩

Proof sketch. Suppose U exists. For two states |ψ⟩, |φ⟩, take the inner product of both sides of U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ and U|φ⟩|0⟩ = |φ⟩|φ⟩. Unitarity preserves inner products, so ⟨ψ|φ⟩ = ⟨ψ|φ⟩². The only solutions are 0 and 1 — meaning |ψ⟩ and |φ⟩ must be orthogonal or identical. Cloning works for those, but not for arbitrary states. Quantum information is fundamentally uncopyable.

Consequences: QKD security (Eve cannot copy intercepted qubits), no perfect quantum amplifiers, no faster-than-light signalling via entanglement, quantum money (Wiesner 1969 → BB84 1984).

5 · The quantum-information conversion table

Three resources interconvert: qubits sent over a quantum channel, cbits sent over a classical channel, and ebits shared as entangled Bell pairs.

ProtocolYou give upYou get
Quantum teleportation
(see Algorithms)
1 ebit + 2 cbits 1 qubit (state transferred)
Superdense coding
(Bennett & Wiesner, 1992)
1 ebit + 1 qubit 2 cbits transmitted
Entanglement swapping 2 ebits + 2 cbits 1 ebit between distant parties
Entanglement distillation n noisy ebits + LOCC k < n high-fidelity ebits

Together, teleportation + superdense coding say that 1 qubit ≡ 2 cbits + 1 ebit and 2 cbits ≡ 1 qubit + 1 ebit — consistent only because entanglement alone cannot send classical information (no-signalling theorem).

6 · Quantum channels

A quantum channel ℰ is a completely-positive trace-preserving (CPTP) map from density matrices to density matrices. It generalises classical noisy channels. Common examples on a single qubit:

ChannelEffectModels
Depolarisingρ → (1−p)ρ + p·I/2Random Pauli noise
Bit-flipρ → (1−p)ρ + p·XρXClassical-style flips (see Noise)
Phase-flipρ → (1−p)ρ + p·ZρZDecoherence in the Z basis
Amplitude dampingρ → ρ' (energy loss to environment)Spontaneous emission, T₁ relaxation
Phase dampingρ → ρ' (off-diagonals shrink)Pure dephasing, T₂ relaxation

Channels have multiple capacities: the classical capacity (cbits per use), the quantum capacity (qubits per use), the entanglement-assisted capacity, the private capacity. Unlike classical channels, these are different numbers, and computing them exactly remains a major open problem.

7 · Shannon ↔ von Neumann — explained with examples

Shannon's three classical theorems (1948–1959) each have a quantum twin. The easiest way in is one concrete example per theorem — then look at the formula.

The basic swap
ClassicalQuantum
Unitbit (0 or 1)qubit (any |ψ⟩ on the Bloch sphere)
Stateprobabilities, e.g. p(0)=¾, p(1)=¼density matrix ρ
EntropyH(X) — ShannonS(ρ) — von Neumann
① Compression — "how few bits do I need?"

Classical example. A weather sensor outputs "sunny" 90% of days and "rainy" 10%. You don't need 1 bit per day — Shannon says you can compress to:

H = −0.9·log₂(0.9) − 0.1·log₂(0.1) ≈ 0.47 bits/day

Real-world example: English text has H ≈ 1.0–1.5 bits per letter (not log₂ 26 ≈ 4.7), which is why zip files shrink novels to ~30% of their size.

Quantum example. A source emits |0⟩ 90% of the time and |+⟩ 10% of the time (non-orthogonal states — you can't even reliably tell them apart). Schumacher's theorem says you can squeeze them into:

S(ρ) ≈ 0.47 qubits/signal

Punchline. Same formula, same answer — just replace "probabilities" with "eigenvalues of ρ". When the quantum states happen to be orthogonal (perfectly distinguishable, like |0⟩ and |1⟩), S(ρ) = H(p) exactly, and Schumacher reduces to Shannon.

② Channel capacity — "how fast can I talk without errors?"

Classical example. A noisy phone line flips each bit with probability 10%. Shannon's noisy-coding theorem says the maximum reliable rate is:

C = 1 − H(0.1) ≈ 0.53 bits per channel use

Send any rate below 0.53 — error rate can be made arbitrarily small with the right code. Try to send faster — errors are unavoidable. This is why your Wi-Fi slows down when the signal is weak but never silently corrupts files.

Quantum example. Send qubits down a noisy fiber. Now you get two capacity numbers:

You want to send…CapacityNamed after
Classical bits over a quantum channelC(𝒩) — Holevo quantity χHolevo–Schumacher–Westmoreland (HSW), 1997
Qubits over a quantum channelQ(𝒩) — coherent information IcLloyd–Shor–Devetak (LSD)

Why two? A quantum channel can carry classical info or quantum info, and the rates are different. Always C ≥ Q (classical is easier).

Surprise without classical analogue — superactivation. Take two quantum channels each with zero quantum capacity (Q = 0 — neither alone can send a single qubit). Use them together and you can get Q > 0! (Smith & Yard, 2008.) Like adding two zeros and getting a positive number. Impossible classically.

③ Lossy compression — "how small can I get if I accept some error?"

Classical example. JPEG, MP3, and video codecs throw away detail your senses won't miss. Shannon's rate–distortion theorem (1959) tells you the minimum bits per pixel/sample for a chosen distortion D (e.g. mean-squared error):

R(D) = min I(X; X̂)  subject to 𝔼[d(X, X̂)] ≤ D

That's why a 4K image compresses to ~1 bit per pixel at "visually perfect" quality but lossless PNG needs 8–12×.

Quantum example. Quantum memory is expensive and noisy. If you can tolerate a small fidelity drop (e.g. 1 − F ≤ 0.05), how few qubits do you need to store ρ? Barnum (2000) and Datta–Hsieh–Wilde (2013) give:

Rq(D) = min Ic(ρ, ℰ)  subject to distortion ≤ D

Same shape as Shannon, with coherent information Ic replacing mutual information I. Useful for compressing quantum data in noisy memories or simulators — and, like the quantum capacity, generally harder to compute than its classical sibling.

What's genuinely new in the quantum world
PropertyClassicalQuantumTiny example
Negative conditional entropy H(A|B) ≥ 0 always S(A|B) can be negative Bell state |Φ⁺⟩: S(A|B) = −1. Bob "knows more than everything" about A — used in entanglement-assisted protocols.
Cloning Trivial — copy-paste Forbidden (no-cloning theorem) You can't backup an unknown qubit. This is what makes QKD secure.
Adding channels Capacity is additive Superadditive (Smith–Yard 2008) 0 + 0 = positive. No classical version exists.
Pre-shared resource boost Shared randomness doesn't help Shared ebits double some capacities Superdense coding: 1 qubit + 1 ebit ⇒ 2 cbits transmitted.

Headline. Quantum information is a strict superset of classical. Take any quantum result, restrict to commuting (≈ classical) states, and Shannon's theorems pop right out. Allow non-commuting states, entanglement, and superposition, and you unlock effects — negative entropy, superactivation, ebit-assisted capacity — that have no classical mirror at all.

Why this matters

Quantum information theory is the rulebook for everything else in this lab. Holevo says encryption keys carried by qubits are not magically larger. No-cloning is why QKD is secure. Density matrices are how you describe a noisy qubit going through a noisy channel. Channel capacities are the ultimate yardstick for error correction. And the resource conversions at the heart of teleportation and superdense coding are why entanglement is treated as a tradable currency in modern quantum networking.

Noise on a Quantum Channel

A qubit travelling across a wire, fiber, or memory cell passes through many tiny environment "steps", each of which has a small chance of flipping it. Errors don't just appear at the end — they accumulate along the way.

For a bit-flip channel with per-step probability p and length N steps, the chance of an odd number of flips (i.e. a wrong final answer) is P(error) = ½(1 − (1−2p)N). Even tiny p adds up over a long channel.

Try it · Send a qubit through a noisy channel

|0⟩
?

Click "Send 1 qubit" to watch one travel through.

Output |0⟩ (correct): 0  0%
Output |1⟩ (error): 0  0%

Theoretical P(error) after the channel: 0%

Mini quiz

Quantum Error Correction

Real qubits flip and decohere. Quantum error correction (QEC) protects information by spreading one logical qubit across many physical qubits, so a single error can be detected and reversed without ever measuring the encoded state.

The simplest example is the 3-qubit bit-flip code: encode |0⟩ → |000⟩ and |1⟩ → |111⟩. If at most one of the three physical qubits flips on the way, a majority vote recovers the original. Two or three flips overwhelm it — this is the trade-off in every QEC code.

Try it · build up the codes step by step

Start here →
Logical bit:
Code ① — protects against bit-flips only, using 3 qubits and a majority vote.
① Encode → ② Channel (noise) → ③ Majority vote
Decoded logical bit: |1⟩

Bare qubit error rate
3-qubit code error rate

Theoretical coded rate = 3p²(1−p) + p³ = . QEC helps only when p < 50% — above that the redundant qubits hurt more than they help.

Circuits & proofs

The demo above uses a plain majority vote. The three derivations below show the real circuits — encode, noisy channel, then a coherent recovery (CNOTs + a Toffoli) that fixes the error without ever measuring the protected amplitudes α, β. We build up from bit-flips, to phase-flips, to Shor's 9-qubit code that beats any single-qubit error.

① Three-qubit bit-flip code — circuit & proof

Goal Protect an unknown qubit |ψ⟩ = α|0⟩ + β|1⟩ against a single X (bit-flip) error on any of three physical qubits, without ever learning α or β.

The full circuit Two CNOTs encode (copy the bit value, not the amplitudes — that would violate no-cloning). After the noisy channel, two more CNOTs un-copy, and a final Toffoli (controlled-controlled-NOT) flips the data qubit back. No measurement is ever needed:

         ──── ENCODE ────      NOISE        ──── DECODE ────    RECOVER
q0 |ψ⟩ ──────●────●─────────[         ]────────●────●─────────────⊕──────  |ψ⟩
             │    │         [ flip one ]       │    │             │
q1 |0⟩ ──────⊕────┼─────────[ bit (X)  ]───────⊕────┼─────────────●──────
                  │         [         ]              │             │
q2 |0⟩ ───────────⊕─────────[         ]─────────────⊕─────────────●──────

state:    α|000⟩+β|111⟩    α|100⟩+β|011⟩     α|111⟩+β|011⟩    α|011⟩+β|111⟩
                          (top qubit flips)                   = |ψ⟩ ⊗ |11⟩

Step 1 — Encode CNOT(q0→q1) then CNOT(q0→q2):

(α|0⟩ + β|1⟩)|0⟩|0⟩
  ──CNOT₀₁──►  α|00⟩|0⟩ + β|11⟩|0⟩
  ──CNOT₀₂──►  α|000⟩ + β|111⟩   ≡  |ψ⟩_L

Step 2 — Noise flips the top qubit the channel applies X₀:

X₀ |ψ⟩_L  =  α|100⟩ + β|011⟩

Step 3 — Decode: the same two CNOTs un-copy CNOT(q0→q1), CNOT(q0→q2). The error gets routed into the two helper qubits:

α|100⟩ + β|011⟩
  ──CNOT₀₁,₀₂──►  α|111⟩ + β|011⟩         (q0 controls, so only the α term flips q1,q2)

Now both branches share the helper pattern q1q2 = 11, with the data qubit q0 holding the flipped value α|1⟩ + β|0⟩. That "11" is the syndrome — it announces "the top qubit was hit" without revealing α or β.

Step 4 — Recover: one Toffoli controls = q1, q2; target = q0. It flips q0 only when both helpers are 1:

Toffoli (α|111⟩ + β|011⟩) = α|011⟩ + β|111⟩ = (α|0⟩ + β|1⟩) ⊗ |11⟩ = |ψ⟩   ✓

Why one Toffoli fixes any single flip the decode CNOTs always push the error into the helpers, so the data qubit q0 only ends up wrong when the helper pattern is exactly 11 — and that is the one case the Toffoli acts on:

Errorhelpers q1q2 after decodeq0 wrong?Toffoli
none0 0noidle
X₀ (top)1 1yesflips q0 back ✓
X₁ (middle)1 0noidle
X₂ (bottom)0 1noidle

Conclusion Any single bit-flip is reversed exactly, for arbitrary α, β, with no measurement — the Toffoli is the majority vote from the demo above, done coherently. The code fails only on ≥2 simultaneous flips — probability 3p²(1−p) + p³, which beats the bare rate p whenever p < ½.

② Three-qubit phase-flip code — circuit & proof

Goal Protect against a single Z (phase-flip) error, which sends |+⟩ ↔ |−⟩ and is invisible to the bit-flip code. The trick: the phase-flip code is the bit-flip code conjugated by Hadamards, using the identity H Z H = X — a phase error in the Z-basis is just a bit error in the X-basis.

Encoding circuit Same two CNOTs, then an H on every qubit. With |±⟩ = (|0⟩ ± |1⟩)/√2:

q0 : |ψ⟩ ──●────●──[H]──        ┌ |0⟩_L = |+++⟩
           │    │           ⟶  ┤
q1 : |0⟩ ──⊕────┼──[H]──        └ |1⟩_L = |−−−⟩
                │
q2 : |0⟩ ───────⊕──[H]──   α|0⟩+β|1⟩ ⟶ α|+++⟩ + β|−−−⟩

Step 1 — A phase error strikes say Z₁. Since Z|+⟩ = |−⟩ and Z|−⟩ = |+⟩:

Z₁ (α|+++⟩ + β|−−−⟩) = α|+−+⟩ + β|−+−⟩

Step 2 — Rotate the problem into the bit-flip code Apply H⊗H⊗H. Because H|+⟩ = |0⟩ and H|−⟩ = |1⟩:

H^⊗3 (α|+−+⟩ + β|−+−⟩) = α|010⟩ + β|101⟩

— this is exactly the X₁ state from derivation ①.

Step 3 — Measure stabilizers X₀X₁ and X₁X₂ (equivalently: H everything, then measure Z₀Z₁, Z₁Z₂ as before). Same syndrome table, with X-parities in place of Z-parities:

syndrome (1 1) ⟹ phase error on qubit 1 ⟹ apply Z₁

Step 4 — Correct & rotate back

α|010⟩ + β|101⟩  ──X₁──►  α|000⟩ + β|111⟩
                 ──H^⊗3──►  α|+++⟩ + β|−−−⟩ = |ψ⟩_L   ✓

Conclusion The phase-flip code corrects any single Z error — but it is now defenceless against X errors (an X just permutes |±⟩ trivially up to sign). Bit-flip and phase-flip codes are mirror images; neither alone covers both. That gap is what Shor's code closes.

③ Shor's 9-qubit code — circuit & proof (corrects any single-qubit error)

The idea — concatenation Nest the two codes: take the phase-flip code (outer), then replace each of its three qubits with a bit-flip block (inner). The result is 9 qubits that correct an X error, a Z error, or both at once (Y = iXZ) — i.e. an arbitrary single-qubit error.

Encoded states

|0⟩_L = (1/2√2) (|000⟩+|111⟩)(|000⟩+|111⟩)(|000⟩+|111⟩)
|1⟩_L = (1/2√2) (|000⟩−|111⟩)(|000⟩−|111⟩)(|000⟩−|111⟩)
          └──── block 1 ────┘└── block 2 ──┘└── block 3 ──┘

Encoding circuit Outer phase-flip encode on qubits 0,3,6 (CNOT-spread + H), then an inner bit-flip encode inside each block:

q0 |ψ⟩ ─●──●──[H]─●──●──         ┐
        │  │      │  │           │ block 1 (q0 q1 q2)
q1 |0⟩ ─┼──┼─────⊕──┼──         │
q2 |0⟩ ─┼──┼────────⊕──         ┘
        │  │
q3 |0⟩ ─⊕──┼──[H]─●──●──         ┐
        │  │      │  │           │ block 2 (q3 q4 q5)
q4 |0⟩ ─┼──┼─────⊕──┼──         │
q5 |0⟩ ─┼──┼────────⊕──         ┘
        │  │
q6 |0⟩ ─┼──⊕──[H]─●──●──         ┐
        │         │  │           │ block 3 (q6 q7 q8)
q7 |0⟩ ─┼────────⊕──┼──         │
q8 |0⟩ ─┼───────────⊕──         ┘
      (outer encode)(inner encode ×3)

The 8 stabilizer generators (9 qubits − 8 checks = 1 logical qubit):

Bit-flip checks (inside each block):
   Z₀Z₁, Z₁Z₂   Z₃Z₄, Z₄Z₅   Z₆Z₇, Z₇Z₈        (6 generators)
Phase-flip checks (compare block signs):
   X₀X₁X₂·X₃X₄X₅      X₃X₄X₅·X₆X₇X₈              (2 generators)

Case A — a bit-flip Xⱼ Whatever qubit j is hit, it lives in one block of three. The two Z-stabilizers of that block give the same syndrome as derivation ① and pinpoint it — apply X to undo it. (6 checks = one bit-flip decoder per block.)

Case B — a phase-flip Zⱼ A Z on any qubit in a block flips that block's sign, |000⟩+|111⟩ ↔ |000⟩−|111⟩. Worked example, Z₀:

Z₀ (|000⟩+|111⟩) = |000⟩−|111⟩      (block 1 sign flips; blocks 2,3 untouched)

The X-stabilizers compare the three block signs. Two agree, one differs ⟹ the odd block is identified ⟹ apply Z to any one qubit of it to restore the sign. Note the code cannot tell Z₀ from Z₁ from Z₂ — and doesn't need to: any single Z in the block fixes the sign. (This is the outer phase-flip code voting on 3 block-signs.)

Case C — Y, or an arbitrary error Y₀ = iX₀Z₀ is caught as a bit-flip and a phase-flip simultaneously by the two independent syndrome types — corrected by both. More generally, write any single-qubit error as

E = c₀ I + c₁ X + c₂ Y + c₃ Z      (Pauli basis — always possible)

so the noisy state is a superposition c₀|ψ_L⟩ + c₁ X|ψ_L⟩ + c₂ Y|ψ_L⟩ + c₃ Z|ψ_L⟩. Measuring the syndrome collapses this onto one branch — this is the key discretization-of-errors theorem: a continuous error is digitised into one of {I, X, Y, Z}, which we then correct exactly.

Worked example — a tiny rotation Let the error be a small over-rotation E = eiθX₀ = cos θ·I + i sin θ·X₀:

|ψ_L⟩ ⟶ cos θ |ψ_L⟩ + i sin θ · X₀|ψ_L⟩

Measure block-1 syndrome Z₀Z₁:
   outcome +1  (prob cos²θ)  ⟹ state = |ψ_L⟩      → do nothing
   outcome −1  (prob sin²θ)  ⟹ state = X₀|ψ_L⟩    → apply X₀
Either branch recovers |ψ_L⟩ exactly — θ has been digitised away.

Conclusion Shor's code corrects an arbitrary single-qubit error on any of the 9 qubits. It was the first proof that quantum information can be protected at all — the seed of fault-tolerant quantum computing, later sharpened into the 7-qubit Steane code, 5-qubit perfect code, and the surface codes used in today's hardware.

Mini quiz

Quantum Algorithms

Quantum algorithms use superposition and interference to find answers in clever ways.

Try it · Pick a demo

Problem Statement

Alice has a qubit |ψ⟩ in some unknown state and wants to send it to Bob across the room. No-cloning forbids copying; measurement collapses it; and a classical description of a continuous state needs infinitely many bits. How does she transmit |ψ⟩ exactly?

Algorithm

Alice and Bob pre-share a Bell pair. Alice performs a Bell-basis measurement on |ψ⟩ together with her half of the pair, getting two classical bits (m₁, m₂). She phones those to Bob. Bob applies Xm₂ Zm₁ to his half — and now his qubit holds |ψ⟩.

Catch: not faster than light. The two classical bits still travel at c, and without them Bob's qubit looks completely random. Apps: quantum repeaters for long-distance QKD, gate teleportation in fault-tolerant QC, distributed quantum networking. First demonstrated 1997 (Bouwmeester); satellite-to-ground 2017 (Micius).

Year: 1993 (Bennett et al.)Speedup: n/a (a primitive)Qubits: 3

Simulator

Derivation (Proof)

Step-by-step derivation (the algebra behind the simulation)

Setup Alice has an unknown qubit |ψ⟩ = α|0⟩ + β|1⟩ (qubit 0). She shares a Bell pair |Φ⁺⟩ = (|00⟩ + |11⟩)/√2 with Bob: qubit 1 is hers, qubit 2 is Bob's.

Step 1 — Joint state of all 3 qubits

|ψ⟩ ⊗ |Φ⁺⟩
  = (α|0⟩ + β|1⟩) ⊗ (|00⟩ + |11⟩)/√2
  = (1/√2) [ α|0⟩(|00⟩+|11⟩) + β|1⟩(|00⟩+|11⟩) ]
  = (1/√2) [ α|000⟩ + α|011⟩ + β|100⟩ + β|111⟩ ]

Step 2 — Alice applies CNOT (control = qubit 0, target = qubit 1) CNOT flips qubit 1 when qubit 0 is 1, so |10⋯⟩ → |11⋯⟩ and |11⋯⟩ → |10⋯⟩.

→ (1/√2) [ α|000⟩ + α|011⟩ + β|110⟩ + β|101⟩ ]

Step 3 — Alice applies H to qubit 0 using H|0⟩ = (|0⟩+|1⟩)/√2 and H|1⟩ = (|0⟩−|1⟩)/√2.

→ (1/2) [ α(|0⟩+|1⟩)|00⟩ + α(|0⟩+|1⟩)|11⟩
        + β(|0⟩−|1⟩)|10⟩ + β(|0⟩−|1⟩)|01⟩ ]

Step 4 — Group by Alice's two-qubit outcome (q0 q1)

= (1/2) [ |00⟩ (α|0⟩ + β|1⟩)
        + |01⟩ (α|1⟩ + β|0⟩)
        + |10⟩ (α|0⟩ − β|1⟩)
        + |11⟩ (α|1⟩ − β|0⟩) ]

Each of the 4 outcomes for Alice's measurement occurs with probability ¼, and Bob's qubit collapses to one of four states — each a known unitary away from |ψ⟩.

Step 5 — Bob's correction (m₁ m₂ = q0 q1)

m₁ m₂ = 00  →  Bob has α|0⟩ + β|1⟩   = |ψ⟩            → apply I
m₁ m₂ = 01  →  Bob has α|1⟩ + β|0⟩   = X|ψ⟩           → apply X
m₁ m₂ = 10  →  Bob has α|0⟩ − β|1⟩   = Z|ψ⟩           → apply Z
m₁ m₂ = 11  →  Bob has α|1⟩ − β|0⟩   = XZ|ψ⟩          → apply X then Z

In one line: Bob applies Xm₂ Zm₁ and recovers |ψ⟩ exactly. Note that α and β never appear in the classical bits Alice sends — the unknown amplitudes ride along inside the entanglement, which is why no-cloning isn't violated: Alice's original collapsed at Step 4.

Sanity check — without Bob's correction averaging over Alice's 4 equally-likely outcomes, Bob's reduced density matrix is ρ = ½ I — the maximally mixed state. The 2 classical bits are exactly the information needed to turn that noise back into |ψ⟩, and they travel at the speed of light: no faster-than-light signalling.


Worked example — Alice sends |ψ⟩ = |0⟩ Plug in α = 1, β = 0 and follow the same five steps. Bob must end up holding |0⟩.

Step 1 — Initial 3-qubit state. Bell pair shared, Alice prepares |0⟩:

|0⟩ ⊗ (|00⟩ + |11⟩)/√2
  = (1/√2) ( |0⟩|00⟩ + |0⟩|11⟩ )
  = (1/√2) ( |000⟩ + |011⟩ )

Step 2 — CNOT (control = q0, target = q1). q0 is |0⟩ in both terms, so q1 is never flipped. State unchanged:

(1/√2) ( |000⟩ + |011⟩ )

Step 3 — H on q0. H|0⟩ = (|0⟩+|1⟩)/√2:

(1/2) ( |0⟩|00⟩ + |1⟩|00⟩ + |0⟩|11⟩ + |1⟩|11⟩ )
= (1/2) ( |000⟩ + |100⟩ + |011⟩ + |111⟩ )

Step 4 — Regroup by Alice's outcome (q0 q1). Pull Bob's qubit (q2) out on the right:

= (1/2) [ |00⟩|0⟩ + |01⟩|1⟩ + |10⟩|0⟩ + |11⟩|1⟩ ]

Each outcome (m₁ m₂) = (q0 q1) occurs with probability ¼. Bob's qubit collapses to:

m₁ m₂ = 00  →  Bob has |0⟩
m₁ m₂ = 01  →  Bob has |1⟩
m₁ m₂ = 10  →  Bob has |0⟩
m₁ m₂ = 11  →  Bob has |1⟩

Step 5 — Bob applies Xm₂ Zm₁. Recall X|0⟩=|1⟩, X|1⟩=|0⟩, Z|0⟩=|0⟩, Z|1⟩=−|1⟩.

00:  Bob has |0⟩  →  I·|0⟩       = |0⟩       ✓
01:  Bob has |1⟩  →  X·|1⟩       = |0⟩       ✓
10:  Bob has |0⟩  →  Z·|0⟩       = |0⟩       ✓
11:  Bob has |1⟩  →  Z·X·|1⟩     = Z·|0⟩ = |0⟩  ✓

Conclusion In every branch — no matter which of the 4 outcomes Alice's measurement produced — Bob's final state is exactly |0⟩, which is the state |ψ⟩ Alice started with. The teleportation is deterministic from Bob's point of view; the randomness is entirely absorbed by the correction.

Mini quiz

Quantum Paradoxes

Quantum mechanics is famously weird. These thought experiments push the rules to their breaking points — and they're still the subject of real philosophical debate about what reality is.

Pick a paradox

Schrödinger's Cat (1935)

A cat is sealed in a box with a radioactive atom and a poison vial. If the atom decays, the poison kills the cat. While the box is closed, the atom is in a superposition of "decayed" and "not decayed" — and so, by extension, the cat is simultaneously alive AND dead.

😺
💀
|alive⟩ + |dead⟩

The box is closed — the cat is in superposition.

The puzzle: standard QM says superposition continues until measurement. But cats, geiger counters, and poison are macroscopic. Where exactly does the line between quantum-blurry and classically-definite reality live?

Quantum Cryptography

Two fundamentally different security models:

  • Classical cryptography — security rests on the computational complexity of math problems (factoring, discrete log, lattice problems). Safe only as long as no efficient algorithm — classical or quantum — is found.
  • Quantum cryptography — security rests on the laws of physics (no-cloning, measurement disturbance, Heisenberg uncertainty). Safe regardless of how much computing power the adversary has.

The flagship application is QKD (Quantum Key Distribution): two parties share a secret key over an open channel, with provable detection of any eavesdropping.

Quantum Key Distribution

Alice and Bob need a shared secret key (e.g. for a one-time pad or AES) but their channel is wide open — Eve can listen, copy, even resend. Classical key-exchange (RSA, Diffie–Hellman, ECC) leans on hard math problems. A future quantum computer running Shor's algorithm would break those problems in polynomial time. QKD doesn't share that fate — its security rests on physics, not complexity.

ALICE photon source BOB detectors quantum channel — single photons → classical (authenticated) channel — bases / sifting / verification EVE eavesdropper ⚡ disturbs photon
Why it works
  • No-cloning theorem. An unknown quantum state cannot be perfectly copied. Eve cannot tap-and-forward like a classical wiretap.
  • Measurement disturbance. Reading a qubit in the wrong basis randomises it. Eve's guesses leave a statistical fingerprint.
  • Consequence. Any eavesdropping raises the error rate in the sifted key — Alice & Bob detect it and abort.
Anatomy of every QKD protocol
  1. Quantum channel — Alice sends single photons (qubits) carrying random key info.
  2. Authenticated classical channel — public, but tamper-evident (Eve can read it, can't forge it).
  3. Sifting — over the classical channel, compare measurement settings (not the bits) and keep only matching shots.
  4. Error estimation — reveal a small random subset of the sifted bits to bound the eavesdropping rate. Abort above threshold (~11% for BB84).
  5. Privacy amplification — compress the surviving key with a 2-universal hash to wash out any partial info Eve may have leaked.
  6. Final key — short, but information-theoretically secret.
Family of QKD protocols
ProtocolYearCore ideaNotes
BB841984Two conjugate bases (Z, X)The workhorse — see next tab
B921992Just two non-orthogonal statesSimpler, lower key rate
E911991Entangled Bell pairs + CHSH testEavesdropping shows up as Bell-inequality violation drop
SARG042004BB84 variantRobust against photon-number-splitting attacks
MDI-QKD2012Measurement-device-independentCloses detector-side-channel attacks
CV-QKD2002+Continuous variables (quadratures)Uses standard telecom homodyne detection
Twin-field QKD2018Single-photon interferenceBeats the repeaterless rate-distance bound
Real-world deployments
  • Commercial systems: ID Quantique, Toshiba, QuintessenceLabs.
  • Beijing–Shanghai QKD backbone — ~2000 km of fibre, 32 trusted nodes.
  • Micius satellite (China, 2017) — first space-to-ground QKD over >1000 km.
  • Inter-bank pilots in Geneva, Vienna, Tokyo, Seoul.

Caveat. QKD only solves key distribution. You still need authenticated classical channels (which require some pre-shared key or post-quantum signatures), and you still encrypt your data with a classical symmetric cipher. QKD & post-quantum cryptography are complements, not rivals.

Post-Quantum Security

Post-Quantum Cryptography (PQC) is the parallel response to the same threat QKD addresses — but going the classical route. Instead of using physics, PQC uses math problems believed to be hard for both classical AND quantum computers.

PQC and QKD are complements, not rivals. PQC is what you can deploy today on existing internet infrastructure (TLS, signatures, VPN, software updates). QKD needs dedicated quantum hardware. Most real systems will use both.

The threat — "harvest now, decrypt later"

A sufficiently large quantum computer running Shor's algorithm would break virtually all the public-key cryptography deployed on the internet today: RSA, Diffie-Hellman, elliptic-curve (ECC). Even though such a computer doesn't exist yet, adversaries are recording encrypted traffic right now to decrypt later when the hardware arrives. Long-lived secrets (medical records, state secrets, source code, banking) are already at risk — measured in 25-year confidentiality windows.

Today's classical cryptoWhat breaks itReplacement
RSA-2048Shor's algorithmML-KEM (lattice)
Diffie-HellmanShor's algorithmML-KEM (lattice)
ECC (P-256, X25519)Shor's algorithmML-KEM, ML-DSA
AES-256 (symmetric)Grover (effective 128-bit)Bigger keys (AES-256 still OK)
SHA-256 (hash)Grover (effective 128-bit)SHA-384/512

Families of post-quantum algorithms

PQC schemes derive their security from problems no quantum algorithm can efficiently solve. The five main families:

FamilyHard problemExamplesTrade-offs
Lattice-based Learning With Errors (LWE), Shortest Vector Problem (SVP) Kyber, Dilithium, NTRU, FrodoKEM Best all-rounders. Small keys + signatures, fast.
Hash-based Pre-image / collision resistance of a hash function SPHINCS+, XMSS, LMS Most conservative — security follows from hashes alone. Larger signatures.
Code-based Decoding random linear codes Classic McEliece, BIKE, HQC Oldest (1978). Huge public keys (~1 MB), but very fast operations.
Isogeny-based Walks between elliptic curves via isogenies SIKE (broken 2022), CSIDH Smallest keys — but the field took a major hit when SIKE fell to a classical attack.
Multivariate Solving systems of multivariate quadratic equations Rainbow (broken 2022), GeMSS Several proposals broken; surviving variants tend to have huge keys.

NIST PQC standardisation

Started in 2016, NIST evaluated >80 submissions over four rounds. The first standards were published in August 2024:

FIPSStandard nameBuilt onUse
FIPS 203ML-KEM (Module-Lattice KEM)KyberKey encapsulation — replaces RSA-OAEP / ECDH
FIPS 204ML-DSA (Module-Lattice DSA)DilithiumDigital signatures — replaces RSA-PSS / ECDSA
FIPS 205SLH-DSA (Stateless Hash-Based DSA)SPHINCS+Hash-based signatures — conservative backup
(2025)FN-DSA (Falcon)Falcon (lattice)Compact lattice signatures
(round 4)HQC, BIKE, Classic McEliececode-basedDiversification away from lattices

SIKE (isogeny-based) was a NIST round-4 candidate — broken by Castryck & Decru in 2022 using ordinary classical math (a Magma laptop, in under an hour). A reminder that "post-quantum" doesn't mean "post-cryptanalysis".

Real-world deployments

  • Cloudflare & Google have deployed hybrid (X25519 + ML-KEM) key exchange on TLS 1.3 since 2023 — over 30% of Chrome's TLS connections in 2025.
  • Apple iMessage PQ3 (2024) — full hybrid post-quantum end-to-end encryption.
  • Signal Messenger rolled out PQXDH (X25519 + Kyber) in 2023.
  • OpenSSH 9.0+ defaults to hybrid sntrup761x25519 key exchange.
  • AWS KMS, Cloudflare 1.1.1.1, Microsoft Azure all support PQ-hybrid TLS.

PQC vs QKD — complementary, not competing

PQCQKD
SecurityMath problems believed quantum-hardLaws of physics (information-theoretic)
HardwareSame as today (CPUs, smartphones)Photon sources, single-photon detectors, dedicated fibre
DistanceAnywhere the internet reaches~100 km fibre or satellite line-of-sight
AuthenticationReplaces classical PKI directlyStill needs PQC or pre-shared keys to authenticate
Use caseTLS, signatures, code-signing, VPN, software updatesBank-to-bank, gov-to-gov, point-to-point ultra-high secrecy
Failure modeDiscovery of an efficient attackHardware side-channels (detector blinding, etc.)

Most realistic deployments will combine both, plus hybrid classical+PQC in the transition period (2025-2030+).

Quantum Simulators

Online tools where you can drag-and-drop gates onto wires and run real quantum circuits in your browser — no install needed.

  • IBM Quantum Composer

    Build circuits visually and run them on IBM's real superconducting QPUs or their simulators. Free tier with an IBM account.

  • Quantastica — Quantum Programming Studio

    Browser-based circuit designer and simulator. Exports to Qiskit, Cirq, Q#, OpenQASM, and runs on multiple backends. No login required.

Glossary

Beginner FAQ

🏆 Final Quantum Challenge

Complete at least 6 modules to unlock the challenge.