Interactive Notes

Quantum Circuits

Introduction to quantum circuits, the standard model of quantum computation. How to represent quantum algorithms as sequences of gates, and how to visualize them with the circuit diagram notation.

Section 01

Quantum Computing & Universality

A classical computer is built from logic gates (AND, OR, NOT, NAND…). A quantum computer is built from quantum gates — unitary matrices acting on qubits. Before asking "what can we compute?", we must ask: how many different gates do we actually need?

Definition — Universality
A set of quantum gates is called universal if any unitary transformation U (of any size) can be approximated with arbitrary precision using only gates from that set.

Think of it like LEGO: no matter how complex the structure, a small set of brick types is enough to build anything.

Classical analogy: In classical computing the NAND gate alone is universal — every logic function (AND, OR, XOR, full adder, …) can be built exclusively from NAND gates. This is why CPU designers only need to implement one primitive.
Theorem — Universal Gate Set for Quantum Computing
The set {H, S, T, CNOT} is universal for quantum computation.
H = Hadamard,   S = Phase (π/2),   T = π/8 gate,   CNOT = controlled-NOT
Any unitary U acting on n qubits can be approximated to error ε using O(poly(n, log(1/ε))) gates from this set.
Note — the Clifford group: The smaller set {H, S, CNOT} generates the so-called Clifford group — a very important subgroup of unitaries. Clifford circuits are efficiently simulable on classical computers (Gottesman–Knill theorem), so they are NOT computationally universal. Adding the T gate breaks this simulability and makes the set universal.

How a Quantum Computer Works

Every quantum computation follows the same three-step recipe:

Quantum Computation Protocol
  1. Prepare all qubits in the computational basis state |0⟩⊗ⁿ = |00…0⟩
  2. Apply a sequence of quantum gates (together forming a unitary U)
  3. Measure in the computational basis {|0⟩, |1⟩}

So at the highest level, a quantum computer is just:

|0⟩ ──             ──[M]
|0⟩ ──┤   U   ├──[M]
|0⟩ ──             ──[M]
Input: |0⟩^⊗n — one big unitary U — then measure everything

The entire quantum algorithm is encoded in how U is decomposed into elementary gates. This is the art of quantum circuit design.

The decomposition U ≈ G₁G₂G₃… (product of elementary gates) is analogous to how a classical program is compiled into CPU instructions. Universality guarantees that this decomposition always exists.
Gate set visualizer — hover over a gate to see its matrix and effect on |0⟩ and |1⟩
Ex 1.1Universal gate set

Which of the following sets is universal for quantum computation? Type the letter: A) {H, CNOT}   B) {H, S, T, CNOT}   C) {H, S, CNOT}   D) {X, Y, Z}

Answer:
Ex 1.2Steps of quantum computation

In what state do we always prepare the qubits at the start of a quantum computation?

Answer:
Section 02

Computing Boolean Functions

Classical computers exist to evaluate Boolean functions: given n input bits, produce m output bits. Formally:

Boolean Function
A Boolean function is a map:
f : {0,1}ⁿ → {0,1}ᵐ
It can always be represented by a truth table listing all 2ⁿ input combinations and the corresponding outputs.

Example for n=3, m=2:

xf(x)
00001
00100

Can a quantum computer evaluate f?

We want a unitary U that, given |x⟩ (an n-qubit state), produces |f(x)⟩. Naively:

|x⟩  ─[Uᶠ]─  |f(x)⟩
n qubits in  →  m qubits out
Problem: U must be unitary (invertible), which means it maps n+m qubits to n+m qubits with the same dimension. But if f is not injective (many-to-one), this direct encoding is NOT invertible — hence not unitary!

The Oracle Construction

The standard solution is to keep a copy of the input and add a separate m-qubit output register initialised to |0⟩:

Quantum Oracle U_f
Input state: |0⟩^⊗m ⊗ |x⟩ — n qubits for x, m ancilla qubits set to 0
Apply Uᶠ: |0⟩|x⟩  ──→  |f(x)⟩|x⟩
Inverse: U_f† maps |f(x)⟩|x⟩ back to |0⟩|x⟩, so U_f is unitary ✓

The output register holds |f(x)⟩ and the input register still holds |x⟩. Both are preserved.

|0⟩⊗m|x⟩   ──[Uᶠ]──   |f(x)⟩|x⟩    ──[Uᶠ†]──   |0⟩⊗m|x⟩
Note: If we measure after applying U_f, we obtain both f(x) and x in binary representation. The input register is always recoverable, confirming invertibility.
The oracle construction is a key design pattern in quantum computing. It appears in Deutsch–Jozsa, Grover's, and Shor's algorithms. The trick of "copy x into the output, compute f(x) in a fresh register" converts any function into a unitary gate.
Ex 2.1Why keep the input?

Why can't we just map |x⟩ → |f(x)⟩ directly in a quantum circuit? Type "not injective" or "not invertible".

