Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Operators 1: Matrices and Dirac Notation

The rules of the game

This lecture and the next three complete the short list of rules, the postulates, from which all of quantum mechanics follows. Two of them we have already met.

PostulateLecture
1The state of a system is a wavefunction ψ\psi, and ∣ψ∣2\lvert\psi\rvert^2 is the probability densityThe Schrödinger Equation
2Every observable is represented by a linear Hermitian operator A^\hat{A}this lecture and Operators 2
3A measurement of AA returns one of the eigenvalues ana_n of A^\hat{A} and leaves the system in its eigenfunction ϕn\phi_nMeasurement
4The outcome ana_n has probability ∣⟨ϕn∣ψ⟩∣2\lvert\langle \phi_n \vert \psi\rangle\rvert^2, so the average is ⟨A⟩=⟨ψ∣A^∣ψ⟩\langle A\rangle = \langle \psi \vert \hat{A} \vert \psi \rangleMeasurement
5The state evolves by iℏ ∂Ψ/∂t=H^Ψi\hbar\,\partial\Psi/\partial t = \hat{H}\PsiThe Schrödinger Equation, Time Dependence

Operators act on functions

Linear operators

Matrices act on vectors

The linear operators you already know are matrices. Before turning functions into vectors, here is what a matrix does to an ordinary arrow in the plane. Vectors and Linear Algebra in Appendix A has more.

A(10)=(2⋅1+1⋅01⋅1+2⋅0)=(21),A(11)=(33)=3(11)A\begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 2\cdot 1 + 1\cdot 0 \\ 1\cdot 1 + 2\cdot 0 \end{pmatrix} = \begin{pmatrix} 2 \\ 1 \end{pmatrix}, \qquad A\begin{pmatrix} 1 \\ 1 \end{pmatrix} = \begin{pmatrix} 3 \\ 3 \end{pmatrix} = 3\begin{pmatrix} 1 \\ 1 \end{pmatrix}

Fig. The matrix AA turns a generic arrow (left) but only stretches its eigenvectors (right): (1,1)(1, 1) by a factor 3 and (1,−1)(1, -1) by a factor 1.

Try it: drag anywhere on the plane to aim the unit arrow v\mathbf{v} and watch AvA\mathbf{v}. Most directions come out turned. Hunt for the two directions that are only stretched; the widget marks each one you find. Sweep carries v\mathbf{v} once around the circle, pausing on each eigenvector, while the tips of AvA\mathbf{v} trace an ellipse.

det⁡(a−λbcd−λ)=(a−λ)(d−λ)−bc=λ2−(a+d) λ+(ad−bc)=0\det\begin{pmatrix} a - \lambda & b \\ c & d - \lambda \end{pmatrix} = (a - \lambda)(d - \lambda) - bc = \lambda^2 - (a + d)\,\lambda + (ad - bc) = 0

From operators to matrices

A computer cannot store a function, only a list of numbers. Turning functions into lists and operators into tables of numbers is how every quantum chemistry program works, and it makes the abstract properties of operators, Hermitian or commuting, concrete enough to check by eye. We build the dictionary in four steps. Operators as Matrices in Appendix A has more on each.

Source
<Figure size 960x375 with 1 Axes>

Fig. The four steps of this section. Each one trades something from calculus (top row) for something a computer can store (bottom row): the function for a column of samples, multiplication for a diagonal matrix, derivatives for rows that link neighbors, and the Schrödinger equation for a matrix whose eigenvalues eigh finds.

Step 1: a function becomes a vector

Source
<Figure size 960x320 with 7 Axes>

Fig. One vector, two pictures. The arrow (2,1)(2, 1) and its two components (red), then the same two numbers as bars. No arrow can show seven components, but seven bars can, and with many bars the tops trace a function.

Source
<Figure size 900x370 with 3 Axes>

Fig. A wavefunction in a box sampled at seven interior points. The walls, where ψ=0\psi = 0, carry no unknowns. The seven samples, stacked in a column, are the vector that stands in for the function.

symbolwhat it is
ψ(x)\psi(x)the function: a value at every xx
NNthe number of grid points
xjx_jgrid point number jj, for j=1,…,Nj = 1, \dots, N
Δx\Delta xthe spacing between neighboring grid points
ψj=ψ(xj)\psi_j = \psi(x_j)one number: the value of the function at xjx_j
∣ψ⟩\lvert\psi\rangleall NN samples stacked in a column: the vector (Dirac notation, below)
⟨ψ∣\langle\psi\rvertthe same numbers written as a row, each one conjugated
∫ϕ∗ ψ dx  ≈  ∑jϕj∗ ψj Δx,∫∣ψ∣2 dx=1  ⟶  ∑j∣ψj∣2 Δx=1\int \phi^*\,\psi\,dx \;\approx\; \sum_{j} \phi_j^*\,\psi_j\,\Delta x, \qquad \int \lvert\psi\rvert^2\,dx = 1 \;\longrightarrow\; \sum_j \lvert\psi_j\rvert^2\,\Delta x = 1

