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.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/itsubaki/qasm-playground/llms.txt
Use this file to discover all available pages before exploring further.
Code
Step-by-step explanation
Gate definitions The circuit defines two gates from first principles using the universal single-qubit gateU(theta, phi, lambda):
h(Hadamard) is defined asU(pi/2, 0, pi), which maps |0⟩ → (|0⟩ + |1⟩)/√2 and |1⟩ → (|0⟩ − |1⟩)/√2.cx(CNOT) is defined using thectrl @modifier, which promotes a single-qubit gate to a controlled version. Here it appliesU(pi, 0, pi)(an X gate) on the target qubit whenever the control qubit is |1⟩.
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:
cx q[0], q[1] flips q[1] only when q[0] is |1⟩:
Expected output
When you measure both qubits, the simulator collapses the entangled state to one of two outcomes with equal probability:| Outcome | Probability |
|---|---|
00 | 50% |
11 | 50% |
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⟩.