 Path:  physics insights > basics >

Basic Lagrangian Mechanics

This page contains an extremely simple but (hopefully!) informative introduction to Lagrangian mechanics.

"Lagrangian mechanics" is, fundamentally, just another way of looking at Newtonian mechanics.  Newtonian mechanics, in a nutshell, says:

(1a) I've labeled them with their common names: the second and third laws.  The "first law", which I didn't show, can be derived from the other two laws, if we assume all forces arise from interactions between objects.  The "Second law" as shown here assumes the mass of a body is constant (unless it ejects a second body or merges with a second body); that's true for Newtonian mechanics but not in relativity theory.  From these two (or three) laws one can derive conservation of energy, momentum, and angular momentum.

The fundamental forces in the universe are all conservative, and many forces we deal with in everyday life are conservative as well (friction being one obvious exception).  A conservative force can be represented as the gradient of a potential; when an object is being affected only by conservative forces, we can rewrite the second law as:

(1b) or, in vector form, using r as the object's position vector,

(1c) where φ is the potential function.

The "Lagrangian formulation" of Newtonian mechanics is based on equation (1c), which, again, is just an alternate form of Newton's laws which is applicable in cases where the forces are conservative.  Lagrangian mechanics adds no new "semantics" -- it's just a mathematical change, not a change in the physics.

So why use it?  Because...

... Newtonian mechanics has a problem:  It works very nicely in Cartesian coordinates, but it's difficult to switch to a different coordinate system.  Something as simple as changing to polar coordinates is cumbersome; finding the equations of motion of a particle acting under a "central force" in polar coordinates is tedious.  The Lagrangian formulation, in contrast, is independent of the coordinates, and the equations of motion for a non-Cartesian coordinate system can typically be found immediately using it.  That's (most of) the point in "Lagrangian mechanics".

Before we go on I should hasten to add that the Lagrangian formulation also generalizes very nicely to handle situations which are outside the realm of basic Newtonian mechanics, including electromagnetism and relativity.  But at the moment we're primarily concerned with the coordinate-independent feature.

The Lagrangian and the Principle of Least Action

Newton's laws are relationships among vectors, which is why they get so messy when we change coordinate systems.  The Lagrangian formulation, on the other hand, just uses scalars, and so coordinate transformations tend to be much easier (which, as I said, is pretty much the whole point).  Given a Lagrangian , which is a function of the location in space and the velocity, we define the action:

(2) Given particular starting and ending positions, the system follows a path between the start and end points which minimizes the "action".  Let's call the coordinates in space "q1" through "qn".  On the shortest path page,  we showed visually that, on the path of least action, for each coordinate, we must have:

 (3) The Lagrangian, , is chosen so that the the path of least action will be the path along which Newton's laws are obeyed.  That's it; fundamentally, it's all there is to it.  For Newtonian mechanics, the Lagrangian is chosen to be:

 (4) where T is kinetic energy, (1/2)mv2, and V is potential energy, which we wrote as φ in equations (1b) and (1c).  For example, for gravity considered in a small region, we might use V=mgh.  For gravity considered over a larger volume, we might use V=-Gm1m2/r.

We'll stick with the convention of using "qi" for the spatial coordinates on the rest of this page.  With that convention, and with the assumption that we're working in an inertial frame with Cartesian coordinates, let's write out the kinetic energy and some of its derivatives (watch out for those "flyspec" dots over the q's -- they almost shrank out of existence when LaTex typeset the equations!):

(5) For an ordinary potential function, which doesn't depend on velocity, we can also write:

(6) (Note that we wrote "Fi" for the ith component of the force vector there, which is a little different from what we were using subscripts for back in (1a).)

Now, plugging the derivatives in (5) and (6) into equation (4) for the Lagrangian, we see that:

(7) And so, for Cartesian coordinates, using equation (4) for our Lagrangian, equation (3) is equivalent to Newton's second law. To obey the second law, a particle must travel a path which minimizes the "action"; if we can find that path, then we'll know what the particle is going to do.

The nice thing is that the path of least action is the same, no matter what coordinates you use.  It's just the integral over time of a scalar -- that won't change, no matter how you choose to measure distances in space.  So, to find the equations of motion in an arbitrary coordinate system K, we just need to figure out what the kinetic and potential energy must be expressed in the K coordinates.  Then we write equation (4), take the derivatives used in equation (3) -- still in K coordinates -- and we'll obtain the equations of motion.

Friction and other Non-Conservative Forces

