Harmonic oscillator

Lagrangian Mechanics viewpoint

It is a particle moving in a potential

u(x)=k2x2

In Lagrangian Mechanics approach we consider the Lagrangian

L=TU=12mx˙212kx2

Euler-Lagrange tell us

Lx=ddtLx˙Lx=kxddtLx˙=ddt(mx˙)=mx¨

and so

mx¨=kx

Hamiltonian point of view

The Hamiltonian for a simple harmonic oscillator is given by:

H=p22m+12mω2q2

where p is the momentum, m is the mass, ω is the angular frequency, and q is the position.
The corresponding Hamiltonian equations are:

p˙=Hq=mω2q

and

q˙=Hp=pm

These equations describe the time evolution of the momentum and position of the harmonic oscillator. The first equation is essentially Newton's second law (force equals mass times acceleration), and the second equation is the definition of velocity in terms of momentum.

Related: several coupled oscillators
Related: quantum harmonic oscillator.