# Classical Mechanics – Lagrangian and Hamiltonian Formulations

Consider a mechanical system. The kinematics of this system is described by giving the space of states, ${\Gamma}$, for this system — a point of this ${\Gamma}$ specifies all that can be known of the system at a given moment of time. A function on ${\Gamma}$ is called an observable. Think of an observable as an measuring instrument. Then the value of the observable function, at a given point of ${\Gamma}$ (state) represents the number that this instrument would record, when applied to the system in that state. Now consider some number, ${s}$, of observables, say ${\left(w^1, \dots, w^s\right)}$. Then each state gives rise to ${s}$ numbers, namely the values of these ${s}$ functions at the corresponding point of ${\Gamma}$. These ${s}$ observables represent coordinates on the space of states provided the values of these ${s}$ numbers uniquely define the state. For a free particle, for example, a suitable system of coordinates on the space of states might consist of the following six observables: ${\left(x, y, z, v^x, v^y, v^z\right)}$, i.e., the position and the velocity components of the particle.

The dynamics of this system is specified by giving a certain vector field ${\xi}$ on ${\Gamma}$, called the dynamical vector field. In terms of a coordinate system, ${\left(w^1, \dots, w^s \right)}$, on ${\Gamma}$, ${\xi}$ is represented by ${s}$ functions of ${s}$ variables:

$\displaystyle \left(\xi^1\left(w^1, \dots, w^s\right), \xi^2\left(w^1, \dots, w^s\right), \dots, \xi^s\left(w^1, \dots, w^s\right)\right).$

These ${s}$ functions are called the components of ${\xi}$, i.e. ${\xi^7\left(w^1, \dots, w^s\right)}$ is the ${w^7}$-component of ${\xi}$. This dynamical vector field describes the dynamics of the system, in the following manner. If the system is left to its own devices, then it evolves, i.e. it traverses some curve ${\gamma(t)}$ in ${\Gamma}$, labeled by the time ${t}$. Thus, ${\gamma(3\text{ PM})}$ is that point of ${\Gamma}$ representing the state of the system at ${3\text{ PM}}$. In terms of some coordinate system, ${\left(w^1, \dots, w^s\right)}$, on ${\Gamma}$, this curve is described by ${s}$ functions of one variable (the time ${t}$): ${\left(w^1(t), \dots, w^s(t)\right)}$. So, for example, the ${s}$ numbers ${\left(w^1(3\text{ PM}), \dots, w^s(3\text{ PM})\right)}$ represent the coordinates of the state of the system at time ${3\text{ PM}}$. Now, the defining property of the dynamical vector field ${\xi}$ is that the curves in ${\Gamma}$ describing the evolution of the system be integral curves of ${\xi}$. This means, in more detail, that, at any point of ${\Gamma}$, the tangent to this curve is precisely the value of the vector field ${\xi}$ there. In terms of a coordinate system, this means that the ${w^i(t)}$ describing the path of the system satisfy the following system of ordinary differential equations:

$\displaystyle dw^i(t)/dt = \xi^i\left(w^1(t), w^2(t), \dots, w^s(t)\right).$

Here, ${i}$ ranges from ${1}$ to ${s}$, so there is a total of ${s}$ equations in this system. It follows that the time-rate of change, under the dynamics, of any observable ${f}$, is given by ${\xi \cdot \nabla f}$, the directional derivative of ${f}$ in the ${\xi}$-direction.

Now suppose we allow this system to interact with other systems, e.g. ourselves. Then, as a result of this interaction, the system will no longer have its dynamics described by ${\xi}$ — we, by pushing the system around, are capable of changing the dynamical behavior of the system. But some observables are not affected directly by such interactions. For a free particle, for example, the equations of motion (from which there can be read off the components of the dynamical vector field) are:

$\displaystyle dx/dt = v^x,\text{ }dy/dt = v^y,\text{ }dz/dt = v^z,\text{ }dv^x/dt = 0,\text{ }dv^y/dt = 0,\text{ }dv^z/dt = 0.$

If we now impose an interaction, represented by a force on the particle, then the first three equations remain the same, while a force-term appears in the last three. So the observables ${x}$, ${y}$, and ${z}$ are “not affected directly” by the interaction, while the observables ${v^x}$, ${v^y}$, and ${v^z}$ are. Returning to the general system, we say that observable ${f}$ is a configuration observable provided the time-rate of change of ${f}$ remains unchanged when interactions are turned on between our system and its environment. Configuration observables are typically denoted “${x}$.” So, we may choose a coordinate system of ${\Gamma}$ consisting of ${\left(x^1, \dots, x^n, c^{n+1}, \dots, c^s\right)}$. That is, the first ${n}$ coordinates are configuration observables, and the remaining ${s-n}$ are “other observables” (which, at the moment, may be chosen freely).

In order that a system have a Lagrangian formulation, it is necesssary, first, that it be possible to choose coordinates on ${\Gamma}$ consisting of ${\left(x^1, \dots, x^n, v^1, \dots, v^n\right)}$. That is, the first ${n}$ coordinates are configuration variables, while the remaining ${n}$ are precisely the corresponding velcotiy-components. So, in particular, this condition requires that ${s = 2n}$. A free particle, for example, satisfies this condition, while a ball rolling on a table (for which there are ${5}$ independent configuration observables, out of a total of ${8}$ observables required to specify a state) does not.

But, for a Lagrangian formulation, we require more than the necessary condition above. Let the above hold, and let us agree to use these coordinates, ${\left(x^1, \dots, x^n, v^1, \dots, v^n\right)}$, for the space of states. Let ${L}$ be any observable of our system, so ${L}$ is expressed as one function of ${2n}$ variables: ${L\left(x^1, \dots, x^n, v^1, \dots, v^n\right)}$. Given such an observable ${L}$, nobody stops us from writing down the following equation (for ${i = 1, \dots, s}$):

$\displaystyle \sum_j\left[\partial^2L/\partial v^i\partial v^j\right]dv^j/dt + \sum_j\left[\partial^2 L/\partial v^i\partial x^j\right]v^j - \partial L/\partial x^i = 0.$

If this equation, together with ${dx^i/dt = v^i}$ (which is the definition of velocity), give precisely and fully the equations of motion of the system, then ${L}$ is said to be a Lagrangian for the system. If there exists such a Lagrangian, then we say that the system has a Lagrangian formulation. Some systems (such as a damped harmonic oscillator) have no Lagrangian formulation (i.e. there is no observable ${L}$ such that the equation above is exactly the dynamical equation for a damped harmonic oscillator); some systems (such as a free particle) have a number of such Lagrangians. If you can find a Lagrangian, then you have a Lagrangian formulation; if you can’t then you don’t. And, at the moment at least, we “find” Lagrangians by trial and error — pick an observable ${L}$, and see if the equations above, for that ${L}$, reproduce precisely and fully the equations of motion of the system. The equation above was, of course, not selected randomly. Rather, it was motivated by a certain result in the calculus of variations. (In more detail, this is precisely the equation that results from extremizing the function on paths, ${x^i(t)}$, that results from integrating the Lagrangian over the path.) But this motivation is not essential for the statement of what a Lagrangian formulation means. Here is a useful result about systems with a Lagrangian formulation — for any such system, the observable given by ${\sum_j \left[v^j\partial L/\partial v^j\right] - L}$ is conserved (i.e. it remains constant along each dynamical trajectory; or in other words, it has vanishing directional derivative by the dynamical vector field ${\xi}$). Another useful observation is that, if a system possess a Lagrangian, then the Lagrangian is never unique. Indeed, if observable ${L}$ is a Lagrangian, then so is ${L + \sum_j v^j\partial h/\partial x^j}$, where ${h\left(x^1, \dots, x^n\right)}$ is any smooth function of the configuration coordinates. To check this, substitute this new candidate Lagrangian in the equation of motion above.