Friction is not conservative, and so it doesn't fit neatly into the scheme we've outlined so far.  Certain non-conservative forces, including some cases of "constant friction" (which doesn't depend on velocity), can be integrated to obtain a "psuedo-potential" function, often called a "generalized potential", which can then be added to V in the Lagrangian formulation already given.  But it's sometimes difficult to do that.  In particular, velocity-dependent friction is difficult to model that way.

For cases where we can't find a generalized potential function, if we can determine a function for the force in the coordinate system in which we're working, we can simply add the force to equation (3), which then becomes:

(8) where Qi is the non-conservative force (which is most often friction).

As we just mentioned, friction often has a constant component.  That's what causes your car to "jerk" back slightly when it finally comes to a stop if you don't lift your foot up from the brake pedal as it finally stops.  It's also why the braking force feels roughly the same no matter what speed the car is traveling at when you press on the brake pedal.  But friction frequently also has a velocity dependent component; in viscous drag that's the only component.  Both components typically depend linearly on the force between the surfaces, which often depends on the mass of a sliding object, and both depend on the direction of the object's motion.  Overall, then, in many cases we can write the frictional force as

(9) Keep in mind that the frictional force, as I just wrote it, is coordinate dependent.  If you change coordinates, you need to recompute it; there's nothing "automatic" about it.

A Simple Example:  Gravity in 2 dimensions

We'll use r and θ for the coordinates.  To find the Lagrangian we need the kinetic and potential energies. The straight-line velocity of a particle in polar coordinates is dr/dt in the radial direction, and r(dθ/dt) in the tangential direction.  The (Newtonian) gravitational potential is -mK/r, where K=GM (which I take to be positive), and M is the mass of the gravitating body (e.g., the Earth or the Sun).  So, after a small amount of effort figuring out the kinetic and potential energy in polar coordinates, we have:

(10) From here on, it's purely mechanical.  Taking the derivatives one by one, we obtain:

(11a) (11b) (11c) (11d) (11e) (11f) Note equation (11b).  That's the angular momentum, and if we combine (11a) and (3), we see that its time derivative is zero -- so, it must be conserved.  Conservation of angular momentum (for this case!) just fell out of the analysis "for free".

Plugging the derivatives from (11a), (11c), (11d), and (11f) into equation (3), we find the equations of motion:

(12a) (12b) The first term on the right side of (12b) is what's commonly called the "centrifugal force".  We can see from equation (12b) that we can have a circular orbit if the "centrifugal force" balances the gravitational attraction; in that case there won't be any radial acceleration.  So, if we replace r(dθ/dt) with v in equation (12b), we can solve immediately for the velocity needed for a circular orbit at any particular altitude:

(13) Here are a few additional simple examples which may help in seeing how one can actually use the Lagrangian in a mechanics problem:

Rotating Polar Coordinates -- A particle's motion in a rotating frame
Rotating Rectangular Coordinates -- A rotating frame again, this time in rectangular coordinates
Two Masses, a Ramp, and a String -- A simple example problem, done with and without friction

Other Lagrangians

It's common to define the Lagrangian for a particular situation as being the function whose path integral must be minimized to get the right equations of motion.  This is useful, again, because it makes it so easy to switch to an arbitrary coordinate system, where the problem may be simpler the but the equations of motion would otherwise be difficult to find.

In electromagnetism, if we set c=1, then the Lagrangian of a particle is given as:

(14) where A is the vector magnetic potential; . Minimizing the action then produces the right motion according to the Lorentz force law, f = q(E+vxB).  Note that in this case the "potential" actually depends on the velocity as well as the position, so it's not really a Newtonian "potential" function at all!  But that doesn't matter; what matters is that, in Cartesian coordinates, the least action principle works with this Lagrangian function.  Since it's a scalar, once we know that, we also know that we can use the same approach to attack the problem using any coordinate system.

In relativity, if we set c=1, we can define the Lagrangian of a free particle to be:

(15) The path of least action then becomes a worldline which follows a geodesic.

A few words about Hamiltonian mechanics

Equation (3) is a second order differential equation.  The Hamiltonian formulation, which is a simple transform of the Lagrangian formulation, reduces it to a system of first order equations, which can be easier to solve.  It's heavily used in quantum mechanics.  The Hamiltonian is the "Legendre transform" of the Lagrangian, but we could just as well say the Lagrangian is (part of) what we get when we integrate the Hamiltonian by parts -- or we could say we just use the product rule (the "Leibnitz rule") to transform between them.

Suppose we have a function u(v), where u is monotonic increasing.  Then it's invertible; in that case we can talk sensibly about the function v(u).  See figure 1.  We've shown a curve representing either u(v) or v(u).  The blue area "under" the curve is the integral of u as a function of v, which we've called f.  The pink area to the left of the curve, which we've labeled g, is the integral of v as a function of u.

figure 1 -- The transformation between f and g In figure 1, consider the function uv. Its derivative, written in differential form, is:

(h.1) Integrating both sides:

(h.2) This is obvious from figure 1.   Equally obvious from figure 1 is:

(h.3) That's integration by parts, of course, which is just a different way of looking at the product rule.  From the definitions of f, g, v, and u as illustrated in figure 1, we also have:

(h.4) Now, let's replace f with , and replace g with .  We'll define such that it's a function of the qi (the position) and the pi (the momenta).  In contrast, is a function of position and velocity.  To do this, in the above discussion we let
 Figure 2 -- The transformation between and : (h.5) As we see in figure 2, the transformation in equation (h.3) then becomes:

(h.6) Just as with u and v, the roles of dqi/dt and pi are swapped vis a vis and .  But the dependency of on position is the same that of (save that it is negated): we didn't transform the position variables (but did flip the sign).  So we have:

 (h.7) Those are the Hamiltonian equations of motion. Instead of a single second-order equation for each coordinate, we have two first-order equations, which may be easier to solve.

The derivation I gave above was hardly air-tight.  However, it's easy to verify that in Newtonian mechanics using Cartesian coordinates, the Hamiltonian we obtain from equation (h.6) reduces to:

 (h.8) which is just the total energy.  In that case it's also easy to verify equations (h.7) directly.  As with the Lagrangian formulation, however, much of the value of the Hamiltonian formulation lies in the fact that equations (h.7) are true regardless of the coordinates we're using.  Also keep in mind that equation (h.8) is only necessarily true when the Lagrangian chosen is the "pure Newtonian" T-V.  For other Lagrangians, the Hamiltonian won't necessarily be the total energy of the system.

Page created on 11/13/06; last updated, with additions and different equation numbers, on 12/1/06.  Corrected equation numbers, 10/4/07.