# Constant of motion that is not the hamiltonian

Given the lagrangian $L(x,\dot x)=\frac12 (\dot x_1^2+\dot x_2^2)-\frac k 2(x_1-x_2)^2$, we know that its hamiltonian is a constant of motion. (See here)

Is there another function $f$, not of the form $f(\mathcal{H})$, that is also a constant of motion?

That is, we look for functions $f$ of $x, \dot x$ or of $x,p$ that are invariant on solutions of the hamiltonian equations.

Such functions should satisfy $0=\frac{\mathrm{d} f}{\mathrm{d} {t}}= \frac{\partial f}{\partial {x}} \frac{\mathrm{d} x}{\mathrm{d} {t}} + \frac{\partial \mathcal{f}}{\partial {\dot x}} \frac{\mathrm d \dot x}{\mathrm{d} {t}}$ in the $f(x,\dot x)$ case, and similarly for the $f(x,p)$ case. We don't seem to have any relations to use in order to simplify this equation and derive an example for $f$.

In terms of center of mass coordinates $$R = \frac{1}{2}\left(x_1 + x_2\right)$$ and $$r = x_1 - x_2,$$ the Lagrangian is $$L(r,R,\dot r, \dot R)={\dot R}^2 + \frac{1}{4} {\dot r}^2 -\frac{k}{2}r^2.$$ Since $$\frac{d}{dt}\left(\frac{\partial L}{\partial \dot R}\right) = \frac{\partial L}{\partial R} = 0,$$ $$\frac{\partial L}{\partial {\dot R}} = 2 {\dot R} = \dot x_1 + \dot x_2 = constant.$$ That is, momentum of the system is conserved.
We shall build such a function $f(x, \dot x)$. First we write down the Euler-Lagrange equations: $\ddot x_1=-k(x_1-x_2)$ and $\ddot x_2=+k(x_1-x_2)$.
Now note that by chance, the solution satisfies $\ddot x_1+\ddot x_2=0$. So our desired function is required to be constant on some $(x_1,x_2)$ that satsify $\ddot x_1+\ddot x_2=0$; we simply take
$f(x, \dot x)=\dot x_1 + \dot x_2$
and get the required identity, $\frac{\mathrm{d} f}{\mathrm{d} {t}}=0. \;\;$