# Harmonic Oscillator

The harmonic oscillator is often used to model spring-mass systems. The force acting on the mass is proportional to the deviation of the spring from its neutral point $q$. This force leads to a potential $\frac{k}{2} \cdot q^2$. The mass has the kinetic energy $\frac{m}{2} \cdot \dot{q}^2=\frac{1}{2k} \cdot \dot{q}^2$. The Lagrangian of the system reads \begin{align} L=\frac{\dot{q}^2}{2 k}-\frac{k\, q^2}{2} \end{align} We easily derive the equations of motion by the formulas \begin{align} \tag{1} \frac{\partial L}{\partial q}=\dot{p}=-k\, q \end{align} \begin{align} \tag{2} \frac{\partial L}{\partial \dot{q}}=p=\frac{\dot{q}}{k} \end{align} This is a system of first order ordinary differential equations, but we can reduce it to the more familiar second order equation by plugging equation (2) into (1) \begin{align} \frac{d}{dt}\frac{\dot{q}}{k}=-k\, q\\ \ddot{q}=-k\, q \end{align}
We can derive the Hamiltonian formulation from the Lagrangian by plugging for $\dot{q}$ from (1) \begin{align} H&= \dot{q} p - L=\dot{q} p - L\\ &=k\, p^2 - \frac{\dot{q}^2}{2 k}+\frac{k\, q^2}{2}\\ &=k\, p^2 - \frac{k \,p^2}{2}+\frac{k\, q^2}{2}\\ \end{align} \begin{align} H&=\frac{k p^2}{2}+\frac{k\, q^2}{2}=\frac{k}{2}(p^2 + q^2)= const. \end{align} This last equation describes a circle in $pq$-space, with radius $r^2=p^2+q^2$. Each radius corresponds to a certain energy.