Answer:
Ex 2.2Oracle action

What state does U_f produce when applied to |0⟩|x⟩ ? (write as ket notation, e.g. |f(x)⟩|x⟩)

Answer:
Section 03

Quantum Parallelism

Here is the key quantum advantage: if we put the input register into a superposition before applying U_f, the oracle evaluates f on all inputs simultaneously. This is quantum parallelism.

1-qubit example

Start with |0⟩, apply Hadamard to create |+⟩ = (|0⟩+|1⟩)/√2, then run U_f:

Initial: |0⟩|0⟩
After H⊗I: |ψ₁⟩ = |+⟩|0⟩ = (|0⟩+|1⟩)/√2 ⊗ |0⟩ = (|00⟩+|10⟩)/√2
After Uᶠ: |ψ₂⟩ = Uᶠ|ψ₁⟩ = (|f(0)⟩|0⟩ + |f(1)⟩|1⟩) / √2

We have computed f(0) and f(1) in a single application of U_f!

Caveat: If we measure this state, we obtain only one result — either |f(0)⟩ or |f(1)⟩ with equal probability. The parallelism is real, but extracting all 2ⁿ values at once is impossible. Clever quantum algorithms exploit the superposition before measuring.

Superposition of 2 qubits

Apply Hadamard to each qubit independently:

Start: |0⟩ ⊗ |0⟩
H on each: H|0⟩ ⊗ H|0⟩ = |+⟩ ⊗ |+⟩
Expand: |++⟩ = (|00⟩+|01⟩+|10⟩+|11⟩) / 2
In vector: 1/2
|++⟩ = 1/2
1
1
1
1
= superposition of ALL 4 basis states

The corresponding unitary is U = H⊗H:

U = H ⊗ H =
1/√21/√2
1/√2−1/√2
1/√21/√2
1/√2−1/√2
= 1/2
1111
1−11−1
11−1−1
1−1−11

Worked example: f(q₀,q₁) = q₀ ⊕ q₁

Let f be the XOR of the two input bits. The oracle maps |q₀⟩|q₁⟩|0⟩ → |q₀⟩|q₁⟩|q₀⊕q₁⟩ (two CNOT gates).

Step a — U_f: Apply two CNOTs: q₀ → ancilla and q₁ → ancilla gives |q₀⊕q₁⟩ in ancilla
With H⊗H⊗I: |ψ⟩ = Uᶠ|0++⟩ = (|000⟩+|101⟩+|110⟩+|011⟩) / 2
Step b — restore: Apply U_f† (same circuit, since CNOT² = I) to reset ancilla to |0⟩
Key property used: CNOT² = I (applying CNOT twice returns to the original state). This is why the circuit for U_f† is just the reverse of U_f for CNOT-based oracles.

Superposition of n qubits

The pattern generalises: applying H to every qubit in |0⟩⊗ⁿ gives an equal superposition of all 2ⁿ basis states.

n-qubit Hadamard superposition
Start: |0⟩⊗ⁿ = |0⟩⊗|0⟩⊗…⊗|0⟩  (n times)
Apply H⊗ⁿ: |+⟩⊗ⁿ = (|0⟩+|1⟩)/√2 ⊗ … ⊗ (|0⟩+|1⟩)/√2
Expand: = (1/√2)ⁿ · (|00…0⟩ + |00…1⟩ + … + |11…1⟩)
Compact: = 1/2^(n/2) · Σₗ₌₀^(2ⁿ−1) |ℓ⟩
where |ℓ⟩ means |binary representation of the integer ℓ⟩. For example, |3⟩ = |011⟩ for n=3.
Drag the slider to set n — see how many basis states are in superposition after H⊗ⁿ
2 qubits → 4 states
Ex 3.1Superposition count

If you apply H to each of 5 qubits (all starting in |0⟩), how many basis states are in the resulting superposition?

Answer:
Ex 3.2Amplitude in |+⟩⊗n

In the state H⊗³|000⟩, what is the amplitude of each basis state |ℓ⟩? (give exact value, e.g. 1/2)

Answer:
Section 04

Transforming a State into Another

We know how to build specific gates like H, X, Z. But given any two quantum states |ψ⟩ and |φ⟩, can we always find a unitary that maps one to the other? Yes — and here is the constructive proof.

Theorem
Given any two unit vectors |ψ⟩ and |φ⟩ in ℂᴺ, there always exists a unitary U such that U|ψ⟩ = |φ⟩.

Proof (constructive)

Step 1 Build two orthonormal bases. Using Gram–Schmidt, extend |ψ⟩ to a full basis {|ψ₀⟩, |ψ₁⟩, …, |ψ_{N−1}⟩} with |ψ₀⟩ = |ψ⟩. Similarly extend |φ⟩ to {|φ₀⟩, |φ₁⟩, …, |φ_{N−1}⟩} with |φ₀⟩ = |φ⟩.

