Algorithm guide · games
Meyer's quantum penny flip
A one-qubit coin game: Q's coherent strategy guarantees heads against a classical flip or pass.
Circuit size: 1 qubit
|+⟩ as an X eigenstate · Gate order · Restricted game rules
Review quantum fundamentals →Notation used in this lesson
- |ψ⟩ and ⟨ψ|
- A state vector (ket) and its conjugate transpose (bra). ⟨a|b⟩ is their inner product.
- α, β and i
- α and β are complex amplitudes; i²=−1. A probability is the squared magnitude |α|².
- XOR, · and ⊗
- XOR adds bits modulo two. In s·x, multiply corresponding bits and XOR them. ⊗ combines registers or operations on different wires.
- U†, Σ and Tr
- U† is the adjoint (inverse for a unitary). Σ sums terms. Tr is the matrix trace, the sum of diagonal entries.
- Probability, shots and angles
- Ideal probabilities describe the model; measured shot frequencies fluctuate. Angles inside trigonometric expressions are in radians unless explicitly labeled turns.
1. The problem
A coin starts heads, |0⟩. Q moves, P either flips or passes, then Q moves again. Q wins if the final outcome is heads. Find a coherent strategy that works without observing P’s hidden move.
2. How it works
Prepare an eigenstate of the opponent’s allowed flip. X cannot change |+⟩, and passing cannot change it either. Undo the preparation after P’s turn to restore heads.
Q first move
Apply H to turn |0⟩ into |+⟩.
P move
P applies X or I, with no intermediate measurement.
Q second move
Apply H again.
Measure
Classical 0 is heads/Q wins; 1 is tails/P wins.
3. The mathematics, one idea at a time
The prepared state is unchanged under either allowed opponent action.
Both full sequences return heads. A random mixture of the two P actions gives the same ideal result.
Work this through by hand
4. One coin, opponent flips
One qubit is both the mathematical and supported minimum.
Choose Quantum H/H and P move Flip.
| Stage | Calculation or state | What it means |
|---|---|---|
| Start | |0⟩ | Heads. |
| Q applies H | (|0⟩+|1⟩)/√2 | This is a coherent state, not a classical secret choice of heads or tails. |
| P applies X | (|1⟩+|0⟩)/√2=|+⟩ | The state is invariant. |
| Q applies H | |0⟩ | Heads is restored with certainty. |
Expected outcomes for this example
These are ideal predictions for the stated configuration, not a result already measured by your browser. Rows describing alternative modes or combined events are labeled explicitly.
| Outcome or event | Ideal probability | Interpretation |
|---|---|---|
| 0 | 100% ideal | Q wins. |
| 1 | 0% ideal | P wins. |
5. Load the worked example in Composer
The worked example can use smaller or simpler inputs than the gallery defaults. The button below loads the exact circuit used in this lesson.
- Q strategy
- Quantum H / H
- P middle move
- Flip (X)
- Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
- Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
- Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
- Inspect the live preview. For a recorded experiment, open Execute, set the available backend options and shots, and Run. Sign in when prompted to retain it in My Jobs.
- Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.
6. Read the output correctly
The heads/Q-win summary is calculated from actual c0 counts.
Switch P to Pass: the ideal answer stays 0. Compare the classical strategy choices to see how a fixed known move can win or lose deterministically.
A bit label is a register value; its bar height is a probability or count. For S shots and observed count k, the sampled frequency is k/S. A typical sampling scale for probability p is √[p(1−p)/S]; this is not a strict error bound. Finite samples do not have to match the ideal percentages exactly.
7. Common mistakes & limits
- The guarantee assumes initial heads, coherence and P restricted to X or I.
- The classical 50% game value concerns optimal mixed play against a hidden opponent, not every fixed deterministic pairing.
8. Check your understanding
If you edit P’s move to Z, does Q still win?
Reveal the reasoning
No. HZH=X, so the final state is |1⟩. The opponent’s allowed-action assumption was essential.
9. Further study
The lesson’s register mappings, supported inputs and loadable example follow Quantket’s implemented circuit. A reference may use different wire names, bit order or resource conventions.
Gallery reference: defaults, definitions & implementation notes
Inputs & default settings
Choose Q's two predetermined moves and P's middle action, then inspect measured heads/tails in Composer.
These are the gallery defaults. The worked example above may override them. Configure the card to change the inputs before loading its editable circuit.
- Q strategy
- Default: quantum · Choices for the current settings: Quantum H / H (Prepare |+>, then restore heads.); Classical pass / pass; Classical pass / flip; Classical flip / pass; Classical flip / flip.
- P middle move
- Default: flip · Choices for the current settings: Flip (X); Pass (I).
Implementation notes
Start heads-up: |0> is heads and |1> tails. Turns are Q, P, Q, with no observation or measurement between them. Q wins on final heads; P wins on tails. Quantum Q uses H, then H: H|0>=|+>, and X|+>=|+>, so either P flip (X) or pass (I) leaves the state unchanged and the final H restores heads. This also wins against any probabilistic mixture of those two P actions. Q's chosen strategy is fixed before play and cannot react to observing P. Classical Q can pass/pass, pass/flip, flip/pass or flip/flip; each pairing with a known P move wins or loses deterministically. Against a fair hidden P action each classical strategy wins 50%; mixing Q's even/odd flip parity equally guarantees 50% against either P action. This is the classical mixed-strategy game value, not a bound for a fixed known move. Quantum success assumes initial heads, ideal coherent gates and P restricted to flip/pass; edits can change the outcome. Pass is an idle turn. Quantum play has two H gates plus an optional X, excluding final measurement and stage barriers.
Default example: predictions & circuit facts
These values describe the unedited default setup. They are predictions and circuit properties, not measured results from your saved execution.
- Ideal Q win (heads)
- 100%
- Ideal P win (tails)
- 0%
- Classical mixed game value
- 50% Q wins
Read your saved result
Check the submitted circuit, measured register and execution settings in Run details. Exact results give computed probabilities; sampled results show frequencies from the recorded shots. Edited circuits and noise can change the expected outcome. The algorithm label records the circuit's origin; it does not certify an edited circuit or a measured result.