Physics Stack Exchange is a question and answer site for active researchers, academics and students of physics. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just finished a Classical Mechanics course, and looking back on it some things are not quite clear. In the first half we covered the Lagrangian formalism, which I thought was pretty cool. I specially appreciated the freedom you have when choosing coordinates, and the fact that you can basically ignore constraint forces. Of course, most simple situations you can solve using good old $F=ma$, but for more complicated stuff the whole formalism comes in pretty handy.

Then in the second half we switched to Hamiltonian mechanics, and that's where I began to lose sight of why we were doing things the way we were. I don't have any problem understanding the Hamiltonian, or Hamilton's equations, or the Hamilton-Jacobi equation, or what have you. My issue is that I don't understand why would someone bother developing all this to do the same things you did before but in a different way. In fact, in most cases you need to start with a Lagrangian and get the momenta from $p = \frac{\partial L}{\partial \dot{q}}$, and the Hamiltonian from $H = \sum \dot{q_i}p_i - L$. But if you already have the Lagrangian, why not just solve the Euler-Lagrange equations?

I guess maybe there are interesting uses of the Hamiltion formalism and we just didn't do a whole lot of examples (it was the harmonic oscillator the whole way, pretty much). I've also heard that it allows a somewhat smooth transition into quantum mechanics. We did work out a way to get Schrödinger's equation doing stuff with the action. But still something's not clicking.

My questions are the following: Why do people use the Hamiltonian formalism? Is it better for theoretical work? Are there problems that are more easily solved using Hamilton's mechanics instead of Lagrange's? What are some examples of that?

share|cite|improve this question
BTW, can you refer video lectures on classical mechanics? – ketan Apr 8 '14 at 5:06
up vote 39 down vote accepted

There are several reasons for using the Hamiltonian formalism:

1) Statistical physics. The standard thermal states weight pure states according to

$$\text{Prob}(\text{state}) \propto e^{-H(\text{state})/k_BT}$$

So you need to understand Hamiltonians to do stat mech in real generality.

2) Geometrical prettiness. Hamilton's equations say that flowing in time is equivalent to flowing along a vector field on phase space. This gives a nice geometrical picture for how time evolution works in such systems. People use this framework a lot in dynamical systems, where they study questions like 'is the time evolution chaotic?'.

3) Generalization to quantum physics. The basic formalism of quantum mechanics (states and observables) is an obvious generalization of the Hamiltonian formalism. It's less obvious how it's connected to the Lagrangian formalism, and way less obvious how it's connected to the Newtonian formalism.

[Edit to answer Javier's comment] This might be too brief, but the basic story goes as follows:

In Hamiltonian mechanics, observables are elements of a commutative algebra which carries a Poisson bracket $\{,\}$. The algebra of observables has a distinguished element, the Hamiltonian, which defines the time evolution via $d\mathcal{O}/dt = \{H,\mathcal{O}\}$. Thermal states are simply linear functions on this algebra. (The observables are realized as functions on the phase space, and the bracket comes from the symplectic structure there. But the algebra of obserbables is what really matters: You can recover the phase space from the algebra of functions.)

On the other hand, in quantum physics, we have an algebra of observables which is not commutative. But it still has a bracket $\{,\} = \frac{i}{\hbar}[,]$ (the commutator), and it still gets its time evolution from a distinguished element $H$, via $d\mathcal{O}/dt = \{H,\mathcal{O}\}$. Likewise, thermal states are still linear functionals on the algebra.

share|cite|improve this answer
Maybe I need to learn more, but I don't see how QM is an obvious generalization of Hamiltonian mechanics. Sure, there is a Hamiltonian, but AFAIK the Hilbert space / operators part doesn't have a lot to do with what I learned in class. – Javier Dec 5 '13 at 15:32
@JavierBadia: See response in my edit. – user1504 Dec 5 '13 at 16:07
Minor comment to the answer (v3) The signs in all 3 equalities in the answer are opposite of standard physics convention. Usually one has $d\mathcal{O}/dt = \{\mathcal{O},H\}_{PB}$ and $\{,\}_{PB} = \frac{1}{i\hbar}[,]$, see e.g. this Phys.SE post. – Qmechanic Dec 5 '13 at 17:22
@Qmechanic: Some of us prefer to go backwards in time. :) – user1504 Dec 5 '13 at 18:14
Personally I wouldn't agree with point 2. The picture I have encountered most often in dynamical systems is the flow in $(q,\dot{q})$ space, not $(q,p)$. In other words, in the coordinates of the Lagrangian and not the Hamiltonian. – ComptonScattering Dec 7 '13 at 17:33