Step 2: multiplying by xx is a diagonal matrix

x^ ψ  ⟶  (x10000x20000x30000x4)(ψ1ψ2ψ3ψ4)=(x1ψ1x2ψ2x3ψ3x4ψ4)\hat{x}\,\psi \;\longrightarrow\; \begin{pmatrix} x_1 & 0 & 0 & 0 \\ 0 & x_2 & 0 & 0 \\ 0 & 0 & x_3 & 0 \\ 0 & 0 & 0 & x_4 \end{pmatrix} \begin{pmatrix} \psi_1 \\ \psi_2 \\ \psi_3 \\ \psi_4 \end{pmatrix} = \begin{pmatrix} x_1\psi_1 \\ x_2\psi_2 \\ x_3\psi_3 \\ x_4\psi_4 \end{pmatrix}

Step 3: derivatives compare neighbors

ψ′(xj)≈ψj+1−ψj−12Δx,ψ′′(xj)≈s+−s−Δx=ψj+1−2ψj+ψj−1Δx2\psi'(x_j) \approx \frac{\psi_{j+1} - \psi_{j-1}}{2\Delta x}, \qquad \psi''(x_j) \approx \frac{s_+ - s_-}{\Delta x} = \frac{\psi_{j+1} - 2\psi_j + \psi_{j-1}}{\Delta x^2}
Source
<Figure size 940x400 with 2 Axes>

Fig. Derivatives from neighboring samples. Left: the chord through the two neighbors of xjx_j is almost parallel to the tangent at xjx_j, so its slope estimates ψ′(xj)\psi'(x_j). Right: the slope drops from s−s_- to s+s_+ across xjx_j; the drop per unit length estimates ψ′′(xj)\psi''(x_j), the curvature.

ψ′′(x2)≈1⋅ψ1−2 ψ2+1⋅ψ3Δx2=1Δx2(1−210)(ψ1ψ2ψ3ψ4)\psi''(x_2) \approx \frac{1\cdot\psi_1 - 2\,\psi_2 + 1\cdot\psi_3}{\Delta x^2} = \frac{1}{\Delta x^2}\begin{pmatrix} 1 & -2 & 1 & 0 \end{pmatrix}\begin{pmatrix} \psi_1 \\ \psi_2 \\ \psi_3 \\ \psi_4 \end{pmatrix}
ddx  ⟶  D1=12Δx(0100−10100−10100−10),d2dx2  ⟶  D2=1Δx2(−21001−21001−21001−2)\frac{d}{dx} \;\longrightarrow\; D_1 = \frac{1}{2\Delta x}\begin{pmatrix} 0 & 1 & 0 & 0 \\ -1 & 0 & 1 & 0 \\ 0 & -1 & 0 & 1 \\ 0 & 0 & -1 & 0 \end{pmatrix}, \qquad \frac{d^2}{dx^2} \;\longrightarrow\; D_2 = \frac{1}{\Delta x^2}\begin{pmatrix} -2 & 1 & 0 & 0 \\ 1 & -2 & 1 & 0 \\ 0 & 1 & -2 & 1 \\ 0 & 0 & 1 & -2 \end{pmatrix}

Step 4: the Hamiltonian is a matrix

H=(2ε+V1−ε00−ε2ε+V2−ε00−ε2ε+V3−ε00−ε2ε+V4),ε=ℏ22m Δx2H = \begin{pmatrix} 2\varepsilon + V_1 & -\varepsilon & 0 & 0 \\ -\varepsilon & 2\varepsilon + V_2 & -\varepsilon & 0 \\ 0 & -\varepsilon & 2\varepsilon + V_3 & -\varepsilon \\ 0 & 0 & -\varepsilon & 2\varepsilon + V_4 \end{pmatrix}, \qquad \varepsilon = \frac{\hbar^2}{2m\,\Delta x^2}
Source
<Figure size 940x400 with 7 Axes>

Fig. Left: the three eigenvectors of the three-point box (dots, joined by straight lines) on top of the exact box states (gray). Each is the exact sine sampled at the grid points. Right: the levels of grids with 3, 10 and 30 points against the exact ones, in units of ℏ2/mL2\hbar^2/mL^2. More points give more levels, and each converges to the exact value from below. The top levels of a coarse grid are the least accurate, because their short wavelengths have few points per wavelength.

Dirac notation

Integrals and matrices are two ways of writing the same objects. Dirac’s notation writes them once, and it reads like matrix algebra: a ket is a column, a bra is a row, and a row times a column is a number.

