Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Master the crown jewel of two-qubit gates: the Controlled-NOT (CNOT) gate, parity flips, and synthesizing Bell states.
Interactive 3D state vector exploration, unitary transformation gates, and Born rule collapse for Topic 6.9
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Control qubit bit (0 or 1) | Remains unchanged after the gate | |
| Target qubit bit (0 or 1) | Flips if and only if c = 1 | |
| Bitwise XOR (addition modulo 2) | Classical XOR truth table: , , , | |
| 4Γ4 CNOT permutation matrix | Swaps basis states while leaving and fixed |
Creating the entangled Bell state |Ξ¦+β© using Hadamard on qubit 0, followed by CNOT(0 β 1):
Result: The two qubits are now maximally entangled: measuring one instantly determines the other with 100% correlation.
Control is 0; target 0 stays 0.
Control is 0; target 1 stays 1.
Control is 1; target 0 flips to 1.
Control is 1; target 1 flips to 0.
Problem: Creating maximally entangled pairs for quantum communications.
Solution: Hadamard on qubit 0 followed by CNOT(0, 1) creates canonical Bell pair (|00> + |11>)/sqrt(2).
Problem: Measuring whether two qubits are identical or different without measuring their individual values.
Solution: CNOT targets an ancilla qubit, recording parity c1 XOR c2.
Interactive activity component
Construct a 2-qubit circuit with Hadamard and CNOT gates to create the canonical Bell state (|00> + |11>)/sqrt(2), execute on the Aer simulator, and analyze correlated counts.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install qiskit qiskit-aer matplotlib1 from qiskit import QuantumCircuit 2 from qiskit_aer import Aer 3 from qiskit.visualization import plot_histogram 4 import matplotlib.pyplot as plt
from qiskit import QuantumCircuit β Circuit constructor
from qiskit_aer import Aer β Qiskit Aer simulator provider
from qiskit.visualization import plot_histogram β Histogram plotting utility
import matplotlib.pyplot as plt β Matplotlib renderer
1 # Create a Quantum Circuit with 2 Qubits and 2 Classical Bits 2 qc = QuantumCircuit(2, 2) 3 4 # Apply Hadamard gate to the first qubit (creates superposition) 5 qc.h(0) 6 7 # Apply CNOT gate (entangles qubit 0 and qubit 1) 8 qc.cx(0, 1) 9 10 # Measure both qubits into respective classical bits 11 qc.measure([0, 1], [0, 1]) 12 13 # Use Qiskit's Aer simulator 14 simulator = Aer.get_backend('aer_simulator') 15 16 # Run the circuit for 1,024 shots 17 job = simulator.run(qc, shots=1024) 18 result = job.result() 19 counts = result.get_counts() 20 21 # Print results 22 print("Measurement Results (Counts):", counts) 23 24 # Plot results histogram 25 plot_histogram(counts) 26 plt.show()
# Create a Quantum Circuit with 2 Qubits and 2 Classical Bits
Circuit creation
qc = QuantumCircuit(2, 2)
2 qubits, 2 classical bits
# Apply Hadamard gate to the first qubit (creates superposition)
Superposition step
qc.h(0)
H gate on q0: (|0> + |1>)/sqrt(2)
# Apply CNOT gate (entangles qubit 0 and qubit 1)
Entanglement step
qc.cx(0, 1)
CNOT: q0 controls q1, generating Bell state (|00> + |11>)/sqrt(2)
# Measure both qubits into respective classical bits
Measurement
qc.measure([0, 1], [0, 1])
Collapse both qubits simultaneously
# Use Qiskit's Aer simulator
Simulator setup
simulator = Aer.get_backend('aer_simulator')
Instantiate Aer backend
# Run the circuit for 1,024 shots
Execution
job = simulator.run(qc, shots=1024)
Simulate 1024 trials
result = job.result()
Extract result object
counts = result.get_counts()
Extract dictionary of outcome counts
# Print results
Console output
print("Measurement Results (Counts):", counts)
Display bitstring frequencies
# Plot results histogram
Visualization
plot_histogram(counts)
Render histogram bar chart
plt.show()
Show matplotlib plot
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Synthesizing and Simulating an Entangled Bell State with CNOT in Qiskit 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install qiskit qiskit-aer matplotlib 8 9 # Step 2: Import libraries 10 from qiskit import QuantumCircuit 11 from qiskit_aer import Aer 12 from qiskit.visualization import plot_histogram 13 import matplotlib.pyplot as plt 14 15 # Step 3: Run Demonstration 16 # Create a Quantum Circuit with 2 Qubits and 2 Classical Bits 17 qc = QuantumCircuit(2, 2) 18 19 # Apply Hadamard gate to the first qubit (creates superposition) 20 qc.h(0) 21 22 # Apply CNOT gate (entangles qubit 0 and qubit 1) 23 qc.cx(0, 1) 24 25 # Measure both qubits into respective classical bits 26 qc.measure([0, 1], [0, 1]) 27 28 # Use Qiskit's Aer simulator 29 simulator = Aer.get_backend('aer_simulator') 30 31 # Run the circuit for 1,024 shots 32 job = simulator.run(qc, shots=1024) 33 result = job.result() 34 counts = result.get_counts() 35 36 # Print results 37 print("Measurement Results (Counts):", counts) 38 39 # Plot results histogram 40 plot_histogram(counts) 41 plt.show()
Hadamard gate on qubit 0 creates an equal superposition of |0> and |1>.
Controlled-NOT gate flips qubit 1 only when qubit 0 is |1>, creating the entangled Bell state (|00> + |11>)/sqrt(2).
Simulator records 1,024 shots. The qubits always collapse in perfect lockstep: ~50% '00' and ~50% '11', with 0% chance of '01' or '10'.
2-qubit circuit with H(0), CX(0, 1), and 1,024 simulator shots
Measurement Results (Counts): {'00': 514, '11': 510}The CNOT gate acts as the universal entangler. Measuring qubit 0 instantly reveals the state of qubit 1 with 100% correlation, experimentally confirming quantum entanglement.
Hadamard, CNOT gate, Bell state synthesis, Aer simulation, and correlated measurement histograms.
Test your understanding with these questions. Remember, this is for learning, not examination!