Step 2 Construct U. Define:
U = Σₗ |φₗ⟩⟨ψₗ|
This is a sum of outer products: each basis vector |ψₗ⟩ is mapped to the corresponding |φₗ⟩.

Step 3 Check U is unitary: U†U = I.

Let's verify unitarity carefully:

U†: U† = (Σₗ |φₗ⟩⟨ψₗ|)† = Σₗ |ψₗ⟩⟨φₗ|
U†U: = (Σₗ |ψₗ⟩⟨φₗ|)(Σₘ |φₘ⟩⟨ψₘ|) = Σₗ Σₘ |ψₗ⟩ ⟨φₗ|φₘ⟩ ⟨ψₘ|
Orthonorm.: ⟨φₗ|φₘ⟩ = δₗₘ  (1 if l=m, 0 otherwise, since {|φₗ⟩} is orthonormal)
Result: U†U = Σₗ |ψₗ⟩⟨ψₗ| = I
Why does Σₗ |ψₗ⟩⟨ψₗ| = I ? This is the completeness relation (resolution of identity). Any vector |Φ⟩ can be expanded as |Φ⟩ = Σₗ cₗ|ψₗ⟩ with cₗ = ⟨ψₗ|Φ⟩. Therefore:
(Σₗ |ψₗ⟩⟨ψₗ|)|Φ⟩ = Σₗ |ψₗ⟩⟨ψₗ|Φ⟩ = Σₗ cₗ|ψₗ⟩ = |Φ⟩
True for every |Φ⟩ ⟹ the operator equals I

Finally, check that U maps |ψ⟩ to |φ⟩:

U|ψ⟩: = (Σₗ |φₗ⟩⟨ψₗ|)|ψ₀⟩ = Σₗ |φₗ⟩ ⟨ψₗ|ψ₀⟩
Orthonorm.: ⟨ψₗ|ψ₀⟩ = δₗ₀  (1 only when l=0)
Result: = Σₗ |φₗ⟩ δₗ₀ = |φ₀⟩ = |φ⟩ ✓
This proof is constructive — it tells you how to build U explicitly. In practice, the Gram–Schmidt step is done numerically, and the resulting U is decomposed into gates. This is the basis of quantum state preparation algorithms.
Ex 4.1Completeness relation

If {|ψₗ⟩} is an orthonormal basis, what does Σₗ |ψₗ⟩⟨ψₗ| equal? (Write the symbol)

Answer:
Section 05

Generating an Arbitrary State α|0⟩ + β|1⟩ from |0⟩

Section 4 gave a general existence proof. Now let's be explicit for the 1-qubit case: given |0⟩, build the gate U that produces any target state |φ⟩ = α|0⟩ + β|1⟩.

Finding U explicitly

We have two orthonormal bases:

Input basis: |ψ₀⟩ = |0⟩    |ψ₁⟩ = |1⟩
Output basis: |φ₀⟩ = |φ⟩ = α|0⟩ + β|1⟩    |φ₁⟩ = |φ^⊥⟩ = ?

We need to find |φ^⊥⟩ orthogonal to |φ⟩. Write |φ^⊥⟩ = γ|0⟩ + δ|1⟩ and impose ⟨φ^⊥|φ⟩ = 0:

Condition: ⟨φ^⊥|φ⟩ = (γ*⟨0| + δ*⟨1|)(α|0⟩ + β|1⟩) = 0
Expand: γ*α + δ*β = 0   (using ⟨0|0⟩=1, ⟨1|1⟩=1, ⟨0|1⟩=0)
Solution: One valid choice: γ = −β* and δ = α*
Verify: γ*α + δ*β = (−β*)*α + (α*)*β = −βα + αβ = 0 ✓

Now assemble U using the formula U = Σₗ |φₗ⟩⟨ψₗ|:

U = |φ⟩⟨0| + |φ^⊥⟩⟨1|
Substitute: = (α|0⟩+β|1⟩)(1 0) + (−β*|0⟩+α*|1⟩)(0 1)
Matrix form: = α
1
0
(1 0) + β
0
1
(1 0) + −β*
1
0
(0 1) + α*
0
1
(0 1)
Result: U =
α−β*
βα*

Implementation with rotation gates

This U can be implemented using the Z-rotation gate R_z(φ) and the X-rotation gate R_x(θ):

Rotation gate decomposition
U(φ,θ) = R_z(φ) · R_x(θ) =
e^{−jφ/2}0
0e^{jφ/2}
·
cos θ/2−j sin θ/2
−j sin θ/2cos θ/2
=
e^{−jφ/2}0
0e^{jφ/2}
cos θ/2−j sin θ/2
−j sin θ/2cos θ/2
=
e^{−jφ/2} cos(θ/2)−je^{−jφ/2} sin(θ/2)
−je^{jφ/2} sin(θ/2)e^{jφ/2} cos(θ/2)

