Interactive Notes

Composite Quantum Systems
and Tensor Products

How to describe joint quantum systems? Introduction to the tensor product, computing basis states of composite systems, and visualizing two-qubit states.

Section 01

Composite Quantum Systems & Tensor Products

So far we have studied a single quantum system β€” a single qubit. But what happens when two quantum systems interact, or are studied together? We need a way to describe a joint system.

Imagine Alice has a quantum system with state space SA, and Bob has one with state space SB. Their combined (composite) system lives in a new, larger state space SAB.

Definition β€” Composite System
If Alice's state space is SA = β„‚α΄Ί with basis {|0⟩A, …, |Nβˆ’1⟩A}, and Bob's is SB = β„‚α΄Ή with basis {|0⟩B, …, |Mβˆ’1⟩B}, then the composite state space is:
SAB = SA βŠ— SB
This is the tensor product of the two spaces. It has dimension NΒ·M.
The basis of SAB consists of all combinations |a⟩A βŠ— |b⟩B, written as |ab⟩ or |a,b⟩.
Notation: |a⟩A βŠ— |b⟩B = |ab⟩AB = |ab⟩ β€” all three mean the same thing. The first letter refers to Alice (MSB), the last to Bob (LSB) β€” more on this convention below.

Example β€” Two Qubits

Alice has 1 qubit: basis {|0⟩A, |1⟩A}. Bob has 1 qubit: basis {|0⟩B, |1⟩B}. The composite system has 2Γ—2 = 4 basis states:

SAB basis: |00⟩, |01⟩, |10⟩, |11⟩

The Tensor (Kronecker) Product

The tensor product tells us how to combine two vectors (or matrices) into a bigger one. For two column vectors:

a₁
aβ‚‚
βŠ—
b₁
bβ‚‚
=
a₁·b₁
a₁·bβ‚‚
aβ‚‚Β·b₁
aβ‚‚Β·bβ‚‚
β€” the result has 4 entries (NΒ·M)

For a general matrix A (nΓ—m) and any matrix B, the Kronecker product replaces each entry aij of A with the entire block aijΒ·B.

Computing the Basis States

Let's verify the two-qubit basis states concretely. Recall |0⟩ = (1,0)α΅€ and |1⟩ = (0,1)α΅€:

|00⟩ =
1
0
βŠ—
1
0
=
1Β·1
1Β·0
0Β·1
0Β·0
=
1
0
0
0

|01⟩ =
1
0
βŠ—
0
1
=
0
1
0
0

|10⟩ =
0
1
βŠ—
1
0
=
0
0
1
0

|11⟩ =
0
1
βŠ—
0
1
=
0
0
0
1
Pattern: The basis state |ab⟩ has a 1 exactly at position (aΒ·2 + b) in the vector β€” matching binary counting: |00⟩ = position 0, |01⟩ = position 1, |10⟩ = position 2, |11⟩ = position 3. The whole system behaves like a binary number!
Interactive: click a basis state to see its vector representation.
Exercise 1.1 Kronecker product of matrices

Consider the matrices A =

01
10
(Pauli X) and B = I =
10
01
. What is A βŠ— B?

The result should be a 4Γ—4 matrix. Hint: replace each entry of A with that entry times B.

Top-left 2Γ—2 block is the zero matrix?
Exercise 1.2 Dimension of composite system

Alice has a 3-level quantum system (a qutrit, β„‚Β³). Bob has a standard qubit (β„‚Β²). What is the dimension of their composite system SAB?

dim(SAB) =
βš› Circuit Lab 1.1 Tensor Product β€” Explore basis states

Each horizontal wire is one qubit starting in |0⟩. Gates from the palette change the state. The outcome panel updates live as you edit.

Drag an X gate onto register 1 (top wire) to prepare |10⟩. You should see 100% probability for |10⟩ in the outcomes.
Live outcomes
Run to see outcomes…
X acts as a quantum NOT: X|0⟩ = |1⟩. Drag X to the top wire (register 1) and you get |1βŸ©βŠ—|0⟩ = |10⟩ β€” 100% |10⟩.
Now build |11⟩: drag X onto both wires. Then try H on one wire to create a superposition like (|00⟩+|10⟩)/√2.
Section 02

