Interactive Notes

Basic Concepts
of Quantum Computing

Introduction to the fundamental ideas of quantum mechanics and quantum computing, with a focus on the postulates of quantum mechanics, the qubit, measurement, and quantum gates.

Section 01

Postulates of Quantum Mechanics

Quantum mechanics is built on three fundamental postulates that tell us how to describe a physical system, how to measure it, and how it evolves over time.

Postulate 1 β€” State of the system

Postulate 1
Every isolated physical system is described by a Hilbert space. The state of the system is a unit-norm state vector: |ψ⟩ ∈ β„‚α΄Ί with ⟨ψ|ψ⟩ = 1.

In practice for a qubit: the space is β„‚Β², and the state is a column vector (Ξ±, Ξ²)α΅€ with |Ξ±|Β²+|Ξ²|Β² = 1. Nothing more exotic than a normalized vector!

Postulate 2 β€” Measurement

First the simple version, then the formal one.

Simple version: when you "look at" a quantum system, you always get one of the possible outcomes of the observable you are using. The outcome is random, but with precise probabilities. After you look, the system makes a definitive "choice".
Postulate 2 β€” Formal definition
Every physical observable is represented by a Hermitian matrix L (Lα΄΄ = L), with spectral decomposition:
L = λ₁|uβ‚βŸ©βŸ¨u₁| + Β·Β·Β· + Ξ»β‚™|uβ‚™βŸ©βŸ¨uβ‚™|
The only possible outcomes are the eigenvalues λ₁,…,Ξ»β‚™ ∈ ℝ.
With the system in state |ψ⟩, the probability of obtaining Ξ»β‚— is:
P(Ξ»β‚—) = |⟨uβ‚—|ψ⟩|Β² (Born rule)
After measurement, the state collapses to the corresponding eigenvector |uβ‚—βŸ©.

This postulate is dense β€” let's tackle it piece by piece with three questions:

πŸ“ Question 1 β€” what can I get?
Only the eigenvalues of L. If L = Z has eigenvalues +1 and βˆ’1, you will never get 0, 0.7, or a complex number β€” only "+1" or "βˆ’1". The eigenvalues are the "menu" of possible outcomes.

Why real? Because L is Hermitian β†’ eigenvalues always real β†’ the results on the instrument are real numbers. If L were not Hermitian, you would get complex numbers on a display, which makes no physical sense.
🎲 Question 2 β€” with what probability?
P(Ξ»β‚—) = |⟨uβ‚—|ψ⟩|Β² β€” the squared modulus of the inner product between state |ψ⟩ and eigenvector |uβ‚—βŸ©.

Geometric intuition: ⟨uβ‚—|ψ⟩ measures how much |ψ⟩ "points in the same direction" as |uβ‚—βŸ©. If |ψ⟩ = |uβ‚—βŸ© exactly, the projection is 1 β†’ P = 1 (certainty). If they are orthogonal, the projection is 0 β†’ P = 0 (impossible).
πŸ’₯ Question 3 β€” what happens next?
The state collapses to |uβ‚—βŸ©. The superposition disappears: the system "chooses" an eigenvector and stays there. If you measure again immediately with the same observable, you get Ξ»β‚— again with P = 1 β€” because |ψ_after⟩ = |uβ‚—βŸ© is already an eigenvector.

Important: measuring changes the state. You are not just "reading" β€” you are interacting.
The connection to spectral decomposition: writing L = Ξ£ Ξ»β‚—|uβ‚—βŸ©βŸ¨uβ‚—| is not just an elegant formula β€” it is the way to find the possible outcomes (Ξ»β‚—), the probabilities (|⟨uβ‚—|ψ⟩|Β²), and the post-measurement states (|uβ‚—βŸ©). A single object contains everything.

Step-by-step example: measuring with Z

Let us follow the three steps of the postulate with L = Z and state |ψ⟩ = α|0⟩ + β|1⟩.

Step 1
eigenvalues
Z =
10
0βˆ’1
 β†’  eigenvalues: λ₁ = +1, Ξ»β‚‚ = βˆ’1
Possible outcomes: only "+1" or "βˆ’1"
✦ Trick
Z is diagonal β†’ the eigenvalues are directly the diagonal elements: 1 and βˆ’1. Zero calculations needed.
Works for any diagonal matrix: diag(a, b) has eigenvalues a and b β€” just read them.

Step 2
eigenvectors
|uβ‚βŸ© = |0⟩ = (1, 0)α΅€   for λ₁ = +1
|uβ‚‚βŸ© = |1⟩ = (0, 1)α΅€   for Ξ»β‚‚ = βˆ’1

Step 3
probabilities
P("+1") = |⟨0|ψ⟩|² = |α*·1 + β*·0|² = |α|²
P("βˆ’1") = |⟨1|ψ⟩|Β² = |Ξ±*Β·0 + Ξ²*Β·1|Β² = |Ξ²|Β²
Check: |Ξ±|Β² + |Ξ²|Β² = 1 βœ“ (probabilities sum to 1)

Step 4
collapse
If "+1" β†’ state becomes |0⟩
If "βˆ’1" β†’ state becomes |1⟩
Measuring again immediately gives the same result with P=1

