Can anyone explain to me Hamiltonian mechanics relation to conservation of energy? I'm not very good at mathematics, and I know it's important into understanding Hamiltonian mechanics. However, can it be explained in a simple way?


4 Answers 4


The time evolution of any quantity $F(q(t),p(t);t)$, where $q,p$ denote the generalized positions and momenta, can be written using the chain rule, Hamilton's equations and the Poisson bracket $\{\cdot,\cdot\}$:

$\frac{\mathrm dF}{\mathrm dt} = \sum_i\left[\frac{\partial F}{\partial q_i}\dot q_i+\frac{\partial F}{\partial p_i}\dot p_i\right]+\frac{\partial F}{\partial t} = \sum_i\left[\frac{\partial F}{\partial q_i}\frac{\partial H}{\partial p_i}-\frac{\partial F}{\partial p_i}\frac{\partial H}{\partial q_i}\right]+\frac{\partial F}{\partial t} = \{F,H\}+\frac{\partial F}{\partial t}$.

A similar equation called Ehrenfest's theorem also holds in quantum mechanics where one considers the time evolution of expectation values and the Poisson bracket is replaced by the commutator.

In particular, for $F=H$ one immediately sees that $\frac{\mathrm dH}{\mathrm dt}=\frac{\partial H}{\partial t}$ as $\{H,H\}=0$. Thus, for a Hamiltonian w/o explicit time-dependence, i.e. when no external energy is fed into the system, the total energy is conserved.


Recall that we say a physical quantity $Q$ is conserved provided its value does not change with time as a system evolves. Mathematically, a physical quantity is just a function that assigns a number $Q(q,p,t)$ to each state (point in phase space plus time) of the system at hand, so conservation of such a quantity can be expressed mathematically as follows: \begin{align} \frac{d}{dt} Q(q(t), p(t),t) = 0 \end{align} for all $(q(t), p(t))$ that are solutions to the equations of motion of the system.

The Hamiltonian $H$ and total energy $E$ of a given system are two such quantities. There is a large class of systems for which the hamiltonian and the total energy are the same, namely $H=E$. In such systems, the energy of the system is conserved if and only if the Hamiltonian of the system is conserved.

  • 1
    $\begingroup$ This answer could be improved by adding that, for not explicitly time-dependent Hamiltonians, the Hamiltonian is always conserved along a trajectory that is a solution to the e.o.m. $\endgroup$
    – ACuriousMind
    Commented Nov 21, 2015 at 14:03
  • $\begingroup$ I was recently reminded in bead on rotating ring that the Hamiltonian does not represent the physical energy of the bead. A pitfall worth mentioning? $\endgroup$ Commented Nov 21, 2015 at 17:54

This answer assumes the reader is new to the concepts discussed.

I discuss the Hamiltonian in classical mechanics. (It applies to both classical and quantum mechanics, but was invented before people knew about quantum).

You can apply the Hamiltonian whenever all the forces that do work are conservative (a.k.a. whenever you can define a potential energy relevant to every force that does work). Forces that do work change the kinetic energy of the system.

Why is the Hamiltonian equal to the total energy at all?

The Hamiltonian formulation builds off the Lagrangian, so to understand it, you need to know a few things about the Lagrangian formulation. Both of these are alternatives to the Newtonian formulation. Each can be can be derived from the others.

In Newtonian mechanics, the equation of motion is $\vec F = m \vec a$, where the force and acceleration are both vector quantities. This one equation actually represents three equations for every spatial direction $x, y,$ and $z$, for each of the $n$ objects or particles involved. The math can get complicated fast. Note that $m \vec a = \dot{\vec p}$, where $\dot{\vec p}$ is the rate of change in momentum over time. Given an initial state (in terms of positions and velocities), the equations of motion uniquely specify how the positions will evolve over time.

