Skip to content

Finite Difference Methods

Finite difference methods approximate derivatives by differences of nearby grid values. In quantum mechanics, they turn differential Hamiltonians into sparse matrices that can be diagonalized, propagated in time by Time-Stepping Methods, or used in boundary-value calculations. The full PDE workflow is organized in PDE Solvers.

The core idea is local: if a wavefunction is smooth on the scale of the grid spacing hh, Taylor expansions relate derivatives at xjx_j to samples at neighboring points. The numerical danger is equally local: if the grid does not resolve the wavefunction or the boundary condition is implemented incorrectly, the resulting matrix solves a different problem.

Finite differences appear in:

  • one-dimensional bound-state calculations;
  • finite-box approximations to continuum problems;
  • tunneling through smooth barriers;
  • radial Schrödinger equations after coordinate reduction;
  • time-dependent wave-packet propagation on grids;
  • finite-volume or finite-element methods in more advanced settings;
  • benchmark calculations for validating more elaborate codes.

They are not always the most accurate method for smooth periodic problems, where Spectral Methods may converge faster. But finite differences are transparent, sparse, local, and easy to inspect.

On a uniform one-dimensional grid,

xj=x0+jh,ψj≈ψ(xj).x_j=x_0+jh, \qquad \psi_j\approx\psi(x_j).

Taylor expansions give

ψ(xj+h)=ψ(xj)+hψ′(xj)+h22ψ′′(xj)+h36ψ′′′(xj)+O(h4),\psi(x_j+h) = \psi(x_j) + h\psi'(x_j) + \frac{h^2}{2}\psi''(x_j) + \frac{h^3}{6}\psi'''(x_j) + O(h^4),

and

ψ(xj−h)=ψ(xj)−hψ′(xj)+h22ψ′′(xj)−h36ψ′′′(xj)+O(h4).\psi(x_j-h) = \psi(x_j) - h\psi'(x_j) + \frac{h^2}{2}\psi''(x_j) - \frac{h^3}{6}\psi'''(x_j) + O(h^4).

Adding or subtracting these expansions produces derivative formulas.

The centered first derivative is

ψ′(xj)=ψj+1−ψj−12h+O(h2).\psi'(x_j) = \frac{\psi_{j+1}-\psi_{j-1}}{2h} + O(h^2).

One-sided formulas are useful near boundaries. The forward difference

ψ′(xj)=ψj+1−ψjh+O(h)\psi'(x_j) = \frac{\psi_{j+1}-\psi_j}{h} + O(h)

is only first-order accurate. Higher-order one-sided formulas exist, but boundary accuracy and boundary conditions should be handled deliberately rather than patched after the fact.

In quantum mechanics, first derivatives appear in momentum operators, current densities, radial transformations, and gauge-coupled Hamiltonians. A careless first-derivative discretization can break Hermiticity or time-reversal properties.

The centered second derivative is

ψ′′(xj)=ψj+1−2ψj+ψj−1h2+O(h2).\psi''(x_j) = \frac{ \psi_{j+1}-2\psi_j+\psi_{j-1} }{h^2} + O(h^2).

For the one-dimensional Hamiltonian

H=−ℏ22md2dx2+V(x),H = - \frac{\hbar^2}{2m} \frac{d^2}{dx^2} + V(x),

this gives the grid action

(Hhψ)j=−ℏ22mψj+1−2ψj+ψj−1h2+Vjψj,(H_h\psi)_j = - \frac{\hbar^2}{2m} \frac{ \psi_{j+1}-2\psi_j+\psi_{j-1} }{h^2} + V_j\psi_j,

where Vj=V(xj)V_j=V(x_j).

This is the standard starting point for finite-difference bound-state calculations.

For NN interior grid points with Dirichlet boundary conditions at the endpoints, the second-difference matrix is

D2=1h2(−210⋯01−21⋯001−2⋯0⋮⋮⋮⋱10001−2).D_2 = \frac{1}{h^2} \begin{pmatrix} -2 & 1 & 0 & \cdots & 0\\ 1 & -2 & 1 & \cdots & 0\\ 0 & 1 & -2 & \cdots & 0\\ \vdots & \vdots & \vdots & \ddots & 1\\ 0 & 0 & 0 & 1 & -2 \end{pmatrix}.

