Skip to main content
The Bell state is the simplest and most iconic example of quantum entanglement. By applying a Hadamard gate followed by a CNOT gate to two qubits initialized in |00⟩, you create a state where neither qubit has a definite value on its own — measuring one instantly determines the other, no matter the distance between them. The resulting state (|00⟩ + |11⟩)/√2 is one of four maximally entangled two-qubit states known as Bell states.

Code

Step-by-step explanation

Gate definitions The circuit defines two gates from first principles using the universal single-qubit gate U(theta, phi, lambda):
  • h (Hadamard) is defined as U(pi/2, 0, pi), which maps |0⟩ → (|0⟩ + |1⟩)/√2 and |1⟩ → (|0⟩ − |1⟩)/√2.
  • cx (CNOT) is defined using the ctrl @ modifier, which promotes a single-qubit gate to a controlled version. Here it applies U(pi, 0, pi) (an X gate) on the target qubit whenever the control qubit is |1⟩.
Initialization qubit[2] q allocates a two-qubit register. reset q explicitly sets both qubits to |0⟩, giving the initial state |q[0]q[1]⟩ = |00⟩. Hadamard on q[0] h q[0] places q[0] into equal superposition:
CNOT with q[0] as control, q[1] as target cx q[0], q[1] flips q[1] only when q[0] is |1⟩:
This is the Φ⁺ Bell state — the two qubits are now maximally entangled.

Expected output

When you measure both qubits, the simulator collapses the entangled state to one of two outcomes with equal probability: Outcomes 01 and 10 have zero probability. This perfect correlation — never a mismatched result — is the defining signature of entanglement.
Because no measurement instruction appears in this circuit, the OpenQASM Playground displays the statevector amplitude of each basis state rather than a histogram of shots. You will see amplitude 1/√2 ≈ 0.707 on both |00⟩ and |11⟩.

Quantum mechanics concepts

Superposition — A qubit in superposition is simultaneously in both |0⟩ and |1⟩ with some probability amplitude for each. The Hadamard gate creates an equal-weight superposition from a definite |0⟩. Entanglement — After the CNOT, the two-qubit state cannot be written as a product of independent single-qubit states. This is the defining property of an entangled state: the measurement outcome of one qubit is perfectly correlated with the outcome of the other. Bell states — There are four maximally entangled two-qubit states (Φ⁺, Φ⁻, Ψ⁺, Ψ⁻). This circuit prepares Φ⁺ = (|00⟩ + |11⟩)/√2. The other three can be reached by adding X or Z gates before or after this circuit. No-communication theorem — Although measuring q[0] instantly determines q[1]‘s outcome, entanglement cannot be used to transmit information faster than light. The correlation is only visible when both measurement results are compared through a classical channel — the basis of quantum teleportation.