Let's consider the case of a simple harmonic oscillator.
For a spring-mass system, we have the potential energy $U(x)=1/2\kappa x^2$, where $\kappa$ is the spring constant. Insert the potential energy into the time-independent Schrödinger equation, we have
Solving this differential equation is beyond the scope of this series. However, we can still guess and check the simplest solution, a Gaussian. Actually, a Gaussian do satisfy the above differential equation. Start with $\psi(x)=A\exp(-ax^2)$, and plug back into the differential equation. The result is that $a=\sqrt{m\kappa}/2\hbar$. Then applying normalization condition gives $A=(m\kappa/\pi^2\hbar^2)^{1/8}$.
Actually this Gaussian is the first eigen equation $\psi_0(x)=(m\kappa/\pi^2\hbar^2)^{1/8}\exp(-(\sqrt{m\kappa}/2\hbar)x^2)$, and its corresponding eigen energy is $E_0=\hbar/2\sqrt{\kappa/m}$. It turned out that the complete eigen equations and eigen energies are
Here $\omega_0=\sqrt{\kappa/m}$ is the natural frequency, and $H_n$ is the Hermite functions (physics) which is defined as
Notice that the eigen energies are equally separated by $\hbar\omega_0$, Thus it is convenient to work in the energy basis, instead of using real space wave functions. Introducing the energy eigenstates $\ket{n}$, and define following operators:
Here the subscription under $\omega$ is omitted for simplicity. Pay attention that here $\hat{x}$ and $\hat{p}$ are operators as well, and if were applied to wave functions, they could be expressed as $\hat{x}=x$, and $\hat{p}=-i\hbar\frac{\partial}{\partial x}$.
One can check the effect of applying $a$ or $a^\dagger$ to an eigen wave equation is to turn it into another eigen wave equation with eigen energy either increased or decreased by $\hbar\omega$ . Thus, in energy basis, we have
Notice that
Therefore, we can define number operator as $N=a^\dagger a$. Then, the Hamiltonian can be expressed as