# Hamiltonian for the two-body problem

References: Shankar, R. (1994), Principles of Quantum Mechanics, Plenum Press. Section 2.5; Exercise 2.5.4.

Here we derive the equations of motion of the two-body problem using the Hamiltonian formalism.

The Hamiltonian is given by

$\displaystyle H\left(q,p\right)=\sum_{i}p_{i}\dot{q}_{i}-L\left(q,\dot{q}\right) \ \ \ \ \ (1)$

where the velocities ${\dot{q}_{i}}$ are expressed in terms of the positions ${q_{i}}$ and momenta ${p_{i}}$. In this case, we start with the Lagrangian in terms of the centre of mass position ${\mathbf{r}_{CM}}$ and the relative position ${\mathbf{r}}$ of mass 2 to mass 1.

 $\displaystyle L$ $\displaystyle =$ $\displaystyle \frac{1}{2}\left(m_{1}+m_{2}\right)\left|\dot{\mathbf{r}}_{CM}\right|^{2}+\frac{1}{2}\frac{m_{1}m_{2}}{m_{1}+m_{2}}\left|\dot{\mathbf{r}}\right|^{2}-V\left(\mathbf{r}\right)\ \ \ \ \ (2)$ $\displaystyle$ $\displaystyle =$ $\displaystyle \frac{M}{2}\left|\dot{\mathbf{r}}_{CM}\right|^{2}+\frac{\mu}{2}\left|\dot{\mathbf{r}}\right|^{2}-V\left(\mathbf{r}\right) \ \ \ \ \ (3)$

where ${M=m_{1}+m_{2}}$ is the total mass and ${\mu=\frac{m_{1}m_{2}}{m_{1}+m_{2}}}$ is the reduced mass.

There are potentially 6 velocity components and 6 coordinate components in the Lagrangian, but the 3 components of ${\mathbf{r}_{CM}}$ do not appear, which simplifies things a bit. To convert to a Hamiltonian, we need the momenta

$\displaystyle p_{i}=\frac{\partial L}{\partial\dot{q}_{i}} \ \ \ \ \ (4)$

The ${x}$ component of momentum of the centre of mass is

$\displaystyle p_{CM,x}=\frac{\partial L}{\partial\dot{r}_{CM,x}}=M\dot{r}_{CM,x} \ \ \ \ \ (5)$

The other two components of the centre of mass velocity, and of the relative velocity, have a similar form, and in general we can write

 $\displaystyle p_{CM,i}$ $\displaystyle =$ $\displaystyle M\dot{r}_{CM,i}\ \ \ \ \ (6)$ $\displaystyle p_{i}$ $\displaystyle =$ $\displaystyle \mu\dot{r}_{i} \ \ \ \ \ (7)$

In vector notation, this becomes

 $\displaystyle \dot{\mathbf{r}}_{CM}$ $\displaystyle =$ $\displaystyle \frac{\mathbf{p}_{CM}}{M}\ \ \ \ \ (8)$ $\displaystyle \dot{\mathbf{r}}$ $\displaystyle =$ $\displaystyle \frac{\mathbf{p}}{\mu}\ \ \ \ \ (9)$ $\displaystyle \left|\dot{\mathbf{r}}_{CM}\right|^{2}$ $\displaystyle =$ $\displaystyle \frac{\left|\mathbf{p}_{CM}\right|^{2}}{M^{2}}\ \ \ \ \ (10)$ $\displaystyle \left|\dot{\mathbf{r}}\right|^{2}$ $\displaystyle =$ $\displaystyle \frac{\left|\mathbf{p}\right|^{2}}{\mu^{2}} \ \ \ \ \ (11)$

The Lagrangian thus becomes

$\displaystyle L=\frac{\left|\mathbf{p}_{CM}\right|^{2}}{2M}+\frac{\left|\mathbf{p}\right|^{2}}{2\mu}-V\left(\mathbf{r}\right) \ \ \ \ \ (12)$

The Hamiltonian is

 $\displaystyle H$ $\displaystyle =$ $\displaystyle \mathbf{p}\cdot\dot{\mathbf{r}}+\mathbf{p}_{CM}\cdot\dot{\mathbf{r}}_{CM}-L\ \ \ \ \ (13)$ $\displaystyle$ $\displaystyle =$ $\displaystyle \frac{\left|\mathbf{p}\right|^{2}}{\mu}+\frac{\left|\mathbf{p}_{CM}\right|^{2}}{M}-\left[\frac{\left|\mathbf{p}_{CM}\right|^{2}}{2M}+\frac{\left|\mathbf{p}\right|^{2}}{2\mu}-V\left(\mathbf{r}\right)\right]\ \ \ \ \ (14)$ $\displaystyle$ $\displaystyle =$ $\displaystyle \frac{\left|\mathbf{p}_{CM}\right|^{2}}{2M}+\frac{\left|\mathbf{p}\right|^{2}}{2\mu}+V\left(\mathbf{r}\right) \ \ \ \ \ (15)$

