Skip to content

Teaching the Rayleigh–Ritz variational principle with neural-network trial wave functions

Oct 2026 · European journal of physics · Vol 47 · 0 citations · 24 references
Physics

Abstract

We present a computational module for upper-level undergraduate quantum mechanics and computational physics courses in which neural networks serve as variational trial wave functions for the Rayleigh–Ritz method. Spatial derivatives are evaluated using automatic differentiation. The infinite square well and harmonic oscillator provide analytically solvable benchmarks, while a quartic anharmonic oscillator illustrates how numerical accuracy can be assessed without a simple analytical solution using network-size convergence, energy variance, and cross-network wave-function overlap. Boundary conditions, decaying envelopes, parity, and orthogonality are incorporated into the trial functions as physical constraints. The examples also demonstrate that excited states require orthogonality to lower states and that a small energy error does not necessarily imply an accurate wave function or node position. The module is intended as a visual and modifiable framework for teaching variational reasoning and numerical error diagnostics.

View source

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.