Kets and bras

∣ψ⟩=(ψ1ψ2⋮),⟨ψ∣=(ψ1∗ψ2∗⋯)\lvert\psi\rangle = \begin{pmatrix} \psi_1 \\ \psi_2 \\ \vdots \end{pmatrix}, \qquad \langle\psi\rvert = \begin{pmatrix} \psi_1^* & \psi_2^* & \cdots \end{pmatrix}
⟨ϕ∣ψ⟩=∑jϕj∗ ψj Δx  ⟶  ∫ϕ∗ ψ dx\langle \phi \vert \psi \rangle = \sum_j \phi_j^*\,\psi_j\,\Delta x \;\longrightarrow\; \int \phi^*\,\psi\,dx
⟨ϕ∣c ψ⟩=∫ϕ∗ (c ψ) dx=c ⟨ϕ∣ψ⟩⟨c ϕ∣ψ⟩=∫(c ϕ)∗ ψ dx=c∗⟨ϕ∣ψ⟩\begin{aligned} \langle \phi \vert c\,\psi \rangle &= \int \phi^*\,(c\,\psi)\,dx = c\,\langle \phi \vert \psi \rangle \\ \langle c\,\phi \vert \psi \rangle &= \int (c\,\phi)^*\,\psi\,dx = c^*\langle \phi \vert \psi \rangle \end{aligned}

Sandwiches: matrix elements

⟨ϕ∣A^∣ψ⟩=∫ϕ∗ A^ψ dx\langle\phi\vert\hat{A}\vert\psi\rangle = \int\phi^*\,\hat{A}\psi\,dx
Source
<Figure size 960x260 with 1 Axes>

Fig. Count the shapes. A bra is a 1×N1\times N row, an operator an N×NN\times N square, a ket an N×1N\times 1 column (here N=4N = 4). Row times column is a single number; a matrix times a column is a new column, a ket; row times matrix times column is again a single number, the matrix element.

Ae2=(2112)(01)=(12)⟨e1∣A∣e2⟩=(10)(12)=1=A12\begin{aligned} A\mathbf{e}_2 &= \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}\begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} 1 \\ 2 \end{pmatrix} \\ \langle \mathbf{e}_1 \vert A \vert \mathbf{e}_2 \rangle &= \begin{pmatrix} 1 & 0 \end{pmatrix}\begin{pmatrix} 1 \\ 2 \end{pmatrix} = 1 = A_{12} \end{aligned}
Ajk=⟨ej∣A∣ek⟩A_{jk} = \langle \mathbf{e}_j \vert A \vert \mathbf{e}_k \rangle

Diagonalizing a Hamiltonian

One language, three dialects

integralDiracnumpy on a grid
inner product∫ϕ∗ψ dx\int \phi^*\psi\,dx⟨ϕ∣ψ⟩\langle \phi \vert \psi \ranglenp.vdot(phi, psi) * dx
normalization∫∣ψ∣2dx=1\int \lvert\psi\rvert^2 dx = 1⟨ψ∣ψ⟩=1\langle \psi \vert \psi \rangle = 1np.vdot(psi, psi) * dx
operator actsA^ψ(x)\hat{A}\psi(x)A^∣ψ⟩\hat{A}\lvert\psi\rangleA @ psi
matrix element∫ϕ∗A^ψ dx\int \phi^*\hat{A}\psi\,dx⟨ϕ∣A^∣ψ⟩\langle \phi \vert \hat{A} \vert \psi \ranglenp.vdot(phi, A @ psi) * dx
eigenvalue problemA^ϕn=anϕn\hat{A}\phi_n = a_n\phi_nA^∣n⟩=an∣n⟩\hat{A}\lvert n\rangle = a_n\lvert n\ranglea, phi = np.linalg.eigh(A)
matrix in new axesAmn′=∫ϕm∗A^ϕn dxA'_{mn} = \int \phi_m^*\hat{A}\phi_n\,dxAmn′=⟨ϕm∣A^∣ϕn⟩A'_{mn} = \langle \phi_m \vert \hat{A} \vert \phi_n \rangleU.conj().T @ A @ U * dx (columns of U: the ϕn\phi_n)

Two matrix properties to watch

Here are x^\hat{x}, p^\hat{p} and H^\hat{H} for a particle on a spring on an 8-point grid, as color maps. At any size they keep the same pattern:

Source
<Figure size 960x380 with 3 Axes>

Fig. Position, momentum and energy of a particle on a spring, on a grid of 8 points. Color shows the sign and size of each entry (teal negative, red positive, white zero). Each matrix equals its own conjugate transpose, the defining property of a Hermitian matrix (Operators 2); momentum manages it with an imaginary, antisymmetric pattern.