Two-Qubit States: Superposition, Measurement & Product States

A general state in the two-qubit space is a superposition of all four basis states:

General Two-Qubit State
|Ψ⟩ = α00|00⟩ + α01|01⟩ + α10|10⟩ + α11|11⟩
Normalization: |Ξ±00|Β² + |Ξ±01|Β² + |Ξ±10|Β² + |Ξ±11|Β² = 1
Each Ξ±ab ∈ β„‚ is the probability amplitude for the outcome (a,b).

MSB / LSB Convention

In the notation |ab⟩, a refers to Alice's qubit (the Most Significant Bit, qA) and b to Bob's (the Least Significant Bit, qB). When drawing circuits, LSB is represented on top.

Example: In |abc⟩, the order is: c = LSB (top wire), b = middle, a = MSB (bottom wire, qA). This matches standard circuit notation.

Measuring a Two-Qubit State

If we measure both qubits simultaneously, the probability of outcome (a,b) is simply:

P(ab) = |⟨ab|Ψ⟩|² = |αab|²

Partial Measurement

What if only Alice measures her qubit? This is more subtle β€” Bob's qubit is not measured, so we sum over Bob's possible outcomes.

Partial Measurement β€” Alice measures |0⟩
Probability:
P(Alice β†’ 0) = P(00) + P(01) = |Ξ±00|Β² + |Ξ±01|Β²

Post-state:
|Ψ⟩ collapses to: (α00|00⟩ + α01|01⟩) / √(|α00|² + |α01|²)
β€” renormalized so total probability remains 1
Alice's qubit is now fixed at |0⟩, but Bob's qubit remains in a (renormalized) superposition.
Key idea: Measuring one qubit of a composite system narrows down the possibilities for the other qubit. If the two qubits are correlated, Alice's measurement result gives us information about what Bob is likely to measure next.

Product States

Suppose Alice and Bob prepare their qubits independently:

Alice:
Ξ±β‚€|0⟩ + α₁|1⟩
Bob:
Ξ²β‚€|0⟩ + β₁|1⟩

Together:
(Ξ±β‚€|0⟩+α₁|1⟩) βŠ— (Ξ²β‚€|0⟩+β₁|1⟩) = Ξ±β‚€Ξ²β‚€|00⟩ + α₀β₁|01⟩ + α₁β₀|10⟩ + α₁β₁|11⟩
Definition β€” Product State
A state |Ψ⟩AB is a product state (or separable state) if it can be written as:
|Ψ⟩AB = |Ο†βŸ©A βŠ— |Ο‡βŸ©B
This means Alice's and Bob's qubits are independent β€” measuring one tells you nothing about the other.

In a product state, the probability of Alice measuring |0⟩ is independent of Bob's state: P(Aliceβ†’0) = |Ξ±β‚€|Β²Β·(|Ξ²β‚€|Β²+|β₁|Β²) = |Ξ±β‚€|Β². Bob's preparation is completely irrelevant to Alice's outcome.

Exercise 2.1 Partial measurement probability

The state is |Ψ⟩ = (1/2)|00⟩ + (1/2)|01⟩ + (1/√2)|11⟩. What is the probability that Alice measures |0⟩?

P(Alice→0) =
Exercise 2.2 Is it a product state?

Is the state |Ψ⟩ = (1/√2)(|00⟩ + |10⟩) a product state? If yes, write it as |Ο†βŸ©A βŠ— |Ο‡βŸ©B.

Product state?
Section 03

Entangled States & the Bell Basis

Not all two-qubit states can be written as a product state. Those that cannot are called entangled.

Definition β€” Entangled State
A state |Ψ⟩AB is entangled if it cannot be written as |Ο†βŸ©A βŠ— |Ο‡βŸ©B for any single-qubit states |Ο†βŸ©, |Ο‡βŸ©.
There is a correlation between the two qubits that has no classical analogue.

For example, (|00⟩ + |01⟩ + |11⟩)/√3 cannot be written as a product state β€” you can verify this by trying to factor it and failing.

The Bell States β€” Maximally Entangled States

The four Bell states are the most entangled two-qubit states possible. They form an orthonormal basis for the two-qubit space:

|Φ⁺⟩
(|00⟩ + |11⟩) / √2
|Φ⁻⟩
(|00⟩ βˆ’ |11⟩) / √2
|Ψ⁺⟩
(|01⟩ + |10⟩) / √2
|Ψ⁻⟩
(|01⟩ βˆ’ |10⟩) / √2
Bell Basis (EPR pairs): |Φ⁺⟩, |Φ⁻⟩, |Ψ⁺⟩, |Ψ⁻⟩ are mutually orthogonal and span the entire two-qubit space. Any two-qubit state can be expressed as a superposition of these four states.

What Entanglement Means Physically

Consider |Φ⁺⟩ = (|00⟩ + |11⟩)/√2. If Alice measures her qubit:

Before:
|Φ⁺⟩ β€” Alice's qubit has 50% probability of being |0⟩ or |1⟩ (equally superposed)
Alice β†’ |0⟩:
State collapses to |00⟩. Now Bob's qubit is definitely |0⟩ β€” 100% probability.
Alice β†’ |1⟩:
State collapses to |11⟩. Now Bob's qubit is definitely |1⟩ β€” 100% probability.
The spooky part: Alice and Bob may be light-years apart. The moment Alice measures, Bob's qubit "knows" the result β€” not because of any signal, but because the two qubits were never truly independent. Einstein called this "spooky action at a distance." Note that this cannot be used to transmit information faster than light, because Alice can't control which outcome she gets.
Click "Measure Alice" to see how the entangled state collapses.
Exercise 3.1 Identify entanglement

Which of these states is entangled?
A: (|00⟩ + |01⟩) / √2    B: (|00⟩ + |11⟩) / √2    C: |00⟩

Entangled state:
Exercise 3.2 Bell state measurement

The system is in state |Ψ⁻⟩ = (|01⟩ βˆ’ |10⟩)/√2. Alice measures her qubit and gets |1⟩. What is Bob's qubit state after the measurement?

Bob's state is:
βš› Circuit Lab 3.1 Bell State Factory β€” Build |Φ⁺⟩ yourself

The circuit board starts empty (2 qubits, 2 moments). Your goal: create the Bell state |Φ⁺⟩ = (|00⟩+|11⟩)/√2.

Exercise: Drag H onto register 1, moment 1. Then drag a controlled-X (*) gate pair: the * (control dot) on register 1 moment 2, and X on register 2 moment 2. You should see 50% |00⟩ and 50% |11⟩.
Live outcomes β€”
Build the circuit to see outcomes…
Step 1 β€” H on r1,m1: puts register 1 into superposition (|0⟩+|1⟩)/√2.
Step 2 β€” CNOT: drag the * control tile to r1,m2 and X target to r2,m2. CNOT flips register 2 only when register 1 = |1⟩.
Result: (|00⟩+|11⟩)/√2 = |Φ⁺⟩ βœ“
Section 04

The CHSH Game β€” Entanglement Beats Classical Correlation

The CHSH game is a clever thought experiment that demonstrates β€” in a concrete, game-theoretic way β€” that quantum entanglement is fundamentally stronger than any classical correlation.

The Setup

CHSH Game Rules
  1. A referee sends random bit X ∈ {0,1} to Alice and random bit Y ∈ {0,1} to Bob.
  2. Alice outputs bit A ∈ {0,1}; Bob outputs bit B ∈ {0,1}.
  3. Alice and Bob win if: X Β· Y = A βŠ• B
  4. Rule: Alice and Bob may agree on a strategy beforehand, but cannot communicate once the game starts.
Win condition decoded: XΒ·Y = AβŠ•B means: "if both inputs are 1, output different bits; otherwise output the same bit." When X=Y=1, AβŠ•B must be 1 (Aβ‰ B). In all other cases, AβŠ•B must be 0 (A=B).

Classical Strategy: Maximum 75%

Alice and Bob preshare correlated bits (pulled from a shared box). The best simple strategy: always output A=B=0.

XYXΒ·YABAβŠ•BWin?
000000βœ“
010000βœ“
100000βœ“
111000βœ—
75% is optimal classically. No matter what classical strategy Alice and Bob use (even probabilistic, shared randomness), they cannot win more than 75% of the time. This is the CHSH inequality: any local hidden variable theory is bounded by 3/4.