Example 2: what if the state is already an eigenvector?

What happens if we measure Z on the qubit |ψ⟩ = |0⟩? Intuitively: we are already "on" |0⟩, so the outcome should be certain.

|ψ⟩ = |0⟩
Ξ± = 1, Ξ² = 0
P("+1") =
|Ξ±|Β² = |1|Β² = 1    ← absolute certainty
P("βˆ’1") =
|Ξ²|Β² = |0|Β² = 0
General rule: if |ψ⟩ = |uβ‚–βŸ© (already an eigenvector), then P(Ξ»β‚–) = |⟨uβ‚–|uβ‚–βŸ©|Β² = 1 and all other probabilities are 0. Eigenvectors are the "certain" states of that measurement.

Example 3: measuring Z on a balanced superposition

What happens with |ψ⟩ = |+⟩ = (|0⟩ + |1⟩)/√2? This state is "exactly halfway" between |0⟩ and |1⟩.

|ψ⟩ = |+⟩
α = 1/√2, β = 1/√2
P("+1") =
|1/√2|Β² = 1/2    ← 50%
P("βˆ’1") =
|1/√2|Β² = 1/2    ← 50%
After measurement:
if "+1" β†’ collapses to |0⟩    if "βˆ’1" β†’ collapses to |1⟩

Quick tricks for finding eigenvalues

Trick A β€” Diagonal matrix: eigenvalues and eigenvectors can be read directly.

Given a diagonal matrix:
a0
0b
1
0
=
a
0
= a Β·
1
0
β†’ |0⟩ is an eigenvector with eigenvalue a
a0
0b
0
1
=
0
b
= b Β·
0
1
β†’ |1⟩ is an eigenvector with eigenvalue b
The eigenvectors are always |0⟩ and |1⟩, regardless of the values of a and b.
Why? A diagonal matrix does not "mix" the components β€” it multiplies each one by its coefficient, leaving it in its direction.

Example:   Z β†’ (Ξ»=+1, |0⟩) e (Ξ»=βˆ’1, |1⟩)  |  S β†’ (Ξ»=1, |0⟩) e (Ξ»=j, |1⟩)  |  T β†’ (Ξ»=1, |0⟩) e (Ξ»=ejΟ€/4, |1⟩)
Trick B β€” LΒ² = I (involutory): eigenvalues are always Β±1.
Proof: L|u⟩ = Ξ»|u⟩ β†’ LΒ²|u⟩ = λ²|u⟩ = |u⟩ β†’ λ² = 1 β†’ Ξ» = Β±1.
Works for X, Y, Z, H and any Pauli β€” no determinant to calculate.
Trick C β€” Trace and determinant (for general 2Γ—2):
For a 2Γ—2 matrix with eigenvalues λ₁ and Ξ»β‚‚:
λ₁ + Ξ»β‚‚ =
tr(L) = sum of diagonal elements
λ₁ Β· Ξ»β‚‚ =
det(L) = diagonal product βˆ’ anti-diagonal product
Example con X = ((0,1),(1,0)):   tr = 0, det = 0Β·0 βˆ’ 1Β·1 = βˆ’1
β†’ λ₁+Ξ»β‚‚ = 0 and λ₁·λ₂ = βˆ’1 β†’ eigenvalues are +1 and βˆ’1. (Again: just sum and product, no equation to solve.)

This is the foundation of the quantum random number generator (QRNG): prepare |+⟩, measure, get 0 or 1 with probability exactly 1/2 β€” and the randomness is fundamental, not due to ignorance.

Measuring with observable Lz = Z is called measuring in the computational basis {|0⟩, |1⟩}. The "name" of the basis comes from the eigenvectors of the observable used.

Postulate 3 β€” Time evolution

Postulate 3
The evolution of a closed system is described by a unitary transformation U (with Uα΄΄U = UUα΄΄ = I):
|ψ'⟩ = U|ψ⟩

A key property: if U is unitary and |ψ⟩, |Ο†βŸ© are orthogonal, then U|ψ⟩ and U|Ο†βŸ© are still orthogonal. Unitary transformations preserve distances.

Measurement ↔ evolution connection: Matrix Z is both Hermitian (β†’ observable, used to measure) and unitary (β†’ gate, used to transform). Same matrix, two completely different roles depending on how you use it!
Reversibility: Since every unitary matrix is invertible (U⁻¹ = Uᴴ), every admissible quantum operation is reversible. This is fundamentally different from classical computing where AND and OR are not invertible.
Ex 1.1Eigenvalues of X as an observable

Given L = X = ((0,1),(1,0)), what are the possible outcomes if we use X as an observable?

Remember: possible outcomes = eigenvalues of L.

λ₁ = Ξ»β‚‚ =
Ex 1.2Probability when measuring with X

Given |ψ⟩ = Ξ±|0⟩ + Ξ²|1⟩ and L = X with eigenvectors |+⟩ = (1/√2)(1,1)α΅€ and |βˆ’βŸ© = (1/√2)(1,βˆ’1)α΅€, what is P("+1")?

P("+1") =
Section 01b

The Pauli Matrices

The Pauli matrices are the three most important 2Γ—2 matrices in quantum computing. They appear everywhere: as observables for measuring, as gates for transforming, and as building blocks for any qubit operation.