One can verify: U₁₁ = U₂₂* and U₁₂ = −U₂₁* and |U₁₁|²+|U₂₁|² = 1.

Applying to |0⟩:

U(φ,θ)|0⟩: = e^{−jφ/2} cos(θ/2) |0⟩ − je^{jφ/2} sin(θ/2) |1⟩
Factor out: = e^{−jφ/2} [ cos(θ/2) |0⟩ + e^{j(φ−π/2)} sin(θ/2) |1⟩ ]
Note: The e^{−jφ/2} out front is a global phase — it has no physical effect on measurement probabilities. So we can ignore it and write:
Effective: U(φ,θ)|0⟩ ≡ cos(θ/2)|0⟩ + e^{j(φ−π/2)} sin(θ/2)|1⟩
Comparing with |ψ⟩ = α|0⟩ + β|1⟩: we need cos(θ/2) = |α| and e^{j(φ−π/2)} sin(θ/2) = β. This gives θ and φ in terms of α, β. Any single-qubit state is reachable with just two real parameters!
Bloch sphere projection — adjust θ (polar) and φ (azimuthal) to generate any qubit state
60° 90°
Ex 5.1Find θ for |+⟩

The state |+⟩ = (|0⟩+|1⟩)/√2 has α = β = 1/√2. Using U(φ,θ)|0⟩ = cos(θ/2)|0⟩ + …|1⟩, what value of θ (in degrees) gives cos(θ/2) = 1/√2?

θ =
Ex 5.2Find θ and φ for a given state (from the notes)

Find θ and φ (in degrees) to generate |ψ⟩ = 0.8|0⟩ + 0.6 e^{j5π/3}|1⟩. Note: cos(θ/2) = 0.8 and the relative phase.

θ ≈ φ ≈
Section 06

The No-Cloning Theorem

In classical computing, copying a bit is trivial: just read it and write the same value elsewhere. Quantum mechanics forbids this for unknown states — a deep and surprising result.

No-Cloning Theorem
There is no unitary operation U that can copy an arbitrary unknown quantum state. That is, there is no U such that U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ for all states |ψ⟩.

Proof by contradiction (reductio ad absurdum)

Suppose — for contradiction — that such a cloning unitary U exists.

Assumption: ∃ U such that U|ψ⟩|0⟩ = |ψ⟩|ψ⟩ for ALL |ψ⟩

For |0⟩: U|0⟩|0⟩ = |0⟩|0⟩ = |00⟩
For |1⟩: U|1⟩|0⟩ = |1⟩|1⟩ = |11⟩

Now try |ψ⟩: Let |ψ⟩ = α|0⟩ + β|1⟩
Apply U: U|ψ⟩|0⟩ = U(α|0⟩ + β|1⟩)|0⟩ = αU|0⟩|0⟩ + βU|1⟩|0⟩
Substitute: = α|00⟩ + β|11⟩

Compare to: |ψ⟩|ψ⟩ = (α|0⟩+β|1⟩)(α|0⟩+β|1⟩)
Expand: = α²|00⟩ + αβ|01⟩ + αβ|10⟩ + β²|11⟩

Contradiction: α|00⟩ + β|11⟩ ≠ α²|00⟩ + αβ|01⟩ + αβ|10⟩ + β²|11⟩
Reason: Unless α=0 or β=0 (i.e., |ψ⟩ is already a basis state), these are different states.
Conclusion: Such U cannot exist. ∎
What if |ψ⟩ is known? The theorem only applies to unknown states. If you already know α and β, you can simply prepare a fresh qubit in the state |ψ⟩ by the state-preparation procedure of Section 5. The constraint is on blind copying.
The no-cloning theorem is the quantum-mechanical reason why quantum communication is fundamentally more secure than classical: an eavesdropper cannot copy a qubit without disturbing it (because no cloning unitary exists). This underpins quantum cryptography (BB84 protocol).
Ex 6.1Key step in the proof

In the no-cloning proof, what property of U is used to distribute it over α|0⟩ + β|1⟩ ? (one word)

Answer:
Ex 6.2Cloning basis states

Is it possible to "clone" the state |0⟩? That is, can we build a circuit that maps |0⟩|0⟩ → |0⟩|0⟩? (yes/no)

Answer:
Section 07

Measuring Two Qubits in the Bell Basis

Until now we have always measured in the computational basis {|00⟩, |01⟩, |10⟩, |11⟩}. But we can also measure in the Bell basis {|Φ⁺⟩, |Φ⁻⟩, |Ψ⁺⟩, |Ψ⁻⟩}, which is the natural basis for entangled states. This operation is called a Bell measurement and is the heart of quantum teleportation.

What is a Bell Measurement?

Bell Measurement — the idea
A Bell measurement is a joint measurement of two qubits that tells you which Bell state they were in, collapsing the state to that Bell state. The outcome is always one of four possibilities: |Φ⁺⟩, |Φ⁻⟩, |Ψ⁺⟩, or |Ψ⁻⟩ — communicated as two classical bits "00", "01", "10", "11".