Problems

Problem 1: Linear or not?

Decide which of these operators are linear: (a) A^f=f+x\hat{A}f = f + x, (b) B^f=x2 d2fdx2\hat{B}f = x^2\,\dfrac{d^2f}{dx^2}, (c) C^f=∫0xf(y) dy\hat{C}f = \displaystyle\int_0^x f(y)\,dy, (d) D^f=ef\hat{D}f = e^{f}.

Problem 2: Eigenvectors by hand

Find the eigenvalues and eigenvectors of B=(222−1)B = \begin{pmatrix} 2 & 2 \\ 2 & -1 \end{pmatrix}. Check them against the trace and the determinant, and check that the two eigenvectors are perpendicular.

Problem 3: Two orbitals, one matrix

In Hückel theory the two pp orbitals of ethylene are described by H=(αββα)H = \begin{pmatrix} \alpha & \beta \\ \beta & \alpha \end{pmatrix}, where α\alpha is the energy of an electron on one carbon and β<0\beta < 0 couples the two. Find the energies and the normalized eigenvectors. Which combination is lower in energy?

Problem 4: Position as a matrix in the box basis

Use the box states ψn=2/L sin⁡(nπx/L)\psi_n = \sqrt{2/L}\,\sin(n\pi x/L) as a basis and build the 3×33\times 3 matrix xmn=⟨ψm∣x^∣ψn⟩x_{mn} = \langle \psi_m \vert \hat{x} \vert \psi_n \rangle, m,n=1,2,3m, n = 1, 2, 3, with numpy on a grid. Is the matrix symmetric? Which entries vanish?

Problem 5: A rotation has no real eigenvectors

The matrix R=(cos⁡θ−sin⁡θsin⁡θcos⁡θ)R = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{pmatrix} turns every arrow by the angle θ\theta. Apply it to (1,0)(1, 0) and (0,1)(0, 1) for θ=90∘\theta = 90^\circ and sketch the results. Then show that its eigenvalues are λ=cos⁡θ±isin⁡θ=e±iθ\lambda = \cos\theta \pm i\sin\theta = e^{\pm i\theta}, find the eigenvectors, and say for which angles the eigenvalues are real. Why does the picture make the answer obvious?

Problem 6: Butadiene as a matrix

In Hückel theory (Chapter 8) the π\pi electrons of butadiene are described by the matrix

H=(αβ00βαβ00βαβ00βα)H = \begin{pmatrix} \alpha & \beta & 0 & 0 \\ \beta & \alpha & \beta & 0 \\ 0 & \beta & \alpha & \beta \\ 0 & 0 & \beta & \alpha \end{pmatrix}

where α\alpha is the energy of an electron on one carbon and β<0\beta < 0 couples neighbors. Set α=0\alpha = 0, β=−1\beta = -1 and use np.linalg.eigh to find the eigenvalues and eigenvectors. Check that the eigenvalues are real (you should find ±1.618\pm 1.618 and ±0.618\pm 0.618) and that the eigenvectors are orthonormal. Draw each eigenvector as four bars, one per carbon, and count the sign changes. Compare with the particle-in-a-box states of butadiene in Particle in a Box.

Problem 7: Brackets on a grid

Sample the box states ψ1\psi_1 and ψ2\psi_2 (L=1L = 1) on NN interior grid points and compute ⟨ψ1∣ψ1⟩\langle \psi_1 \vert \psi_1 \rangle, ⟨ψ2∣ψ2⟩\langle \psi_2 \vert \psi_2 \rangle and ⟨ψ1∣ψ2⟩\langle \psi_1 \vert \psi_2 \rangle with np.vdot(...) * dx. How close are they to 1, 1 and 0 for N=5N = 5, 20 and 100? Then multiply ψ2\psi_2 by c=2ic = 2i and confirm that ⟨c ψ2∣ψ2⟩=c∗⟨ψ2∣ψ2⟩\langle c\,\psi_2 \vert \psi_2 \rangle = c^*\langle \psi_2 \vert \psi_2 \rangle while ⟨ψ2∣c ψ2⟩=c ⟨ψ2∣ψ2⟩\langle \psi_2 \vert c\,\psi_2 \rangle = c\,\langle \psi_2 \vert \psi_2 \rangle.

Problem 8: How many points per wavelength?

Adapt the five lines of numpy to the particle in a box: V=0V = 0 on NN interior points, ℏ=m=L=1\hbar = m = L = 1, exact levels En=n2π2/2E_n = n^2\pi^2/2. For n=1n = 1, 5 and 10, find how many points you need for a 1 percent error, and express each answer as points per wavelength, 2(N+1)/n2(N + 1)/n. What rule of thumb do you find?