In Goldstein's Classical Mechanis section 8.2 (page 345 in the third edition) there is as example that should illustrate how the Hamiltonian can be conserved without energy being conserved. It goes like this:
Suppose a point mass $m$ is attached to a spring, of force constant $k$, the other end of which is fixed on a massless cart that is being moved uniformly by an external device with speed $v_0$ if we take as the general coordinate the position $x$ then the Lagrangian of the system is obviously $$L=\frac{m\dot{x}^2}{2}-\frac{k}{2}(x-v_0t)^2$$$$L=\frac{m\dot{x}^2}{2}-\frac{k}{2}(x-v_0t)^2.$$
whyWhy is this true?
if the coodrinatecoordinate is given by $x-v_0t$ then ''$\dot{x}$'' should be $\dot{x}-v_0$ but that would mean that the Lagrangian would be
$$L=\frac{m(\dot{x}-v_0)^2}{2}-\frac{k}{2}(x-v_0t)^2=L=\frac{m(\dot{x}^2-2\dot{x}v_0+v_0^2)}{2}-\frac{k}{2}(x-v_0t)^2$$$$L=\frac{m(\dot{x}-v_0)^2}{2}-\frac{k}{2}(x-v_0t)^2=L=\frac{m(\dot{x}^2-2\dot{x}v_0+v_0^2)}{2}-\frac{k}{2}(x-v_0t)^2,$$
which is obviously not the same as the above Lagrangian.
whatWhat is wrong with this picture?