Bell States Tutorial¶

Introduction to Bell States¶

Bell states are the four maximally entangled two-qubit quantum states that form the foundation of quantum entanglement and quantum information protocols. They were introduced by physicist John Stewart Bell and are fundamental to understanding quantum mechanics.

The Four Bell States¶

  1. |Ψ+⟩ = (|00⟩ + |11⟩)/√2 - Both qubits always give the same measurement outcome
  2. |Ψ-⟩ = (|00⟩ - |11⟩)/√2 - Same outcomes with phase difference
  3. |Φ+⟩ = (|01⟩ + |10⟩)/√2 - Qubits always give opposite outcomes
  4. |Φ-⟩ = (|01⟩ - |10⟩)/√2 - Opposite outcomes with phase difference

This tutorial will guide you through creating, executing, and analyzing all four Bell states using the QpiAI Quantum SDK.

Auntentication the USER¶

Setting up the API configuration to run jobs on quantum hardware:

In [1]:
import sys
import os
import numpy as np
sys.path.append('../')

from dotenv import load_dotenv
load_dotenv()

from qpiai_quantum import QpiAIQuantumAuth
API_KEY = os.getenv("API_KEY")
QpiAIQuantumAuth.login(API_KEY)
Out[1]:
'API key stored. It will be validated on first cloud access.'

Verify the User API Configuration¶

Setting up the API configuration to run the jobs on quantum experiment:

In [2]:
QpiAIQuantumAuth.me()
Out[2]:
{'name': 'Quantum Hardware Super Admin',
 'email': 'xxxxxxxxxxx@qpiai.tech',
 'api_key': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'}

Part 1: Creating a Single Bell State¶

Let's start with the most common Bell state: |Ψ+⟩

This state creates perfect correlation: both qubits will always measure the same value (either both 0 or both 1).

Circuit Construction¶

The circuit consists of:

  1. Hadamard (H) gate on qubit 0: Creates superposition (|0⟩ + |1⟩)/√2
  2. CNOT gate: Entangles qubit 0 (control) with qubit 1 (target)
In [3]:
from qpiai_quantum.state_preparation import BellStateGenerator

bell = BellStateGenerator(state_type='|Ψ+>')
circuit = bell.build_circuit(measure=True)
circuit.show()
No description has been provided for this image

Executing the Circuit on QpiAI Quantum Hardware¶

Now we'll execute the circuit and analyze the results:

In [5]:
shots = 10000
result = bell.run(shots=shots, experiment_name='Bell', device_type="qpu")
print(f"Counts : {result.get_counts()}")
Counts : {'00': 4940, '11': 5060}

Visualize Results as Histogram¶

In [6]:
bell.visualize('histogram', result=result)
No description has been provided for this image

Get Expected Outcomes¶

Check the theoretical probability distribution for this Bell state:

In [7]:
expected = bell.get_expected_outcomes()
print(f"Expected outcomes: {expected}")
Expected outcomes: {'00': 0.5, '11': 0.5}

Part 2: Exploring All Four Bell States¶

Now let's explore all four Bell states individually to understand their unique properties.

Create All Four Bell States¶

In [8]:
all_bells = BellStateGenerator.get_all_bell_states()

for state_name, generator in all_bells.items():
    print(f"\n{state_name}:")
    print(f"  {generator.description}")
|Ψ+>:
  Bell state |Ψ+⟩ = (|00⟩ + |11⟩)/√2 - Both qubits always same

|Ψ->:
  Bell state |Ψ-⟩ = (|00⟩ - |11⟩)/√2 - Same with phase flip

|Φ+>:
  Bell state |Φ+⟩ = (|01⟩ + |10⟩)/√2 - Qubits always opposite

|Φ->:
  Bell state |Φ-⟩ = (|01⟩ - |10⟩)/√2 - Opposite with phase flip

Visualize Circuit Diagrams for All States¶

In [9]:
# Build and display circuits for each Bell state
for state_name, generator in all_bells.items():
    print(f"\n{'='*50}")
    print(f"Circuit for {state_name}")
    print(f"{'='*50}")
    circuit = generator.build_circuit(measure=True)
    circuit.show()
==================================================
Circuit for |Ψ+>
==================================================
No description has been provided for this image
==================================================
Circuit for |Ψ->
==================================================
No description has been provided for this image
==================================================
Circuit for |Φ+>
==================================================
No description has been provided for this image
==================================================
Circuit for |Φ->
==================================================
No description has been provided for this image

Expected Outcomes for Each Bell State¶

In [10]:
print("Expected probability distributions for each Bell state:\n")
for state_name, generator in all_bells.items():
    expected = generator.get_expected_outcomes()
    print(f"{state_name}: {expected}")
Expected probability distributions for each Bell state:

|Ψ+>: {'00': 0.5, '11': 0.5}
|Ψ->: {'00': 0.5, '11': 0.5}
|Φ+>: {'01': 0.5, '10': 0.5}
|Φ->: {'01': 0.5, '10': 0.5}

Summary and Key Takeaways¶

In this tutorial, we've comprehensively explored:

  1. Bell State Fundamentals: Understanding the four maximally entangled states
  2. Circuit Construction: How to build Bell state circuits using quantum gates
  3. Execution: Running Bell states on quantum hardware and simulators
  4. Comparison: Analyzing all four Bell states simultaneously
  5. Advanced Features: Convenience functions and customizable parameters

Key Methods Reference¶

  • BellStateGenerator(state_type) - Create a Bell state generator
  • build_circuit(measure=True) - Build the quantum circuit
  • run(shots, backend, experiment_name) - Execute on quantum backend
  • get_expected_outcomes() - Get theoretical probability distribution
  • visualize(plot_type, result) - Create visualizations
  • get_all_bell_states() - Get all four Bell state generators
  • compare_all_bell_states(shots, backend) - Compare all states at once

Thank you for learning with QpiAI!

In [11]:
import qpiai_quantum
print(qpiai_quantum.__version__)
0.1.9