Skip to content

Bell State ​

The smallest entangled state, run through the Qiskit backend.

py
"""Bell state through the Qiskit BackendV2 adapter."""

from qiskit import QuantumCircuit

from menos.qiskit import MENOSBackend

qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])

backend = MENOSBackend()
result = backend.run(qc, shots=1000, seed_simulator=7).result()
counts = result.get_counts()
print(counts)

# A Bell pair only ever yields 00 or 11, and every shot is accounted for.
assert set(counts) <= {"00", "11"}
assert sum(counts.values()) == 1000

Output ​

text
{'00': 507, '11': 493}

With seed_simulator=7 this is the same every run. Only 00 and 11 ever appear, because the two qubits are perfectly correlated, and the counts add up to the 1000 shots requested.

What to try ​

  • Change seed_simulator and watch the split change while staying close to 50/50.
  • Remove the seed: each run then draws its own.

See also ​

Your First Circuit · Counts

Released under the Apache-2.0 license. GitHub · PyPI