Superposition & Measurement
Category: Quantum Computing
Difficulty: Intermediate
Time Complexity: O(2^n)
Space Complexity: O(2^n)
Overview
Section titled “Overview”Quantum measurement is the bridge between the quantum and classical worlds. A qubit in superposition exists in a combination of |0⟩ and |1⟩ simultaneously, with complex amplitudes α and β satisfying |α|² + |β|² = 1. When measured, the Born rule dictates that the probability of each outcome equals the squared magnitude of its amplitude: P(0) = |α|² and P(1) = |β|². Upon measurement the wave function collapses irreversibly to the observed eigenstate — all other amplitudes become zero and the state is renormalized. For entangled states such as Bell pairs, measuring one qubit instantly determines the other’s state: if two qubits share the state (|00⟩ + |11⟩)/√2, measuring the first qubit as |0⟩ collapses the second to |0⟩ as well, demonstrating the non-local correlations that make quantum computing powerful. This visualization walks through state preparation, probability computation, and collapse step by step.
Try It
Section titled “Try It”- Web: Open in Eigenvue →
- Python:
import eigenvueeigenvue.show("superposition-measurement")
Default Inputs
Section titled “Default Inputs”{ "numQubits": 2, "preparationGates": [ { "gate": "H", "qubits": [ 0 ] }, { "gate": "CNOT", "qubits": [ 0, 1 ] } ], "measurements": [ { "qubit": 0, "outcome": 0 }, { "qubit": 1, "outcome": 0 } ]}Input Examples
Section titled “Input Examples”Bell state measurement
Section titled “Bell state measurement”{ "numQubits": 2, "preparationGates": [ { "gate": "H", "qubits": [ 0 ] }, { "gate": "CNOT", "qubits": [ 0, 1 ] } ], "measurements": [ { "qubit": 0, "outcome": 0 }, { "qubit": 1, "outcome": 0 } ]}Single qubit superposition
Section titled “Single qubit superposition”{ "numQubits": 1, "preparationGates": [ { "gate": "H", "qubits": [ 0 ] } ], "measurements": [ { "qubit": 0, "outcome": 1 } ]}Opposite Bell outcome
Section titled “Opposite Bell outcome”{ "numQubits": 2, "preparationGates": [ { "gate": "H", "qubits": [ 0 ] }, { "gate": "CNOT", "qubits": [ 0, 1 ] } ], "measurements": [ { "qubit": 0, "outcome": 1 }, { "qubit": 1, "outcome": 1 } ]}X gate then measure
Section titled “X gate then measure”{ "numQubits": 1, "preparationGates": [ { "gate": "X", "qubits": [ 0 ] } ], "measurements": [ { "qubit": 0, "outcome": 1 } ]}Bell state — correlated |1,1⟩
Section titled “Bell state — correlated |1,1⟩”{ "numQubits": 2, "preparationGates": [ { "gate": "H", "qubits": [ 0 ] }, { "gate": "CNOT", "qubits": [ 0, 1 ] } ], "measurements": [ { "qubit": 1, "outcome": 1 }, { "qubit": 0, "outcome": 1 } ]}Pseudocode
Section titled “Pseudocode”function superpositionMeasurement(numQubits, gates, measurements): // 1. Initialize state to |0...0⟩ state = zeroState(numQubits) // 2^n amplitudes, all zero except first
// 2. Apply preparation gates for gate in gates: state = applyGate(state, gate) // e.g., H creates superposition, CNOT entangles
// 3. Measure qubits one by one for (qubit, outcome) in measurements: prob = |amplitude(state, qubit=outcome)|² // Born rule state = project(state, qubit, outcome) // collapse: zero out inconsistent amps state = normalize(state) // renormalize remaining amplitudes record classicalBit = outcome
return classicalBitsPython
Section titled “Python”import numpy as np
def superposition_measurement(n_qubits, gates, measurements): """Demonstrate quantum measurement with predetermined outcomes.""" # 1. Initialize |0...0⟩ dim = 2 ** n_qubits state = np.zeros(dim, dtype=complex) state[0] = 1.0
# 2. Apply preparation gates for gate_name, qubits, angle in gates: if gate_name == "H": H = np.array([[1, 1], [1, -1]]) / np.sqrt(2) state = apply_single_gate(state, H, qubits[0], n_qubits) elif gate_name == "CNOT": state = apply_cnot(state, qubits[0], qubits[1], n_qubits) # ... other gates ...
# 3. Measure each qubit classical_bits = [] for qubit, outcome in measurements: # Born rule: probability of this outcome prob = compute_probability(state, qubit, outcome, n_qubits) print(f"P(q{qubit}={outcome}) = {prob:.4f}")
# Collapse: project onto outcome subspace state = project_and_normalize(state, qubit, outcome, n_qubits) classical_bits.append(outcome)
return classical_bitsJavaScript
Section titled “JavaScript”function superpositionMeasurement(numQubits, gates, measurements) { // 1. Initialize |0...0⟩ const dim = 2 ** numQubits; const state = Array.from({ length: dim }, (_, i) => i === 0 ? [1, 0] : [0, 0] // [real, imag] );
// 2. Apply preparation gates for (const { gate, qubits, angle } of gates) { if (qubits.length === 1) { applySingleQubitGate(state, getGateMatrix(gate, angle), qubits[0], numQubits); } else { applyTwoQubitGate(state, getGateMatrix(gate), qubits[0], qubits[1], numQubits); } }
// 3. Measure each qubit const classicalBits = []; for (const { qubit, outcome } of measurements) { // Born rule: P(outcome) = sum of |amplitude|^2 consistent with outcome const prob = computeProbability(state, qubit, outcome, numQubits); console.log(`P(q${qubit}=${outcome}) = ${(prob * 100).toFixed(1)}%`);
// Collapse and renormalize projectAndNormalize(state, qubit, outcome, numQubits); classicalBits.push(outcome); }
return classicalBits;}Key Concepts
Section titled “Key Concepts”Superposition
Section titled “Superposition”A qubit can exist in a linear combination of |0⟩ and |1⟩, written α|0⟩ + β|1⟩ where α and β are complex amplitudes. Unlike a classical bit that must be 0 or 1, a qubit in superposition encodes information in both amplitudes simultaneously. The Hadamard gate (H) creates an equal superposition from the |0⟩ state: H|0⟩ = (|0⟩ + |1⟩)/√2.
Measurement (Born Rule)
Section titled “Measurement (Born Rule)”When a qubit in state α|0⟩ + β|1⟩ is measured, the Born rule determines the outcome probabilities: P(0) = |α|² and P(1) = |β|². For the equal superposition (|0⟩ + |1⟩)/√2, each outcome has probability 1/2. The measurement result is fundamentally probabilistic — no hidden variable determines it in advance.
Wave Function Collapse
Section titled “Wave Function Collapse”After measurement, the quantum state irreversibly collapses to the observed eigenstate. If a qubit in superposition is measured as |0⟩, its state becomes exactly |0⟩ — the |1⟩ amplitude is destroyed. Subsequent measurements will always yield the same result. This collapse is instantaneous and irreversible, distinguishing quantum measurement from classical observation.
Entanglement
Section titled “Entanglement”Two qubits are entangled when their joint state cannot be written as a product of individual qubit states. The Bell state (|00⟩ + |11⟩)/√2 is the canonical example: neither qubit has a definite state individually, but measuring one instantly determines the other. This correlation is stronger than any classical correlation and is the basis for quantum teleportation, superdense coding, and quantum error correction.
Bell States
Section titled “Bell States”The four Bell states are maximally entangled two-qubit states: |Φ+⟩ = (|00⟩ + |11⟩)/√2, |Φ-⟩ = (|00⟩ - |11⟩)/√2, |Ψ+⟩ = (|01⟩ + |10⟩)/√2, |Ψ-⟩ = (|01⟩ - |10⟩)/√2. They are created by applying a Hadamard gate followed by a CNOT gate. Bell states are fundamental resources in quantum information protocols.
Common Pitfalls
Section titled “Common Pitfalls”- Measurement is irreversible: Once a qubit is measured, its superposition is permanently destroyed. You cannot ‘un-measure’ a qubit or recover the original amplitudes. This is why quantum algorithms must carefully choose when and what to measure — premature measurement collapses useful quantum information.
- Entanglement correlates outcomes: For entangled qubits like the Bell state (|00⟩ + |11⟩)/√2, measuring one qubit collapses the other’s state too. If you measure the first qubit and get |0⟩, the second qubit is guaranteed to also be |0⟩ — there is zero probability of getting |1⟩. Students often forget that measurement on one qubit affects the entire system’s state vector.
- No-cloning theorem: It is physically impossible to create an exact copy of an unknown quantum state. This means you cannot simply duplicate a qubit’s superposition for backup before measuring. The no-cloning theorem is a fundamental consequence of the linearity of quantum mechanics and has deep implications for quantum cryptography and error correction.
Q1: A qubit is in the state (|0⟩ + |1⟩)/√2. What is the probability of measuring |1⟩?
- A) 0%
- B) 25%
- C) 50%
- D) 100%
Show answer
Answer: C) 50%
The amplitude of |1⟩ is 1/√2. By the Born rule, the probability is |1/√2|² = 1/2 = 50%. This equal superposition is created by the Hadamard gate applied to |0⟩.
Q2: Two qubits are in the Bell state (|00⟩ + |11⟩)/√2. You measure the first qubit and get |0⟩. What state is the second qubit in?
- A) |0⟩ with certainty
- B) |1⟩ with certainty
- C) (|0⟩ + |1⟩)/√2
- D) Cannot be determined
Show answer
Answer: A) |0⟩ with certainty
In the Bell state (|00⟩ + |11⟩)/√2, the qubits are perfectly correlated. Measuring the first qubit as |0⟩ collapses the state to |00⟩, so the second qubit is |0⟩ with 100% certainty. This is the signature of entanglement — measuring one qubit instantly determines the other.
Q3: After measuring a qubit in superposition and getting |0⟩, what happens if you measure it again?
- A) You get |0⟩ or |1⟩ with equal probability
- B) You always get |0⟩
- C) You always get |1⟩
- D) The qubit returns to superposition
Show answer
Answer: B) You always get |0⟩
After collapse, the qubit is in the definite state |0⟩. The superposition has been irreversibly destroyed. Subsequent measurements of a collapsed state always yield the same result — this is a direct consequence of wave function collapse.
Further Reading
Section titled “Further Reading”- Quantum Measurement — Wikipedia (reference)
- Born Rule — Wikipedia (reference)
- Bell State — Wikipedia (reference)
- Qiskit Textbook: Single Qubit Gates (tutorial)