The Lagrangian $\mathcal{L}(q_1, ...,q_n, \dot{q_1}, ...,\dot{q_n})$ is defined as $\mathcal{L} = T - U$, where $T$ is the kinetic energy, and $U$ is the potential energy. It is a function of the generalized position coordinates $(q_1, ...,q_n)$ and the generalized velocities $(\dot{q_1}, ..., \dot{q_n})$. There will always be some equations relating these generalized coordinates to the more familiar (Cartesian) expressions of positions $(x_1,y_1,z_1, ... x_n,y_n,z_n)$ and velocities $(\dot{x_1},\dot{y_1},\dot{z_1}, ... \dot{x_n},\dot{y_n},\dot{z_n})$ of the $n$ objects or particles. Defining our own coordinates relevant to the system at hand can greatly simplify the equations of motion. I won't go into the proof here but it turns out that the equations of motion are $\frac{\partial \mathcal{L}}{\partial q_i} = \frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot{q_i}}$, for every generalized coordinate $q_i$. The quantity $\mathcal{L}$ is not intuitively meaningful, but using it in the equations above lets you naturally derive equations of motion in terms of any generalized coordinates (it's much harder to do in Newtonian mechanics). $\frac{\partial \mathcal{L}}{\partial q_i}$ is called the generalized force, and $\frac{d}{dt}\frac{\partial \mathcal{L}}{\partial \dot{q_i}}$ is the time derivative of the generalized momentum, $p_i = \frac{\partial \mathcal{L}}{\partial \dot{q_i}}$. If you use Cartesian coordinates for position and velocity, these are the usual force and momentum.

Mathematically, the Hamiltonian is a function of the generalized positions $(q_1, ...,q_n)$ and the generalized momentums $(\dot{p_1}, ... \dot{p_n})$:

$$H = \sum_i p_i \dot{q_i} - \mathcal{L}$$

It has it's own associated equations of motion which you can derive from the Lagrangian ones.

It turns out that if the generalized coordinates are natural (more on this below), then $\sum_i p_i \dot{q_i}$ is just twice the kinetic energy. That means

$$H = 2T - \mathcal{L} = 2T - (T-U) = T + U$$

Or the total energy of the system.

Also, if the Lagrangian is not explicitly dependent on time, then the Hamiltonian is not either. If the coordinates are natural and the the Lagrangian has no explicit time-dependence, then the Hamiltonian is the total energy, and it is conserved.

The Lagrangian can be explicitly time-dependent, even if the coordinates are natural. This is if the potential energy ($U$) is time-dependent. ($\mathcal{L} = T - U$) For instance, say your system involves charged particles and there is an electromagnet outside the system. The electromagnet is supplied with current, and the potential energy changes even though nothing in your system moved. The Hamiltonian still represents the total energy, it's just that the energy of your system is not conserved.

Natural Coordinates:

The Hamiltonian is equal to the total energy of a system when:

The relationship between the coordinates you use to describe the position of every particle or object and their actual positions is consistent over time. In other words, the coordinates are natural.

Mathematically, the coordinates are natural if $\vec r_\alpha = \vec r_\alpha(q_1, q_2, ...,q_n)$ and not if $\vec r_\alpha = \vec r_\alpha(q_1, q_2, ...,q_n, t)$.
$\vec r_\alpha$ is the position of an object or particle $\alpha$ in physical space. You are probably more used to seeing expressed in Cartesian coordinates: $\vec r_\alpha = \vec r_\alpha(x, y, x)$.

An example of unnatural coordinates: say we had a pendulumn affixed to the ceiling of an accelerating train car. The position $x$ relative to some stationary axes is $at^2$ + a function of the pendulum angle, where $a$ is the acceleration of the train car. If you describe the position relative to a set of axes that moves with the train car, say position $q = x - at^2$, then the math will be easier, the coordinates are more convenient for the system at hand, but the relationship between the true position $x$ and the coordinate $q$ depends on time. In this case, the kinetic energy associated with a constant value of $q$ keeps increasing, and the Hamiltonian is not equal to the total energy.


If time derivative of hamiltonian equals to zero the hamiltonian is conserved. ie., if Poission bracket (H,H)+Partial time derivative of H = 0 the hamiltonian is conserved. If hamiltonian is conserved the energy is conserved.


Not the answer you're looking for? Browse other questions tagged or ask your own question.