Quantum Strategy: ~85.4%

The idea: Alice and Bob preshare one EPR pair |Φ⁺⟩ = (|00⟩+|11⟩)/√2. Instead of outputting a pre-agreed bit, they each measure their half of the pair β€” but the measurement basis they choose depends on their input X or Y. The outcome of that measurement becomes their output A or B.

Key insight: In an EPR pair, Alice's and Bob's measurement outcomes are correlated in a way that depends on the angle between their measurement bases. By cleverly choosing which angle to use for each input, they can make their outputs satisfy the win condition AβŠ•B = XΒ·Y more often than any classical strategy allows.

Step 1 β€” Agree on measurement bases before the game

Alice and Bob pre-agree on the following angles on the Bloch sphere equator (think of the qubit state as a direction in a 2D plane, parameterized by an angle ΞΈ):

Alice, X=0:
Measures at angle 0: basis {|0⟩, |1⟩}
β†’ output A=0 if she gets |0⟩, output A=1 if she gets |1⟩
Alice, X=1:
Measures at angle Ο€/4 (45Β°): basis {|+⟩, |βˆ’βŸ©}
β†’ output A=0 if she gets |+⟩, output A=1 if she gets |βˆ’βŸ©

Bob, Y=0:
Measures at angle Ο€/8 (22.5Β°): basis {|v⟩, |vβŠ₯⟩} where |v⟩ = cos(Ο€/8)|0⟩ + sin(Ο€/8)|1⟩
β†’ output B=0 if he gets |v⟩, output B=1 if he gets |vβŠ₯⟩
Bob, Y=1:
Measures at angle βˆ’Ο€/8 (βˆ’22.5Β°): basis {|w⟩, |wβŠ₯⟩} where |w⟩ = cos(Ο€/8)|0⟩ βˆ’ sin(Ο€/8)|1⟩
β†’ output B=0 if he gets |w⟩, output B=1 if he gets |wβŠ₯⟩

Picture Alice's and Bob's bases as arrows on a compass. The angle between the two arrows determines how correlated their outcomes will be β€” closer together means more correlated.

The four measurement bases on the unit circle. The angle between Alice's and Bob's chosen bases determines P(same outcome).

Step 2 β€” A crucial fact about EPR pairs

For an EPR pair |Φ⁺⟩, if Alice measures in some basis and Bob measures in a basis that is rotated by angle δ relative to Alice's, the probability that they get the same outcome is:

P(same outcome) = cosΒ²(Ξ΄/2)
where Ξ΄ = angle between the two measurement bases. When Ξ΄=0 (same basis) β†’ P=1 (always agree). When Ξ΄=Ο€/2 (orthogonal) β†’ P=1/2 (random).
Translation to the game: "Same outcome" means A=B, so AβŠ•B=0. "Different outcome" means Aβ‰ B, so AβŠ•B=1.
P(AβŠ•B=0)
= P(same) = cosΒ²(Ξ΄/2)
P(AβŠ•B=1)
= P(different) = sinΒ²(Ξ΄/2)

Step 3 β€” Work out the angle for each of the 4 input cases

The win condition is AβŠ•B = XΒ·Y. Let's compute the angle Ξ΄ between Alice's and Bob's bases in each case, and check whether the win condition is "same" (AβŠ•B=0) or "different" (AβŠ•B=1):

X=0, Y=0:
Alice at 0, Bob at Ο€/8 β†’ Ξ΄ = Ο€/8
Win condition: XΒ·Y = 0Β·0 = 0 β†’ need AβŠ•B = 0 (same outcome)
P(win) = P(same) = cosΒ²(Ο€/16) … wait β€” let's be careful.
The angle between the bases is Ο€/8, so Ξ΄ = Ο€/8. P(same) = cosΒ²(Ο€/8Β·Β½) = cosΒ²(Ο€/16)? No!
Careful with the formula! The formula P(same) = cosΒ²(Ξ΄/2) uses the angle Ξ΄ between the two basis vectors on the Bloch sphere. An angle ΞΈ on the unit circle corresponds to a state rotated by ΞΈ from |0⟩, but on the Bloch sphere this is a rotation of 2ΞΈ. So the angle between two states at circle-angles ΞΈ_A and ΞΈ_B is Ξ΄Bloch = 2|ΞΈ_A βˆ’ ΞΈ_B|, and P(same) = cosΒ²(|ΞΈ_A βˆ’ ΞΈ_B|).