X β€” "quantum NOT"
01
10
Y β€” "bit + phase flip"
0βˆ’j
j0
Z β€” "phase flip"
10
0βˆ’1
Fundamental properties
All three are simultaneously Hermitian (LH = L) and Unitary (LHL = I).
This means the same matrix can do two things depending on how you use it:
As an observable
measure the system β†’ get an eigenvalue (+1 or βˆ’1) with a certain probability
As a gate
transform the state β†’ apply |ψ'⟩ = P|ψ⟩ without measuring anything

The eigenvectors of each

Each one has a pair of orthogonal eigenvectors with eigenvalues +1 and βˆ’1. These eigenvectors define the measurement basis β€” the possible states the system can collapse into.

Z
|0⟩ = (1,0)T with Ξ»=+1    |1⟩ = (0,1)T with Ξ»=βˆ’1
Z is diagonal β†’ eigenvectors are |0⟩ and |1⟩ by trick A β€” zero calculations

X
|+⟩ = (1,1)T/√2 with Ξ»=+1    |βˆ’βŸ© = (1,βˆ’1)T/√2 with Ξ»=βˆ’1
X is not diagonal β†’ eigenvectors are "tilted" relative to |0⟩ and |1⟩

Y
|+j⟩ = (1,j)T/√2 with Ξ»=+1    |βˆ’j⟩ = (1,βˆ’j)T/√2 with Ξ»=βˆ’1
Like X but with complex coefficients
Identical eigenvalues, different eigenvectors: X, Y and Z all have eigenvalues +1 and βˆ’1. What distinguishes them are the eigenvectors β€” i.e. the bases in which they "live". Measuring with Z the system collapses to |0⟩ or |1⟩; measuring with X collapses to |+⟩ or |βˆ’βŸ©.
Click a Pauli matrix to see its eigenvectors.
Section 01c

What does "measuring in a basis" mean

When we say "measuring in basis {|0⟩,|1⟩}" or "measuring in basis {|+⟩,|βˆ’βŸ©}", we are specifying which states the system can collapse into β€” not the numbers we read.

Measurement basis = eigenvectors of the observable
Choosing a measurement basis means choosing an observable L.
The "basis"
are the eigenvectors {|uβ‚βŸ©, |uβ‚‚βŸ©} of L β€” the possible states of collapse
The "outcomes"
are the eigenvalues (+1 and βˆ’1 for all Paulis) β€” the numbers on the display
The "collapse"
occurs to the eigenvector corresponding to the outcome obtained

Direct comparison: same state, different bases

Start from the same state |ψ⟩ = |+⟩ = (|0⟩+|1⟩)/√2 and measure first with Z, then with X:

Measurement with Z β€” basis {|0⟩, |1⟩}:
P("+1") =
|⟨0|+⟩|Β² = |1/√2|Β² = 1/2 β†’ collapse in |0⟩
P("βˆ’1") =
|⟨1|+⟩|Β² = |1/√2|Β² = 1/2 β†’ collapse in |1⟩
Result:
completely random β€” 50/50

Measurement with X β€” basis {|+⟩, |βˆ’βŸ©}:
P("+1") =
|⟨+|+⟩|Β² = |1|Β² = 1 β†’ collapse in |+⟩
P("βˆ’1") =
|βŸ¨βˆ’|+⟩|Β² = |0|Β² = 0
Result:
absolute certainty β€” |+⟩ is already an eigenvector of X!
The key: the same state |+⟩ gives completely different results depending on the observable used. With Z it is maximally random; with X it is completely certain.
The chosen basis determines how much you "resolve" the superposition.

Geometric visualization

Measuring in a basis is like projecting the state vector onto the axes of the chosen basis. The probability of each outcome is the square of that projection.

If the state is already aligned with a basis axis β†’ P = 1 (certainty). If it is at 45Β° β†’ P = 1/2 (maximum uncertainty).

Rotate |ψ⟩ with the slider and change the basis to see how the probabilities change.
Basis: 45Β°

Summary: the three Pauli bases

PauliBasis (collapse states)Outcomes Z|0⟩ = (1,0)T    |1⟩ = (0,1)T+1 β†’ |0⟩  /  βˆ’1 β†’ |1⟩ X|+⟩ = (1,1)T/√2    |βˆ’βŸ© = (1,βˆ’1)T/√2+1 β†’ |+⟩  /  βˆ’1 β†’ |βˆ’βŸ© Y|+j⟩ = (1,j)T/√2    |βˆ’j⟩ = (1,βˆ’j)T/√2+1 β†’ |+j⟩  /  βˆ’1 β†’ |βˆ’j⟩
Section 02

The Qubit

A qubit is the simplest quantum physical system: when measured, it gives one of two possible outcomes (e.g. spin up/down, horizontal/vertical polarization).

State of a Qubit
|ψ⟩ = α|0⟩ + β|1⟩ =
Ξ±
Ξ²
Ξ±, Ξ² ∈ β„‚    |Ξ±|Β² + |Ξ²|Β² = 1

Global phase β€” changes nothing

