Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Measurement is the only way classical information leaves a quantum computer, and it is irreversible — it is the unique non-unitary step in the model. The Born rule says: when you measure in the computational basis, you get outcome with probability and outcome with probability , and after the measurement the state collapses to whichever basis state you observed. This is the bottleneck that makes quantum algorithms hard to design: you have one shot per run to extract a number, and you have to engineer the amplitudes so that the useful answer has high probability while the wrong answers cancel by interference. Every quantum cryptanalytic attack — Shor, Grover, Simon — is structured around this constraint, and every quantum-key-distribution protocol uses it as a security primitive (the eavesdropper cannot measure without collapsing).
A measurement in the computational basis is described by the projectors and . Outcome occurs with probability , and the post-measurement state is .
Use these three in order. Each builds on the one before.
In one paragraph, state the Born rule precisely. What's the difference between an amplitude and a probability, and why are amplitudes the more fundamental object?
Walk me step by step through what 'measurement collapse' means. (a) Pre-measurement state. (b) Pick an outcome at random with the Born-rule probability. (c) Renormalise. Why is step (c) needed and what does it represent?
BB84 quantum key distribution uses the fact that an eavesdropper measuring an unknown qubit in the wrong basis disturbs the state and is detectable. Walk through the security argument concretely: Alice sends $|0\rangle$, Eve measures in the X-basis, Bob then measures in the Z-basis. What's the probability Bob gets the wrong answer? Why does this give Alice and Bob a way to bound Eve's information?
// main.go
// go run main.go
package main
import (
"fmt"
"math"
"math/rand/v2"
)
// measureZ samples `shots` times from a qubit state psi = [alpha, beta]
// and returns counts for outcome 0 and 1, plus the theoretical probabilities.
func measureZ(psi [2]complex128, shots int, rng *rand.Rand) (map[int]int, [2]float64) {
p0 := math.Pow(cmplxAbs(psi[0]), 2)
p1 := math.Pow(cmplxAbs(psi[1]), 2)
counts := map[int]int{0: 0, 1: 0}
for range shots {
if rng.Float64() < p0 {
counts[0]++
} else {
counts[1]++
}
}
return counts, [2]float64{p0, p1}
}
func cmplxAbs(c complex128) float64 {
return math.Sqrt(real(c)*real(c) + imag(c)*imag(c))
}
func main() {
// State: (sqrt(0.7) |0> + sqrt(0.3) |1>)
psi := [2]complex128{complex(math.Sqrt(0.7), 0), complex(math.Sqrt(0.3), 0)}
shots := 10_000
rng := rand.New(rand.NewPCG(42, 0))
counts, theory := measureZ(psi, shots, rng)
fmt.Printf("theoretical (p0, p1) = (%g, %g)\n", theory[0], theory[1])
fmt.Printf("empirical counts = map[0:%d 1:%d]\n", counts[0], counts[1])
fmt.Printf("empirical fractions = map[0:%g 1:%g]\n",
float64(counts[0])/float64(shots),
float64(counts[1])/float64(shots))
}go run main.go