[[Harmonic Oscillator]] # Lagrangian The [Lagrangian](Harmonic%20Oscillator.md#Lagrangian) is as follows $\mathcal{L}(q,\dot{q})=\frac{1}{2}m\dot{q}^2-\frac{k}{2}q^2$ # Hamiltonian The [Hamiltonian](Harmonic%20Oscillator.md#Hamiltonian) is obtained from the [Lagrangian](Harmonic%20Oscillator.md#Lagrangian) through a [Legendre transform](Hamiltonians.md#Legendre%20transform). This gives $\mathcal{H}(q,p)=\frac{1}{2}\frac{p^2}{m}+\frac{k}{2}q^2$ Alternatively we may write the Hamiltonian as $\mathcal{H}(q,p)=\frac{1}{2}\frac{p^2}{m}+\frac{m\omega^2}{2}q^2$ where $k=m\omega^2.$ ## Energy of a 1D Harmonic Oscillator ![](Harmonic%20Oscillator.md#%5E0c15d6) Thus the energy at an initial displacement is given by the potential in terms of a known displacement $q=x_0,$ such that $E=\frac{1}{2}m\omega^2 x_0^2$ ^8583bd # Equations of motion ## Lagrange Equation of motion The [Euler-Lagrange equation](Euler-Lagrange%20equation.md) of motion, a [[2nd order ODE]], is $\ddot{q}=-\frac{k}{m}q = -\omega^2 q$ where $\omega^2=\frac{k}{m}$ is the [[Frequency]]. ### Solution The solution is a classical [superposition](Superposition%20principle.md) of $\sin$ and $\cos$ functions: $q(t) = q_1 \cos{(\omega t)}+q_2 \sin{(\omega t)} = Ae^{i\omega t}+Be^{-i\omega t}$ ## Hamilton Equations of Motion The [[Hamilton equations of motion]] in terms of [Conjugate momentum](Conjugate%20position-momentum%20coordinates.md), $p$, are $\dot{q}=\frac{p}{m}\;\;\;\;\mbox{and}\;\;\;\;\dot{p}=-kq$ ### solution The pair of solutions is as follows where we can treat these equations as [[2nd order ODE]]s. $(q(t),p(t))=(q_i \cos{(\omega t)}+q_s \sin{(\omega t)}, -\omega mq_i \cos{(\omega t)}+ \omega mq_s \sin{(\omega t)})$ # 3D Harmonic oscillator These results generalize trivially to the [three dimensional case](3D%20Harmonic%20Oscillator.md) #Mechanics #Mechanics/WaveMechanics #PhysicalExamples/PhysicalExamplesInMechanics