Two states |ψ⟩ and ejΟ†|ψ⟩ are physically indistinguishable. The global phase does not change any measurable probability:

|ψ'⟩ = ejΟ†|ΟˆβŸ©β†’ same physical state, we write |ψ⟩ ≑ |ψ'⟩

Why?
P(outcome) = |⟨u|ψ'⟩|Β² = |ejΟ†βŸ¨u|ψ⟩|Β² = |ejΟ†|Β²Β·|⟨u|ψ⟩|Β² = 1Β·|⟨u|ψ⟩|Β² = P(outcome) βœ“
Relative phase does change things! |+⟩ = (|0⟩+|1⟩)/√2 and |βˆ’βŸ© = (|0βŸ©βˆ’|1⟩)/√2 are different states that can be distinguished. The sign between terms is physically relevant.

Bloch representation

Using the fact that the global phase is irrelevant, we can write every qubit as:

|ψ⟩ = cos(ΞΈ/2)|0⟩ + ejΟ† sin(ΞΈ/2)|1⟩
with ΞΈ ∈ [0, Ο€] and Ο† ∈ [0, 2Ο€) β€” two real parameters describe the entire qubit space!
Bloch Sphere β€” every point on the surface is a valid qubit. Drag to rotate.
45Β° 0Β°

Orthogonal state β€” quick trick

Given |ψ⟩ = Ξ±|0⟩ + Ξ²|1⟩, the orthogonal state (⟨ψ|Ο†βŸ© = 0) is always:
|Ο†βŸ© = Ξ²*|0⟩ βˆ’ Ξ±*|1⟩
No need to solve any linear system!
Check:
⟨ψ|Ο†βŸ© = Ξ±*Β·Ξ²* + Ξ²*Β·(βˆ’Ξ±*) = Ξ±*Ξ²* βˆ’ Ξ±*Ξ²* = 0 βœ“
Example:
|+⟩ = (1/√2, 1/√2)α΅€  β†’  orthogonal = (1/√2)Β·|0⟩ βˆ’ (1/√2)Β·|1⟩ = |βˆ’βŸ© βœ“
Ex 2.1Inner product βŸ¨Ο†|ψ⟩

Given |ψ⟩ = (1/√2)|0⟩ + (j/√2)|1⟩  and  |Ο†βŸ© = |1⟩, calculate βŸ¨Ο†|ψ⟩.

Remember: the bra βŸ¨Ο†| = conjugate transpose of |Ο†βŸ©.

βŸ¨Ο†|ψ⟩ =
Ex 2.2Orthogonal state

Find |Ο†βŸ© orthogonal to |ψ⟩ = (1/√2)|0⟩ + (j/√2)|1⟩ using the quick trick.

|Ο†βŸ© = ( , )α΅€
Section 03

Measuring a Qubit

Measuring a qubit in the computational basis {|0⟩, |1⟩} means applying the observable Lz = Z. The quantum circuit is drawn as:

|ψ⟩
M
|0⟩ / |1⟩    "0" / "1"
|ψ⟩ =
α|0⟩ + β|1⟩
P("0") =
|⟨0|ψ⟩|² = |α|²
P("1") =
|⟨1|ψ⟩|² = |β|²
After measurement:
state collapses to |0⟩ (if outcome "0") or |1⟩ (if outcome "1")

Global phase β€” changes nothing

If |ψ'⟩ = ejΟ†|ψ⟩, then:

P("0") = |Ξ±Β·ejΟ†|Β² = |Ξ±|Β²Β·|ejΟ†|Β² = |Ξ±|Β²Β·1 = |Ξ±|²← identical! βœ“

Relative phase β€” changes everything

|+⟩ = (|0⟩+|1⟩)/√2 and |βˆ’βŸ© = (|0βŸ©βˆ’|1⟩)/√2 give the same results when measured in the {|0⟩,|1⟩} basis (P("0")=P("1")=1/2 for both). But they are distinguishable when measured in the {|+⟩,|βˆ’βŸ©} basis!

Measurement simulator β€” click "Measure" to collapse the state. Observe the empirical vs. theoretical distribution.
60Β°
Ex 3.1Measurement probability

Given |ψ⟩ = (√3/2)|0⟩ + (1/2)|1⟩, what is the probability of getting "1"?

P("1") =
Ex 3.2Global vs. relative phase

|ψ⟩ = (1/√2)|0⟩ + (1/√2)|1⟩ and |ψ'⟩ = (1/√2)|0⟩ βˆ’ (1/√2)|1⟩. When measured in the {|0⟩,|1⟩} basis, do they give the same distribution? (yes/no)

Section 04

Transforming a Qubit

Quantum transformations on a qubit are represented by 2Γ—2 unitary matrices. The most important are the Pauli matrices:

identity I
10
01
Pauli X (NOT / Bit-flip)
01
10
Pauli Z (Phase-flip)
10
0βˆ’1
Pauli Y (Bit & Phase flip)
0βˆ’j
j0
The Pauli matrices are both unitary and Hermitian: the same matrix serves as a gate (transformation) and as an observable (measurement).

Effect of each gate

