Skip to main content

Quantum core · institution-dependent · Interactive lesson

The Fock basis and operators as matrices

Once |n⟩ is generated by a†, every oscillator operator becomes a band built from √n's you can type straight into NumPy without evaluating a single Hermite integral. The price is the last row: truncate the ladder and the matrix stops obeying the algebra that built it.

UPV-07.05 · Lesson 5 of 9 in this unit. Position is not a completion score.
Starting model: The Fock basis and operators as matricesDiagonal entries ⟨n|x²|n⟩ in units of x_zpf² = ħ/2mω. The dashed line marks the exact 2n + 1, with a ring on it at the selected level; bars and the filled dot are what the N × N truncated matrix product returns. With N = 4 kept, level n = 3 returns 3 where the operator itself gives 7.⟨n|x²|n⟩ ÷ xzpf² ring + line: exact 2n + 1bars: the N×N product, N = 4 keptexact through n = 2n = 0n = 6
Start with a picture. Change the model in the lab below.

Quantum core · institution-dependent. Your university determines the required depth of these quantum topics, including the use of operators, differential equations and computation. Institution-dependent does not automatically mean optional.

1

Build the model

Every ladder matrix element is a square root of an integer — and truncation breaks the top row.

The key idea

The Fock basis is the orthonormal set of number eigenvectors |0⟩, |1⟩, |2⟩, … generated by applying a† to the vacuum, in which every oscillator operator is stored as an array of matrix elements ⟨m|O|n⟩ rather than as a differential operator.

Example. In it a is strictly upper triangular with √1, √2, √3 on the first superdiagonal, so the 4×4 block of x/xzpf has rows (0, 1, 0, 0), (1, 0, 1.414, 0), (0, 1.414, 0, 1.732), (0, 0, 1.732, 0).

The complete physical model and assumptions

The ladder hands you a basis for free. Starting from the one vector killed by a, repeated raising generates |n⟩ = (a†)ⁿ|0⟩/√(n!), and because each rung is an eigenvector of the Hermitian number operator a†a with a distinct eigenvalue, the set is automatically orthonormal — no Gram–Schmidt, no Gaussian integrals. In that basis every question about the oscillator becomes matrix bookkeeping: ⟨m|a|n⟩ = √n δ(m, n−1) puts a on the first superdiagonal, a† on the first subdiagonal, H = ħω(a†a + ½) on the diagonal, and x and p become tridiagonal combinations with zero diagonal. Products inherit bands rather than filling in — x² and p² are pentadiagonal, x⁴ spans nine diagonals — and the width of the band is a selection rule you can read off by eye. What it costs is that the space is infinite and your array is not. Truncating to N states replaces the identity by a projector P, and (PAP)(PBP) is not P(AB)P: the commutator picks up a defect −N|N−1⟩⟨N−1|, and ⟨N−1|x²|N−1⟩ comes out (N−1)xzpf² instead of (2N−1)xzpf². The matrix is the operator only well below the top of the basis, which is a convergence test to run, not an assumption to make.

1The basis generates itself from a|0⟩ = 0

Start from the one vector annihilated by a and let a† do the rest. The coefficient is not a convention pulled from nowhere: ‖a†|n⟩‖² = ⟨n|aa†|n⟩ = ⟨n|(a†a + 1)|n⟩ = n + 1, so a†|n⟩ = √(n+1)|n+1⟩ once the phase is chosen real and positive. Likewise ‖a|n⟩‖² = ⟨n|a†a|n⟩ = n gives a|n⟩ = √n|n−1⟩, and at n = 0 that returns the zero vector, which is what closes the ladder from below. Iterating the raising rule accumulates the product √1⋅√2⋅…⋅√n, so (a†)ⁿ|0⟩ = √(n!)|n⟩ and |n⟩ = (a†)ⁿ|0⟩/√(n!). Orthogonality is then free: a†a is Hermitian and its eigenvalues are distinct integers, so ⟨m|n⟩ = δ(m, n) without a single Gaussian integral being done. What the algebra does not supply is that each rung is one-dimensional; non-degeneracy is a separate input, and it is what lets the single label n name a basis vector.

2Matrix multiplication is the completeness relation

