Algorithm guide · primitive
GHZ / W states + CHSH test
Prepare three-qubit GHZ or W entanglement, or test a Bell inequality with four independently prepared Bell pairs.
Circuit size: 3 qubits (GHZ/W) or 8 qubits (CHSH)
Bell pairs · Measurement bases · Correlation versus individual outcomes
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
Choose among three experiments: prepare GHZ entanglement, prepare a W state, or estimate four Bell correlations for CHSH. These are different questions and use different circuit sizes.
2. How it works
GHZ places amplitude on two fully correlated strings. W shares one excitation across three wires. CHSH asks how correlations vary across local measurement choices; one fixed-basis histogram cannot answer that question.
Choose mode
GHZ and W use three wires. CHSH uses four independent Bell pairs, eight wires, to represent four setting combinations.
Prepare
GHZ uses H and CX; W uses calibrated controlled rotations; CHSH starts four Bell resources.
Choose bases
CHSH uses A0=Z, A1=X and B0=(Z+X)/√2, B1=(Z−X)/√2.
Measure and decode
Read state outcomes for GHZ/W, or estimate each pair’s parity correlation and combine them for CHSH.
3. The mathematics, one idea at a time
Their squared amplitudes give two probabilities of 1/2 or three probabilities of 1/3.
Map measured bits to ±1 outcomes using (−1)^bit. Local hidden-variable models obey |S|≤2 under the Bell assumptions.
These settings are measured on separate prepared pairs, not sequential incompatible measurements on one pair.
Work this through by hand
4. Start with the three-qubit GHZ state
Three qubits is the smallest width offered by this combined card. A two-qubit Bell pair is a simpler prerequisite, but not a mode here.
Choose GHZ state.
| Stage | Calculation or state | What it means |
|---|---|---|
| H on q0 | (|000⟩+|001⟩)/√2 | Only q0 is superposed in the q2q1q0 labeling. |
| CX q0→q1 | (|000⟩+|011⟩)/√2 | The first two wires are correlated. |
| CX q1→q2 | (|000⟩+|111⟩)/√2 | All three wires are correlated. |
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 |
|---|---|---|
| 000 | 50% ideal | All three measured bits zero. |
| 111 | 50% ideal | All three measured bits one. |
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.
- Experiment
- GHZ state
- 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
In GHZ/W, read c2c1c0. In W mode only 001,010,100 occur, ideally 1/3 each.
For CHSH, pair j uses classical bits c(2j+1),c(2j), for j=0,1,2,3 corresponding to settings 00,01,10,11. Marginalize the eight-bit histogram to each pair, compute E, then S. Count a pair’s equal outcomes regardless of its individual bit bias.
Finite-sample S fluctuates. A simulated violation is a teaching result, not a loophole-free laboratory Bell test.
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
- A 000/111 histogram by itself does not distinguish coherent GHZ from a classical mixture.
- Do not compute CHSH from one selected pair or add probabilities from incompatible register meanings.
8. Check your understanding
What is P(000) in ideal W mode?
Reveal the reasoning
Zero. The W state contains exactly one excitation, never all zeros.
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 a state preparation or the CHSH experiment, then inspect its editable circuit and sampled outcomes 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.
- Experiment
- Default: ghz · Choices for the current settings: GHZ state (000 or 111, each 50%.); W state (001, 010 or 100, each 1/3.); CHSH test (Four Bell-pair measurement settings.).
Implementation notes
This example uses the gallery's default configuration. Check Run details for the settings used in your execution.
The GHZ state is (|000> + |111>)/sqrt(2). Measuring all three qubits in the Z basis gives 000 or 111 with equal probability. The circuit prepares a coherent state before measurement.
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.
- Z-basis outcomes
- 000 and 111 (50% each)
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.