X:
Ξ±|0⟩+Ξ²|1⟩  β†’  Ξ²|0⟩+Ξ±|1⟩    swaps the amplitudes β€” it is the quantum NOT
Z:
Ξ±|0⟩+Ξ²|1⟩  β†’  Ξ±|0βŸ©βˆ’Ξ²|1⟩    flips the sign of the |1⟩ component
Y:
Ξ±|0⟩+Ξ²|1⟩  β†’  jΞ±|1βŸ©βˆ’jΞ²|0⟩ = Ξ²|0βŸ©βˆ’Ξ±|1⟩    bit-flip + phase-flip

Hadamard Gate

Hadamard Gate
H = 1/√2
11
1βˆ’1

H|0⟩ =
|+⟩ = (|0⟩+|1⟩)/√2    transforms a "certain" state into a superposition!
H|1⟩ =
|βˆ’βŸ© = (|0βŸ©βˆ’|1⟩)/√2

Hadamard is fundamental in almost all quantum algorithms for creating superposition. It also has a remarkable property:

HXH = Z   and   HZH = X
Putting H before and after a gate "changes" it to the opposite axis. In formulas:
1/2
11
1βˆ’1
01
10
11
1βˆ’1
=
10
0βˆ’1
= Z βœ“
Ex 4.1Applying gate X

Given |ψ⟩ = (3/5)|0⟩ + (4/5)|1⟩, calculate X|ψ⟩.

X|ψ⟩ = ( )|0⟩ + ( )|1⟩
Ex 4.2Hadamard gate on |1⟩

Calculate H|1⟩. What state do you get? Write the result as a combination of |0⟩ and |1⟩.

H|1⟩ = ( )|0⟩ + ( )|1⟩
Section 05

Quantum Gates β€” Complete Catalogue

Each gate is presented with three pieces of information: the matrix, the visual effect on the Bloch sphere, and how it appears and is used in circuits.

Single-qubit Pauli gates

The three Pauli gates X, Y, Z are both unitary and Hermitian β€” they act as gates (transformations) and as observables (measurements).

X Pauli-X β€” "quantum NOT / bit-flip"
Matrix
01
10
XΒ² = I   eigenvalues: Β±1
Effect on the Bloch sphere
Rotation of 180Β° around the X axis.
β€’ |0⟩ β†’ |1⟩ and |1⟩ β†’ |0⟩: swaps the poles
β€’ |+⟩ β†’ |+⟩ and |βˆ’βŸ© β†’ |βˆ’βŸ©: equator points fixed
The quantum analogue of a classical NOT gate.
In circuits
|0⟩
X
|1⟩
|1⟩
X
|0⟩
Used to initialize a qubit to |1⟩ from |0⟩, and as the target of CNOT gates. Eigenvectors are |+⟩ and |βˆ’βŸ©.
Z Pauli-Z β€” "phase-flip"
Matrix
10
0βˆ’1
ZΒ² = I   eigenvalues: Β±1
Z = S² = T⁴
Effect on the Bloch sphere
Rotation of 180Β° around the Z axis.
β€’ |0⟩ β†’ |0⟩: north pole fixed (eigenvector, Ξ»=+1)
β€’ |1⟩ β†’ βˆ’|1⟩: south pole gains phase βˆ’1 (Ξ»=βˆ’1)
β€’ |+⟩ ↔ |βˆ’βŸ©: swaps the equator states
Diagonal matrix β€” eigenvalues and eigenvectors readable at a glance.
In circuits
|+⟩
Z
|βˆ’βŸ©
Used for phase corrections in teleportation and error correction. Its eigenstates are the computational basis vectors |0⟩ and |1⟩.
Y Pauli-Y β€” "bit-flip + phase-flip"
Matrix
0βˆ’j
j0
YΒ² = I   Y = iXZ
eigenvalues: Β±1
Effect on the Bloch sphere
Rotation of 180Β° around the Y axis.
β€’ |0⟩ β†’ j|1⟩ and |1⟩ β†’ βˆ’j|0⟩
β€’ Combines bit-flip (like X) with phase-flip (like Z)
β€’ Eigenstates: |+j⟩ = (|0⟩+j|1⟩)/√2 (Ξ»=+1) and |βˆ’j⟩ (Ξ»=βˆ’1)
The only Pauli with purely imaginary off-diagonal entries.
In circuits
|ψ⟩
Y
Y|ψ⟩
Appears in error correction (bit+phase errors) and in the decomposition of arbitrary rotations. Equivalent to applying X then Z (up to a global phase).
H Hadamard β€” "the superposition creator"
Matrix
1/√2
11
1βˆ’1
HΒ² = I   HXH = Z   HZH = X
Effect on the Bloch sphere
Rotates 180Β° around the diagonal X+Z axis.
β€’ |0⟩ β†’ |+⟩: the north pole goes to the equator (east)
β€’ |1⟩ β†’ |βˆ’βŸ©: the south pole goes to the equator (west)
β€’ Swaps the Z ↔ X axes on the sphere
Used to create superposition from a classical state.
In circuits
|0⟩
H
|+⟩
|1⟩
H
|βˆ’βŸ©
Appears at the start of almost every quantum algorithm to initialize qubits in superposition. Applied twice it returns to the original state.
S Phase Gate β€” "quarter turn around Z"
Matrix
10
0j
SΒ² = Z
Effect on the Bloch sphere
Rotation of 90Β° around the Z axis.
β€’ |0⟩ β†’ |0⟩: north pole fixed (eigenvector)
β€’ |1⟩ β†’ j|1⟩: south pole gains phase j (≑ 90Β° rotation)
β€’ |+⟩ β†’ |+j⟩: (1,1)/√2 becomes (1,j)/√2
Moves points on the equator a quarter turn eastward.
In circuits
|+⟩
S
|+j⟩
Used to build states with 90Β° relative phase. Applying S twice gives Z. Appears in phase estimation algorithms and in building arbitrary gates.
T Ο€/8 Gate β€” "eighth turn around Z"
Matrix
10
0ejΟ€/4
TΒ² = S   T⁴ = Z   T⁸ = I
Effect on the Bloch sphere
Rotation of 45Β° around the Z axis.
β€’ |0⟩ β†’ |0⟩: north pole fixed
β€’ |1⟩ β†’ ejΟ€/4|1⟩: phase of Ο€/4 (45Β°)
β€’ Half of S, which is half of Z
The "smallest" rotation gate in the Z family.
In circuits
|ψ⟩
T
phase +Ο€/4
It is the most important gate for universality: with T and H any single-qubit gate can be approximated. Appears in the Quantum Fourier Transform and phase estimation algorithms.
Phase hierarchy on Z:
T (45Β°) Γ—2 β†’ S (90Β°) Γ—2 β†’ Z (180Β°) Γ—2 β†’ I (360Β°)
TΒ² = S  Β·  SΒ² = Z  Β·  ZΒ² = I  Β·  T,S,Z act only on the phase of |1⟩, leaving |0⟩ fixed
√X √NOT β€” "half NOT"
Matrix
1/2
1+j1βˆ’j
1βˆ’j1+j
(√X)² = X
Effect on the Bloch sphere
Rotation of 90Β° around the X axis.
β€’ |0⟩ β†’ (|0⟩ βˆ’ j|1⟩)/√2: halfway towards |1⟩
β€’ Applied twice: |0⟩ β†’ X|0⟩ = |1⟩ (complete NOT)
How to do half a NOT β€” the state is "halfway" between |0⟩ and |1⟩.
In circuits
|0⟩
√X
√X
|1⟩
Useful when you want to build a NOT in two separate steps β€” for example to insert an intermediate operation between the two half-NOTs.

