Quantum mechanics is written in the language of operators and differential equations. But underneath that calculus lies a simpler and more powerful truth: quantum mechanics is linear algebra. Wavefunctions are vectors, operators are matrices, and the Schrodinger equation is the eigenvalue problem in disguise. Undergraduate courses often bury this under derivatives and integrals; this page brings it to the surface first, then returns to the differential equations as the tools for working in one particular basis.
Functions are vectors, operators are matrices¶
A function is a vector with one component per point¶
Take any function and evaluate it at points . The list of values is a vector with components. For example sampled at becomes the vector .
Now let the grid get finer, with spacing . The vector gains a component for every point , and in that limit the function is an infinite-dimensional vector. The value plays the role of “the component at ,” exactly as is the component of along basis direction .
The inner product becomes an integral¶
This is the link that makes the analogy precise. The dot product of two vectors sums the products of matching components. For function-vectors, that sum over grid points, weighted by the spacing , is a Riemann sum, and in the fine-grid limit it becomes an integral:
So the quantum-mechanical inner product is nothing more than the dot product from the previous page, carried to infinite dimensions. Everything built on the dot product carries over verbatim: normalization is just , and orthogonal wavefunctions () are just perpendicular vectors.
An operator is a matrix¶
A linear operator takes a function and returns a function, that is, it takes a vector and returns a vector. Any linear map on vectors is a matrix, so every quantum operator is a matrix acting on the function-vector. The derivative operator, for instance, becomes the finite-difference matrix built in the next section. This gives the full dictionary between the linear algebra you already know and the quantum mechanics ahead:
| Linear algebra (finite dimensions) | Quantum mechanics (functions) |
|---|---|
| vector | wavefunction |
| component | value |
| dot product | inner product |
| normalized | normalized |
| orthonormal basis | orthonormal functions |
| matrix | operator (such as , , ) |
| eigenvector equation | eigenfunction equation |
| eigenvalue | measured value (energy, momentum) |
| symmetric / Hermitian matrix | Hermitian operator (real eigenvalues) |
| expansion | superposition |
The rest of this page makes the “operator is a matrix” half concrete: we build the derivative as an explicit matrix, see why operator order matters, and then meet the differential equations that these operators live in.
The derivative as a finite-difference matrix¶
We approximate the first derivative by a centered difference, the slope between the neighbor on the left and the neighbor on the right:
Written as a matrix acting on the sampled vector (with one-sided formulas at the two boundaries), this is
import numpy as np
n = 5
x = np.linspace(0, 4, n)
h = x[1] - x[0]
psi = x**2
D1 = (1 / (2 * h)) * np.array([
[-3, 4, -1, 0, 0],
[-1, 0, 1, 0, 0],
[0, -1, 0, 1, 0],
[0, 0, -1, 0, 1],
[0, 0, 1, -4, 3],
])
print("finite-difference derivative of x^2:", D1 @ psi)
print("exact derivative 2x :", 2 * x)finite-difference derivative of x^2: [0. 2. 4. 6. 8.]
exact derivative 2x : [0. 2. 4. 6. 8.]
The second derivative uses the three-point stencil over . This matrix is the discrete kinetic-energy operator, the heart of every numerical Schrodinger solver. Below we build it on a fine grid, apply it to , and recover , since .
Source
import numpy as np
import matplotlib.pyplot as plt
N = 200
x = np.linspace(0, 2 * np.pi, N)
h = x[1] - x[0]
# Second-derivative matrix, tridiagonal (1, -2, 1) / h^2
D2 = (np.diag(np.ones(N - 1), 1)
- 2 * np.diag(np.ones(N))
+ np.diag(np.ones(N - 1), -1)) / h**2
psi = np.sin(x)
d2psi = D2 @ psi
fig, ax = plt.subplots(figsize=(7, 3.6))
ax.plot(x, psi, 'k', lw=2, label=r'$\psi = \sin x$')
ax.plot(x[1:-1], d2psi[1:-1], color='#d1495b', lw=2, label=r'$D_2\,\psi$ (numerical)')
ax.plot(x, -np.sin(x), '--', color='#66a182', lw=2, label=r'$-\sin x$ (exact)')
ax.axhline(0, color='gray', lw=0.6)
ax.set_xlabel('x')
ax.legend(fontsize=9, loc='upper right')
ax.set_title('Fig.1 The second-derivative matrix turns sin x into -sin x')
plt.tight_layout()
plt.show()
Operator order matters¶
Matrices, and therefore operators, generally do not commute: . With
we get but .
import numpy as np
A = np.array([[1, 2], [0, 1]])
B = np.array([[0, 1], [1, 0]])
print("AB =\n", A @ B)
print("BA =\n", B @ A)
print("\ncommutator AB - BA =\n", A @ B - B @ A)AB =
[[2 1]
[1 0]]
BA =
[[0 1]
[1 2]]
commutator AB - BA =
[[ 2 0]
[ 0 -2]]
The order matters because applying a shear then a rotation is not the same as rotation then shear. In quantum mechanics this same non-commutation, packaged as the commutator , is exactly what forbids simultaneous sharp values of position and momentum. It is the algebra behind the uncertainty principle.
When do operators commute?
Diagonal matrices always commute with each other, and the identity commutes with everything. More generally, two operators commute if and only if they share a common set of eigenvectors, which is the condition for two observables to be simultaneously measurable.
Ordinary differential equations¶
A differential equation relates a function to its derivatives. An ordinary differential equation (ODE) involves derivatives with respect to a single variable. Two show up everywhere in chemistry.
First order: exponential growth and decay¶
The rate of change is proportional to the amount present. With this is radioactive decay or a first-order reaction; with it is unchecked growth. The solution is the exponential because is the one function equal to its own derivative up to the constant .
Second order: oscillation¶
Here the second derivative is proportional to the negative of the function, so the solution oscillates. This is a swinging pendulum, a vibrating bond, and, with in place of , the spatial shape of a particle-in-a-box wavefunction. Using Euler’s formula the same solution reads , which is why complex exponentials and oscillations are inseparable.
Source
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 10, 400)
fig, axes = plt.subplots(1, 2, figsize=(10, 3.6))
# First order: decay for several rates
for k, c in zip([-0.2, -0.5, -1.0], ['#66a182', '#edae49', '#d1495b']):
axes[0].plot(t, np.exp(k * t), color=c, lw=2, label=f'k = {k}')
axes[0].set_title(r"Fig.2a First order: $y' = ky$ (decay)")
axes[0].set_xlabel('t')
axes[0].set_ylabel('y')
axes[0].legend(fontsize=9)
# Second order: oscillation for several frequencies
for w, c in zip([1.0, 1.5, 2.0], ['#66a182', '#edae49', '#d1495b']):
axes[1].plot(t, np.cos(w * t), color=c, lw=2, label=fr'$\omega$ = {w}')
axes[1].set_title(r"Fig.2b Second order: $y'' = -\omega^2 y$ (oscillation)")
axes[1].set_xlabel('t')
axes[1].axhline(0, color='gray', lw=0.6)
axes[1].legend(fontsize=9)
plt.tight_layout()
plt.show()
Partial differential equations¶
A partial differential equation (PDE) involves derivatives with respect to more than one variable, for example both position and time . The two central equations of the course are PDEs:
Separation of variables¶
The workhorse technique is separation of variables: guess that the solution factors into pieces that each depend on only one variable,
Substituting this guess turns one PDE into two independent ODEs, one in and one in , tied together by a shared constant. For the Schrodinger equation the spatial ODE is the time-independent Schrodinger equation , and the temporal ODE gives the phase factor .
This is why the earlier ODE solutions matter: the spatial equation is a second-order ODE whose oscillating solutions are the stationary states, and the temporal equation is a first-order ODE whose solution is a complex-exponential phase. Notice the recurring pattern of the whole appendix: the eigenvalue problem is the operator-as-matrix idea, the energies are eigenvalues, and the wavefunctions are eigenvectors.
Problems¶
Problem 1: Read off a derivative matrix¶
Using the first-derivative matrix above with , apply it to the constant vector . What do you expect, and why?
Solution
Each interior row computes a difference of equal neighbors, so the derivative is 0 everywhere. The derivative of a constant is zero, and the boundary rows are built to return zero for a constant as well.
Problem 2: Solve a decay ODE¶
A first-order reaction obeys with . Write and find the half-life.
Solution
The half-life solves , giving .
Problem 3: Verify an oscillator solution¶
Show that satisfies .
Solution
Differentiate twice: and . The equation holds for any .
Problem 4: A commutator¶
Compute the commutator for and .
Solution
Problem 5: Separation of variables setup¶
Insert into and divide by . Show that one side depends only on and the other only on , so both equal a constant.
Problem 6: Build a second-derivative matrix¶
Modify the code to build on a grid of points over , apply it to , and check that you recover .
Problem 7: Which ODE?¶
A bond vibrates about equilibrium with restoring force proportional to displacement. Write the differential equation for the displacement and state its general solution.
Problem 8: Non-commuting rotations¶
Numerically verify that a 2D shear and a 2D rotation do not commute by computing for the shear and rotation matrices from the previous page on vectors and linear algebra.