As an example, a suitable Lagrangian for a particle in a potential is that given by

$\displaystyle L\left(x, y, z, v^x, v^y, v^z\right) = m/2\left(\left(v^x\right)^2 + \left(v^y\right)^2 + \left(v^z\right)^2\right) - U(x, y, z),$

where ${U}$ denotes the potential. When does a system have a Lagrangian formulation, and when does it not? There seems to be no easy answer to this question. What you must do, at least in principle, is try various observables ${L\left(x^i, y^i\right)}$ to see if they lead to the correct equations of motion. If the one you happen to try does not work, then try another. But, mostly through experience, one acquires some skill in Lagrangian-selecting. For the vast majority of practical problems, the story is the following. The system has a “kinetic energy,” ${T\left(x^i, v^i\right)}$, which is quadratic in the velocity-components. This means, in more detail, that there is some symmetric, ${n \times n}$-matrix function of the configuration variables, ${M\left(x^j\right)_{ij}}$, such that ${T}$ is given by ${T\left(x^i, v^i\right) = 1/2\sum_{i,j}\left[M\left(x^k\right)_{ij}v^iv^j\right]}$. Furthermore, the system has a “potential energy,” ${U\left(x^i\right)}$, i.e. a certain function of the configuration variables. Then “the story” is that the Lagrangian is given by ${L\left(x^i, v^i\right) = T\left(x^i, v^i\right) = T\left(x^i, v^i\right) - U\left(x^i\right)}$. That is, in the vast majority of practical problems, this particular ${L\left(x^i, v^i\right)}$ does indeed give the correct equations of motion of the system. For instance, this is true for a particle in a potential, for which ${M\left(x^k\right)_{ij} = m\delta_{ij}}$, where ${\delta_{ij}}$ is the unit matrix (so ${M}$ is independent of ${x^k}$ in this case); and ${U\left(x^i\right)}$ is the potential. So, if you can identify such kinetic and potential energies, this is a good candidate for ${L}$. Unfortunately, this scheme does not always work. For a particle in a magnetic field, for example, there does exist a Lagrangian, but it is not of the form above. So, at least in principle (but rarely done in practice), one must check that this candidate Lagrangian actually works.

A system is said to have a Hamiltonian formulation if there exists a coordinate system on ${\Gamma}$ consisitng of ${\left(q^1, \dots, q^n, p_1, \dots, p_n\right)}$, where the ${q}$‘s are configuration observables and the ${p}$‘s are nonconfiguration observables, together with an observable ${H\left(q^1, \dots, q^n, p_1, \dots, p_n\right)}$ such that the system of equations

$\displaystyle dq^i/dt = \partial H(q, p)/\partial p_i,\text{ }dp_i/dt = -\partial H(q, p)/\partial q^i$

(for ${i = 1, \dots, n}$) give precisely the equations of motion of our system. Note that we have no designated the configuration observables ${q}$ (rather than ${x}$ as before) — this is just a convention. So, if you can find such coodinates and such an observable ${H}$, then you have a Hamiltonian formulation; if you can not, then you do not. The ${q}$‘s are called canonical configuration observables, the ${p}$‘s canonical momentum observables, and the observable ${H(q, p)}$ the Hamiltonian. For example, a particle in a potential has a Hamiltonian formulation. Let the new coordinates (in terms of the old) be ${q^i = x^i}$ and ${p_i = mv^i}$. Let the Hamiltonian observable be that given by ${H\left(q^i, p_i\right) = (1/2m)\left((p_1)^2 + (p_2)^2 + (p_3)^2\right) + U(q)}$. One checks that these choices do indeed lead, via the equation above, to the correct equations of motion for a particle in a potential. A damped harmonic oscillator, by contrast, does not have any Hamiltonian formulation. Note that, in order that a system have a Hamiltonian formulation, it is necessary that the dimension of the space of states ${\Gamma}$ be precisely twice the dimension of the space of configuration observables. Thus, for example, a ball rolling on a table is not even a candidate for a Hamiltonian formulation. If a system has a Hamiltonian formulation, then that formulation is never unique.

