Teaching the Variational Method Using a Quantum Harmonic Oscillator and MATLAB

Authors

  • Huanbo Luo School of Physics and Optoelectronic Engineering, Foshan University, Foshan, China Author
  • Jiayao Huang School of Physics and Optoelectronic Engineering, Foshan University, Foshan, China Author
  • Yongyao Li School of Physics and Optoelectronic Engineering, Foshan University, Foshan, China Author
  • Bin Liu School of Physics and Optoelectronic Engineering, Foshan University, Foshan, China Author

DOI:

https://doi.org/10.70088/6a5a9165

Keywords:

quantum mechanics, variational method, one-dimensional harmonic oscillator, MATLAB, visualization-based teaching

Abstract

The variational method is an important approach for solving approximate eigenvalue problems in quantum mechanics. To address the difficulty of directly comparing variational results in traditional helium-atom examples, which lack an accessible analytical exact solution, this paper presents a teaching design based on the one-dimensional quantum harmonic oscillator combined with MATLAB visualization. Using the exact ground state of the harmonic oscillator as a benchmark, variational calculations are performed with exponential and Gaussian trial wavefunctions. The results are presented through energy functionals, wavefunctions, and kinetic- and potential-energy contribution curves, while the state overlap is introduced to evaluate the accuracy of the approximate wavefunctions. The results show that the minimum energy obtained with the exponential trial function is 41.42% higher than the exact value, although its state overlap still reaches 0.9693. In contrast, the Gaussian trial function reproduces both the exact energy and the exact wavefunction. Comparing the two trial functions reveals the relationship among the variational upper bound, the trial-function space, and the accuracy of the approximation. On this basis, a corresponding classroom teaching procedure and assessment scheme are developed, providing reproducible computational examples and visualization materials for teaching the variational method in quantum mechanics.

References

D. J. Griffiths and D. F. Schroeter, Introduction to Quantum Mechanics, 3rd ed. Cambridge University Press, Cambridge, 2018.

J. J. Sakurai and J. Napolitano, Modern Quantum Mechanics, 3rd ed. Cambridge University Press, Cambridge, 2020.

E. Besalú and M. Martí, “Exploring the Rayleigh–Ritz Variational Principle,” J. Chem. Educ., vol. 75, no. 1, p. 105, 1998.

R. Garcia, A. Zozulya, and J. Stickney, “MATLAB Codes for Teaching Quantum Physics: Part 1,” arXiv:0704.1622, 2007.

A. van der Vaart, S. T. Le Phan, and B. Wolfe, “Interactive Application and Visualization of the Variational Method to Aid Conceptual Understanding of Introductory Quantum Mechanics,” J. Chem. Educ., vol. 102, pp. 2160–2166, 2025.

S. Z. Ahmed, C. A. Weidner, J. H. M. Jensen, J. F. Sherson, and H. J. Lewandowski, “Student Use of a Quantum Simulation and Visualization Tool,” Eur. J. Phys., vol. 43, no. 6, p. 065703, 2022.

Downloads

Published

02 December 2026

Issue

Section

Article

How to Cite

Luo, H., Huang, J., Li, Y., & Liu, B. (2026). Teaching the Variational Method Using a Quantum Harmonic Oscillator and MATLAB. Education Insights, 3(12), 13-20. https://doi.org/10.70088/6a5a9165