Introduction to Quantum Computing
Quantum computing leverages quantum mechanical phenomena like superposition and entanglement to process information in fundamentally different ways than classical computers. Instead of bits (0 or 1), quantum computers use qubits that can exist in superposition of both states simultaneously.
Key Difference: Classical computing is deterministic; quantum computing is probabilistic. You run circuits multiple times and analyze the distribution of results.
Linear Algebra Essentials
Vectors
Quantum states are represented as vectors in complex vector spaces. A qubit state is a 2D vector:
|ψ⟩ = α|0⟩ + β|1⟩
Where |α|² + |β|² = 1 (normalization condition)
|0⟩ = [1, 0]ᵀ (basis state 0)
|1⟩ = [0, 1]ᵀ (basis state 1)
Matrices & Quantum Gates
Quantum gates are unitary matrices that transform qubit states. They must preserve probability (be reversible).
Pauli-X Gate (quantum NOT):
X = [0 1]
[1 0]
Hadamard Gate (creates superposition):
H = 1/√2 × [1 1]
[1 -1]
CNOT Gate (2-qubit controlled gate):
CNOT = [1 0 0 0]
[0 1 0 0]
[0 0 0 1]
[0 0 1 0]
Tensor Products
Multi-qubit states are tensor products of individual qubit states:
|ψ⟩ ⊗ |φ⟩ = |ψφ⟩
Example: |0⟩ ⊗ |1⟩ = |01⟩ = [0, 1, 0, 0]ᵀ
Key Linear Algebra Operations
- Inner Product: ⟨ψ|φ⟩ = measure of overlap between states
- Outer Product: |ψ⟩⟨φ| = creates operators/projections
- Matrix Multiplication: How gates transform states
- Eigenvalues/Eigenvectors: Measurement outcomes and basis states
Quantum Concepts Quick Reference
Superposition
A qubit can be in multiple states simultaneously until measured. Like a coin spinning in the air.
Entanglement
Two qubits become correlated such that measuring one instantly affects the other, regardless of distance.
Interference
Quantum amplitudes can add constructively or destructively, amplifying correct answers and canceling wrong ones.
Measurement
Collapses superposition to classical state. Probabilistic outcome based on amplitudes squared.
Qiskit Tutorial
Installation
pip install qiskit qiskit-aer qiskit-ibm-runtime
Basic Circuit - Bell State (Entanglement)
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit_aer import Aer
from qiskit.visualization import plot_histogram
import matplotlib.pyplot as plt
# Create quantum and classical registers
qr = QuantumRegister(2, 'q')
cr = ClassicalRegister(2, 'c')
circuit = QuantumCircuit(qr, cr)
# Build Bell State: creates entanglement
circuit.h(qr[0]) # Hadamard on qubit 0 (superposition)
circuit.cx(qr[0], qr[1]) # CNOT with 0 as control, 1 as target
# Measure
circuit.measure(qr, cr)
# Simulate
simulator = Aer.get_backend('qasm_simulator')
job = simulator.run(circuit, shots=1024)
result = job.result()
counts = result.get_counts(circuit)
print(counts) # Should show ~50% |00⟩ and ~50% |11⟩
# plot_histogram(counts)
Common Gates in Qiskit
# Single-qubit gates
circuit.x(0) # Pauli-X (NOT gate)
circuit.y(0) # Pauli-Y
circuit.z(0) # Pauli-Z (phase flip)
circuit.h(0) # Hadamard (superposition)
circuit.s(0) # S gate (Ï€/2 phase)
circuit.t(0) # T gate (Ï€/4 phase)
circuit.rx(θ, 0) # Rotation around X-axis
circuit.ry(θ, 0) # Rotation around Y-axis
circuit.rz(θ, 0) # Rotation around Z-axis
# Two-qubit gates
circuit.cx(0, 1) # CNOT (controlled-X)
circuit.cy(0, 1) # Controlled-Y
circuit.cz(0, 1) # Controlled-Z
circuit.swap(0, 1) # SWAP gate
# Three-qubit gates
circuit.ccx(0, 1, 2) # Toffoli (controlled-controlled-X)
Quantum Teleportation Example
from qiskit import QuantumCircuit
from qiskit_aer import Aer
# Create circuit with 3 qubits
qc = QuantumCircuit(3, 3)
# Prepare state to teleport on qubit 0
qc.ry(1.0, 0) # Arbitrary state
# Create Bell pair between qubits 1 and 2
qc.h(1)
qc.cx(1, 2)
# Barrier for visualization
qc.barrier()
# Bell measurement on qubits 0 and 1
qc.cx(0, 1)
qc.h(0)
qc.measure([0, 1], [0, 1])
# Apply corrections to qubit 2 based on measurements
qc.barrier()
qc.cx(1, 2)
qc.cz(0, 2)
# Measure final qubit
qc.measure(2, 2)
# Run simulation
simulator = Aer.get_backend('qasm_simulator')
result = simulator.run(qc, shots=1024).result()
print(result.get_counts())
Running on Real Quantum Hardware
from qiskit_ibm_runtime import QiskitRuntimeService
# Save your IBM Quantum account (one time)
# QiskitRuntimeService.save_account(channel="ibm_quantum", token="YOUR_TOKEN")
# Load account
service = QiskitRuntimeService(channel="ibm_quantum")
# Get least busy backend
backend = service.least_busy(operational=True, simulator=False)
# Run your circuit
job = backend.run(circuit, shots=1024)
result = job.result()
counts = result.get_counts()
Cirq Overview
Installation
pip install cirq cirq-google
Basic Cirq Circuit
import cirq
# Create qubits
q0, q1 = cirq.LineQubit.range(2)
# Create circuit
circuit = cirq.Circuit()
# Add gates
circuit.append([
cirq.H(q0), # Hadamard on q0
cirq.CNOT(q0, q1), # CNOT controlled by q0
cirq.measure(q0, q1, key='result')
])
# Simulate
simulator = cirq.Simulator()
result = simulator.run(circuit, repetitions=1000)
print(result.histogram(key='result'))
Cirq Gate Examples
# Single qubit gates
cirq.X(qubit) # Pauli-X
cirq.Y(qubit) # Pauli-Y
cirq.Z(qubit) # Pauli-Z
cirq.H(qubit) # Hadamard
cirq.S(qubit) # S gate
cirq.T(qubit) # T gate
cirq.rx(angle)(qubit) # X rotation
cirq.ry(angle)(qubit) # Y rotation
cirq.rz(angle)(qubit) # Z rotation
# Two qubit gates
cirq.CNOT(control, target)
cirq.CZ(control, target)
cirq.SWAP(q0, q1)
# Measurements
cirq.measure(qubit, key='m')
Key Differences: Qiskit vs Cirq
| Feature |
Qiskit |
Cirq |
| Developer |
IBM |
Google |
| Focus |
IBM quantum hardware, general purpose |
Google hardware (Sycamore), NISQ algorithms |
| Circuit Syntax |
circuit.gate(qubit) |
gate(qubit) or circuit.append() |
| Qubit Notation |
Indexed: qr[0], qr[1] |
LineQubit, GridQubit objects |
| Documentation |
Extensive tutorials, large community |
More research-focused, smaller community |
| Hardware Access |
IBM Quantum Platform |
Google Quantum AI (limited access) |
Glossary of Terms
Amplitude
Complex number coefficient in a quantum state superposition. The square of its magnitude gives the probability of measuring that state.
Ancilla Qubit
Helper qubit used in quantum algorithms but not part of the final result. Often used for error correction or intermediate calculations.
Basis State
Fundamental quantum states from which all other states can be constructed. For qubits: |0⟩ and |1⟩.
Bell State
One of four maximally entangled two-qubit states. Example: (|00⟩ + |11⟩)/√2
Bloch Sphere
Geometric representation of a single qubit state as a point on a unit sphere. North pole = |0⟩, South pole = |1⟩.
Coherence Time
How long a qubit maintains its quantum properties before decoherence destroys it. Currently milliseconds to seconds.
Decoherence
Loss of quantum properties due to environmental interference. Main source of errors in quantum computing.
Deutsch-Jozsa Algorithm
Quantum algorithm that determines if a function is constant or balanced with one query (classical needs exponential queries).
Entanglement
Quantum correlation where measuring one qubit instantly determines the state of another, regardless of distance.
Gate Fidelity
Measure of how accurately a quantum gate operates. Perfect gate = 100% fidelity. Real hardware: 99-99.9%.
Grover's Algorithm
Quantum search algorithm providing quadratic speedup for unstructured search. Finds item in √N time vs N classical.
Hadamard Gate
Single-qubit gate creating equal superposition: |0⟩ → (|0⟩ + |1⟩)/√2, |1⟩ → (|0⟩ - |1⟩)/√2
NISQ (Noisy Intermediate-Scale Quantum)
Current era of quantum computing: 50-1000 qubits with limited coherence, no full error correction.
Oracle
Black-box function in quantum algorithms that marks solutions. Used in Grover's and Deutsch-Jozsa algorithms.
Pauli Gates
Three fundamental single-qubit gates: X (bit flip), Y (bit + phase flip), Z (phase flip).
Phase Kickback
Phenomenon where eigenvalue information from a target qubit is transferred to the control qubit. Key to many algorithms.
Quantum Fourier Transform (QFT)
Quantum version of discrete Fourier transform. Exponentially faster than classical FFT. Core of Shor's algorithm.
Quantum Register
Collection of qubits treated as a unit. In Qiskit: QuantumRegister(n, 'name')
Quantum Supremacy / Advantage
Point where quantum computers solve problems classical computers practically cannot. Achieved by Google (2019) and others for specific tasks.
Qubit
Quantum bit. Can be in superposition of |0⟩ and |1⟩ simultaneously. Physical implementations: superconducting circuits, trapped ions, photons.
Shots
Number of times a quantum circuit is executed. More shots = better statistical accuracy of results.
Shor's Algorithm
Quantum algorithm for factoring integers exponentially faster than known classical algorithms. Threatens RSA encryption.
Superposition
Quantum state that's a linear combination of basis states. Allows quantum parallelism.
Toffoli Gate
Three-qubit gate: controlled-controlled-NOT. Universal for reversible classical computing.
Transpilation
Converting high-level quantum circuit to hardware-compatible gates and qubit layout. Required before running on real devices.
Unitary Matrix
Matrix U where U†U = I (inverse equals conjugate transpose). All quantum gates must be unitary to preserve probability.
Variational Quantum Eigensolver (VQE)
Hybrid quantum-classical algorithm for finding ground state energies. Popular NISQ algorithm for chemistry.
Wave Function
Mathematical description of quantum state. Contains all information about the system's probabilities.
Quick Start Resources
Qiskit Resources
Cirq Resources
General Learning
Practical Next Steps
- Install Qiskit and run the Bell state example above
- Work through the Qiskit textbook basics (first 3 chapters)
- Implement Deutsch-Jozsa algorithm yourself
- Try running a circuit on IBM's real quantum hardware
- Build a quantum random number generator
- Explore VQE for a simple molecule (H2)
- Compare same algorithm implementation in Qiskit and Cirq
Reality Check: Quantum computing is still experimental. Focus on understanding the principles and exploring algorithms rather than expecting to build production applications yet. Most valuable skill right now is knowing when quantum advantage actually applies to a problem.