Using P(same outcome) = cosΒ²(|ΞΈ_A βˆ’ ΞΈ_B|) where ΞΈ is the circle angle:

X=0, Y=0:
ΞΈA=0, ΞΈB=Ο€/8 β†’ |ΞΈAβˆ’ΞΈB| = Ο€/8
Need AβŠ•B = 0 (same)    P(win) = cosΒ²(Ο€/8) β‰ˆ 0.854 βœ“

X=0, Y=1:
ΞΈA=0, ΞΈB=βˆ’Ο€/8 β†’ |ΞΈAβˆ’ΞΈB| = Ο€/8
Need AβŠ•B = 0 (same)    P(win) = cosΒ²(Ο€/8) β‰ˆ 0.854 βœ“

X=1, Y=0:
ΞΈA=Ο€/4, ΞΈB=Ο€/8 β†’ |ΞΈAβˆ’ΞΈB| = Ο€/8
Need AβŠ•B = 0 (same)    P(win) = cosΒ²(Ο€/8) β‰ˆ 0.854 βœ“

X=1, Y=1:
ΞΈA=Ο€/4, ΞΈB=βˆ’Ο€/8 β†’ |ΞΈAβˆ’ΞΈB| = 3Ο€/8
Need AβŠ•B = 1 (different)    P(win) = sinΒ²(3Ο€/8) = cosΒ²(Ο€/8) β‰ˆ 0.854 βœ“
The magic of the angles: For cases (0,0), (0,1), (1,0), Alice and Bob need to agree (same outcome). Their bases are always Ο€/8 apart, giving cosΒ²(Ο€/8) β‰ˆ 85.4%. For the hard case (1,1), they need to disagree. Their bases are 3Ο€/8 apart β€” and sinΒ²(3Ο€/8) = cosΒ²(Ο€/8) by the identity sin(x)=cos(Ο€/2βˆ’x). All four cases give the same win probability!

Step 4 β€” Overall win probability

P(win) =
ΒΌ Β· P(win|X=0,Y=0) + ΒΌ Β· P(win|X=0,Y=1) + ΒΌ Β· P(win|X=1,Y=0) + ΒΌ Β· P(win|X=1,Y=1)
= ΒΌ Β· cosΒ²(Ο€/8) + ΒΌ Β· cosΒ²(Ο€/8) + ΒΌ Β· cosΒ²(Ο€/8) + ΒΌ Β· cosΒ²(Ο€/8)
= cosΒ²(Ο€/8) β‰ˆ 0.854  >  0.75 βœ“
Aspect's Experiment (1982): This quantum advantage was confirmed experimentally by Alain Aspect, who measured violations of the CHSH inequality with entangled photons. This experimentally ruled out local hidden variable theories, confirming that quantum mechanics is genuinely non-local in this sense.
Interactive: Play the CHSH Game
Referee assigns:
X = ?    Y = ?
Alice outputs A:
Bob outputs B:
Exercise 4.1 Classical bound

Alice and Bob decide to use the strategy: Alice always outputs A=1, Bob always outputs B=1. How many of the 4 possible input combinations (X,Y) ∈ {00,01,10,11} do they win?

Number of wins:
Exercise 4.2 Quantum win probability

The quantum win probability is P(win) = cosΒ²(Ο€/8). Use the identity cos(Ο€/8) = cos(22.5Β°) β‰ˆ 0.9239 to compute P(win) to 3 decimal places.

P(win) β‰ˆ
Section 05

Multi-Qubit Gates β€” Complete Catalogue

When we have multiple qubits, we need multi-qubit gates. Each gate is presented with its matrix, its action on basis states, and how it appears in circuits. Some gates act independently on each qubit; others create entanglement by coupling two qubits together.

Independent Transformations (Tensor product of single-qubit gates)

If we apply gate U₁ on qubit 1 and Uβ‚€ on qubit 0 independently, the combined unitary is their tensor product U = U₁ βŠ— Uβ‚€. This gate cannot create entanglement.