Once we’ve got the Hamiltonian, we can apply Hamilton’s canonical equations to get the equations of motion.

 $\displaystyle \frac{\partial H}{\partial p_{i}}$ $\displaystyle =$ $\displaystyle \dot{r}_{i}\ \ \ \ \ (16)$ $\displaystyle -\frac{\partial H}{\partial r_{i}}$ $\displaystyle =$ $\displaystyle \dot{p}_{i} \ \ \ \ \ (17)$

Since ${\mathbf{r}_{CM}}$ does not appear in the Hamiltonian, we have

 $\displaystyle \dot{\mathbf{p}}_{CM}$ $\displaystyle =$ $\displaystyle 0\ \ \ \ \ (18)$ $\displaystyle \mathbf{p}_{CM}$ $\displaystyle =$ $\displaystyle \mbox{constant} \ \ \ \ \ (19)$

so the momentum of the centre of mass does not change, as expected.

For ${\mathbf{r}}$, we have

 $\displaystyle \frac{\partial H}{\partial p_{i}}$ $\displaystyle =$ $\displaystyle \frac{p_{i}}{\mu}=\dot{r}_{i}\ \ \ \ \ (20)$ $\displaystyle \frac{\partial H}{\partial r_{i}}$ $\displaystyle =$ $\displaystyle \frac{\partial V}{\partial r_{i}}=-\dot{p}_{i} \ \ \ \ \ (21)$

The first equation tells us nothing new, while the second is just Newton’s law for a central force: ${\mathbf{\dot{p}}=-\nabla V}$.

# Hamiltonians for harmonic oscillators

References: Shankar, R. (1994), Principles of Quantum Mechanics, Plenum Press. Section 2.5; Exercises 2.5.2 – 2.5.3.

Here are a couple of examples of equations of motion using the Hamiltonian formalism. First, we look at the simple harmonic oscillator, in which we have a mass ${m}$ sliding on a frictionless horizontal surface. The mass is connected to a spring with constant ${k}$, with the other end of the spring connected to a fixed support.

The Hamiltonian is given by

$\displaystyle H\left(q,p\right)=\sum_{i}p_{i}\dot{q}_{i}-L\left(q,\dot{q}\right) \ \ \ \ \ (1)$

where the velocities ${\dot{q}_{i}}$ are expressed in terms of the positions ${q_{i}}$ and momenta ${p_{i}}$. In this case, we have, using the coordinate ${x}$ as the displacement from equilibrium

 $\displaystyle L\left(x,\dot{x}\right)$ $\displaystyle =$ $\displaystyle \frac{1}{2}m\dot{x}^{2}-\frac{1}{2}kx^{2}\ \ \ \ \ (2)$ $\displaystyle p$ $\displaystyle =$ $\displaystyle \frac{\partial L}{\partial\dot{x}}=m\dot{x}\ \ \ \ \ (3)$ $\displaystyle \dot{x}$ $\displaystyle =$ $\displaystyle \frac{p}{m}\ \ \ \ \ (4)$ $\displaystyle L\left(x,\dot{x}\left(x,p\right)\right)$ $\displaystyle =$ $\displaystyle \frac{p^{2}}{2m}-\frac{1}{2}kx^{2}\ \ \ \ \ (5)$ $\displaystyle H$ $\displaystyle =$ $\displaystyle \frac{p^{2}}{m}-\left(\frac{p^{2}}{2m}-\frac{1}{2}kx^{2}\right)\ \ \ \ \ (6)$ $\displaystyle$ $\displaystyle =$ $\displaystyle \frac{p^{2}}{2m}+\frac{1}{2}kx^{2} \ \ \ \ \ (7)$

We can now apply Hamilton’s canonical equations:

 $\displaystyle \frac{\partial H}{\partial p}$ $\displaystyle =$ $\displaystyle \dot{x}\ \ \ \ \ (8)$ $\displaystyle -\frac{\partial H}{\partial x}$ $\displaystyle =$ $\displaystyle \dot{p} \ \ \ \ \ (9)$