In principle, the method for deciding whether or not a system has a Hamiltonian formulation is, just as for the Lagrangian formulation, trial and error, ultimately augmented by some skill in Hamiltonian selection. One important result is the following — under the Hamilton equations, the observable ${H(q, p)}$ itself is conserved (i.e., is a constant of the motion). So, it is not even worth trying, as a candidate Hamiltonian, a nonconserved observable. For example, for a free particle, “${x}$” would be a terrible try for a Hamiltonian. In the vast majority of practical problems, the Hamiltonian is the energy of the system. Unfortunately, this is not enough information to write down the Hamiltonian formulation of the system. The problem is that, for the Hamiltonian formulation, you need both the observable ${H}$ and the canonical coordinates, ${\left(q^1, \dots, q^n, p_1, \dots, p_n\right)}$. If I just tell you ${H}$ (as an observable), that does not come with any instructions as to how to choose the ${p}$‘s, in order that the equations of motion take the desired form. In short, finding a Hamiltonian formulation for a system is in some ways easier than finding a Lagrangian formulation (in that you need only try conserved observables — and will try “the energy” first (if there is one)), and is in some ways harder (in that the remaining, nonconfiguration, coordinates are not handed to you on a silver platter, as in the Lagrangian formulation).

A crucial result in this subject is a construction that allows you to obtain, given a Lagrangian formulation of a system, a Hamiltonian formulation of that system. For fully ninety percent of all systems with a known Hamiltonian formulation, that formulation was obtained via this construction. Here it is. Let ${\left(x^1, \dots, x^n, v^1, \dots, v^n\right)}$ be the coodinates for the Lagrangian formulation of our system; and let ${L\left(x^i, v^i\right)}$ be the Lagrangian observable. We now set, for ${i = 1, \dots, n}$, ${p_i = \partial L/\partial v^i}$. This formula defines ${n}$ new observables, the ${p_i}$ (which are here given as functions of the old coordinates, ${\left(x^1, \dots, x^n, v^1, \dots, v^n\right)}$. We also set ${q^i = x^i}$. These — the ${\left(q^1, \dots, q^n, p_1, \dots, p_n\right)}$ — are our new coordinates (noting that they are indeed given as functions of the old). Now consider the observable ${H}$, given by ${H = \sum_j v^j \partial L/\partial v^j - L}$. Note that this is indeed an observable, and, in fact, that it is precisely the observable we found, earlier, to be conserved for any Lagrangian formulation). Then, we claim, these new coordinates (the ${\left(q^i, p_i\right)}$), with this new observable ${(H)}$, is indeed a Hamiltonian formulation for our system. What we must show, to prove this, is that the Hamilton equations, for these choices of coordinates and ${H}$, reduce exactly to the original (Lagrangian) equations for this system. The proof is straightforward. We essentially translate the (Lagrangian) equations of motion for the system into the coordinates ${\left(q^i, p_i\right)}$, and lo and behold, discover that the result is exactly the Hamilton equations, for this Hamiltonian and these canonical variables.

Note that the construction of the paragraph above gives a particular Hamiltonian formulation of the system (given some particular Lagrangian formulation, with which we started). There may very well be other Hamiltonian formulations of this system. There could be Hamiltonian formulations that do not arise in this way from any Lagrangian formulation. Indeed, it is possible, at least in principle, that a system might have a Hamiltonian formulation but not admit any Lagrangian formulation.

In any case, we have concluded that if there exists a Lagrangian formulation for a system, then there necessarily exists a Hamiltonian formulation for that system.