Rotation Gates Rx, Ry, Rz

The rotation gates are the continuous version of the Pauli gates: they rotate the state on the Bloch sphere by any angle ΞΈ around a chosen axis.

Rz(ΞΈ) Rotation around Z
Matrix
eβˆ’jΞΈ/20
0ejΞΈ/2
ΞΈ=Ο€/4 β†’ T  |  ΞΈ=Ο€/2 β†’ S  |  ΞΈ=Ο€ β†’ Z
Effect on the Bloch sphere
Rotates the point on the Bloch sphere by ΞΈ degrees around the vertical Z axis.
β€’ Never changes the measurement probability in the Z basis (|Ξ±|Β² and |Ξ²|Β² remain unchanged)
β€’ Only changes the relative phase between |0⟩ and |1⟩
Imagine a globe rotating: latitude unchanged, longitude changes.
In circuits
|ψ⟩
Rz(ΞΈ)
|Οˆβ€²βŸ©
Used to set precise phases. With variable ΞΈ you can perform any rotation around Z.
Rx(ΞΈ) Rotation around X
Matrix
cos ΞΈ/2βˆ’j sin ΞΈ/2
βˆ’j sin ΞΈ/2cos ΞΈ/2
ΞΈ=Ο€ β†’ X (complete NOT)
Effect on the Bloch sphere
Rotates around the horizontal X axis (which passes through |+⟩ and |βˆ’βŸ©).
β€’ ΞΈ=Ο€/2: |0⟩ β†’ (|0⟩ βˆ’ j|1⟩)/√2
β€’ ΞΈ=Ο€: |0⟩ β†’ |1⟩ (i.e. gate X!)
Mixes the |0⟩ and |1⟩ components, changing the measurement probabilities.
In circuits
|ψ⟩
Rx(ΞΈ)
|Οˆβ€²βŸ©
Appears in section 7 to build measurement circuits in arbitrary bases.
Ry(ΞΈ) Rotation around Y β€” "the only one with real elements"
Matrix
cos ΞΈ/2βˆ’sin ΞΈ/2
sin ΞΈ/2cos ΞΈ/2
ΞΈ=Ο€ β†’ Y (up to global phase)
Effect on the Bloch sphere
Rotates around the Y axis (depth).
β€’ ΞΈ=Ο€/2: |0⟩ β†’ (|0⟩+|1⟩)/√2 = |+⟩ (like H but without phases)
β€’ ΞΈ=Ο€: |0⟩ β†’ |1⟩
β€’ It is the only rotation that keeps amplitudes real if you start from a real vector
Used when you want to mix |0⟩ and |1⟩ without introducing complex phases.
In circuits
|ψ⟩
Ry(ΞΈ)
|Οˆβ€²βŸ©
Appears in section 7: to measure in an arbitrary basis, use Z β†’ Ry(Ο€/4) β†’ measure.

