University Physics V · Particle in a Box · 5.5
Observables as Matrices in the Energy Basis
The box hands you an orthonormal basis for nothing, so use it. Every observable becomes a matrix NumPy can hold: H diagonal, x and p checkerboards whose only surviving entries have m - n odd. The craft is knowing which entries vanish before you integrate, and what breaks when you cut the array off at N.
Build the model
Connect the measurement to the mechanism.
Once the Dirichlet problem is solved, the sine functions |n⟩ = √(2/L) sin(n π x/L) are an orthonormal basis of L²([0, L]) and Σₙ |n⟩⟨n| = 1. Slide that identity in on either side of any operator and the operator becomes an array: A = Σₘₙ |m⟩ Aₘₙ ⟨n| with Aₘₙ = ⟨m|A|n⟩. Nothing has been approximated; this is the same operator written in a different alphabet.
The alphabet was chosen so that H comes out diagonal, Hₘₙ = Eₙ δₘₙ, and that is the whole point of it, because exp(−iHt/ℏ) is then diagonal too and evolution is a phase on each coefficient. But an operator is diagonal in the energy basis only if it commutes with H, and neither x nor p does. Their matrices are checkerboards fixed by the parity of ψₙ about the midpoint: ⟨m|x|n⟩ = −8Lmn/(π² (m² - n²)²) when m - n is odd, and exactly zero when it is even.
The cost arrives the moment you truncate to an N by N array. Truncation is a projector, projectors do not commute with x or p, and so the product of two truncated matrices is not the truncation of the product: p² is exactly diagonal here, yet squaring the 3 by 3 truncation of p returns 72% of its (1,1) entry and invents a (1,3) entry where the true value is zero. Sum rules are how you catch that before it ruins an answer.
- Simple definition
- A matrix representation of an observable is the array of numbers Aₘₙ = ⟨m|A|n⟩ taken in some orthonormal basis; in the box that basis is the energy eigenstates, and the array carries every prediction the operator can make.
- Example
- For a box of width L = 0.800 nm, ⟨2|x|2⟩ = L/2 = 0.400 nm, ⟨1|x|2⟩ = −16L/(9 π²) = −0.144 nm, and ⟨1|x|3⟩ = 0 exactly, because 3 - 1 is even.
Two indices and one integral turn an operator into an array you can hand to numpy.linalg.
m and n run over 1, 2, 3, ...; Aₘₙ carries whatever unit A carries
A is diagonal in this basis if and only if [A, H] = 0, which is exactly why x and p are not.
M is the particle mass and L the wall separation; Eₙ in joules
Parity settles half the matrix before any integral, and it is why the box absorbs only when m - n is odd.
zero for every m ≠ n with m - n even; xₘₙ in metres
p = (i M/ℏ)[H, x] builds the whole momentum matrix from the position matrix and the spectrum: no second integral.
m - n odd, else zero; pₙₙ = 0 always; units kg m s⁻¹
((P₃)²)₁₁ = 64/9 ℏ²/L² is 72% of π² ℏ²/L², and ((P₃)²)₁₃ = −12.8 ℏ²/L² where p² has a clean zero.
V = 0 inside, so p² = 2MH exactly; PN is p cut to N by N
Row 1 of x is 99.99% complete by N = 4, while the same test on p is still 0.8% short at N = 100.
n = 1 gives 0.28267 L²; both sides in m²
Insert the identity and the operator becomes an array
Completeness licenses the whole move. The sine states satisfy Σₙ |n⟩⟨n|= 1, so A = 1 A 1 = Σₘₙ |m⟩ ⟨m|A|n⟩ ⟨n|, and a Hermitian operator is completely specified by the numbers Aₘₙ = ⟨m|A|n⟩, subject to Aₘₙ = Aₙₘ*. The basis was chosen to diagonalise H, so Hₘₙ = Eₙ δₘₙ with Eₙ = n² π² ℏ²/(2 M L²). That is the free lunch and the reason for the basis: exp(−iHt/ℏ) is diagonal too, so evolution is cₙ(t) = cₙ(0) exp(−i Eₙ t/ℏ), one phase per coefficient. Everything else costs an integral. The criterion for a second free lunch is exact, and worth stating as a rule: A is diagonal in the energy basis if and only if [A, H] = 0. Since [x, H] = i ℏ p/M is not zero, x cannot be diagonal here. The off-diagonal entries you are about to compute are not clutter, they are the statement that position and energy are incompatible.
Parity does the integral before you do
Move the origin to the centre and set u = x - L/2. Then ψₙ has parity (−1)(n+1) in u: odd n gives an even function, even n an odd one. The operator u is odd, so ⟨m|u|n⟩ vanishes unless ψₘ ψₙ is odd, which happens only when m - n is odd. That single argument kills half the matrix with no integration at all. ⟨1|x|3⟩, ⟨2|x|4⟩ and ⟨1|x|5⟩ are exactly zero, while the diagonal is ⟨n|x|n⟩ = L/2 by symmetry alone. For the surviving entries the integral gives xₘₙ = −8Lmn/(π² (m² - n²)²). In units of L that is x₁₂ = −0.18013, x₂₃ = −0.19454 and x₃₄ = −0.19851 next to the diagonal, but only x₁₄ = −0.014410 two steps out: the squared denominator makes distant entries fall like 1/m³, so the position matrix is strongly band-dominated. The shared sign is a phase convention rather than physics, since replacing |2⟩ by -|2⟩ flips x₁₂ with it. Only |xₘₙ|² is measurable.
Take p from the commutator, not from a second integral
For any H = p²/2M + V(x) the identity p = (i M/ℏ)[H, x] is exact. Sandwich it between energy eigenstates and the commutator collapses to a number, because H acts on its own eigenvectors: pₘₙ = i M (Eₘ - Eₙ) xₘₙ/ℏ. The momentum matrix therefore falls out of the position matrix and the spectrum, with no new integration. Putting in Eₘ - Eₙ = π² ℏ² (m² - n²)/(2 M L²) gives pₘₙ = −4 i ℏ m n/(L (m² - n²)) for m - n odd and zero otherwise. Three checks pay for themselves. The entries are purely imaginary and antisymmetric in their indices, so pₘₙ = pₙₘ* and the matrix is Hermitian. Every diagonal entry vanishes, so ⟨p⟩ = 0 in each stationary state, as it must be for a real bound eigenfunction. And the fall-off is only 1/m, because the factor Eₘ - Eₙ grows like m² and cancels one power of the denominator. In units of ℏ/L the near-diagonal entries are p₁₂ = 2.667i, p₂₃ = 4.800i, p₃₄ = 6.857i: they grow, they do not decay.
Truncation is a projector, and projectors do not commute
To compute, you keep N rows and columns, so A becomes ΠN A ΠN. That is harmless for one operator and wrong for a product, because ΠN A B ΠN equals ΠN A ΠN B ΠN only when ΠN commutes with A or with B. The resolution of the identity you inserted between the two factors was truncated along with everything else. The box supplies a clean test case. Inside the walls V = 0, so p² = 2MH is exactly diagonal, (p²)ₘₙ = (n π ℏ/L)² δₘₙ. Now truncate p to 3 by 3. In units of ℏ/L only p₁₂ = 2.667i and p₂₃ = 4.800i survive, so ((P₃)²)₁₁ = |p₁₂|² = 64/9 = 7.111 against the exact π² = 9.870, just 72% of it. Worse, ((P₃)²)₁₃ = p₁₂ p₂₃ = −12.8, where the true p² has a clean zero: the columns m = 4, 6, 8, ... whose contributions cancel that term were thrown away. Widening to N = 9 lifts the (1,1) entry only to 8.977 and drags the spurious (1,3) entry to −2.771.
Sum rules tell you whether N was large enough
Completeness also hands you a test you can run without knowing the answer: Σₘ |Aₘₙ|² = ⟨n|A-dagger A|n⟩. For position that reads Σₘ |xₘₙ|² = ⟨n|x²|n⟩ = L² (1/3 - 1/(2 n² π²)), which is 0.282673 L² in the ground row. Add the terms up. The diagonal alone gives 0.250000 L², or 88.4%; m = 2 lifts it to 0.282446, or 99.92%; m = 3 adds nothing at all because 3 - 1 is even; and m = 4 reaches 0.282653, or 99.993%. Four columns are already better than a part in ten thousand. Run the same test on momentum and the verdict reverses. Σₘ |pₘₙ|² = 2 M Eₙ = (n π ℏ/L)², and in the ground row the partial sums reach 72.1% at N = 2, 92.6% at N = 10, 99.20% at N = 100 and still only 99.92% at N = 1000, because |p₁m|² falls like 16 ℏ²/(L² m²) while |x₁m|² falls like 1/m6. A truncated basis is a fine place to compute ⟨x⟩ and a poor place to compute ⟨p²⟩. Take that one from H.
What no finite matrix can ever do
[x, p] = i ℏ has no finite-dimensional solution, and the box shows why in one line: the trace of a commutator of finite matrices is tr(XP) - tr(PX) = 0, while tr(i ℏ IN) = i N ℏ. A truncated pair must therefore fail the canonical commutation relation, and it is worth seeing where. At N = 3 the diagonal of [X₃, P₃] in units of i ℏ is 0.9607, 0.9069, −1.8676: the first entry is already within 4% of the exact 1 and the second within 10%, while the whole deficit is dumped into the last kept row so that the trace comes out exactly zero. At N = 9 the (1,1) entry has climbed to 0.9985 and the last entry has fallen to −7.08. The working rule is to trust the top-left corner of a truncated array, never the last few rows, and to quote no number that leans on them. Diagonalising the truncated x is the same story with a happier ending: the eigenvalues of X₃ are 0.235L, 0.500L and 0.765L, a coarse quadrature grid inside the well, and X₈ gives eight nearly evenly spaced nodes from 0.101L to 0.899L.
Change one variable at a time
Make the relationship visible.
Hold the cut at 5 and sweep n: the zero bars change parity, the L/2 diagonal spike walks along the row, and the p bars grow while the x bars shrink. Now pull the cut back to 2 at n = 4 and you have deleted the largest momentum element in the row.
Eₙ / E₁4
|x| at m = n+10.1945 L
|p| at m = n+14.800 ℏ/L
row sum rule for x²0.3207 L²
Live interpretationEₙ / E₁: 4. |x| at m = n+1: 0.1945 L. |p| at m = n+1: 4.800 ℏ/L. row sum rule for x²: 0.3207 L²
Catch the common trap
Explain before calculating.
Inside the box V = 0, so p² = 2MH is exactly diagonal in the energy basis, with (p²)₁₁ = π² ℏ²/L² = 9.87 ℏ²/L2. You truncate p to the 3 by 3 matrix P₃ and square that matrix. What is the (1,1) entry of (P₃)²?
Choose an answer to test the model.
Practice & worked examples
Reason from the model, then test the result.
EasyA particle sits in an infinite square well of width L = 0.800 nm. Without integrating, say which of ⟨1|x|3⟩, ⟨2|x|4⟩, ⟨1|x|2⟩ and ⟨2|x|5⟩ are zero, then evaluate the two that are not.
- Shift the origin to the midpoint. There ψₙ has parity (−1)(n+1), so ψₘ ψₙ is even whenever m - n is even, while x - L/2 is odd. Every element with m - n even therefore collapses to (L/2) δₘₙ.
- ⟨1|x|3⟩ and ⟨2|x|4⟩ both have m - n = 2, so both are exactly zero and no integral is needed to say so.
- ⟨1|x|2⟩ and ⟨2|x|5⟩ have m - n odd, so use xₘₙ = −8Lmn/(π² (m² - n²)²).
- ⟨1|x|2⟩ = −8(0.800 nm)(1)(2)/(π² (1 - 4)²) = −12.8/(9 π²) nm = −12.8/88.83 nm = −0.1441 nm.
- ⟨2|x|5⟩ = −8(0.800 nm)(2)(5)/(π² (4 - 25)²) = −64/(441 π²) nm = −64/4352.5 nm = −0.01470 nm.
Answer⟨1|x|3⟩ = ⟨2|x|4⟩ = 0 by parity; ⟨1|x|2⟩ = −0.1441 nm and ⟨2|x|5⟩ = −0.01470 nm. An element one step off the diagonal is about ten times one three steps off, which is the 1/m³ fall-off at work.
MediumTest the truncation of the position matrix. For the ground row n = 1, sum |x₁m|² over the first four columns and compare it with the exact ⟨1|x²|1⟩ = L² (1/3 - 1/(2 π²)). Then say how the same test goes for momentum.
- Row 1 of x in units of L: x₁₁ = 0.500000, x₁₂ = −16/(9 π²) = −0.180127, x₁₃ = 0 because 3 - 1 is even, and x₁₄ = −32/(225 π²) = −0.014410.
- Square them, in units of L²: 0.250000, 0.032446, 0, 0.000208.
- Partial sum over four columns, carrying full precision through the addition: 0.282653 L2.
- Exact value: L² (1/3 - 1/(2 π²)) = L² (0.333333 - 0.050661) = 0.282673 L², so the four-column sum captures 99.993% of it.
- The momentum sum rule is Σₘ |p₁m|² = (π ℏ/L)² = 9.8696 ℏ²/L², but the m = 2 term alone is (8/3)² = 7.1111, only 72.1% of it, and |p₁m|² falls like 1/m² rather than like 1/m6.
- Partial sums for p reach 92.6% at N = 10, 99.20% at N = 100 and 99.92% at N = 1000.
Answer0.282653 L² against the exact 0.282673 L²: four columns capture 99.993% of the x sum rule. Momentum would need N of order 10⁴ for the same accuracy, which is why ⟨p²⟩ should be read off H rather than off a truncated p.
HardShow that no truncated pair of matrices can satisfy [x, p] = i ℏ. Compute the diagonal of [X₃, P₃] in units of i ℏ and take its trace.
- x is real and symmetric, xcn = xnc, while p is purely imaginary and antisymmetric, pnc = −pcn. So ([X, P])ₙₙ = Σc (xnc pcn - pnc xcn) = 2 Σc xnc pcn.
- Inside a 3 by 3 block the m - n odd rule leaves one term for n = 1 (c = 2), two for n = 2 (c = 1 and c = 3) and one for n = 3 (c = 2).
- n = 1: 2 x₁₂ p₂₁ = 2 (−16L/(9 π²))(−8 i ℏ/(3L)) = 256 i ℏ/(27 π²) = 0.9607 i ℏ.
- n = 2: 2 x₂₁ p₁₂ + 2 x₂₃ p₃₂ = −256 i ℏ/(27 π²) + 2304 i ℏ/(125 π²) = (−0.9607 + 1.8676) i ℏ = 0.9069 i ℏ.
- n = 3: 2 x₃₂ p₂₃ = −2304 i ℏ/(125 π²) = −1.8676 i ℏ.
- Trace: 0.9607 + 0.9069 - 1.8676 = 0 exactly, whereas tr(i ℏ I₃) = 3 i ℏ. Any finite commutator is traceless, so the canonical relation cannot hold.
AnswerThe diagonal is (0.9607, 0.9069, −1.8676) i ℏ and the trace is exactly 0, against 3 i ℏ for i ℏ I₃. At N = 9 the (1,1) entry has reached 0.9985 i ℏ while the last row has sunk to −7.08 i ℏ.