Eigenstates of the Quantum Harmonic Oscillator Using Spectral Methods
Consider Schrödinger's differential equation, , where . This problem describes the quantum harmonic oscillator (i.e., the quantum-mechanical analog of the classical harmonic oscillator). Values of the eigenvalues can be determined analytically and are when . The corresponding eigenfunctions are given by , where are the Hermite polynomials associated with the eigenvalue . This Demonstration approximates values of the eigenvalues numerically using spectral methods. When the number of grid points is large, the numerical values match their analytical counterparts perfectly. In addition, the first five eigenfunctions (analytical solutions in blue and numerical solution in red dots) are plotted for the choice of 100 grid points.
The eigenvalues of the quantum harmonic oscillator are found as follows:
1. First form the vector , , where , is the number of grid points, and is an arbitrarily large value (e.g., ).
2. Then, build the matrix , where is the Toeplitz matrix of with the components and for .
3. Finally, find the eigenvalues and eigenvectors of matrix .
 L. N. Trefethen, Spectral Methods in MATLAB, Philadelphia: SIAM, 2000.