The Hamiltonian matrix is

Hh=−ℏ22mD2+diag⁡(V1,…,VN).H_h = - \frac{\hbar^2}{2m}D_2 + \operatorname{diag}(V_1,\dots,V_N).

For real VjV_j, this matrix is real symmetric. With the usual uniform-grid inner product, it is Hermitian and can be passed to a Hermitian eigensolver.

The resulting matrix is sparse: each row couples only neighboring grid points. This sparsity is one reason finite differences scale to much larger grids than dense methods. The storage and matrix-vector-product language is developed in Sparse Matrices.

Boundary conditions change the first and last rows of the matrix.

For Dirichlet boundaries, one often stores only interior points and sets the exterior boundary values to zero. For periodic boundaries, the first and last interior points are coupled:

ψ−1=ψN−1,ψN=ψ0.\psi_{-1}=\psi_{N-1}, \qquad \psi_N=\psi_0.

For Neumann boundaries, one approximates a derivative condition such as ψ′(xmin⁡)=0\psi'(x_{\min})=0. A simple ghost-point implementation sets

ψ−1=ψ1,\psi_{-1}=\psi_1,

which enforces the centered derivative to vanish at the boundary point.

Boundary rows are common sources of errors because they are not the same as the interior stencil. Always state how the boundary condition was implemented.

The basic centered second derivative is second-order accurate. A fourth-order version is

ψ′′(xj)≈−ψj+2+16ψj+1−30ψj+16ψj−1−ψj−212h2.\psi''(x_j) \approx \frac{ -\psi_{j+2} + 16\psi_{j+1} - 30\psi_j + 16\psi_{j-1} - \psi_{j-2} }{12h^2}.

Higher-order stencils can improve accuracy for smooth wavefunctions, but they use wider neighborhoods. Wider stencils complicate boundaries, increase matrix bandwidth, and may behave poorly near nonsmooth potentials or discontinuities.

Order is not the only criterion. A lower-order method with correct boundary treatment can outperform a higher-order stencil with inconsistent boundary rows.

On a rectangular two-dimensional grid with spacings hxh_x and hyh_y, a common Laplacian approximation is

∇h2=Dx⊗Iy+Ix⊗Dy,\nabla_h^2 = D_x\otimes I_y + I_x\otimes D_y,

where DxD_x and DyD_y are one-dimensional second-difference matrices and ⊗\otimes is the matrix Kronecker product.

This tensor-product structure is valuable. It gives sparse Hamiltonians and makes separable benchmark problems easy to check. On irregular domains or curvilinear coordinates, additional metric factors and boundary geometry must be handled carefully.

For a second-order stencil, the local derivative error is O(h2)O(h^2) when the wavefunction is sufficiently smooth. For eigenvalues, the observed convergence can depend on the state, boundary conditions, potential smoothness, and box size.

A standard grid-refinement test compares results at hh, h/2h/2, and h/4h/4. If the leading error is proportional to h2h^2, then the error should shrink by about a factor of 44 when hh is halved.

This is only meaningful after domain truncation error is under control. For bound states in a finite box, increase the box size and refine the grid separately.

For a systematic refinement workflow, see Convergence Tests.

Derivative matrices grow as hh shrinks. The second-difference matrix has entries of size 1/h21/h^2, so roundoff and conditioning can become more visible on very fine grids.

For a second derivative, a schematic error balance is

error∼C1h2+C2uh2,\text{error} \sim C_1h^2 + C_2\frac{u}{h^2},

where uu is the unit roundoff. The first term decreases with refinement; the second can increase. See Floating-Point Arithmetic and Conditioning and Stability for the numerical background.

Finite-difference Hamiltonians should be tested on known cases:

  • infinite square well energies;
  • harmonic oscillator low-lying levels;
  • free-particle dispersion on a periodic grid;
  • symmetry of even and odd states in symmetric potentials;
  • normalization and orthogonality under the discrete inner product.