Rotation axes β€” visual summary

Each gate rotates the Bloch sphere around a fixed axis. The coloured axis line and circular arrow show exactly which axis and which direction.

Rβ‚“(ΞΈ)
X axis Β· ΞΈ=Ο€ β†’ gate X
Rα΅§(ΞΈ)
Y axis Β· ΞΈ=Ο€/2 β†’ |0βŸ©β†’|+⟩
R_z(ΞΈ)
Z axis Β· ΞΈ=Ο€/2 β†’ S gate
H
X+Z diagonal Β· 180Β°
S
Z axis Β· fixed 90Β°
T
Z axis Β· fixed 45Β°

Interactive: choose a gate

Highlighted axis = rotation axis Β· Circular arrow = direction of rotation
Gate:

Relationships between Paulis

XY =
jZ
ZX =
jY
YZ =
jX

The Paulis "cycle": X β†’ Y β†’ Z β†’ X, with a factor j at each step.
Ex 5.1Check HZH = X

Calculate HZH by multiplying the three matrices (you can do it step by step: first ZH, then HΒ·(ZH)).

Expected result: the matrix X = ((0,1),(1,0)).

ZH[0,0] = ZH[0,1] =
Ex 5.2Gate S on |+⟩

Calculate S|+⟩ where |+⟩ = (1/√2)(1,1)α΅€. Write the result as a vector.

S|+⟩ = (1/√2)( , )α΅€
Section 06

Basis Change

Given two orthonormal bases {|0⟩,|1⟩,...,|Nβˆ’1⟩} and {|vβ‚€βŸ©,|vβ‚βŸ©,...,|vNβˆ’1⟩}, there exists a unitary operator U that maps one basis to the other:

Basis Change Operator
U = Ξ£β‚— |vβ‚—βŸ©βŸ¨β„“|maps |β„“βŸ© β†’ |vβ‚—βŸ©

Example: from {|0⟩,|1⟩} to {|+⟩,|βˆ’βŸ©}

U = |+⟩⟨0| + |βˆ’βŸ©βŸ¨1|

= 1/√2
1
1
(1   0) + 1/√2
1
βˆ’1
(0   1)
= 1/√2
10
10
+ 1/√2
01
0βˆ’1
= 1/√2
11
1βˆ’1
= H βœ“

The Hadamard gate is the basis change from {|0⟩,|1⟩} to {|+⟩,|βˆ’βŸ©}!

Checking that U is unitary

Uα΄΄U = (Ξ£β‚— |β„“βŸ©βŸ¨vβ‚—|)(Ξ£β‚– |vβ‚–βŸ©βŸ¨k|) = Ξ£β‚— Ξ£β‚– |β„“βŸ©βŸ¨vβ‚—|vβ‚–βŸ©βŸ¨k|
Since {|vβ‚–βŸ©} is orthonormal: ⟨vβ‚—|vβ‚–βŸ© = Ξ΄β‚—β‚–
= Ξ£β‚— |β„“βŸ©βŸ¨β„“| = I βœ“

Decomposition in the new basis

Any state |ψ⟩ can be written in the basis {|vβ‚—βŸ©}:   |ψ⟩ = Ξ£β‚— cβ‚—|vβ‚—βŸ©   with   cβ‚— = ⟨vβ‚—|ψ⟩.
The components in the new basis are computed as inner products with the new basis vectors.
Geometric basis change. Move the point to see the components in the {|0⟩,|1⟩} system (black) and {|+⟩,|βˆ’βŸ©} (blue).
Ex 6.1Components in the Hadamard basis

Given |ψ⟩ = |0⟩, write its components in the basis {|+⟩, |βˆ’βŸ©}, i.e. find cβ‚Š and cβ‚‹ such that |0⟩ = cβ‚Š|+⟩ + cβ‚‹|βˆ’βŸ©.

cβ‚Š = cβ‚‹ =
Ex 6.2Basis change matrix

U = H maps |0βŸ©β†’|+⟩ and |1βŸ©β†’|βˆ’βŸ©. Which matrix maps in the opposite direction, i.e. |+βŸ©β†’|0⟩ and |βˆ’βŸ©β†’|1⟩?

Section 07

Measurement in an Arbitrary Basis

In the lab, we can usually only measure in the computational basis {|0⟩,|1⟩}. How do we measure in a different basis, e.g. {|+⟩,|βˆ’βŸ©}?

Strategy: basis change + standard measurement
To measure |ψ⟩ in basis {|vβ‚€βŸ©,|vβ‚βŸ©}:
1. Apply U (which maps |vβ‚—βŸ© β†’ |β„“βŸ©) to obtain |ψ'⟩ = U|ψ⟩
2. Measure |ψ'⟩ in the computational basis {|0⟩,|1⟩}
3. The outcome "β„“" corresponds to result |vβ‚—βŸ© in the original system

Example: measuring in the basis {|+⟩, |βˆ’βŸ©}