U₁ βŠ— Uβ‚€ Independent gates β€” "each qubit on its own"
Matrix (example: X βŠ— Z)
01
10
βŠ—
10
0βˆ’1
=
0010
000βˆ’1
1000
0βˆ’100
(Uβ‚βŠ—Uβ‚€)|ab⟩ = U₁|a⟩ βŠ— Uβ‚€|b⟩
Effect on qubits
Each qubit is transformed independently.
β€’ No information passes between the two wires
β€’ Cannot create or destroy entanglement
β€’ Probabilities on each qubit change as if the other doesn't exist
Think of two parallel single-qubit operations happening simultaneously.
In circuits
|a⟩
Z
Z|a⟩
|b⟩
X
X|b⟩
Two separate boxes on separate wires β€” the dashed box around them indicates they form a single 4Γ—4 unitary U = Z βŠ— X.

Entangling Gates (genuinely two-qubit)

CNOT  /  CX Controlled-NOT β€” "the entanglement machine"
Matrix
1000
0001
0010
0100
CX = IβŠ—|0⟩⟨0| + XβŠ—|1⟩⟨1|
CXΒ² = I   (self-inverse)
Action on basis states
Control qβ‚€, Target q₁. If control is |1⟩, flip the target:
|00⟩ β†’
|00⟩  (ctrl=0, no flip)
|01⟩ β†’
|11⟩  (ctrl=1, flip)
|10⟩ β†’
|10⟩
|11⟩ β†’
|01⟩
Cannot be written as Uβ‚βŠ—Uβ‚€ β€” genuinely 2-qubit.
In circuits & key use
qβ‚€
qβ‚€
q₁
βŠ•
qβ‚€βŠ•q₁
Used to generate Bell states (H then CNOT), implement quantum teleportation, and build any multi-qubit circuit. Together with single-qubit gates, CNOT is universal.
Bell state factory β€” H + CNOT: Starting from |00⟩, apply H on qβ‚€, then CNOT:
|Ξ¨β‚€βŸ© =
|00⟩    (product state)
after H:
|0⟩ βŠ— H|0⟩ = (|00⟩+|01⟩)/√2
after CNOT:
(|00⟩+|11⟩)/√2 = |Φ⁺⟩ ← entangled!
CZ Controlled-Z β€” "sign flipper for |11⟩"
Matrix
1000
0100
0010
000βˆ’1
CZΒ² = I
CZ = IβŠ—|0⟩⟨0| + ZβŠ—|1⟩⟨1|
Action on basis states
Multiplies by (βˆ’1) only when both qubits are |1⟩:
|q₁qβ‚€βŸ© β†’
(βˆ’1)^(q₁·qβ‚€)|q₁qβ‚€βŸ©

|00⟩ β†’
|00⟩
|01⟩ β†’
|01⟩
|10⟩ β†’
|10⟩
|11⟩ β†’
βˆ’|11⟩
Unlike CNOT, CZ is symmetric: either qubit can be the "control."
In circuits & key use
qβ‚€
q₁
Both endpoints shown as dots (symmetric). Naturally related to CNOT via Hadamard: CZ = (IβŠ—H)Β·CNOTΒ·(IβŠ—H). Common in superconducting quantum processors.
SWAP Swap gate β€” "exchange two qubits"
Matrix
1000
0010
0100
0001
SWAPΒ² = I
SWAP = 3Γ— CNOT
Action on basis states
Swaps the entire quantum states of the two qubits:
|Ξ¨βŸ©βŠ—|Φ⟩ β†’
|Ξ¦βŸ©βŠ—|Ψ⟩