An operator becomes a matrix the moment you write Oₘₙ = ⟨m|O|n⟩, row m and column n. For a, the delta δ(m, n−1) kills everything except the first superdiagonal, whose entries are √1, √2, √3, …; a† is its transpose, on the first subdiagonal. In a four-state block a has rows (0, 1, 0, 0), (0, 0, √2, 0), (0, 0, 0, √3), (0, 0, 0, 0) — strictly upper triangular, hence nilpotent, so a⁴ = 0 there. That nilpotency is the truncation talking, not the operator. Meanwhile H = ħω(a†a + ½) is diagonal with entries ħω(n + ½), so the eigenvalue problem is already solved in this basis and nothing needs diagonalising. The reason products of matrices compute products of operators is completeness: ⟨m|AB|n⟩ = Σₖ ⟨m|A|k⟩⟨k|B|n⟩ is the insertion of 1 = Σₖ |k⟩⟨k| written as a row-times-column sum. Hold on to that identity — it is exactly the step a truncation breaks.

3x and p are one band wide, and that is a selection rule

Inverting a = √(mω/2ħ)(x + ip/mω) gives x = xzpf(a + a†) and p = i√(mħω/2)(a† − a), with xzpf = √(ħ/2mω). Both are tridiagonal with a zero diagonal: ⟨n|x|n⟩ = 0 in every Fock state, so no stationary state of the oscillator sits off centre, and the only surviving elements are ⟨n+1|x|n⟩ = √(n+1) xzpf and ⟨n−1|x|n⟩ = √n xzpf. One band means Δn = ±1, which is the dipole selection rule: a strictly harmonic mode absorbs at ω and nowhere else. Put numbers on it. The CO stretch at 2143 cm⁻¹ has ω = 4.04 × 10¹⁴ rad s⁻¹ and reduced mass μ = 1.138 × 10⁻²⁶ kg, so xzpf = 3.39 pm — about 3% of the 113 pm bond. Then ⟨1|x|0⟩ = 3.39 pm and ⟨2|x|1⟩ = √2 × 3.39 = 4.79 pm, while ⟨2|x|0⟩ = 0 exactly, which is why the overtone stays dark until anharmonicity or a quadratic dipole term supplies it.

4Products widen the band; sparsity is what you buy

Squaring keeps the structure but doubles the reach. x² = xzpf²(a² + a†² + 2a†a + 1) is pentadiagonal: a diagonal ⟨n|x²|n⟩ = xzpf²(2n + 1), which hands you ⟨x²⟩ = (ħ/mω)(n + ½) and, with the matching p² result, the uncertainty product ΔxΔp = (n + ½)ħ by counting rather than integrating; plus a Δn = ±2 band with entries xzpf²√((n+1)(n+2)), the route by which a dipole or polarisability quadratic in x reaches the Δn = 2 overtone. Four factors reach further still: x⁴ spans nine diagonals, of which only the five at Δn = 0, ±2, ±4 are non-zero. Bandwidth is the point. An anharmonic Hamiltonian H = ħω(a†a + ½) + λx⁴ is banded, not full, so storing it costs O(N) and scipy.sparse.linalg.eigsh can extract the lowest levels without touching the rest. But banded is still not diagonal: with ε = λxzpf⁴/ħω the first-order spacing becomes ħω[1 + 12ε(n + 1)], a drift no ħω(a†a + ½) can imitate.

5Truncation: where the matrix stops being the operator

Your array has N rows; the space does not. Keeping n = 0 … N−1 replaces the identity by the projector P = Σ |n⟩⟨n| over kept rungs, and multiplying two truncated matrices evaluates PAPBP, not P(AB)P. The difference is PA(1−P)BP, which bites whenever B can carry a kept state out of the retained space and A can bring it back. Two symptoms, both exact and both checkable. The commutator loses a whole rung in one corner: [a, a†] built from N × N matrices equals 1 − N|N−1⟩⟨N−1|, so its last diagonal entry is −(N−1), not +1 — at N = 4 the diagonal reads (1, 1, 1, −3). And ⟨N−1|x²|N−1⟩ comes out (N−1)xzpf² where the operator gives (2N−1)xzpf²; at N = 4 that is 3xzpf² against 7xzpf², low by 57%. The counting rule is simple: a product of k ladder factors returning to level n passes through intermediates as high as n + ⌈k/2⌉, so the entry is exact only when N ≥ n + ⌈k/2⌉ + 1. For x² that reads N ≥ n + 2; for x⁴, N ≥ n + 3.