Goal:
P(|ψ⟩ è "|+⟩") = |⟨+|ψ⟩|²
Apply:
U = H (which maps |+βŸ©β†’|0⟩, |βˆ’βŸ©β†’|1⟩)
Therefore:
|ψ'⟩ = H|ψ⟩ = |0⟩⟨+|ψ⟩ + |1βŸ©βŸ¨βˆ’|ψ⟩
P("|0⟩" su ψ') =
|⟨0|ψ'⟩|Β² = |⟨0|H|ψ⟩|Β² = |⟨+|ψ⟩|Β² = P("|+⟩" su ψ) βœ“

The circuit is very simple: a single H gate before the measurement:

|ψ⟩
H
M
measurement in {|+⟩,|βˆ’βŸ©}

General case: measuring in the eigenvector basis of L = (Z+X)/√2

From the notes: L = (Z+X)/√2 = H (Hadamard). The eigenvalues are Β±1 (trick: LΒ² = I β†’ Ξ» = Β±1) and the eigenvectors are:

λ₁ = +1:
|uβ‚βŸ© ∝ (1, √2βˆ’1)α΅€  β†’ 
cos Ο€/8
sin Ο€/8
(using tan Ο€/8 = √2βˆ’1)
Ξ»β‚‚ = βˆ’1:
|uβ‚‚βŸ© ∝ (1, βˆ’(√2+1))α΅€  β†’ 
sin Ο€/8
βˆ’cos Ο€/8
(using cot Ο€/8 = √2+1)

Circuit for measuring in the basis {|uβ‚βŸ©, |uβ‚‚βŸ©}

The basis change matrix U = |0⟩⟨u₁| + |1⟩⟨uβ‚‚| turns out to be U = Ry(Ο€/4)Β·Z, so the circuit is:

|ψ⟩
Z
Ry(Ο€/4)
M
measurement in {|uβ‚βŸ©,|uβ‚‚βŸ©}
Data |ψ⟩ =
α|0⟩ + β|1⟩
P(|uβ‚βŸ©) =
|⟨ψ|uβ‚βŸ©|Β² = |Ξ± cos Ο€/8 + Ξ² sin Ο€/8|Β²
Trick LΒ² = I: If a matrix L satisfies LΒ² = I (and L = Lα΄΄), then the eigenvalues are necessarily Β±1 without computing det(Lβˆ’Ξ»I) = 0. Simply: L|u⟩ = Ξ»|u⟩ β†’ LΒ²|u⟩ = λ²|u⟩ = |u⟩ β†’ λ² = 1 β†’ Ξ» = Β±1.
Ex 7.1Measurement in the basis {|+⟩,|βˆ’βŸ©}

Given |ψ⟩ = α|0⟩ + β|1⟩, calculate P("+") = |⟨+|ψ⟩|².

P("+") =
Ex 7.2Eigenvalues of L = X using the trick LΒ² = I

Check that XΒ² = I, then use this to immediately conclude the eigenvalues of X.

Eigenvalues of X: e
Section 08

Tricks & Summary

Trick 1 β€” LΒ² = I implies eigenvalues Β±1
If L is Hermitian and LΒ² = I, then Ξ» = Β±1 without any calculation. Works for X, Y, Z, H and any unitary combination of Paulis.
Trick 2 β€” HXH = Z and HZH = X
H "swaps" the X and Z axes of the Bloch sphere. Use it to transform a problem with X into one with Z (easier because Z is diagonal).
Trick 3 β€” Global phase: always ignore it
If you have ejΟ†|ψ⟩ in front of something, immediately drop the ejΟ† factor β€” it does not change any probability and greatly simplifies the calculation.
Trick 4 β€” Orthogonal state: Ξ²*|0⟩ βˆ’ Ξ±*|1⟩
Given Ξ±|0⟩ + Ξ²|1⟩, the orthogonal state is Ξ²*|0⟩ βˆ’ Ξ±*|1⟩. No system to solve.
Trick 5 β€” Measuring in basis {|vβ‚€βŸ©,|vβ‚βŸ©} = H + measurement in {|0⟩,|1⟩} (with H = basis change)
Build the matrix U = Ξ£β‚— |β„“βŸ©βŸ¨vβ‚—|, apply it before the standard measurement. For {|+⟩,|βˆ’βŸ©} a single H gate suffices.
Trick 6 β€” TΒ² = S, SΒ² = Z, ZΒ² = I
The phase gate hierarchy. Useful for simplifying gate sequences: SΒ·S = Z, TΒ·T = S, etc.

Summary table of gates

GateMatrixEffect on Ξ±|0⟩+Ξ²|1⟩ X((0,1),(1,0))β†’ Ξ²|0⟩+Ξ±|1⟩ (bit-flip) Z((1,0),(0,βˆ’1))β†’ Ξ±|0βŸ©βˆ’Ξ²|1⟩ (phase-flip) Y((0,βˆ’j),(j,0))β†’ Ξ²|0βŸ©βˆ’Ξ±|1⟩ (bit+phase flip) H1/√2Β·((1,1),(1,βˆ’1))|0βŸ©β†”|+⟩, |1βŸ©β†”|βˆ’βŸ© S((1,0),(0,j))β†’ Ξ±|0⟩+jΞ²|1⟩ T((1,0),(0,ejΟ€/4))β†’ Ξ±|0⟩+ejΟ€/4Ξ²|1⟩