The quantum harmonic oscillator is a foundational problem in quantum mechanics.
The time-independent Schrödinger equation for this system is:
$$
-\frac{\hbar^2}{2m} \frac{d^2\psi(x)}{dx^2} + \frac{1}{2} m \omega^2 x^2 \psi(x) = E \psi(x)
$$
- $( \hbar )$: Reduced Planck’s constant
- $( m )$: Mass of the particle
- $( \omega )$: Angular frequency
- $( \psi(x) )$: Wavefunction
- $( E )$: Energy eigenvalue
We’ll solve this equation numerically using the finite difference method and plot the wavefunctions $ \psi(x) $ for the first few energy levels.
Python Code
1 | import numpy as np |
Explanation of the Code
Grid Setup:
- A finite grid is used to represent the position $( x )$ over a symmetric range.
- The number of points $( n_{points} )$ determines the resolution.
Hamiltonian:
- The kinetic energy is approximated using a finite difference method.
- The potential energy is represented as $( \frac{1}{2} m \omega^2 x^2 )$.
Solving Eigenvalue Problem:
- The eigenvalues correspond to energy levels.
- The eigenvectors are the wavefunctions $( \psi(x) )$.
Wavefunction Plot:
- The first $5$ energy levels’ wavefunctions are plotted as probability densities $( |\psi(x)|^2 )$.
Let’s execute the code to see the results.
Graph Explanation

Wavefunctions:
- The plotted curves represent the probability densities ($(|\psi(x)|^2)$) of the quantum harmonic oscillator for the first $5$ energy levels ($n = 0$ to $n = 4$).
- Each wavefunction corresponds to a distinct energy eigenvalue $(E_n)$, labeled in electron volts (eV).
Nodes:
- Higher energy levels $(n > 0)$ have more nodes (points where $(|\psi(x)|^2 = 0)$) in their wavefunctions, a characteristic feature of quantum systems.
Bound States:
- The wavefunctions are localized, indicating bound states of the particle within the potential well.
This result aligns with theoretical expectations and provides a clear visualization of quantum mechanical states in a harmonic potential.










