Foundation Tier
By the end of this module, you will be able to:
- Understand the fundamental differences between classical and quantum bits
- Explain superposition and its computational implications
- Describe quantum entanglement and its role in quantum computing
- Understand the measurement process and wave function collapse
- Identify basic quantum gates and their functions
- Create your first quantum circuit using Qiskit
- Basic programming knowledge (Python preferred)
- High school level mathematics
- Curiosity about quantum mechanics!
Let's start with what you already know! In the digital world around us - your smartphone, laptop, the internet - everything is built on bits.
Think of a classical bit like a light switch:
- 0 = Switch is OFF (no electricity flowing, false, low voltage)
- 1 = Switch is ON (electricity flowing, true, high voltage)
# Classical bit examples - just like light switches!
bedroom_light = 0 # Light is OFF
kitchen_light = 1 # Light is ON
living_room_light = 0 # Light is OFF
# A byte is 8 switches (bits) in a row
classical_byte = [0, 1, 1, 0, 1, 0, 0, 1] # 8 light switches
# This could represent the letter 'i' in ASCII encoding- Your computer's memory: Each bit stores one piece of information
- Digital photos: Each pixel's color is stored as bits
- Text messages: Each letter is converted to bits
- Music files: Sound waves are converted to 0s and 1s
Classical bits are predictable - like a light switch:
- If you check a switch that's ON, it's always ON (until someone flips it)
- If you check it 1000 times, you get the same answer 1000 times
- No surprises, no randomness!
# Classical bit behavior - completely predictable
my_bit = 1
for i in range(1000):
print(f"Check #{i+1}: {my_bit}") # Always prints 1Now, imagine a magical light switch that can be ON, OFF, or spinning between both states at the same time! This is essentially what a qubit is.
A qubit (quantum bit) is the fundamental unit of quantum information. Unlike our simple light switches, qubits can exist in:
- State |0⟩ (similar to classical 0 - switch OFF)
- State |1⟩ (similar to classical 1 - switch ON)
- Superposition of both states simultaneously (switch spinning!)
Note: The |⟩ notation is called "Dirac notation" or "bra-ket notation" - it's just a fancy way physicists write quantum states. Think of |0⟩ as "the state zero" and |1⟩ as "the state one".
- Spinning Coin: While in the air, it's neither heads nor tails - it's both!
- Schrödinger's Cat: The famous thought experiment where a cat is both alive AND dead until observed
- Double-slit Experiment: A particle goes through both slits simultaneously
- GPS Navigation: Like being on multiple routes at once until you choose one
# We can't directly create real qubits in regular Python, but we can represent them mathematically
# A qubit in superposition looks like: |ψ⟩ = α|0⟩ + β|1⟩
# where α and β are complex numbers called "probability amplitudes"
# Example: A qubit with equal chance of being 0 or 1
qubit_amplitudes = {
'alpha': 1/math.sqrt(2), # amplitude for |0⟩ state
'beta': 1/math.sqrt(2) # amplitude for |1⟩ state
}
print(f"This qubit has {abs(qubit_amplitudes['alpha'])**2 * 100:.1f}% chance of being 0")
print(f"This qubit has {abs(qubit_amplitudes['beta'])**2 * 100:.1f}% chance of being 1")- Before measurement: The qubit IS both 0 and 1 simultaneously
- During measurement: The qubit "chooses" to be either 0 or 1
- After measurement: The qubit becomes a regular classical bit
Think of it like this: Imagine you could be in multiple places at once, but the moment someone looks for you, you suddenly appear in just one location!
| Property | Classical Bit | Qubit | Everyday Analogy |
|---|---|---|---|
| States | 0 or 1 (like ON/OFF switch) | |0⟩, |1⟩, or superposition | Spinning coin vs. landed coin |
| Measurement | Always gives same result | Probabilistic outcome | Light switch vs. lottery ticket |
| Copying | Easy to copy (Ctrl+C) | Cannot be cloned* | Xeroxing paper vs. teleporting |
| Operations | Logic gates (AND, OR, NOT) | Quantum gates (X, Y, Z, H) | Simple math vs. magic tricks |
| Information | 1 bit = 1 piece of info | 1 qubit = infinite possibilities | Single answer vs. all possibilities |
*This is called the "No-cloning theorem" - one of the fundamental laws of quantum mechanics!
# Classical computing with 3 bits
classical_states = ['000', '001', '010', '011', '100', '101', '110', '111']
print(f"3 classical bits can be in 1 state at a time: {classical_states[0]}")
print(f"To check all possibilities, we need 8 separate computations")
# Quantum computing with 3 qubits
print(f"3 qubits can be in ALL 8 states simultaneously!")
print(f"One quantum computation can explore all possibilities at once")This is why quantum computers are potentially so powerful - they can explore many solutions simultaneously!
Imagine you ask someone "Are you happy or sad?" and they answer "Yes!"
In classical logic, this doesn't make sense. But in quantum mechanics, this is perfectly normal! A quantum system can be in multiple states simultaneously until you measure it.
Superposition is the ability of a quantum system to exist in multiple states at the same time. It's like:
- A coin spinning in the air (neither heads nor tails, but both)
- Being in multiple lanes of traffic simultaneously until you pick one
- A light that's both on AND off until someone looks at it
Classical commute: You take EITHER Route A OR Route B to work
Quantum commute: You take Route A AND Route B simultaneously,
arriving at work having experienced both routes!
Classical order: "I'll have the pizza" OR "I'll have the burger"
Quantum order: "I'll have a superposition of pizza and burger"
(You experience both meals until the bill arrives!)
Classical password: Either correct OR incorrect
Quantum password: Correct AND incorrect simultaneously
(Until the system checks it!)
A qubit in superposition is written as:
|ψ⟩ = α|0⟩ + β|1⟩
Translation to English:
- "|ψ⟩" = "the quantum state psi" (just a name for our qubit)
- "α" = how much the qubit "leans toward" being 0
- "β" = how much the qubit "leans toward" being 1
- "|0⟩ and |1⟩" = the basic states (like North and South on a compass)
The Rules:
- |α|² = probability of measuring |0⟩ (chance of getting 0)
- |β|² = probability of measuring |1⟩ (chance of getting 1)
- |α|² + |β|² = 1 (probabilities must add up to 100%)
import math
# A qubit where α = 1/√2 and β = 1/√2
alpha = 1/math.sqrt(2) # ≈ 0.707
beta = 1/math.sqrt(2) # ≈ 0.707
probability_of_0 = abs(alpha)**2 # = 0.5 = 50%
probability_of_1 = abs(beta)**2 # = 0.5 = 50%
print(f"This qubit has a {probability_of_0*100}% chance of being measured as 0")
print(f"This qubit has a {probability_of_1*100}% chance of being measured as 1")
print(f"But right now, it's BOTH 0 AND 1 simultaneously!")The Hadamard gate (H) is like a "quantum coin flipper" - it takes a definite state and puts it into equal superposition.
What it does:
H|0⟩ = (1/√2)|0⟩ + (1/√2)|1⟩
Translation: "Take a qubit that's definitely 0, and make it 50% likely to be 0 and 50% likely to be 1"
Real-world analogy:
- Input: A coin lying flat showing heads
- Hadamard gate: Flip the coin high in the air
- Output: A spinning coin (50% heads, 50% tails)
# Let's see this in action with Qiskit
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram
# Create a simple superposition
qc = QuantumCircuit(1, 1)
# Start with |0⟩ (all qubits start this way)
print("Starting state: |0⟩ (definitely 0)")
# Apply Hadamard gate to create superposition
qc.h(0)
print("After Hadamard: (1/√2)|0⟩ + (1/√2)|1⟩ (maybe 0, maybe 1)")
# Measure the result
qc.measure(0, 0)
# Run it many times to see the randomness
simulator = AerSimulator()
job = simulator.run(qc, shots=1000)
result = job.result()
counts = result.get_counts()
print(f"Results after 1000 measurements: {counts}")
print("Notice: roughly 50% zeros and 50% ones!")Not all superpositions are 50/50! We can create "biased" superpositions:
# A qubit that's 75% likely to be |0⟩ and 25% likely to be |1⟩
alpha = math.sqrt(0.75) # ≈ 0.866
beta = math.sqrt(0.25) # = 0.5
print(f"α = {alpha:.3f}, β = {beta:.3f}")
print(f"Probability of 0: {abs(alpha)**2*100:.1f}%")
print(f"Probability of 1: {abs(beta)**2*100:.1f}%")
print("This qubit is 'leaning' toward being 0!")Sometimes the amplitudes can be negative or even complex numbers:
# A qubit with negative amplitude
alpha = 1/math.sqrt(2) # positive
beta = -1/math.sqrt(2) # negative!
print("Even with negative amplitude:")
print(f"Probability of 0: {abs(alpha)**2*100:.1f}%") # Still 50%!
print(f"Probability of 1: {abs(beta)**2*100:.1f}%") # Still 50%!
print("The negative sign affects interference, not probabilities directly")This is where quantum computing gets its "superpowers"! With superposition, quantum computers can process multiple possibilities simultaneously.
Classical Computer Checking Passwords:
# Classical computer must check each password one by one
passwords_to_check = ['1234', '5678', '9999', 'abcd']
correct_password = '9999'
for i, password in enumerate(passwords_to_check):
print(f"Try {i+1}: Checking '{password}'...")
if password == correct_password:
print(f"Found it! Password is '{password}'")
break
# This took 3 tries (sequential checking)Quantum Computer (Conceptually):
# Quantum computer can check ALL passwords simultaneously!
print("Creating superposition of all possible passwords...")
print("Checking ALL passwords at once...")
print("Found correct password in 1 quantum operation!")
# This is the essence of quantum parallel processing# Number of states that can exist simultaneously
def quantum_states(num_qubits):
return 2 ** num_qubits
print("Simultaneous states possible:")
for qubits in [1, 2, 3, 10, 20, 50]:
states = quantum_states(qubits)
print(f"{qubits:2d} qubits: {states:,} states simultaneously")
# Output shows exponential growth:
# 1 qubit: 2 states
# 2 qubits: 4 states
# 3 qubits: 8 states
# 10 qubits: 1,024 states
# 20 qubits: 1,048,576 states
# 50 qubits: 1,125,899,906,842,624 states!- Database Search: Find items in unsorted databases faster
- Cryptography: Factor large numbers (break current encryption)
- Optimization: Find best solutions among millions of possibilities
- Machine Learning: Train on multiple datasets simultaneously
- Drug Discovery: Simulate molecular interactions at quantum level
This exponential scaling is why quantum computers are potentially so powerful - they can explore an exponentially large space of possibilities in parallel!
Imagine you have a pair of magical coins. When you flip one coin and it lands heads, the other coin instantly lands tails, no matter how far apart they are. This instant connection is what Einstein called "spooky action at a distance."
Entanglement is a quantum phenomenon where two or more qubits become correlated in such a way that:
- Measuring one qubit instantly affects the others
- This happens regardless of the distance between them
- The qubits share their quantum fate
Imagine identical twins who always do opposite things:
- When one twin laughs, the other cries (instantly!)
- When one twin eats pizza, the other eats salad
- This happens even if they're on different continents
- They're "entangled" in their behavior
You have two dice that are "quantum entangled":
- Roll one die and get 6, the other automatically shows 1
- Roll one die and get 3, the other automatically shows 4
- They always add up to 7, no matter where they are!
- The dice "communicate" instantly across any distance
Two dancers performing on different stages worldwide:
- When one spins left, the other spins right (simultaneously)
- When one jumps, the other crouches (at the exact same moment)
- They're perfectly synchronized without any communication
- This is the essence of quantum entanglement
When qubits become entangled:
- They lose their individual identities
- They become parts of a larger quantum system
- Measuring one reveals information about all others
- The correlation is perfect and instantaneous
The most famous entangled state is called a Bell state:
|Φ⁺⟩ = (1/√2)(|00⟩ + |11⟩)
What this mathematical expression means:
- "There's a 50% chance both qubits are 0"
- "There's a 50% chance both qubits are 1"
- "There's a 0% chance one is 0 and the other is 1"
- "The qubits are perfectly correlated!"
# Let's create entanglement step by step
from qiskit import QuantumCircuit
print("Step 1: Start with two separate qubits")
print("Qubit 1: |0⟩ (definitely 0)")
print("Qubit 2: |0⟩ (definitely 0)")
print("Total system: |00⟩ (both definitely 0)")
qc = QuantumCircuit(2, 2)
print("\nStep 2: Put first qubit in superposition")
qc.h(0) # Hadamard on first qubit
print("Qubit 1: (1/√2)|0⟩ + (1/√2)|1⟩ (50% either way)")
print("Qubit 2: |0⟩ (still definitely 0)")
print("Total: (1/√2)|00⟩ + (1/√2)|10⟩")
print("\nStep 3: Apply CNOT gate to create entanglement")
qc.cx(0, 1) # CNOT gate
print("Now the qubits are entangled!")
print("Total system: (1/√2)|00⟩ + (1/√2)|11⟩")
print("They're either both 0 OR both 1, never mixed!")# In an entangled Bell state |Φ⁺⟩ = (1/√2)(|00⟩ + |11⟩)
print("If you measure the first qubit and get 0...")
print("Then the second qubit will ALWAYS be 0 (100% certainty)")
print("\nIf you measure the first qubit and get 1...")
print("Then the second qubit will ALWAYS be 1 (100% certainty)")
print("\nThis correlation is perfect - no exceptions!")print("Distance doesn't matter for entanglement:")
print("- Qubits 1 meter apart: Instant correlation ✓")
print("- Qubits 1 kilometer apart: Instant correlation ✓")
print("- Qubits on different planets: Instant correlation ✓")
print("- Qubits in different galaxies: Instant correlation ✓")
print("\nThis is faster than light - it's instantaneous!")Entanglement is extremely delicate:
# Things that can destroy entanglement:
environmental_factors = [
"Temperature fluctuations",
"Electromagnetic radiation",
"Cosmic rays",
"Vibrations",
"Measuring one of the qubits",
"Even looking at the system wrong! (just kidding... or am I?)"
]
print("Entanglement can be broken by:")
for factor in environmental_factors:
print(f"- {factor}")
print("\nThis is why quantum computers need:")
print("- Ultra-cold temperatures (near absolute zero)")
print("- Isolation from electromagnetic interference")
print("- Vibration-free environments")
print("- Careful error correction")# 1. Phi Plus - perfectly correlated
print("Bell State 1: |Φ⁺⟩ = (1/√2)(|00⟩ + |11⟩)")
print(" Both qubits always give the SAME result")
# 2. Phi Minus - correlated with phase difference
print("Bell State 2: |Φ⁻⟩ = (1/√2)(|00⟩ - |11⟩)")
print(" Both qubits give same result, but with quantum phase difference")
# 3. Psi Plus - perfectly anti-correlated
print("Bell State 3: |Ψ⁺⟩ = (1/√2)(|01⟩ + |10⟩)")
print(" Qubits always give OPPOSITE results")
# 4. Psi Minus - anti-correlated with phase
print("Bell State 4: |Ψ⁻⟩ = (1/√2)(|01⟩ - |10⟩)")
print(" Qubits give opposite results with phase difference")# Entanglement can involve many qubits!
print("GHZ State (3 qubits): |GHZ⟩ = (1/√2)(|000⟩ + |111⟩)")
print("All three qubits are entangled together!")
print("Measuring one affects the other two simultaneously")
print("\nW State (3 qubits): |W⟩ = (1/√3)(|001⟩ + |010⟩ + |100⟩)")
print("Each qubit has equal probability of being the 'special' one")Entanglement isn't just a curiosity - it enables revolutionary technologies:
# Quantum teleportation protocol (simplified explanation)
print("Step 1: Alice has a qubit she wants to 'teleport' to Bob")
print("Step 2: Alice and Bob share an entangled pair")
print("Step 3: Alice measures her qubits together")
print("Step 4: Alice calls Bob and tells him her measurement results")
print("Step 5: Bob applies operations based on Alice's call")
print("Result: Bob's qubit is now identical to Alice's original!")
print("\nNote: No matter was actually teleported, just quantum information!")Real-world applications:
- Secure quantum internet
- Quantum sensor networks
- Distributed quantum computing
print("Quantum Key Distribution (QKD) using entanglement:")
print("1. Alice and Bob share entangled photons")
print("2. Any eavesdropper (Eve) breaks the entanglement")
print("3. Alice and Bob detect the disturbance")
print("4. If no disturbance detected, communication is 100% secure")
print("\nThis is physically impossible to hack!")Real-world applications:
- Banking security systems
- Government communications
- Military encryption
print("Many quantum algorithms depend on entanglement:")
algorithms = [
"Shor's Algorithm (factoring large numbers)",
"Grover's Search (database searching)",
"Quantum Error Correction",
"Variational Quantum Eigensolver",
"Quantum Machine Learning"
]
for alg in algorithms:
print(f"- {alg}")
print("\nWithout entanglement, these algorithms wouldn't work!")print("Entangled sensors can achieve unprecedented precision:")
print("- Atomic clocks (GPS satellites)")
print("- Gravitational wave detectors (LIGO)")
print("- Medical imaging (MRI)")
print("- Navigation systems")
print("- Geological surveying")Entanglement challenges our everyday understanding of reality:
# The Einstein-Podolsky-Rosen (EPR) Paradox
print("Einstein's concern (1935):")
print("'If entanglement is real, then either:'")
print("1. Information travels faster than light (impossible!)")
print("2. Reality doesn't exist until we measure it (weird!)")
print("3. There are hidden variables we don't know about")
print("\nBell's Theorem (1964) proved:")
print("Hidden variables cannot explain quantum correlations")
print("Reality really IS this strange!")
print("\nExperimental verification:")
print("- 1972: First Bell test experiments")
print("- 1982: Aspect's decisive experiments")
print("- 2015: 'Loophole-free' Bell tests")
print("- 2022: Nobel Prize awarded for Bell test experiments")
print("\nConclusion: Quantum entanglement is real and verified!")Entanglement shows us that the universe is fundamentally interconnected in ways that seem impossible from our everyday experience, but are absolutely real and measurable!
Measurement is the bridge between the weird quantum world and our familiar classical world. It's the moment when all the quantum "maybes" become definite "yes" or "no" answers.
Think of measurement like taking a photograph of a spinning coin:
- Before the photo: The coin is spinning (superposition)
- During the photo: The camera captures one specific moment
- After the photo: You see either heads or tails (classical result)
- Important: The coin stops spinning after the photo!
# The quantum measurement process
print("BEFORE measurement:")
print("Qubit state: α|0⟩ + β|1⟩")
print("The qubit is in superposition - it's both 0 AND 1")
print("Reality is 'fuzzy' and probabilistic")
print("\nDURING measurement:")
print("Quantum detector interacts with the qubit")
print("This interaction is irreversible!")
print("The superposition becomes unstable")
print("\nAFTER measurement:")
print("Qubit state: EITHER |0⟩ OR |1⟩")
print("We get a definite classical result")
print("The quantum 'magic' is gone - it's now just a classical bit")
print("Reality has become 'sharp' and definite")For a qubit |ψ⟩ = α|0⟩ + β|1⟩, the probability of getting each result is:
import random
import math
def quantum_measurement_simulation(alpha, beta, num_measurements=1000):
"""Simulate measuring a qubit many times"""
# Calculate probabilities
prob_0 = abs(alpha)**2
prob_1 = abs(beta)**2
print(f"Qubit state: ({alpha:.3f})|0⟩ + ({beta:.3f})|1⟩")
print(f"Probability of measuring 0: {prob_0:.1%}")
print(f"Probability of measuring 1: {prob_1:.1%}")
# Simulate many measurements
results = []
for _ in range(num_measurements):
if random.random() < prob_0:
results.append(0)
else:
results.append(1)
# Count results
count_0 = results.count(0)
count_1 = results.count(1)
print(f"\nAfter {num_measurements} measurements:")
print(f"Got 0: {count_0} times ({count_0/num_measurements:.1%})")
print(f"Got 1: {count_1} times ({count_1/num_measurements:.1%})")
return results
# Example 1: Equal superposition
print("=== Example 1: Equal Superposition ===")
alpha = 1/math.sqrt(2) # 70.7% amplitude
beta = 1/math.sqrt(2) # 70.7% amplitude
quantum_measurement_simulation(alpha, beta)
print("\n=== Example 2: Biased Toward 0 ===")
alpha = math.sqrt(0.8) # 89.4% amplitude → 80% probability
beta = math.sqrt(0.2) # 44.7% amplitude → 20% probability
quantum_measurement_simulation(alpha, beta)
print("\n=== Example 3: Almost Certain to be 1 ===")
alpha = math.sqrt(0.01) # 10% amplitude → 1% probability
beta = math.sqrt(0.99) # 99.5% amplitude → 99% probability
quantum_measurement_simulation(alpha, beta)The transition from quantum to classical is one of the deepest mysteries in physics:
# The measurement paradox
print("Before measurement: Qubit exists in ALL possible states")
print("During measurement: ??? (What exactly happens here?) ???")
print("After measurement: Qubit is in ONE definite state")
print("\nThis transition is called 'wave function collapse'")
print("Nobody fully understands HOW or WHY it happens!")interpretations = {
"Copenhagen": "Measurement causes instant collapse (most common view)",
"Many-Worlds": "All outcomes happen, we just see one branch",
"Hidden Variables": "There are secret factors we can't detect",
"Consciousness": "Conscious observation causes collapse",
"Objective Collapse": "Collapse happens naturally over time"
}
print("Different theories about what measurement means:")
for name, description in interpretations.items():
print(f"- {name}: {description}")
print("\nAfter 100+ years, physicists still debate this!")from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
# Create a superposition and measure it
qc = QuantumCircuit(1, 1)
qc.h(0) # Create superposition: (1/√2)|0⟩ + (1/√2)|1⟩
qc.measure(0, 0) # Measure it
# Run multiple times to see randomness
simulator = AerSimulator()
job = simulator.run(transpile(qc, simulator), shots=10)
result = job.result()
print("Individual measurement results:")
# Note: This shows the pattern, actual implementation varies
for i in range(10):
print(f"Measurement {i+1}: {random.choice([0, 1])}") # Simulated
print("Each measurement gives a random result!")
print("But over many measurements, we get 50% each")# Create entangled Bell state and measure
qc_bell = QuantumCircuit(2, 2)
qc_bell.h(0) # Superposition on first qubit
qc_bell.cx(0, 1) # Entangle with second qubit
qc_bell.measure([0, 1], [0, 1]) # Measure both
print("Measuring entangled qubits:")
print("Possible outcomes: 00 or 11 only")
print("If first qubit is 0, second is guaranteed to be 0")
print("If first qubit is 1, second is guaranteed to be 1")
print("The correlation is perfect!")The Born Rule is the fundamental law that gives us measurement probabilities:
def born_rule_explanation():
"""Explain the Born Rule with examples"""
print("Born Rule: P(outcome = i) = |⟨i|ψ⟩|²")
print("\nIn plain English:")
print("The probability of getting outcome i equals")
print("the square of the amplitude for that outcome")
print("\nExamples:")
# Example 1
alpha = 0.6
beta = 0.8
print(f"\nState: {alpha}|0⟩ + {beta}|1⟩")
print(f"P(0) = |{alpha}|² = {alpha**2:.3f} = {alpha**2*100:.1f}%")
print(f"P(1) = |{beta}|² = {beta**2:.3f} = {beta**2*100:.1f}%")
print(f"Check: {alpha**2:.3f} + {beta**2:.3f} = {alpha**2 + beta**2:.3f} ✓")
# Example 2 - with complex numbers
print(f"\nState with complex amplitude: 0.6|0⟩ + (-0.8i)|1⟩")
print(f"P(0) = |0.6|² = 0.36 = 36%")
print(f"P(1) = |-0.8i|² = 0.64 = 64%") # |complex|² = real² + imag²
print("Notice: Negative and complex amplitudes don't change probabilities!")
born_rule_explanation()print("Measurement is crucial because:")
print("1. It's how we get classical output from quantum computers")
print("2. It's the bottleneck - we can only measure at the end")
print("3. It destroys quantum information (irreversible)")
print("4. It's probabilistic - we might need many runs")
print("5. It's how we verify our quantum algorithms worked")
print("\nQuantum algorithm structure:")
print("Classical Input → Quantum Processing → Measurement → Classical Output")
print(" ↑ ↑")
print(" Superposition & Wave function")
print(" Entanglement collapse")The measurement process is what makes quantum computing both powerful (through superposition and entanglement) and challenging (through probabilistic outcomes and information loss)!
Quantum gates are the building blocks of quantum circuits. They are unitary operations that manipulate qubits while preserving quantum properties.
X|0⟩ = |1⟩
X|1⟩ = |0⟩
Matrix representation:
X = [0 1]
[1 0]
Y|0⟩ = i|1⟩
Y|1⟩ = -i|0⟩
Z|0⟩ = |0⟩
Z|1⟩ = -|1⟩
H|0⟩ = (1/√2)(|0⟩ + |1⟩)
H|1⟩ = (1/√2)(|0⟩ - |1⟩)
- Control qubit: Determines if operation happens
- Target qubit: Gets flipped if control is |1⟩
CNOT|00⟩ = |00⟩
CNOT|01⟩ = |01⟩
CNOT|10⟩ = |11⟩
CNOT|11⟩ = |10⟩
- Unitary: All quantum gates are reversible
- Probabilistic: Some gates introduce randomness
- Composable: Gates can be combined to create complex operations
Let's create your first quantum circuit! We'll build a simple circuit that demonstrates superposition and measurement.
# Install Qiskit (run in terminal or notebook)
# pip install qiskit qiskit-aer matplotlib
# Import necessary libraries
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
from qiskit.visualization import plot_histogram
import matplotlib.pyplot as plt# Create a quantum circuit with 1 qubit and 1 classical bit
qc = QuantumCircuit(1, 1)
# Apply Hadamard gate to create superposition
qc.h(0)
# Measure the qubit
qc.measure(0, 0)
# Visualize the circuit
print("Quantum Circuit:")
print(qc.draw())
# Output:
# ┌───┐ ░ ┌─┐
# q_0: ┤ H ├─░─┤M├
# └───┘ ░ └╥┘
# c_0: ══════════╩═# Create a simulator
simulator = AerSimulator()
# Transpile the circuit for the simulator
transpiled_qc = transpile(qc, simulator)
# Run the circuit 1000 times
job = simulator.run(transpiled_qc, shots=1000)
result = job.result()
# Get the counts
counts = result.get_counts()
print("Measurement results:", counts)
# Expected output: {'0': ~500, '1': ~500}
# Plot the results
plot_histogram(counts)
plt.title("Superposition Measurement Results")
plt.show()# Create a circuit with 2 qubits and 2 classical bits
qc_entangled = QuantumCircuit(2, 2)
# Create superposition on first qubit
qc_entangled.h(0)
# Create entanglement with CNOT gate
qc_entangled.cx(0, 1) # CNOT gate
# Measure both qubits
qc_entangled.measure([0, 1], [0, 1])
print("Entangled Circuit:")
print(qc_entangled.draw())
# Run the circuit
job = simulator.run(transpile(qc_entangled, simulator), shots=1000)
result = job.result()
counts = result.get_counts()
print("Entangled measurement results:", counts)
# Expected: {'00': ~500, '11': ~500} - perfectly correlated!
plot_histogram(counts)
plt.title("Entangled Qubits Measurement Results")
plt.show()- Superposition circuit: Random 0s and 1s (50/50 split)
- Entangled circuit: Only 00 and 11 outcomes (perfect correlation)
Create a quantum circuit that simulates a fair coin flip using the Hadamard gate.
# Your code here
def quantum_coin_flip():
# Create circuit
# Apply Hadamard gate
# Measure
# Return result
passCreate a circuit that gives three equally likely outcomes using multiple qubits.
Implement all four Bell states:
- |Φ⁺⟩ = (1/√2)(|00⟩ + |11⟩)
- |Φ⁻⟩ = (1/√2)(|00⟩ - |11⟩)
- |Ψ⁺⟩ = (1/√2)(|01⟩ + |10⟩)
- |Ψ⁻⟩ = (1/√2)(|01⟩ - |10⟩)
- Qubits can exist in superposition of 0 and 1
- Superposition allows quantum computers to process multiple states simultaneously
- Entanglement creates powerful correlations between qubits
- Measurement collapses quantum states to classical outcomes
- Quantum gates manipulate qubits while preserving quantum properties
- Quantum computers can solve certain problems exponentially faster
- Quantum cryptography provides unbreakable security
- Quantum sensing achieves unprecedented precision
- Quantum simulation models complex physical systems
In Module 2, we'll dive deeper into the mathematical foundations that make quantum computing possible, including:
- Linear algebra for quantum states
- Complex numbers and probability amplitudes
- Matrix representations of quantum operations
- Visualization techniques for quantum states
- "Quantum Computing: An Applied Approach" by Hidary
- "Programming Quantum Computers" by Johnston, Harrigan, and Gimeno-Segovia
- IBM Qiskit Textbook: qiskit.org/textbook
- IBM Qiskit YouTube Channel
- Microsoft Quantum Development Kit tutorials
- MIT OpenCourseWare: Quantum Information Science
Test your understanding with these questions:
- What is the main difference between a classical bit and a qubit?
- If a qubit is in the state (1/√2)|0⟩ + (1/√2)|1⟩, what are the measurement probabilities?
- What happens to an entangled state when you measure one of the qubits?
- Which gate creates equal superposition from the |0⟩ state?
- Why can't you copy an arbitrary quantum state?
Next Module: Module 2: Mathematical Foundations (Developer-Friendly)
This module is part of the Quantum Computing 101 curriculum. For questions or feedback, please refer to the course discussion forum.