We get

 $\displaystyle \frac{\partial H}{\partial p}$ $\displaystyle =$ $\displaystyle \frac{p}{m}=\dot{x}\ \ \ \ \ (10)$ $\displaystyle -\frac{\partial H}{\partial x}$ $\displaystyle =$ $\displaystyle -kx=\dot{p} \ \ \ \ \ (11)$

We thus get a pair of first order ODEs which can be solved in the usual way, given ${x\left(0\right)}$ and ${p\left(0\right)}$. The second order ODE that we got by using the Lagrangian method can be obtained by differentiating the first equation and plugging it into the second:

 $\displaystyle \ddot{x}$ $\displaystyle =$ $\displaystyle \frac{\dot{p}}{m}\ \ \ \ \ (12)$ $\displaystyle$ $\displaystyle =$ $\displaystyle -\frac{k}{m}x \ \ \ \ \ (13)$

From 7 we see that, since in the absence of external force, the total energy ${H=T+V=E}$ is a constant,

$\displaystyle \frac{p^{2}}{2m}+\frac{1}{2}kx^{2}=E=\mbox{constant} \ \ \ \ \ (14)$

This can be written as the equation of an ellipse:

$\displaystyle \frac{p^{2}}{b^{2}}+\frac{x^{2}}{a^{2}}=1 \ \ \ \ \ (15)$

where

 $\displaystyle a^{2}$ $\displaystyle =$ $\displaystyle \frac{2E}{k}\ \ \ \ \ (16)$ $\displaystyle b^{2}$ $\displaystyle =$ $\displaystyle 2mE \ \ \ \ \ (17)$

We can use the Hamiltonian formalism to get the equations of motion of the coupled harmonic oscillator. From our Lagrangian treatment, we had

$\displaystyle L=\frac{1}{2}m\left(\dot{x}_{1}^{2}+\dot{x}_{2}^{2}\right)-k\left(x_{1}^{2}+x_{2}^{2}-x_{1}x_{2}\right) \ \ \ \ \ (18)$

Converting to coordinates and momenta, we have

 $\displaystyle p_{i}$ $\displaystyle =$ $\displaystyle \frac{\partial L}{\partial\dot{x}_{i}}=m\dot{x}_{i}\ \ \ \ \ (19)$ $\displaystyle \dot{x}_{i}$ $\displaystyle =$ $\displaystyle \frac{p_{i}}{m}\ \ \ \ \ (20)$ $\displaystyle H$ $\displaystyle =$ $\displaystyle \sum_{i}p_{i}\dot{x}_{i}-L\left(x,\dot{x}\right)\ \ \ \ \ (21)$ $\displaystyle$ $\displaystyle =$ $\displaystyle \frac{1}{m}\left(p_{1}^{2}+p_{2}^{2}\right)-\left[\frac{1}{2m}m\left(p_{1}^{2}+p_{2}^{2}\right)-k\left(x_{1}^{2}+x_{2}^{2}-x_{1}x_{2}\right)\right]\ \ \ \ \ (22)$ $\displaystyle$ $\displaystyle =$ $\displaystyle \frac{1}{2m}\left(p_{1}^{2}+p_{2}^{2}\right)+k\left(x_{1}^{2}+x_{2}^{2}-x_{1}x_{2}\right) \ \ \ \ \ (23)$

Applying the canonical equations gives

 $\displaystyle \frac{\partial H}{\partial p_{i}}$ $\displaystyle =$ $\displaystyle \frac{p_{i}}{m}=\dot{x}_{i}\ \ \ \ \ (24)$ $\displaystyle -\frac{\partial H}{\partial x_{1}}$ $\displaystyle =$ $\displaystyle -2kx_{1}+kx_{2}=\dot{p}_{1}\ \ \ \ \ (25)$ $\displaystyle -\frac{\partial H}{\partial x_{2}}$ $\displaystyle =$ $\displaystyle -2kx_{2}+kx_{1}=\dot{p}_{2} \ \ \ \ \ (26)$

Again, by taking the derivative of the first line and substituting into the last two lines, we get back the previous equations of motion:

 $\displaystyle \ddot{x}_{1}$ $\displaystyle =$ $\displaystyle -2\frac{k}{m}x_{1}+\frac{k}{m}x_{2}\ \ \ \ \ (27)$ $\displaystyle \ddot{x}_{2}$ $\displaystyle =$ $\displaystyle \frac{k}{m}x_{1}-2\frac{k}{m}x_{2} \ \ \ \ \ (28)$