A particle of mass $m$ can move in one dimension under the influence of two springs connected to fixed points a distance $a$ apart (see figure). The springs obey Hooke’s law and have zero unstretched lengths and force constants $k_1$ and $k_2$, respectively.
a) Using the position of the particle from one fixed point as the generalized coordinate $q$, find the Lagrangian and the corresponding Hamiltonian. Is the energy conserved? Is the Hamiltonian conserved?
b) Introduce a new coordinate $Q$ defined by
$$Q= q-b \;\sin(\omega t) \\ b=\frac{k_2}{k_1+k_2} a $$
What is the Lagrangian in terms of $Q$? What is the corresponding Hamiltonian? Is the energy conserved? Is the Hamiltonian conserved?