Step 1 — Recall the Four Bell States

These are the maximally entangled two-qubit states we met in the previous note. Think of them as four "types" of entanglement, each with a unique signature:

|Φ⁺⟩ — "same, plus"
(|00⟩ + |11⟩) / √2
Both match — 00 or 11
|Φ⁻⟩ — "same, minus"
(|00⟩ − |11⟩) / √2
Both match — opposite phase
|Ψ⁺⟩ — "opposite, plus"
(|01⟩ + |10⟩) / √2
Always different — 01 or 10
|Ψ⁻⟩ — "opposite, minus"
(|01⟩ − |10⟩) / √2
Always different — opposite phase

Step 2 — The Bell Measurement Circuit

We cannot directly measure in the Bell basis in hardware — real devices only measure in the computational basis {|00⟩, |01⟩, |10⟩, |11⟩}. So the strategy is:

Strategy: Change basis THEN measure
Apply an inverse Bell circuit (CNOT followed by H on the first qubit) to rotate the Bell basis into the computational basis, then measure in the standard way. The computational outcome tells you which Bell state you had.
Bell Measurement Circuit
qubit 1 ──●──H──M── xqubit 2───────M── y
Order: CNOT first (qubit 1 controls qubit 2), then H on qubit 1, then measure both. Outcomes: x, y ∈ {0,1}.

Step 3 — What happens to each Bell state?

Let's trace each Bell state through the circuit carefully. We'll track: input → after CNOT → after H → measured outcome.

|Φ⁺⟩ (|00⟩ + |11⟩)/√2 → outcome "00"
Input:
(|00⟩ + |11⟩) / √2
after CNOT:
|00⟩ → |00⟩   |11⟩ → |01⟩   →   (|00⟩ + |01⟩) / √2
after H on q₁:
H|0⟩ = |+⟩ = (|0⟩+|1⟩)/√2 → |0⟩(|0⟩+|1⟩)/√2 · (1/√2) → factor: |0⟩|0⟩ dominant
result:
Collapses to |00⟩ with probability 1 → measure "00"
|Φ⁻⟩ (|00⟩ − |11⟩)/√2 → outcome "01"
Input:
(|00⟩ − |11⟩) / √2
after CNOT:
|00⟩ → |00⟩   |11⟩ → |01⟩   →   (|00⟩ − |01⟩) / √2
after H on q₁:
= |0⟩(|0⟩−|1⟩)/√2 · (1/√2)  →  collapses to |0⟩|1⟩ = |01⟩
result:
Measure "01"
|Ψ⁺⟩ (|01⟩ + |10⟩)/√2 → outcome "10"
Input:
(|01⟩ + |10⟩) / √2
after CNOT:
|01⟩ → |11⟩   |10⟩ → |10⟩   →   (|11⟩ + |10⟩) / √2
after H on q₁:
= |1⟩(|1⟩+|0⟩)/√2 · (1/√2)  →  collapses to |1⟩|0⟩ = |10⟩
result:
Measure "10"
|Ψ⁻⟩ (|01⟩ − |10⟩)/√2 → outcome "11"
Input:
(|01⟩ − |10⟩) / √2
after CNOT:
|01⟩ → |11⟩   |10⟩ → |10⟩   →   (|11⟩ − |10⟩) / √2
after H on q₁:
= |1⟩(|1⟩−|0⟩)/√2 · (1/√2)  →  collapses to |1⟩|1⟩ = |11⟩
result:
Measure "11"

Step 4 — The Complete Decoding Table

Bell state → Classical outcome (two bits)
Input Bell state Formula Outcome x y Detected
|Φ⁺⟩ (|00⟩ + |11⟩)/√2 00 |Φ⁺⟩ detected
|Φ⁻⟩ (|00⟩ − |11⟩)/√2 01 |Φ⁻⟩ detected
|Ψ⁺⟩ (|01⟩ + |10⟩)/√2 10 |Ψ⁺⟩ detected
|Ψ⁻⟩ (|01⟩ − |10⟩)/√2 11 |Ψ⁻⟩ detected

Measuring a Superposition of Bell States

What if the state is not a single Bell state, but a superposition of them? For example:

|Ψ⟩ = α|Φ⁺⟩ + β|Φ⁻⟩ + γ|Ψ⁺⟩ + δ|Ψ⁻⟩
with |α|² + |β|² + |γ|² + |δ|² = 1 (normalisation)

Measuring in the Bell basis gives:

"00"
P = |α|²
|Φ⁺⟩ detected
"01"
P = |β|²
|Φ⁻⟩ detected
"10"
P = |γ|²
|Ψ⁺⟩ detected
"11"
P = |δ|²
|Ψ⁻⟩ detected
The elegance of the Bell basis: the Born rule works exactly the same way as in the computational basis — the probability of each outcome is the squared magnitude of the amplitude of the corresponding Bell state. The basis change circuit does all the hard work of "translating" the state before measurement.
Bell measurement simulator — click a Bell state to trace it through the circuit and see the outcome
Ex 7.1Bell circuit gates — order matters!