6Building it in NumPy, and the tests it must pass

Four lines: a = np.diag(np.√(np.arange(1, N)), 1), then ad = a.T, x = xzpf*(a + ad), H = ℏ*w*(ad @ a + 0.5*np.eye(N)). Everything else is a matrix product. Then test rather than assume. First, np.allclose(a @ ad - ad @ a, np.eye(N)) will fail, and it should: check instead that the identity holds on the leading (N−1)×(N−1) block and that the last entry is −(N−1). Second, np.linalg.eigvalsh(H) must return ħω(n + ½) to machine precision, since H is already diagonal — that only checks your indexing, nothing physical. Third, the test that matters: double N and keep only the levels whose eigenvalues move by less than your tolerance; for a quartic term at ε = 0.002 the lowest six settle at N of a few tens, not at N = 8. Finally, cross-check against a real-space grid diagonalisation. Both methods degrade high on the ladder but for unrelated reasons — a finite box and a coarse mesh there, a missing top rung here — so agreement between them is evidence, while agreement of one method with itself is not.

2

Key equations

Read the units, assumptions and limits before substituting.

Ladder action and its norms

a|n⟩ = √n |n−1⟩, a†|n⟩ = √(n+1) |n+1⟩

The root comes from a norm: ‖a†|n⟩‖² = ⟨n|(a†a + 1)|n⟩ = n + 1.

n = 0, 1, 2, …; both coefficients are pure numbers; a|0⟩ = 0 closes the ladder from below

Fock state built from the vacuum

|n⟩ = (a†)ⁿ |0⟩ / √(n!)

Normalisation with no integral: every Fock state is fixed by the vacuum and a power of a†.

√(n!) is the running product √1⋅√2⋅…⋅√n picked up by n successive raisings

Matrix elements and where the bands sit

⟨m|a|n⟩ = √n δ(m, n−1), ⟨m|a†|n⟩ = √(n+1) δ(m, n+1)

In NumPy this is one line: a = np.diag(np.√(np.arange(1, N)), 1).

row m, column n: a is the first superdiagonal, a† the first subdiagonal, both with zero diagonal

x and p as tridiagonal matrices

x = xzpf (a + a†), p = i √(mħω/2) (a† − a), xzpf = √(ħ/2mω)

Zero diagonal means ⟨n|x|n⟩ = 0; one band means Δn = ±1, the dipole selection rule.

xzpf = √(ħ/2mω) in m, the momentum scale √(mħω/2) in kg m s⁻¹; both are tridiagonal

Squares are pentadiagonal

x² = xzpf²(a² + a†² + 2a†a + 1) → ⟨n|x²|n⟩ = (2n + 1) xzpf²

Delivers ⟨x²⟩ and ΔxΔp = (n + ½)ħ by counting, plus the Δn = ±2 overtone band.

bands at Δn = 0 and ±2, with ⟨n+2|x²|n⟩ = xzpf²√((n+1)(n+2))

What an N-state truncation breaks

[a, a†]N = 1 − N |N−1⟩⟨N−1|

Why ⟨N−1|x²|N−1⟩ returns (N − 1)xzpf² instead of (2N − 1)xzpf²: never trust the top rungs.

N × N truncation; the defect sits only in the bottom-right corner and grows with N
3

Interactive lab

Predict first. Explore the model. Compare the result.

Explore the model

4 states
2 to 7 states; steps of 1.
3
0 to 6; steps of 1.

Try this. Set N = 4 and read n = 3: the bar stops at 3 where the operator says 7, because the rung to |4⟩ that x² needs is not in the space. Every bar below it is exact. Raise N and the short bar just moves to the new top row — truncation error never spreads downward.

Live results

EXACT 2n + 1
7 xzpf²
N×N MATRIX PRODUCT
3 xzpf²
SHORTFALL
57 %
TOP EXACT LEVEL
2

Results follow this lesson’s model and assumptions. Displayed values are rounded.

