Teleport an unknown qubit with a Bell pair and two classical bits; then test the fidelity on thousands of random states.
Check running...
The science
Qubit q0 holds an unknown state |ψ〉 = cos(θ/2)|0〉 + e^{iφ} sin(θ/2)|1〉. Qubits q1 (Alice) and q2 (Bob) share a Bell pair (|00〉+|11〉)/√2, made by H on q1 then CNOT q1→q2. The full register is an 8-component complex state vector, ordered |q0 q1 q2〉.
Alice applies CNOT q0→q1 and H on q0, then measures q0, q1 (Born rule, P(m)=∑|amp|² over the matching basis states, then collapse and renormalise). Bob applies X^m1 then Z^m0. Algebraically the four outcomes each have probability 1/4 and leave Bob with exactly |ψ〉.
Fidelity is F = ⟨ψ|ρBob|ψ〉 = (1 + nin·nBob)/2 from Bloch vectors; a second, separate number reads Bob's two amplitudes straight from the collapsed vector and computes |⟨ψ|χ〉|².
Noise model (illustrative): after the Bell pair is made, q2 suffers a random X, Y or Z with probability p. Averaged over outcomes, F̄ = 1 − 2p/3 for every input state (each Pauli leaves a pure state's overlap ni², average 1/3).
Simplifications: ideal gates and perfect measurement; no photon loss or decoherence beyond the single Pauli kick. No information travels faster than light: Bob's qubit is maximally mixed (Bloch vector length 0) until Alice's two classical bits arrive. Nothing is copied: q0 is destroyed by the measurement.