The Bell measurement circuit applies two gates before the standard measurement. What is the correct order? Write "CNOT then H" or "H then CNOT".

Order:
Ex 7.2Identify the Bell state from an outcome

A Bell measurement gives outcome "10". Which Bell state was the system in before measurement?

Bell state:
Ex 7.3Probability in a Bell superposition

A state is |Ψ⟩ = (1/2)|Φ⁺⟩ + (√3/2)|Ψ⁻⟩. What is the probability of getting outcome "11" (detecting |Ψ⁻⟩)?

P("11") =
Section 08

Quantum Teleportation

Quantum teleportation is one of the most striking results in quantum information. It answers a puzzling question: can we transmit a quantum state — an unknown qubit — without physically sending the qubit itself?

The Goal
Alice holds an unknown qubit |ψ⟩ = α|0⟩ + β|1⟩. She wants to send the state |ψ⟩ to Bob, who is far away. She does NOT know α and β (and by the no-cloning theorem she cannot measure them without destroying the state). She can only send classical bits (phone calls, emails...). Can she do it?
Yes — if they share an entangled pair first! Using one pre-shared Bell pair and just 2 classical bits of communication, Alice can transfer the full quantum state |ψ⟩ to Bob. No qubit physically travels. This is quantum teleportation.

What We Need (Resources)

🔗
1 Bell pair
|Φ⁺⟩ shared between Alice and Bob before the protocol
📡
2 classical bits
Alice sends x, y ∈ {0,1} over a classical channel
⚙️
Bob's correction
Bob applies at most X and Z based on (x, y)

The Three Steps of the Protocol

1
Share a Bell pair. Alice and Bob meet (or use a quantum channel) and create the entangled pair |Φ⁺⟩ = (|00⟩+|11⟩)/√2. Alice keeps qubit q₀ and Bob keeps qubit q₁. They can now be light-years apart.
2
Alice performs a Bell measurement. Alice has the state |ψ⟩ to send plus her half q₀ of the Bell pair. She applies the Bell measurement circuit (CNOT + H + measure) to these two qubits and gets a 2-bit outcome (x, y) ∈ {00, 01, 10, 11}. She sends (x, y) to Bob via a classical channel.
3
Bob applies a correction gate. Based on the 2 bits (x, y) he received, Bob applies a simple correction (I, Z, X, or XZ) to his qubit q₁. After the correction, q₁ is in the state |ψ⟩ — the teleportation succeeded!

The Complete Teleportation Circuit

Here is the full circuit with all three qubits. Read it left to right. The dashed vertical lines mark the three stages of the protocol.

Full Teleportation Circuit
① Share Bell pair
② Alice measures
③ Bob corrects
|ψ⟩ =
α|0⟩+β|1⟩
H
M
x
q₀ → Alice
Bell pair
H
M
y
q₁ → Bob
Bell pair
Xif x=1
Zif y=1
|ψ⟩
|ψ₀⟩
|ψ₁⟩ after CNOT+H
|ψ₂⟩ after correction
Classical communication (x, y) from Alice to Bob shown as dashed lines. Bob's correction uses at most two gates.

Step-by-Step Calculation

Let's trace the mathematics carefully. Alice has |ψ⟩ = α|0⟩ + β|1⟩ to teleport. The three qubits are ordered as (q_in, q₀, q₁).

Initial state |ψ₀⟩:
|ψ₀⟩ = |Φ⁺⟩ ⊗ |ψ⟩ = (|00⟩ + |11⟩)/√2 ⊗ (α|0⟩ + β|1⟩)
Expand: = (α|000⟩ + α|110⟩ + β|001⟩ + β|111⟩) / √2

After CNOT
(q_in → q₀):
CNOT flips q₀ when q_in = |1⟩:
|000⟩ → |000⟩   |110⟩ → |100⟩   |001⟩ → |011⟩   |111⟩ → |101⟩
= (α|000⟩ + α|100⟩ + β|011⟩ + β|101⟩) / √2

