When examining the simple undamped harmonic motion of a cart of mass m on a spring with stiffness $k$, we can derive the differential equation of motion using various techniques;techniques: Newton's 2nd law, d'Alembert's principle, conservation of energy, Lagrange's equations.., etc.
I don't understand the "conservation of energy" technique. It reminds me of the Hamiltonian formalism, but it looks so simple that it doesn't make sense to me.
- First, we write out the conservation of energy for our system (of course, no dissipation effects presumed)
$$E_k+E_p=C$$
$$\frac{m\dot x^2}{2}+\frac{kx^2}{2}=C$$$$\frac{m\dot x^2}{2}+\frac{kx^2}{2}=C.$$
- We take the time derivative of the equation
$$\frac{d}{dt}\left(\frac{m\dot x^2}{2}+\frac{kx^2}{2}\right)=0$$$$\frac{\mathrm{d}}{\mathrm{d}t}\left(\frac{m\dot x^2}{2}+\frac{kx^2}{2}\right)=0$$
$$m\dot x \ddot x+kx\dot x=0$$
$$\ddot x+\frac{k}{m} x=0$$$$\ddot x+\frac{k}{m} x=0.$$
And that is it. That is the differential equation governing simple harmonic motion. I don't get how are we able to so easily obtain the equation just by taking the derivative of the sum of the kinetic and the potential energy.
That sum is the Hamiltonian, $H=E_k+E_P$, and Hamilton's equations have a slightly more refined look that just
$$\frac{dH}{dt}=0\tag1$$$$\frac{\mathrm{d}H}{\mathrm{d}t}=0 \tag{1}\label{eq:1}$$
they are
$${\displaystyle {\frac {\mathrm {d} {\boldsymbol {q}}}{\mathrm {d} t}}={\frac {\partial {\mathcal {H}}}{\partial {\boldsymbol {p}}}},\quad {\frac {\mathrm {d} {\boldsymbol {p}}}{\mathrm {d} t}}=-{\frac {\partial {\mathcal {H}}}{\partial {\boldsymbol {q}}}}.}\tag2$$$${\displaystyle {\frac {\mathrm {d} {\boldsymbol {q}}}{\mathrm {d} t}}={\frac {\partial {\mathcal {H}}}{\partial {\boldsymbol {p}}}},\quad {\frac {\mathrm {d} {\boldsymbol {p}}}{\mathrm {d} t}}=-{\frac {\partial {\mathcal {H}}}{\partial {\boldsymbol {q}}}}.}\tag{2}\label{eq:2}$$
How is it that we can get the governing differential equation just by using $(1)$$\eqref{eq:1}$ instead of $(2)$$\eqref{eq:2}$ (ofc.of course, we can obtain it using the full Hamilton eqtionsequations $(2)$$\eqref{eq:2}$ also.)?