Interactive Physics V modelDiagonal entries ⟨n|x²|n⟩ in units of x_zpf² = ħ/2mω. The dashed line marks the exact 2n + 1, with a ring on it at the selected level; bars and the filled dot are what the N × N truncated matrix product returns. With N = 4 kept, level n = 3 returns 3 where the operator itself gives 7.⟨n|x²|n⟩ ÷ xzpf² ring + line: exact 2n + 1bars: the N×N product, N = 4 keptexact through n = 2n = 0n = 6
Diagonal entries ⟨n|x²|n⟩ in units of xzpf² = ħ/2mω. The dashed line marks the exact 2n + 1, with a ring on it at the selected level; bars and the filled dot are what the N × N truncated matrix product returns. With N = 4 kept, level n = 3 returns 3 where the operator itself gives 7.

Predict → change one variable → check

Plan a change before running it. Every other input stays at the saved baseline.

Saved baseline. Fock states kept N: 4 states; Level read off n: 3

Baseline 4; choose 2 to 7, in steps of 1.
4. Compared with the saved baseline, this result will…

This experiment is kept only while this page is open. It does not change saved course progress.

4

Catch the common trap

The tempting error is to reason that because a and a† are represented exactly — every entry is a √n, with no approximation anywhere — anything built from them must be exact too. It is not, and the reason is not rounding. Truncating to N states replaces the identity 1 = Σₖ |k⟩⟨k| by the projector P over the kept rungs, and multiplying two truncated matrices evaluates PAPBP rather than P(AB)P. The dropped piece is PA(1−P)BP, which is non-zero exactly when B can carry a kept state out of the retained space and A can bring it back. That is why a 4×4 X² carries 3 in its bottom corner where the operator carries 7, and why [a, a†] reads −(N−1) instead of 1 in the same slot: the individual matrices are exact, and their product is not.

5

Practice & worked examples

3 authored examples. Make an attempt, then reveal the reasoning one step at a time.

EasyExample 1

Using only a|n⟩ = √n |n−1⟩ and a†|n⟩ = √(n+1) |n+1⟩, evaluate a†a|2⟩ and aa†|2⟩, confirm that [a, a†]|2⟩ = |2⟩, and find the matrix element ⟨4|(a†)²|2⟩.

Sketch your answer or reasoning, then compare it with the authored solution. Your writing is not automatically graded or saved.

0 of 5 steps revealed.

MediumExample 2

Keep four Fock states (n = 0…3) and write X = x/xzpf = a + a† as a 4×4 matrix. Form X² by matrix multiplication, then compare its diagonal and its Δn = 2 band with the exact ⟨n|x²|n⟩ = (2n + 1) xzpf² and ⟨n+2|x²|n⟩ = √((n+1)(n+2)) xzpf².

Sketch your answer or reasoning, then compare it with the authored solution. Your writing is not automatically graded or saved.

0 of 6 steps revealed.

HardExample 3

A mode is modelled as H = ħω(a†a + ½) + λx⁴ with x = xzpf(a + a†), and ε = λxzpf⁴/ħω = 0.002. Name the bands of x⁴, give ⟨n|x⁴|n⟩, then find the first-order E₀ and E₅, the spacings E₁ − E₀ and E₅ − E₄, and the smallest truncation N for which ⟨5|x⁴|5⟩ comes out exact.

Sketch your answer or reasoning, then compare it with the authored solution. Your writing is not automatically graded or saved.

0 of 6 steps revealed.

6

Quick check

Select an answer and explain it before checking.

You keep four Fock states (n = 0…3) and build X = a + a† as a 4×4 matrix in units of xzpf, then form X² by matrix multiplication. Set against the operator's own ⟨n|x²|n⟩ = (2n + 1) xzpf², what does the diagonal of that product read?
7

Review & continue

The Fock basis is the orthonormal set of number eigenvectors |0⟩, |1⟩, |2⟩, … generated by applying a† to the vacuum, in which every oscillator operator is stored as an array of matrix elements ⟨m|O|n⟩ rather than as a differential operator.

  • Explain the relationship without looking at the equation.
  • Check a sign, a unit and a model assumption in your working.
  • Return to the lab or worked example if a step is still unclear.

Extra challenging questions

Connect several ideas, explore supplied data, and compare your reasoning with a worked solution.