After H
(on q_in):
H|0⟩ = (|0⟩+|1⟩)/√2 and H|1⟩ = (|0⟩−|1⟩)/√2. Collecting by the (q_in, q₀) outcome:
|ψ₁⟩ ∝ (α|0⟩+β|1⟩)|00⟩ + (α|0⟩−β|1⟩)|01⟩ + (α|1⟩+β|0⟩)|10⟩ + (α|1⟩−β|0⟩)|11⟩
How to read this: The state |ψ₁⟩ is a superposition of all four possible outcomes. The first two qubits (Alice's) are in a superposition of "00", "01", "10", "11". For each outcome, Bob's qubit q₁ is in a different state — shown by the coloured expressions. Alice's measurement collapses everything to one of these four terms.

The Four Possible Outcomes and Corrections

After Alice's Bell measurement she gets one of four results. For each, Bob's qubit is in a specific state that differs from |ψ⟩ by at most a simple gate:

"00"
Bob's qubit: α|0⟩ + β|1⟩
This is already |ψ⟩ — no correction needed!
Apply: I
"01"
Bob's qubit: α|0⟩ − β|1⟩ = Z|ψ⟩
Phase is flipped — Z gate corrects it (Z²=I)
Apply: Z
"10"
Bob's qubit: α|1⟩ + β|0⟩ = X|ψ⟩
Bit is flipped — X gate corrects it (X²=I)
Apply: X
"11"
Bob's qubit: α|1⟩ − β|0⟩ = XZ|ψ⟩
Both flipped — apply Z first then X (or ZX, up to global phase)
Apply: ZX
The resource equation: 1 Bell pair + 2 classical bits = 1 qubit transferred. This is tight — you cannot teleport a qubit with fewer resources. Quantum teleportation turns entanglement (a non-classical resource) into a quantum communication channel.
Teleportation simulator — set |ψ⟩ with θ and φ, simulate Alice's Bell measurement, and watch Bob apply corrections
60° 45°

Common Misconceptions

Does teleportation violate the no-cloning theorem? No! After teleportation, Alice's original qubit is destroyed (it was measured and collapsed). The state |ψ⟩ is not duplicated — it has moved. The original is gone; the copy appears at Bob's end.
Does teleportation violate special relativity (faster than light)? No! Alice must send the 2 classical bits (x, y) to Bob via a classical channel, which travels at most at the speed of light. Without those bits, Bob's qubit is in a completely mixed state — he cannot extract |ψ⟩ from it alone. The quantum channel carries no usable information until the classical bits arrive.
What exactly is being "teleported"? The quantum state |ψ⟩ — encoded in the two complex numbers α and β. This is an infinite amount of classical information (two arbitrary real numbers), yet only 2 classical bits + 1 entangled pair are needed! The trick: we don't need to learn α and β, we just need to transfer them. Entanglement enables this "wholesale" transfer without knowledge of the contents.
Ex 8.1Classical bits needed

How many classical bits does Alice send to Bob in the teleportation protocol? Why is that the minimum?

Number of bits:
Ex 8.2Bob's correction gate

Alice's Bell measurement gives outcome (x=1, y=0), i.e., "10". What gate should Bob apply to his qubit to recover |ψ⟩? Use the correction table above.

Bob applies:
Ex 8.3Why doesn't teleportation clone?

After teleportation succeeds, how many qubits are in the state |ψ⟩? Alice's original or Bob's copy — or both?

Qubits in state |ψ⟩:
Section 09

Quantum State Tomography

Suppose we have a quantum device that repeatedly produces qubits all in the same unknown pure state |ψ⟩ = α|0⟩ + β|1⟩. Can we figure out α and β just by measuring? This process is called quantum state tomography.

The problem
Given many identical copies of an unknown qubit state |ψ⟩ = α|0⟩ + β|1⟩, estimate the complex amplitudes α and β from measurement statistics alone.

Step 0 — Simplify the parametrisation

α and β are complex numbers, so naively we have 4 real parameters. But two constraints reduce this:

Constraint 1: Normalisation: |α|² + |β|² = 1  →  only 3 independent real parameters
Constraint 2: Global phase is unobservable — we can always choose α ∈ ℝ, α ≥ 0 without loss of generality

Here is why: write the general state as γ|0⟩ + δ|1⟩ with γ, δ ∈ ℂ. Factor out the phase of γ:

Write γ, δ: γ = |γ|e^{jφ_γ},   δ = |δ|e^{jφ_δ}
Factor e^{jφ_γ}: |ψ⟩ = e^{jφ_γ} [ |γ| |0⟩ + |δ| e^{j(φ_δ − φ_γ)} |1⟩ ]
Drop global: α |0⟩ + β |1⟩   with α = |γ| ∈ ℝ and β = β_R + jβ_I ∈ ℂ
So we have exactly 3 real unknowns: α (real, ≥ 0), β_R = Re(β), β_I = Im(β), linked by α² + β_R² + β_I² = 1. We need 3 independent measurements to recover all three.

Measurement 1 — Z basis (standard measurement)

Measure the observable L_Z = Z (Pauli-Z). This distinguishes |0⟩ from |1⟩ directly.

Circuit: |ψ⟩ ──[M]──   repeat N times, count N₀ outcomes of "0"
Born rule: P("0") = |α|² = |⟨0|ψ⟩|²
Frequency: P("0") ≈ N₀/N   (frequentist estimate for large N)
Since α ∈ ℝ: α = √(N₀/N)   and   |β| = √(1 − N₀/N)
This first measurement pins down α exactly (given enough shots N). All subsequent measurements can use this estimated α.

Measurement 2 — X basis (after Hadamard)

To extract β_R, we measure in the X (Hadamard) basis. Apply H before measuring in the Z basis:

Circuit: |ψ⟩ ──[H]──[M]──
H rotates: H maps |+⟩ → |0⟩ and |−⟩ → |1⟩, so measuring in X basis = measuring {|+⟩,|−⟩}
After H: H|ψ⟩ = α|+⟩ + β|−⟩ = (α+β)/√2|0⟩ + (α−β)/√2|1⟩

Compute P("0") carefully:

P("0"): = |α+β|²/2
Expand: = (|α|² + |β|² + αβ* + α*β) / 2
Since α ∈ ℝ: αβ* + α*β = αβ* + αβ = α(β+β*) = 2αβ_R
Use |α|²+|β|²=1: P("0") = (1 + 2αβ_R) / 2

Solve for β_R: N₀/N ≈ (1 + 2αβ_R)/2  ⟹  β_R = (2N₀/N − 1) · 1/(2α)

Measurement 3 — Y basis (after S†·H)

To extract β_I, we measure in the Y basis. The eigenstates of Y are |+j⟩ = (|0⟩+j|1⟩)/√2 and |−j⟩ = (|0⟩−j|1⟩)/√2. We need a circuit that maps these to |0⟩ and |1⟩.

Goal: Map |+j⟩ = (|0⟩+j|1⟩)/√2 → |0⟩   and   |−j⟩ = (|0⟩−j|1⟩)/√2 → |1⟩
Apply S: S = diag(1, j):   S|±j⟩ = (|0⟩ ± j·j|1⟩)/√2 = (|0⟩ ∓ |1⟩)/√2 = |±⟩
Then H: H|±⟩ = |0⟩ / |1⟩   ✓   (the X gate at the end just swaps labels — ignorable)
Circuit: |ψ⟩ ──[S]──[H]──[M]──

After S, the state becomes:

S|ψ⟩: S(α|0⟩ + β|1⟩) = α|0⟩ + |1⟩   (S multiplies |1⟩ by j)
H(S|ψ⟩): = α|+⟩ + jβ|−⟩ = (α+jβ)/√2|0⟩ + (α−jβ)/√2|1⟩

Now compute P("0"):

P("0"): = |α+jβ|²/2
Expand: = (|α|² + |β|² + α(−jβ*) + α(jβ)) / 2
Simplify: = (1 + αj(β − β*)) / 2  =  (1 + αj · 2jβ_I) / 2 = (1 + 2αβ_I) / 2
Note: β − β* = (β_R + jβ_I) − (β_R − jβ_I) = 2jβ_I,   so j·2jβ_I = −2β_I... wait:
Careful: −jβ* + jβ = j(β − β*) = j·2jβ_I = 2j²β_I = −2β_I... let's redo with α real:
Direct: α(−jβ*) + α(jβ) = αj(β−β*) = αj·2jβ_I = α·2j²·β_I = −2αβ_I
So: Hmm — this gives P = (1−2αβ_I)/2. The S† gate (instead of S) would give P = (1+2αβ_I)/2. The notes use S†·H:
Final result: P("0") = (1 + 2αβ_I) / 2  ⟹  β_I = (2N₀/N − 1) · 1/(2α)
All three formulas have the same structure: β_R and β_I are obtained by the same formula (2N₀/N−1)/(2α), just with different measurement circuits. The only difference is which basis change gate precedes the standard measurement.

Summary — The three measurements

StepCircuit (before M)P("0")Estimated quantity
1 — Z basis ──[M] |α|² = α² α = √(N₀/N)
2 — X basis ──[H]──[M] (1 + 2αβ_R)/2 β_R = (2N₀/N−1)/(2α)
3 — Y basis ──[S†]──[H]──[M] (1 + 2αβ_I)/2 β_I = (2N₀/N−1)/(2α)
How many copies do we need? Each measurement is a Bernoulli trial with variance p(1−p)/N. To estimate each parameter to precision ε, we need roughly N ~ 1/ε² shots per basis. For three bases, total shots ≈ 3/ε². For an n-qubit system, the number of parameters grows exponentially (4ⁿ − 1), making full tomography classically expensive.
Tomography simulator — set the true state with θ and φ, then simulate N=2000 measurements per basis
70° 120°
Ex 9.1Number of real parameters

A general qubit state |ψ⟩ = α|0⟩ + β|1⟩ has how many independent real parameters once we fix α ∈ ℝ and use normalisation? (enter a number)

Answer:
Ex 9.2Estimating α

In N=1000 Z-basis measurements we observe N₀ = 640 outcomes of "0". What is the estimate for α? (give 2 decimal places, e.g. 0.80)

α ≈
Ex 9.3Estimating β_R

Using α = 0.80 from Ex 9.2, in N=1000 X-basis measurements we observe N₀ = 620. What is the estimate for β_R? (give 2 decimal places)

β_R ≈