# How can I derive the Hamiltonian of simple harmonic oscillator from this Lagrangian?

I'm working through Leonard Susskind's Theoretical Minimum: Classical Mechanics and I can't seem to understand how the Hamiltonian of a simple harmonic oscillator is derived from the following Lagrangian:

$$L~=~\frac{\omega}{2} \dot q^2 - \frac{\omega}{2}q^2$$

where $\omega=\sqrt{\frac{k}{m}}$.

The main problem I'm having is that while I understand the basic substitution required to transform the Lagrangian into the Hamiltonian form, I can't understand how the final form of the Hamiltonian is derived in the book:

$$H~=~\frac{\omega}{2}(p^2 + q^2)$$

$$H= \frac{p^2}{m} - \frac{p^2}{2m^2\omega} + \omega\frac{q^2}{2}$$

I don't see the intuition behind the substitutions necessary to derive the final form of this equation. How does $\frac{p^2}{m} - \frac{p^2}{2m^2\omega}$ become $\frac{\omega}{2}p^2$?

• Have you heard of the Legendre transformation? – ACuriousMind Aug 18 '14 at 13:06
• RAther than say "I made it this far:", could you walk us through the steps you took to get to the formula below that line? I say this because it's definitely wrong -- just look at the units your Hamiltonian should have, and the units that your terms have. – Jerry Schirmer Aug 18 '14 at 13:24
• Apparently there are as many as 58 errors in this book; many of them quite signicificant! Check out the errata file: madscitech.org/tm/errata.pdf – user60765 Oct 10 '14 at 0:20

I don't know where you're getting those $m$s from, or what substitution you're making. The appropriate substitution to perform is $$p = \frac{\partial L}{\partial \dot{q}} = \omega \dot{q}.$$ If you do this, then the hamiltonian becomes $$H = p\dot{q} - L = \frac{p^2}{\omega} - \frac{p^2}{2\omega} + \frac{1}{2} \omega q^2 = \frac{1}{2\omega}\left(p^2 + \omega^2 q^2\right).$$ This is still not the hamiltonian you mentioned, but it is the one corresponding to your lagrangian. I think, however, that it is unlikely that the lagrangian you wrote down is correct, since the units are bizarre: your kinetic term has dimensions $L^2/T^3$, while your potential term has $L^2/T$. A more typical lagrangian would be $$L = \frac{1}{2} m \dot{q}^2 - \frac{1}{2} m \omega^2 q^2$$ which gives as its hamiltonian $$H = \frac{1}{2m} \left( p^2 + m^2 \omega^2 q^2 \right).$$

Once you have the Lagrangian (1) (there is a mistake in your equation, look at the book), just express the momemtum as $p = \partial L / \partial \dot{q} = \dot{q}/\omega$. Insert this expression in the lagrangian expression, and you have the result.

I know this was asked years ago but I just finished this exercise myself..

First know that the $L$ you wrote is not the same as the books which is: $$L=\frac {1}{2\omega} \dot q^2 - \frac {\omega}{2}q^2$$

Now find conjugate momentum $$\frac {\partial L}{\partial \dot q} = \rho = \frac {\dot q}{\omega}$$

it follows that: $$\dot q = \rho \omega$$

Plug into the definition of H:

$$H = \rho \dot q - (\frac{1}{2\omega}\dot q^2 - \frac{\omega}{2}q^2)$$

Then substitute the $\dot q$ 's for $\rho$'s :

$$H = \rho \frac {\rho \omega}{\omega} - \frac {(\rho \omega)^2}{2\omega} + \frac {\omega}{2}q^2$$

We now have the form $H = \rho \dot q - T + V$. The book goes on to say (pg 150) that if $L$ is expressed as $T - V$ (which, it is) then: $$H = T + V$$ in our case $T = \frac {(\rho \omega)^2}{2\omega}$ and $V = \frac {\omega}{2}q^2$

finally $$H = \frac {(\rho \omega)^2}{2\omega} + \frac {\omega}{2}q^2$$

This simplifies to the $H$ you pointed out