As classical mechanics was formulated into more advanced and deeper forms of advanced mechanics expressing the laws of physics more and more fundamentally, two big formulations of classical mechanics were developed; Lagrangian mechanics and Hamiltonian mechanics.
In short, here is a comparison of the key differences between Lagrangian and Hamiltonian mechanics:
|Lagrangian mechanics||Hamiltonian mechanics|
|One second order differential equation||Two first order differential equations|
|Difference of kinetic and potential energy||Sum of kinetic and potential energy|
|Motion is described by position and velocity||Motion is described by position and momentum|
|Configuration space||Phase space|
|The Lagrangian is not a conserved quantity||The Hamiltonian is a conserved quantity|
While there may seem to be a lot of differences between the two formulations of mechanics, they really are just different perspectives to describe the same phenomena; two sides of the same classical mechanics -coin. However, both of these formulations have their own advantages as well.
Also, in the context of classical mechanics, the Lagrangian and the Hamiltonian formulations are both equivalent to Newtonian mechanics. I go into more detail about this in my article comparing Lagrangian mechanics to Newtonian mechanics.
The equations of motion
In Lagrangian mechanics, the equations of motion are obtained by something called the Euler-Lagrange equation, which has to do with how a quantity called action describes the trajectory (path in space) that a particle or a system will take.
A detailed derivation and explanation of the Euler-Lagrange equation can be found in one of my articles here.
Anyway, the Euler-Lagrange equation is inherently a second order differential equation, which means that it involves second derivatives. Here is the equation in its full glory:
Let me just briefly go over the details of this equation, since we’ll need them later in more detail. The q and q̇ are simply just position and its time derivative (i.e. velocity, denoted by putting a dot above it). More accurately speaking, they are the generalized position and velocity coordinates, but this isn’t especially important for our purposes here.
The L here represents the Lagrangian of the system, which is a function that basically describes motion through the difference of kinetic and potential energy. This, and its relation to the Hamiltonian is discussed later, but you can find all the details in my article.
But how exactly is this Euler-Lagrange equation a second order differential
You see, the equation has a second order derivative with respect to time if you recall that q̇, the velocity, is just the time derivative of the position.
Then, as we have the other time derivative term, this velocity term gets time differentiated once more (becoming acceleration).
This is easiest to see through an example. If we have a super simple case of just one particle moving somewhere where it also has some potential energy V(x), the Lagrangian is simply:
Then plugging in this to the Euler-Lagrange equation and defining our generalized coordinates to be x, we get:
Here, it’s clear that the Euler-Lagrange equation ultimately leads to second order time derivative terms. Also notice how this equation is simply just F = ma.
On the other hand, there are two different, but similar looking equations of motion in the Hamiltonian formulation:
Both of these are just first order differential equations with respect to time, which becomes more clear if you know what the Hamiltonian is.
Anyway, sometimes working with simple first order derivatives might be easier even if there are two separate equations.
It simply depends on the situation whether using one second order differential (the Euler-Lagrange equation) or two first order differentials (Hamilton’s equations) is more beneficial, but this is still an important distinction between the two formulations.
Now, if you want to know more about what these Hamilton’s equations are and where they come from, you can read this article, which covers the basics of Hamiltonian mechanics.
For our purposes though, we’ll just go over what the H here is. The H is the Hamiltonian, which represents the total energy of the system and the general form of it is:
Using the example from earlier, recall what our Lagrangian was:
Now, inserting the Lagrangian into this Hamiltonian, defining the generalized coordinates to be x’s and summing over all the dimensions (just the x-dimension, so the i’s and the summation sign can be removed) gives:
If you recall from Lagrangian mechanics, the definition of generalized momentum is:
And inserting this into the Hamiltonian, we get:
This, as you can see is simply the total energy. Yes, this particular example was very simple, but the same concept applies to more difficult situations as well; the Hamiltonian represents total energy.
These examples clearly show one of the fundamental differences between the Lagrangian and the Hamiltonian. The Lagrangian is in the form of kinetic minus potential, T – V, while the Hamiltonian is T + V.
While this difference may seem quite insignificant, it actually has some pretty important consequences in terms of conservation laws, which are discussed more later in this article.
Also to be fair, both the Lagrangian and Hamiltonian take a little bit of a different form in other areas of physics, such as in relativity. This you can read more about in my introductory article on special relativity.
Momentum vs. velocity
One of the key differences that becomes explicitly important in for example quantum mechanics, is the fact that Hamiltonian mechanics uses position and momentum to describe motion and Lagrangian mechanics mainly deals with position and velocity.
Okay, you might ask what the point of that even is. Momentum and velocity are almost the same thing, right? Well, not quite.
While in classical mechanics the two don’t really have any too significant differences, once you start going into relativity and quantum mechanics, it becomes obvious why you would rather want to use momentum instead of velocity.
In relativity, mass has a little bit of different meaning than what we’re normally used to in classical physics, so it’s sometimes useful to describe the mass and velocity in just one quantity, momentum. Add to this the fact that momentum is a conserved quantity, while velocity generally is not.
This makes momentum much more useful in many cases where there are changes in the mass or velocity, since the quantity connecting the two (momentum) stays constant.
An example of these could be different kinds of collisions, since in those the momentum is simply just transferred between the colliding objects, but the total momentum stays constant.
Also in quantum mechanics, velocity usually does not have quite as clear of a meaning, while momentum is much easier to calculate and describe.
Ultimately, this relates to the uncertainty principle and the connection between position and momentum, which becomes more useful in quantum mechanics.
Earlier though, we calculated the Hamiltonian with velocities. Generally, the kinetic energy term in the Hamiltonian is replaced by something that rather includes momentum. This is simple to do. Just take the classical Newtonian version of momentum and rearrange that:
Then put that in the Hamiltonian for the velocity:
So, to recap; the Lagrangian is a function of position and velocity, while the Hamiltonian is a function of position and momentum. In generalized coordinates, this means that:
Phase space vs. configuration space
Lagrangian and Hamiltonian mechanics also differ from one another in the way they are represented. What I mean by this is that in physics, it is typical to represent physical systems in different spaces, which are useful to visualize states of systems as well as describe the nature of how a specific system works.
In particular, Lagrangian mechanics is usually represented in something called configuration space, while Hamiltonian mechanics is represented in phase space.
The difference between these two is that configuration space is the representation of all of the possible spacial positions of a system, while phase space is more like a representation of all the possible motion states of a system as phase space includes both momentum and position.
Let me explain this further. Both of these spaces are simply just coordinate systems with as many dimensions as the particular situation requires to describe a system.
First, let’s look at what configuration space really means. As an example, consider a simple case of two particles that are limited to only move horizontally, meaning in only one dimension.
In addition, the horizontal line where the particles can move has two walls on each side, so that the particles can only move within a length L between the walls.
We’re not going to take into account the collisions of these particles, so just imagine them as some sorts of “ghost” particles that can move through each other. Here’s what I mean:
Now, we add each of these particles’ positions in the configuration space as an axis. Note that if we had more than one dimension at play, then we would have to have an axis for each direction of each particle.
But in this case, we only have one dimension, the horizontal direction, as well as two particles, so two axis is enough. The configuration of the system then consists of both of the particles’ positions together. This is how our configuration space looks like in this example:
Now, imagine you start moving the particles along the line of length L. As they move from one of the boundaries to the other (from one side to the other), we can track both of the particles’ position on the configuration space and then get a representation for all of the possible configurations this system can have:
This yellow square in the video then represents all of the possible configurations, meaning all of the possible ways you can have the two particles positioned on this line L.
While this concept of configuration space and tracking the positions of things is useful in many cases, it really lacks to tell you anything about the motion of these particles. Configuration space only gives you information about the positions. To fix this, we need another space to also represent motion; phase space.
Phase space is simply a space in which you, in addition to mapping an object’s position, also map the momentum of the object at that particular position. So, instead of a point representing only the position, in phase space a point represents the position as well as momentum.
Let me explain this through a simple example. Let’s now only consider the particle A from our earlier example. In this case, we only need one axis to represent position and one for momentum. This is what the phase space of our system looks like:
To make this example more interesting, let’s make the particle accelerate up to the halfway point and decelerate the rest of the way as it moves along the line. Acceleration and deceleration of course mean that the momentum changes.
Let’s also choose the halfway point of the line to be our origin in phase space (this is a completely arbitrary choice though and doesn’t make any difference other than making the phase space look nice and symmetric). Now, as the particle moves, this is what happens:
This yellow rotated square here completely describes the laws of motion for this simple system. In general, phase space is useful for describing the motion of a system, unlike configuration space, which only gives information about the possible positions of the different components of the system.
If you’re interested in learning about phase spaces in more detail, this is covered in my article about Hamiltonian mechanics.
Conservation laws and applications to other areas in physics
Among other things, because the Hamiltonian represents the total energy of a system, it is a conserved quantity. That’s simply due to the law of energy conservation, which can actually be proven many different ways.
The Lagrangian, on the other hand does not really represent anything physically meaningful about a system, as it is the difference of energies.
The Lagrangian is simply a tool to describe motion (a very useful tool in all areas of physics for that matter), but it doesn’t represent any particular physical phenomena like the Hamiltonian does.
There is also no such thing as the conservation of the Lagrangian, so it is generally speaking not a conserved quantity. This clearly gives the Hamiltonian the upper hand in many things.
To be fair, in classical mechanics, the differences between Hamiltonians and Lagrangians are not too significant and you can mostly describe the same phenomena and derive the same laws of physics as well with either of them.
In more advanced areas of physics, you really start seeing the power of these formulations and their differences quite well.
For example, the Hamiltonian is a fundamental part of quantum mechanics as it can be used to calculate the total energy.
In fact, the Hamiltonian has an operator (a thing that gives you some measurable quantity) associated with it; the Hamiltonian operator, which looks like this:
Essentially, the first term is just the kinetic energy and the second is the potential.
It turns out that among other things, this operator also tells you how the system changes with time (time-evolution) when you apply it to a wave function, so it is extremely important for quantum mechanics, partly also because it has a conservation law associated with it.
The Lagrangian, on the other hand, is used more in something like classical field theory and quantum field theory, simply because the principle of stationary action applies to fields as well, and that is what Lagrangian mechanics is fundamentally based on.
Anyway, the bottom rule is that in classical mechanics, Lagrangian and Hamiltonian mechanics can both be used for pretty much the same things and it is mostly a matter of preference or choice. They both give you the same equations of motion and they can both derive you the same laws of physics.