# Tutorial 13. Interactive -- Harmonic Oscillator in 1D

### Learning objectives

- Try the interactive python code to plot the wave function of Harmonic Oscillator (1D).
- Play with the different parameters and try answering the questions asked at the end of this tutorial.

## Background

1D harmonic oscillator is a simple, but very important model for chemists, because its relation with diatomic molecule vibration. The potential of the 1D harmonic oscillator is a quadratic function with respect to the position $x$:

\[V(x) = \frac{1}{2} m\omega^2 x^2\]where $m$ is the mass of the harmonic oscillator, $\omega=\sqrt{\frac{k}{m}}$ is the angular frequency, and $k$ is the force constant.

### Solution

The eigenvalues of the Hamiltonian of 1D Harmonic oscillator are very simple:

\(E_v = \hbar \omega (v+\frac{1}{2}),\ \ v=0,1,2,\dots\), where $v$ is an integer quantum number.

However, the corresponding eigenfunctions are relatively complicated:

\[\psi_v(x) = \frac{1}{(2^vv!)^{\frac{1}{2}}}(\alpha/\pi)^{\frac{1}{4}}H_v(\sqrt{\alpha x})e^{-\frac{1}{2}\alpha x^2}, \ \ v=0,1,2,\dots\]where $\alpha$ is defined as

\[\alpha = \frac{m\omega}{\hbar}\]and $H_v(x)$ are Hermite polynomials, for which we don’t have an intuition about the shapes.

Because of the complexity of the formula, visualization is important to deepen the students’ understanding of the Harmonic Oscillator wave functions.

## Try and learn

Run the following code to see how the Harmonic Oscillator wave function shape changes with the quantum number $v$, angular frequency $\omega$, and mass $m$ (all can be tuned interactively).

**Instructions**

- First, click “Activate” to activate the code block.
- Once you see the buttons to “run” at the bottom left corner of the code block, click “run” to run the code.
- Please be patient. Starting the kernel can be slow sometimes.
- You will see a plot with three panels. The upper is the $v$-th order Hermite polynomial, the middle is $\psi_v$, and the lower is $\vert\psi_v\vert ^2$.
- Play with the slider to select the quantum number you want. $v$ can be any non-negative integer. In this demo, we allow $n$ up to 20.
- Enter the mass (in atomic unit) and angular frequency in the text boxes. In this demo, we allow $m$ and $\omega$ to be any float number between 0.1 and 100 just for demonstration purposes. Theoretically, they can be any positive real number.

### Plot the probability distribution together with the energy levels and the potential

After visualizing the individual states, we can do something even more exciting. You might have seen some textbook figures plotting the wave functions (or probability distributions) of multiple states and the harmonic potential together, clearly showing how the wave functions extend beyond the classical forbidden area. We can do the same thing here!

**Instructions**

- Run the following code block in your browser
- You may adjust the number of states to display at the same time by tuning $v_{max}$.

## Question

- Did you observe certain symmetry in the eigenfunctions?
- Where is the maximum of the probability distribution when $v=0$ or other small numbers?
- Where are the maxima of the probability distribution when $v$ takes large numbers, say 15? How does that relate to the result of classical mechanics?
- As $v$ increases, do you see more probability outside the classical region? Or less?
- Do you know how this analytical solution is obtained?
- Apart from the analytical solution, can you solve this problem numerically with the Numerov method?