For the infinite well, the exact continuum energies are proportional to n2n^2. A finite-difference grid should reproduce low-nn levels increasingly well under refinement, while high-nn levels near the grid cutoff converge poorly.

  • Using the interior stencil at a boundary without implementing the boundary condition.
  • Forgetting the factor 1/h21/h^2 in the Laplacian.
  • Assuming high-energy eigenvalues converge as quickly as low-energy eigenvalues.
  • Treating a finite-box spectrum as a continuum spectrum.
  • Refining hh while ignoring roundoff or box-size effects.
  • Breaking Hermiticity with an asymmetric derivative stencil.
  • Comparing grid wavefunctions without using the correct discrete inner product.
  • Using a high-order stencil near a discontinuity and expecting high-order convergence.
  • R. J. LeVeque, Finite Difference Methods for Ordinary and Partial Differential Equations, SIAM, 2007.
  • J. M. Thijssen, Computational Physics, 2nd ed., Cambridge University Press, 2007.
  • T. Pang, An Introduction to Computational Physics, 2nd ed., Cambridge University Press, 2006.
  • W. H. Press, S. A. Teukolsky, W. T. Vetterling, and B. P. Flannery, Numerical Recipes: The Art of Scientific Computing, 3rd ed., Cambridge University Press, 2007.
  • G. D. Smith, Numerical Solution of Partial Differential Equations: Finite Difference Methods, 3rd ed., Oxford University Press, 1985.
  1. Derive the centered second-derivative formula by adding Taylor expansions at x+hx+h and x−hx-h.
Solution

Taylor expansion gives

ψ(x+h)=ψ+hψ′+h22ψ′′+h36ψ′′′+h424ψ(4)+O(h5),\psi(x+h) = \psi + h\psi' + \frac{h^2}{2}\psi'' + \frac{h^3}{6}\psi''' + \frac{h^4}{24}\psi^{(4)} + O(h^5),

and

ψ(x−h)=ψ−hψ′+h22ψ′′−h36ψ′′′+h424ψ(4)+O(h5).\psi(x-h) = \psi - h\psi' + \frac{h^2}{2}\psi'' - \frac{h^3}{6}\psi''' + \frac{h^4}{24}\psi^{(4)} + O(h^5).

Adding and solving for ψ′′\psi'' gives

ψ′′=ψ(x+h)−2ψ(x)+ψ(x−h)h2+O(h2).\psi'' = \frac{\psi(x+h)-2\psi(x)+\psi(x-h)}{h^2} + O(h^2).
  1. Write the second-difference matrix for three interior points with Dirichlet boundary conditions.
Solution

With three interior points, the matrix is

D2=1h2(−2101−2101−2).D_2 = \frac{1}{h^2} \begin{pmatrix} -2 & 1 & 0\\ 1 & -2 & 1\\ 0 & 1 & -2 \end{pmatrix}.

The missing boundary values are fixed to zero by the Dirichlet condition.

  1. For real VjV_j, explain why the standard finite-difference Hamiltonian with Dirichlet boundaries is Hermitian.
Solution

The second-difference matrix is real symmetric, so D2†=D2D_2^\dagger=D_2. The potential matrix diag⁡(Vj)\operatorname{diag}(V_j) is also real diagonal, hence Hermitian. A real linear combination of Hermitian matrices is Hermitian, so

Hh=−ℏ22mD2+diag⁡(Vj)H_h = - \frac{\hbar^2}{2m}D_2 + \operatorname{diag}(V_j)

is Hermitian.

  1. A second-order finite-difference eigenvalue error is dominated by Ch2Ch^2. If halving hh does not reduce the error by about a factor of 44, name two possible explanations.
Solution

One possibility is that another error source dominates, such as finite-box error, roundoff, or eigensolver tolerance. Another is that the assumptions behind second-order convergence are not met, for example because the potential or wavefunction is not sufficiently smooth or because the boundary stencil is only first-order accurate.

  1. How does a periodic boundary condition modify the one-dimensional second-difference matrix?
Solution

The first and last grid points become neighbors. In addition to the usual tridiagonal entries, the matrix has corner entries connecting the first row to the last column and the last row to the first column. These entries implement

ψ−1=ψN−1,ψN=ψ0.\psi_{-1}=\psi_{N-1}, \qquad \psi_N=\psi_0.