# Quantum Harmonic Oscillator

**Prerequiresites:** Quantum Mechanics course

**Slinkies**. They started out as toys. I still have one to play with on my desk.

**Rubber bands** What was once something useful, is now a wonderful projectile weapon.

**Swings** I still love them, but people seem to not make them in adult sizes for some reason.

A person’s perception of these objects starts to change as they enter their first physics class. Even in that beginning class of classical mechanics, the problems are filled with harmonic oscillators, like slinkies, rubber bands, or swings, which exert a force proportional to their displacement

and therefore a quadratic potential

This is all extremely fun and useful in the classical regime, but we add Quantum Mechanics to the mix, and LOW AND BEHOLD! we have one of the few exactly solvable models in Quantum Mechanics. Moreso, this solution demonstrates some extremely important properties of quantum mechanical systems.

**The Hamiltonian**

** The Solution**

Today, I just intend to present the form of the solution, calculate this equation numerically, and visualize the results. If you wish to know how the equation is derived, you can find a standard quantum mechanics textbook, or stay tuned till I manage to write it up.

### Physicists’ Hermite Polynomials

Note: These are not the same as the “probabilists’ Hermite Polynomial”. The two functions differ by scaling factors.

Physicists’ Hermite polynomials are defined as eigenfunctions for the differential equation

I leave it as an exercise to the reader to:

- demonstrate orthogonality with respect to the measure $e^{-x^2}$, i.e.

- demonstrate completeness. This means we can describe every function by a linear combination of Hermite polynomials, provided it is suitably well behaved.

Though a formula exists or calculating a function at $n$ directly, the most efficient method at low $n$ for calculating polynomials relies on recurrence relationships. These recurrence relationships will also be quite handy if you ever need to show orthogonality, or expectation values.

### Recurrence Relations

```
#Pkg.update();
#Pkg.add("PyPlot");
#Pkg.update()
#Pkg.add("Roots")
using Roots;
using PyPlot;
```

### Programming Tip!

Since Hermite polynomials are generated recursively, I wanted to generate and save all the functions up to a designated value at once. In order to do so, I created an array, whose values are anonymous functions.Let’s generate some Hermite polynomials and look at them.
** Make sure you don’t call a Hermite you haven’t generated yet!**

### Programming Tip!

Since the Hermite polynomials, and the wavefunctions after them, are composed of anonymous functions, we need to use`map(f,x)`

in order to map the function `f`

onto the array `x`

. Otherwise our polynomials only work on single values.
### Finding Zeros

The eigenvalue maps to the number of zeros in the wavefunction. Below, I use Julia’s roots package to indentify roots on the interval from -3 to 3.

## Example Result

## More to come

This barely scratched the surface into the richness that can be seen in the quantum harmonic oscillator. Here, we have developed a way for calculating the functions, and visualized the results. Stay tuned to hear about ground state energy, ladder operators, and atomic trapping.