Some more comments to add to user1504's response:

  1. For a system with configuration space of dimension $n$, Hamilton's equations are a set of $2n$, coupled, first-order ODEs while the Euler-Lagrange equations are a set of $n$ uncoupled, second-order ODEs. In a given problem it might be easier to solve the first order Hamilton's equations (although sadly, I can't think of a good example at the moment).

  2. It's true that quantum mechanics is usually presented in the Hamiltonian formalism, but as is implicit in user1504's answer, it is possible to use a Lagrangian to quantize classical systems. The Hamiltonian approach is commonly referred to as "canonical quantization", while the Lagrangian approach is referred to as "path integral quantization".

Edit. As user Qmechanic points out, my point 2 is not strictly correct; path integral quantization can also be performed with the Hamiltonian. See, for example, this physics.SE post:

In Path Integrals, lagrangian or hamiltonian are fundamental?

share|cite|improve this answer
Should that second $2n$ be just $n$? I would hope the Lagrangian method doesn't require twice as many IC's. – Chris White Dec 5 '13 at 7:04
@ChrisWhite Woops! Thanks. – joshphysics Dec 5 '13 at 7:28
Comment to the last sentence of the answer (v2): It should be stressed that there also exists a Hamiltonian formulation of the path integral, cf. e.g. this Phys.SE post. – Qmechanic Dec 5 '13 at 7:41
I have an example for you. First order ODEs are much easier to solve numerically: you can write a vector $x$ with 2n generalized coordinates and momenta, and write $\dot{x} = F(x)$. Then at each point $x$ in phase space, you know which direction to "step" in. You can even analyze stability by linearizing $F$, and looking at the sign of the real parts of the eigenvalues of the jacobian. – ZachMcDargh Dec 7 '13 at 17:20
A remark to (1): It is always trivial to translate a system of second order equations into first oder equations: Just replace $\ddot x$ by $\dot y$ (introducing the function $y$) and add the equation $y = \dot x$. You don't need Hamilton's formulation to achieve that. Hamilton's equations are however much more symmetrical than the ones I just proposed. – Friedrich May 6 '14 at 16:56
  1. First of all, Lagrangian is a mathematical quantity which has no physical meaning but Hamiltonian is physical (for example, it is total energy of the system, in some case) and all quantities in Hamiltonian mechanics has physical meanings which makes easier to have physical intuition.

  2. In Hamiltonian mechanics you have canonical transformations which allows you change coordinates and find an easier canonical coordinates and momenta in which it is easier to solve problem.

  3. The best of all is, Lagrangian is a powerful mathematical method to solve problems in classical mechanic but Hamiltonian is a powerful method to solve problems in classical mechanics, quantum mechanics, statistical mechanics, thermodynamics... etc actually almost all physics...

For example: In thermodynamics: Gibbs free energy, Helmholtz free energy... are all canonical transformations of Hamiltonian..

share|cite|improve this answer
Hamiltonian is not always total energy, though it is in many of the systems one typically studies in a classical mechanics course. – BMS Dec 5 '13 at 4:03
Yes, it isn't always total energy but my point is "it is always physical." – maynak Dec 5 '13 at 4:23
Not all Hamiltonian quantities have direct physical meaning. Generalized momenta and coordinates can be mixed functions of Cartesian coordinates and their corresponding momenta, with no guarantee that the result has simple physical interpretation. Also in thermodynamics, Gibbs and Helmholtz functions are not Legendre transformations of Hamiltonian, but of internal energy. For homogeneous system, this is function $U(S,V,N)$, which is related to Hamiltonian from mechanics, but still is a very different thing. – Ján Lalinský Dec 5 '13 at 14:23
Lagrangian has a clear physcial meaning. That is the difference between the kinetic and potential energy. – Dimiter P Jan 8 at 0:25

An additional point which was not emphasized by the previous answers enough is that Hamiltonian formalism allows you to do canonical transformations to switch to the best possible coordinate system in phase space to describe the system. This is a lot better than in Lagrangian mechanics, where you can only do coordinate transformations in configuration space. (The phase space has twice the number of dimensions, so you have a larger freedom.) I find Poisson brackets very useful in Hamiltonian mechanics to write the equations of motion of an arbitrary function of phase space variables: $\dot{Q} = \{Q, H\}$. It is possible to find conserved quantities ($\dot{Q}=0$) in Hamiltonian mechanics which are not obvious in Lagrangian mechanics.


  1. Normal mode oscillations. If the Hamiltonian turns out to be a quadratic function of coordinates and momenta for a system of $N$ objects, e.g. $H=\sum_{ij} M_{ij} q_i q_j + \sum_{ij} M_{ij} p_i p_j$ then you can simply do a canonical transformation along the eigenvectors of $M_{ij}$ to diagonalize $M_{ij}$, and your system separates into independent harmonic oscillators.

  2. Perturbation theory. You can simply examine the oscillations around the equilibrium state by expanding the Hamiltonian to second order in the phase space variables.

  3. In planetary dynamics, there is a large separation of scales between the interaction of planets with the central star and their mutual interactions. "Secular theory" describes the very long term evolution of the system using Hamiltonian mechanics. You can apply a canonical transformation (Von Zeipel transformation) along the action-angle variables of the short term interactions. You can then derive the long term evolution, (for example that of the eccentricities and inclinations), investigate whether the long-term perturbing effects of planets add up resonantly or not, whether the system is chaotic, etc.

share|cite|improve this answer

The canonical (Hamiltonian) formalism offers one of the main paths for quantizing gravity. General Relativity can be expressed in terms of the ADM 3+1 decomposition of spacetime:

And Hamiltonian's underlie quantum mechanics:

Not only does this provide an elusive link between otherwise fundamentally incompatible theories (quantum field theory and general relativity), but in the Hamiltonian formalism of GR it is possible to solve problems numerically which are otherwise extremely difficult or impossible via the standard Einstein Field Equations.

By the way, the Lagrangian (and Lagrange density) is physical in general relativity, since one can derive the Einstein Field Equations directly from the Einstein-Hilbert action. This minimization of action is also the foundation of the path integral approach to quantum field theory:

The Feynman diagrams so useful in QFT derive directly from this, and of course string theory is a higher dimensional generalization of the path integral approach.

share|cite|improve this answer

This is a fact about the hamiltonian compared to the lagrangian which I find not trivial (and worth to keep in mind).

Suppose that the lagrangian $L$ and hamiltonian $H$ are cyclic with respect to some coordinate $q_1$. Then we have a theorem (cfr. [1]):

The evolution of the other coordinates $q_2,...,q_n$ is the one of a system with $n-2$ independent coordinate $q_2,...,q_n$ with Hamiltonian $$H(p_2,...,p_n,q_2,...,q_n,t,c),$$ dependent from the parameter $c=p_1$.

Note that this is false if instead of $H$ we state the theorem for the lagrangian $L$.

To see exactly what I mean, consider the simplified Lagrangian of the two body problem: $$L=\frac{\mu}{2} (\dot r ^2+r^2\dot \varphi ^2 )-U(r).$$ We have $$p_\varphi=\mu r^2 \dot \varphi=\ell \quad(\text {constant}).$$ Now try to plug $$\dot \varphi=\frac{\ell}{\mu r^2}$$ inside the lagrangian and compare the equations of motion so obtained with the ones that you get plugging it directly into the equations of motion $\frac{\partial L}{\partial r}=\frac{d}{dt}\frac{\partial L}{\partial \dot r}$.

[1] “Mathematical methods of classical mechanics“ V.I. Arnold, §15 Cor.2.

share|cite|improve this answer

One way to see the relationship of Hamilotian classical mechanics and Quantum mechanics is not to look for a direct translation of Hamiltionian -> Quantum Hamiltionian (which exists: Geometric Quantization), but consider the reverse relationship. Given a Hamiltion operator and evaluating it on wave functions of the form $e^{\frac{i}{\hbar} \phi}$ (which can be thought as a highly located wave packet) simplifies in the limit $\hbar \to 0$ to the Hamiltion-Jacobi-equation with the classical Hamiltionian. This is known as WKB-approximation and also applies to optics (i.e light rays follow the integral curves of the associated Hamiltionian picture in first approximation).

share|cite|improve this answer

The Hamiltonian can be used to describe an evolution of the "density in phase" of a system of N bodies. The density in phase is a conserved quantity for a system in equilibrium by Liouville's Theorem. The position and momenta can describe any general intensive parameter. Gibbs used this approach to derive statistical mechanics.

This approach of the concept of the evolution of a probability density function can be used in many other applications. My current research applies this to state space control theory, economic analysis, and assessing radiation damage in cells. So while it is a little convoluted, it is extremely useful. It goes hand in hand with entropy maximization.

share|cite|improve this answer

Also, you can write Hamilton's equations of motion in sympletic form: $$ \dot\xi_i = \omega_{ij}\frac{\partial H}{\partial\xi_j} $$

Where $\xi_i$ are the coordinates in the phase space, that is, $\xi = (\mathbf q, \mathbf p)$. And, $\omega$ is the sympletic matrix: $$ \omega = \begin{bmatrix} 0 && -I_{n\times n} \\ I_{n\times n} && 0 \\ \end{bmatrix} $$

Where $I_{n\times n}$ is the identity matrix, with a system of $n$ spatial coordinates (and thus, $n$ speeds, and those, $2n$ amounts of phase space coordinates). Also, for an observable $G$, we have: $\dot G = \{G, H\}$ as you know. So, you can easily have the dynamics of an given observable $G$. All very nice and neat and general, but....

But.. here is what I consider to be the most amazing part of hamiltonian mechanics: $$ X = x^i\partial_i = \{\xi^i, H\}\partial_i $$

Where $X$ is an hamiltonian vector field. Now, instead, we can generalize for an observable $G$, its vector field: $$ X_G = x^i_G\partial_i, \quad x^i_G = \{\xi^i, G\} = \frac{d\xi^i}{d\epsilon} $$

For any given parameter $\epsilon$ for observable $G$, generating an operator $X_G$. Its first order taylor expansion: $$ \xi^i(\epsilon) - \xi^i(\epsilon_0) = (\epsilon - \epsilon_0)X_G\xi^i $$

Where operator $X_G$ is acting on $\xi^i$. We can solve the differential equation in sucessive infinitesimal transformations, arriving in the fundamental exponential limit, thus having the complete general solution of any hamiltonian system for any observable $G$: $$ \xi^i(\epsilon) = \exp\left(\Delta\epsilon X_G\right)\xi^i_0 $$

Do you understand the power of it?? Pointing out, again, here it is the solution of any hamiltonian system for any observable $G$ with parameter $\epsilon$ generated by operator $X_G$. If you want to analyse dynamics, then $\epsilon$ is the time, and $G$ is the hamiltonian, where $X_H$ defines the hamiltonian vector space. All hamiltonian systems has the same solution. The same solution!! So, lets solve for the dynamics (ie, where $\epsilon$ is time): $$ \xi^i(t) = \exp\left(\Delta t\frac{d}{dt}\right)\xi^i_0 $$

So, as you can see, pretty nice. Lagrange mechanics gives you nice unified equations of motion. Hamiltonian mechanics gives nice phase-space unified solutions for the equations of motion. And also gives you the possibility get an associated operator, and a coordinate-independent sympletic-geometrical interpretation. The former is crucial in quantum mechanics, the later is crucial in dynamical systems.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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