Category:
If the Lagrangian does not depend on time explicitly, the Hamiltonian \(H=\sum_{k=1}\frac {\partial{L}}{\partial{\dot q_k}}\dot q_k-L\) is a constant of motion. For conservative systems of many particles, the Hamiltonian coincides with the total energy. is conserved.
Conservation of Energy
If the Lagrangian does not depend on time explicitly, there is a conservation law and the corresponding conserved quantity will be called as Hamiltonian. The Hamiltonian coincides with energy $(=KE+PE)$ for a mechanical systems. For other physical systems also it qualifies to be identified with energy. If Lagrangian does not contain $t$ explicitly
\begin{equation} \frac{\partial{L}}{\partial{t}}=0 \end{equation} \begin{equation} and ~~~~~~~~~ \frac{dL}{dt}=\sum_k \frac{\partial{L}}{\partial{ q_k}}\dot q_k+\sum_k\frac{\partial{L}}{\partial{\dot q_k}}(\ddot q_k) \end{equation}
using Euler Lagrange EOM we get
\begin{eqnarray}
\frac{dL}{dt} &=& \sum_k\Big[\frac {d}{dt}(\frac{\partial{L}}{\partial{\dot
q_k}})\dot q_k + \frac{\partial{L}}{\partial{\dot q_k}}\ddot q_k\Big]\\
&=&\frac{d}{dt}\sum_{k=1}\frac{\partial{L}}{\partial{\dot q_k}}\dot q_k
\end{eqnarray}
\begin{equation} \frac{d}{dt}\Big(\sum_k\frac{\partial{L}}{\partial{\dot q_k}}\dot q_k-L\Big )=0 \end{equation}
Hence $H$ defined by
\begin{equation} H\stackrel{\rm def}{\equiv}\sum_{k=1}\frac {\partial{L}}{\partial{\dot q_k}}\dot q_k-L \end{equation}
is a constant of motion. We can also write
\begin{equation} H= \sum_{k=1}^{N}p_k\dot{q}_k-L \end{equation}
where $p_k=\frac{\partial{L}}{\partial{\dot q_k}}$ is called the {\bf canonical momentum conjugate} to the coordinate $\dot q_k$and $H$ will be called {\bf Hamiltonian} of the system In an alternate form of dynamics, the canonical momenta take over the role played by velocities and Hamiltonian becomes central quantity which governs the dynamics.The EOM can be written in an alternate form called the Hamiltonian EOM. In the Hamiltonian dynamics the velocities are eliminated in favour of canonical momenta.
For conservative mechaniical systems of many particles, the Hamiltonian coincides with total energy as sum of kinetic and potential energies.
An Example:
Let us consider a single particle moving in force field described by potential energy $V(\vec{r})$. Then \begin{equation} L=\frac{1}{2}m\dot{\vec {r}}^{\,2} - V(\vec{r}); \qquad\vec {r}=(x,y,z) \end{equation} the canonical momenta are \begin{equation} p_x=\frac{\partial{L}}{\partial{\dot x}} = m\dot x;~~~~~ p_y=\frac{\partial{L}}{\partial{\dot y}}=m \dot y;~~~~ p_z=\frac{\partial{L}}{\partial{\dot z}}=m\dot z, \end{equation} and the Hamiltonian is given by
\begin{eqnarray}
H &=& \sum p_k\dot q_k-L \\
&=& p_x m\dot x+p_ym\dot y+p_zm\dot z - L \\
&=& m(\dot x^2+\dot y^2+\dot z^2)-[\frac{1}{2}m(\dot x^2+\dot y^2+\dot
z^2)-V(\vec r)] \\
&=& \frac{1}{2}m(\dot x^2+\dot y^2+\dot z^2)+V(\vec {r}) \\
&=& \frac{1}{2}m\dot{\vec {r}}\,^2+V(\vec{r})
\end{eqnarray}
Thus the canonical momenta, in this example, coincide with the components of momentum $m\dot{\vec r}$ and Hamiltonian is equal to the energy. However, it must be remarked that {\it the canonical momenta are not always equal to `ordinary' momenta and Hamiltonian need not be a sum of} $K.E+P.E$. This is the case when the system is described, for example, by a velocity dependent generalized potential. Motion of a charged particle in external magnetic field constitutes an example of this type where the canonical momentum is not equal to ordinary momentum.