|00⟩ β†’
|00⟩
|01⟩ β†’
|10⟩
|10⟩ β†’
|01⟩
|11⟩ β†’
|11⟩
In circuits & key use
|Ψ⟩
βœ•
|Φ⟩
|Φ⟩
βœ•
|Ψ⟩
Used when qubit connectivity is limited (physical qubits can't always interact directly). Decomposable into 3 CNOT gates: CNOTΒ·CNOT(reversed)Β·CNOT.
C-U Controlled-U β€” "any gate, conditionally"
Block matrix structure
The 4Γ—4 matrix is built from four 2Γ—2 blocks:
C-U =
I 0
0 U
β–ͺ top-left = I (2Γ—2 identity)
  ctrl=|0⟩: target unchanged
β–ͺ off-diagonal = 0 (2Γ—2 zero)
  ctrl=0 and ctrl=1 never mix
β–ͺ bottom-right = U (any unitary)
  ctrl=|1⟩: U applied to target
C-X: ctrl = q₁ (MSB, 1st letter)
When q₁ is the control, the ctrl=0 subspace is {|00⟩,|01⟩} (rows 0–1) and ctrl=1 is {|10⟩,|11⟩} (rows 2–3). Plug X into the bottom-right:
1 0 0 0
0 1 0 0
0 0 0 1
0 0 1 0
|00βŸ©β†’|00⟩, |01βŸ©β†’|01⟩, |10βŸ©β†’|11⟩, |11βŸ©β†’|10⟩
βœ“ CNOT with ctrl=q₁ (MSB)
C-X: ctrl = qβ‚€ (LSB, 2nd letter)
When qβ‚€ is the control (as in these notes), the ctrl=0 subspace is {|00⟩,|10⟩} and ctrl=1 is {|01⟩,|11⟩} β€” interleaved in the standard basis order. The matrix is not in clean block form, but the logic is the same:
1000
0001
0010
0100
|00βŸ©β†’|00⟩, |01βŸ©β†’|11⟩, |10βŸ©β†’|10⟩, |11βŸ©β†’|01⟩
← This is the CNOT used in these notes (ctrl=qβ‚€)
Convention matters! The I/0/0/U block form produces a clean matrix only when the MSB (first letter, q₁) is the control. When the LSB (qβ‚€) is the control β€” as used in these notes β€” the ctrl=0 and ctrl=1 rows are interleaved in the standard basis order, so the matrix looks different even though the gate does the same thing. Both are valid CNOTs; they just label which qubit is "in charge."
The general recipe: C-H? Put H in the bottom-right block (ctrl=q₁). C-Rz(ΞΈ)? Put Rz(ΞΈ) there. The block form always works cleanly when the MSB is the control. Together with single-qubit gates, any C-U is sufficient for universal quantum computation.
Exercise 5.1 CNOT action

Apply CNOT (control = qβ‚€, target = q₁) to the state |Ψ⟩ = (|00⟩ + |10⟩)/√2. What is the output state?

Output state:
Exercise 5.2 CZ gate

Apply the CZ gate to the Bell state |Φ⁺⟩ = (|00⟩ + |11⟩)/√2. What is the output state?

Output state:
Exercise 5.3 SWAP verification

Apply SWAP to the state |01⟩. What is the result?

Result:
βš› Circuit Lab 5.1 Gate Sandbox β€” Explore CNOT, CZ and SWAP

A free 2-qubit, 4-moment sandbox. Use the palette to drag any gates and see the outcomes live. Try the challenges below one at a time.

Live outcomes
Build a circuit to see outcomes…
Challenge A β€” CNOT: Place X on r1,m1 (preparing |10⟩). Then CNOT (control r1, target r2) at m2. Expected output: |11⟩.
Challenge B β€” Superposition + CNOT: H on r1,m1. CNOT at m2. Expected: 50% |00⟩ + 50% |11⟩ (Bell state!).
Challenge C β€” SWAP via 3Γ—CNOT: Prepare |10⟩ (X on r1). Then place CNOT-CNOT-CNOT alternating directions to swap. Expected: |01⟩.
Challenge D β€” CZ via HΒ·CNOTΒ·H: Prepare |11⟩ (X on both). Apply H on r2, CNOT, H on r2 again. This is a CZ gate β€” it flips the sign of |11⟩.
Section 06

Mixed States & the Density Matrix

So far we have dealt with pure states β€” states that are described by a single known state vector |ψ⟩. But in practice, we often have classical uncertainty about which quantum state a system is in. This requires a more general description.

Definition β€” Mixed State
A mixed state is a statistical ensemble of pure states {(pα΅’, |ψᡒ⟩)}, meaning: with probability pα΅’ the system is in pure state |ψᡒ⟩. Here pα΅’ β‰₯ 0 and Ξ£α΅’ pα΅’ = 1.
Two kinds of uncertainty: In a pure state like |+⟩ = (|0⟩+|1⟩)/√2, the uncertainty in measurement is quantum β€” it is an intrinsic feature of the state. In a mixed state, there is an additional classical uncertainty about which quantum state the system is actually in. These are fundamentally different!

The Density Matrix

Instead of tracking {(pᡒ, |ψᡒ⟩)} as a list, we encode everything in a single matrix called the density matrix ρ:

Density Matrix
ρ = Σᡒ pᡒ |ψᡒ⟩⟨ψᡒ|
For a single pure state |ψ⟩, the density matrix is simply ρ = |ψ⟩⟨ψ|.

Examples

Pure state |0⟩ β†’ ρ = |0⟩⟨0|
ρ =
1
0
10
=
10
00

Pure state |+⟩ = (|0⟩+|1⟩)/√2 β†’ ρ = |+⟩⟨+|
ρ =
Β½Β½
Β½Β½

Mixed state: 50% |0⟩, 50% |1⟩
ρ =
½|0⟩⟨0| + ½|1⟩⟨1| =
Β½0
0Β½
β‰  |+⟩⟨+|
Pure vs mixed β€” key distinction: The state |+⟩ and the 50/50 mixture of {|0⟩, |1⟩} both give 50% probability for 0 or 1 when measured in the computational basis. But they are completely different: |+⟩ gives definite 0 when measured in the Hadamard basis, while the mixture gives 50/50 in any basis. The density matrix captures this difference.

Properties of the Density Matrix

Properties of ρ
  • Hermitian: ρ = ρ† (ρ equals its conjugate transpose)
  • Trace 1: tr(ρ) = Ξ£β‚‘ ρₑₑ = 1 (probabilities sum to 1)
  • Positive semi-definite: ⟨ψ|ρ|ψ⟩ β‰₯ 0 for all |ψ⟩ (probabilities non-negative)
  • Pure state test: ρ² = ρ iff the state is pure; tr(ρ²) ≀ 1, with equality iff pure

The density matrix works for any quantum system, not just single qubits. For an n-qubit system the state space has dimension 2ⁿ, so ρ is a 2ⁿ×2ⁿ matrix. A 2-qubit system has a 4Γ—4 density matrix; 3 qubits give 8Γ—8; and so on. The diagonal entry ρii is always the probability of measuring basis state |i⟩.

1 qubit (2Γ—2):
2 qubits (4Γ—4):
Diagonal = measurement probabilities Β· Off-diagonal = quantum coherences
Exercise 6.1 Compute a density matrix

A qubit is in state |βˆ’βŸ© = (|0⟩ βˆ’ |1⟩)/√2 with probability 1/3, and in state |1⟩ with probability 2/3. Compute the off-diagonal element ρ₀₁ of the density matrix.

ρ₀₁ =
Exercise 6.2 Pure or mixed?

A density matrix is given as ρ =

ΒΎ0
0ΒΌ
. Is this a pure state or a mixed state?

State type:
βš› Circuit Lab 6.1 Pure vs Mixed β€” What measurements can and cannot tell you

Both a pure superposition and an entangled state can give identical measurement probabilities. Build both circuits and compare the outcomes β€” then read why they are physically different.

Circuit A β€” Product State |+βŸ©βŠ—|0⟩
Drag H onto register 1. Expected: 50% |00⟩, 50% |10⟩. Qubit r1 is pure |+⟩.
β€”
Circuit B β€” Bell State |Φ⁺⟩
Build H + CNOT. Expected: 50% |00⟩, 50% |11⟩. Qubit r1 is mixed ρ=I/2.
β€”
The key paradox: Circuit A gives 50% |00⟩ / 50% |10⟩ and circuit B gives 50% |00⟩ / 50% |11⟩ β€” different joint outcomes, but if you only look at register 1 alone, both give exactly 50% |0⟩ and 50% |1⟩. You cannot tell pure from mixed by measuring one qubit in one basis. You need quantum tomography (Section 5 of Quantum Circuits notes) or entanglement witnesses.
Composite Quantum Systems Β· Interactive Notes 2026 βš› Q.js circuits powered by quantumjavascript.app