Back to the on-screen lesson ·

Lagrange's equations

Hamilton's principle, the Lagrangian $T - U$, generalized coordinates and constraints, and Lagrange's equations for Atwood machines, rotating rods and spinning hoops.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

By the end of this lesson you will be able to choose generalized coordinates, write a system's Lagrangian, and derive and use its equations of motion.

2. What you already have

The last lesson found that the path making $\int f(y, y', x)\,dx$ stationary obeys the Euler–Lagrange equation, one for each unknown function. You can write kinetic and potential energies in any coordinates, and you have used polar coordinates to find accelerations the hard way. This lesson makes the calculus of variations into mechanics, and shows how it removes the need to find constraint forces or coordinate accelerations by hand.

3. Words for this lesson

TermWhat it means
Lagrangian$\mathcal{L} = T - U$, kinetic minus potential energy, as a function of $q$, $\dot{q}$ and $t$.
Action$S = \int\mathcal{L}\,dt$ along a path of the system through time.
Hamilton's principleThe actual motion makes the action stationary between fixed start and end configurations.
Generalized coordinatesAny set of numbers $q_1, \ldots, q_n$ that fixes the configuration, such as angles or distances.
Degrees of freedomThe number of independent generalized coordinates.
Holonomic constraintA constraint written as an equation among the coordinates, such as a string's fixed length.
Generalized momentum$p_i = \partial\mathcal{L}/\partial\dot{q}_i$.

4. Mechanics from a stationary action

Define the Lagrangian $\mathcal{L} = T - U$. Hamilton's principle says that of all the ways a system could get from one configuration at time $t_1$ to another at $t_2$, it takes the one that makes the action $S = \int_{t_1}^{t_2}\mathcal{L}\,dt$ stationary. The calculus of variations, with time in place of $x$, turns that into one equation for each coordinate:

$$\frac{\partial\mathcal{L}}{\partial q_i} = \frac{d}{dt}\frac{\partial\mathcal{L}}{\partial\dot{q}_i}, \qquad i = 1, \ldots, n.$$

These are Lagrange's equations. For a particle in Cartesian coordinates, $\mathcal{L} = \tfrac{1}{2}m\dot{x}^2 - U(x)$ gives $-\partial U/\partial x = m\ddot{x}$: exactly Newton's second law. The power of the method is that the $q_i$ can be any generalized coordinates, angles, arc lengths, distances along a wire, chosen so that the constraints are built in. A bead on a wire needs one coordinate, its position along the wire, and the normal force of the wire, which does no work, never appears.

Another way: picture

Newton's method asks, at every instant, what forces act and which way. Lagrange's method asks a different question about the whole motion: of all the histories that start and end in the right places, which one balances kinetic against potential energy just right. Both give the same answer, but the second lets you pick coordinates that fit the problem and ignore the forces that only keep things on track.

Another way: steps

  1. Count the degrees of freedom and choose that many generalized coordinates.
  2. Write $T$ and $U$ in those coordinates and their rates.
  3. Form $\mathcal{L} = T - U$.
  4. For each $q_i$: $\partial\mathcal{L}/\partial q_i = \frac{d}{dt}\partial\mathcal{L}/\partial\dot{q}_i$.
  5. Solve, or find equilibria and small oscillations.

5. Why Lagrange's equations are Newton's laws

For one particle in three dimensions with $U(\vec{r})$, $\mathcal{L} = \tfrac{1}{2}m(\dot{x}^2 + \dot{y}^2 + \dot{z}^2) - U$. Then $\partial\mathcal{L}/\partial x = -\partial U/\partial x = F_x$ and $\partial\mathcal{L}/\partial\dot{x} = m\dot{x} = p_x$, so Lagrange's $x$ equation reads $F_x = \dot{p}_x$. The same holds for $y$ and $z$: in Cartesian coordinates Hamilton's principle is Newton's second law.

Lagrange's equations hold in any coordinates because Hamilton's principle does not mention coordinates: the action is a number, whatever labels are used. If they hold for $x, y, z$, they hold for $r, \theta, \phi$ or anything else. This is the deep reason the method is so convenient: the one equation, applied in whatever coordinates suit the problem, automatically includes every centripetal and Coriolis term that took care to derive in the first lesson.

6. Constraints and why their forces disappear

A holonomic constraint is an equation among the coordinates: a pendulum's bob stays at distance $L$ from the pivot, and an Atwood machine's two masses move together because the string's length is fixed. Each such constraint removes one degree of freedom. Choosing generalized coordinates that satisfy the constraints automatically, an angle for the pendulum and one distance for the Atwood machine, leaves only the free motions.

The forces that enforce the constraints, the tension and the normal force, do no work on any motion the constraint allows, so they have no potential energy and never enter $\mathcal{L}$. That is why Lagrange's method finds the motion of a bead on a hoop without ever computing the push of the hoop. When the constraint force is itself wanted, the lesson after next shows how to recover it.

7. The Atwood machine and effective mass

The Atwood machine has one degree of freedom, $x$, the distance $m_1$ has fallen. The kinetic energy is $\tfrac{1}{2}(m_1 + m_2)\dot{x}^2$, and if the pulley is a uniform disk of mass $M$ and radius $R$ turning at $\dot{x}/R$, it adds $\tfrac{1}{2}\cdot\tfrac{1}{2}MR^2(\dot{x}/R)^2 = \tfrac{1}{4}M\dot{x}^2$. The potential energy is $-(m_1 - m_2)gx$.

Lagrange's equation gives $(m_1 + m_2 + \tfrac{1}{2}M)\ddot{x} = (m_1 - m_2)g$. The combination $m_1 + m_2 + \tfrac{1}{2}M$ is an effective mass: everything that has to be accelerated when $x$ changes. The Newtonian solution needs two different tensions and a torque equation for the pulley; the Lagrangian solution needs neither, because the tensions are constraint forces.

8. A bead on a rotating rod, and a moving constraint

A bead slides on a straight rod turning in a horizontal plane at a steady rate $\omega$. Its position is fixed by one coordinate, the distance $r$ along the rod, since $\phi = \omega t$ is imposed. The kinetic energy is $\tfrac{1}{2}m(\dot{r}^2 + r^2\omega^2)$, and Lagrange's equation gives $\ddot{r} = \omega^2r$, with solutions $r = Ae^{\omega t} + Be^{-\omega t}$: the bead is flung outward exponentially.

Here the constraint depends on time, and the rod's push does do work on the bead, which gains energy as it moves out. Lagrange's equations still hold, but $T + U$ is no longer conserved. The lesson on conserved quantities makes this precise: energy is conserved when the Lagrangian does not depend on time explicitly, and here, through the imposed rotation, it effectively does.

9. The bead on a spinning hoop

A bead slides on a vertical circular hoop of radius $R$ that spins about its vertical diameter at rate $\omega$. With $\theta$ the angle from the bottom, the bead's speed has a part $R\dot{\theta}$ along the hoop and a part $R\omega\sin\theta$ around the axis, so $\mathcal{L} = \tfrac{1}{2}mR^2(\dot{\theta}^2 + \omega^2\sin^2\theta) + mgR\cos\theta$.

Lagrange's equation is $\ddot{\theta} = \sin\theta(\omega^2\cos\theta - g/R)$. Equilibria are where the right side vanishes: at the bottom, $\theta = 0$, and, if $\omega^2 > g/R$, at $\cos\theta = g/R\omega^2$ on either side. Below the critical spin the bottom is stable; above it the bottom becomes unstable and the bead settles at the side. That qualitative change as a parameter crosses a threshold is a bifurcation, and it appears again in the lesson on chaos.

10. The method, step by step, and how to check it

  1. Count degrees of freedom: the number of coordinates minus the number of constraints.
  2. Choose coordinates that satisfy the constraints and make $T$ and $U$ simple.
  3. Write $T$ carefully: the velocity of each mass in terms of the $\dot{q}$'s, squared. Most errors are here.
  4. Form and apply Lagrange's equations, one per coordinate.

Checking an answer. Setting a parameter to a simple value should give a known result: $M = 0$ in the Atwood machine, $\omega = 0$ on the hoop giving a pendulum. Every term of an equation must have the same units. The equation for a Cartesian coordinate must reproduce $F = ma$. And if energy should be conserved, differentiate $T + U$ along your solution and check that it vanishes.

11. When to reach for the Lagrangian

Newton's method is simplest when the forces are few and the coordinates Cartesian: a projectile, a block on a flat surface. Lagrange's method wins when constraints are many or curved, when natural coordinates are angles, and when several bodies are linked: a double pendulum, a pendulum hanging from a sliding cart, a spinning top, a robot arm.

Robotics engineers derive the equations of motion of multi-jointed arms from Lagrangians, because each joint angle is a generalized coordinate and the constraint forces at the joints drop out. The same formalism extends to fields, where electromagnetism and general relativity are each written as a single Lagrangian, and to quantum mechanics, where the action becomes the phase of Feynman's sum over paths.

12. Two coordinates: a pendulum hanging from a cart

Systems with more than one degree of freedom get one Lagrange equation per coordinate, and the equations are usually coupled. Hang a pendulum of length $L$ and mass $m$ from a cart of mass $M$ that rolls freely on a level track. Two coordinates fix everything: the cart's position $x$ and the pendulum's angle $\phi$. The bob's velocity is the cart's velocity plus its own swing, so $T = \tfrac{1}{2}M\dot{x}^2 + \tfrac{1}{2}m(\dot{x}^2 + 2L\dot{x}\dot{\phi}\cos\phi + L^2\dot{\phi}^2)$, and $U = -mgL\cos\phi$.

The $x$ equation says $(M + m)\dot{x} + mL\dot{\phi}\cos\phi$ is constant, the total horizontal momentum, because nothing pushes the system sideways. The $\phi$ equation is the pendulum equation with an extra term from the cart's acceleration. For small swings the pendulum oscillates at $\sqrt{(M + m)g/ML}$, faster than on a fixed pivot, because the cart moves back and forth opposite to the bob. Deriving this with Newton's laws requires the tension and the track's reaction; here neither appears.

13. In the world: the flyball governor

James Watt's flyball governor regulated steam engines for more than a century and can still be seen turning on restored engines at museums such as the Henry Ford in Michigan. Two heavy balls on hinged arms spin with the engine; as the engine speeds up, the balls swing outward and upward, and a linkage partly closes the steam valve.

The bead on a spinning hoop is a good model of one ball. Its off-axis equilibrium, $\cos\theta = g/R\omega^2$, rises with spin: for arms of effective radius $0.20$ m, the balls ride at $61°$ from the vertical at $10$ rad/s and at $70°$ at $12$ rad/s. Below $\omega = \sqrt{g/R}$, about $7$ rad/s here, they hang straight down and the governor does nothing. James Clerk Maxwell's 1868 analysis of governors, using exactly these equations, founded the mathematical theory of feedback control that now runs cruise control and autopilots.

14. In the world: robot arms

An industrial robot arm on an automotive assembly line in Tennessee has six joints, and its configuration is six angles: six generalized coordinates. Writing the kinetic energy of every link in terms of those angles and their rates, and the potential energy of every link in gravity, gives a Lagrangian from which six coupled equations of motion follow directly.

The forces at the joints that hold the links together never appear, because they are constraint forces. What does appear is the torque each motor must supply to produce a desired motion, which the controller computes hundreds of times a second. Deriving the same equations with Newton's laws would require the force and torque at every joint and a great deal of bookkeeping; with Lagrange's equations it is a systematic calculation that software can do for any arm.

15. The Lagrangian is not the energy

The kinetic and potential energies are familiar, and their sum is conserved, so it is easy to write $\mathcal{L} = T + U$. That Lagrangian gives $m\ddot{x} = +\partial U/\partial x$: a ball would roll uphill. The Lagrangian is the difference, $T - U$, and it is not conserved in general; the quantity that is conserved, when time does not appear explicitly, is built from it in the lesson after next.

A second error is to write the kinetic energy with only the obvious velocity, such as $\tfrac{1}{2}mR^2\dot{\theta}^2$ on the spinning hoop, forgetting the motion the rotating constraint imposes. Always build $T$ from the full velocity of each mass in an inertial frame.

16. Newton's law from the Lagrangian

  1. Write the Lagrangian of a particle on a line in a potential $U(x)$.

    $\mathcal{L} = \tfrac{1}{2}m\dot{x}^2 - U(x)$

    Kinetic minus potential.

  2. Differentiate with respect to position.

    $\dfrac{\partial\mathcal{L}}{\partial x} = -\dfrac{dU}{dx} = F$

    The generalized force is the ordinary force.

  3. Differentiate with respect to velocity.

    $\dfrac{\partial\mathcal{L}}{\partial\dot{x}} = m\dot{x} = p$

    The generalized momentum is the ordinary momentum.

  4. Take the time derivative of the momentum.

    $\dfrac{d}{dt}(m\dot{x}) = m\ddot{x}$

    Mass is constant.

  5. Write Lagrange's equation.

    $F = m\ddot{x}$

    Newton's second law.

17. An Atwood machine

  1. Masses $m_1 = 5.0$ kg and $m_2 = 3.0$ kg hang over a light pulley. Choose one coordinate.

    $x = \text{distance } m_1 \text{ has descended}$

    The string ties the two motions together: one degree of freedom.

  2. Write the kinetic energy.

    $T = \tfrac{1}{2}(5.0 + 3.0)\dot{x}^2 = 4.0\dot{x}^2$

    Both move at speed $\dot{x}$.

  3. Write the potential energy.

    $U = -5.0gx + 3.0gx = -2.0gx$

    One falls, the other rises.

  4. Form the Lagrangian.

    $\mathcal{L} = 4.0\dot{x}^2 + 2.0gx$

    $T - U$.

  5. Apply Lagrange's equation.

    $2.0g = \dfrac{d}{dt}(8.0\dot{x}) = 8.0\ddot{x}$

    $\partial\mathcal{L}/\partial x = \frac{d}{dt}\partial\mathcal{L}/\partial\dot{x}$.

  6. Solve for the acceleration.

    $\ddot{x} = \dfrac{g}{4} = 2.45\ \text{m/s}^2$

    $(m_1 - m_2)g/(m_1 + m_2)$, with no tension anywhere in the working.

18. A bead on a spinning hoop

  1. Write the bead's velocity components on a hoop of radius $R$ spinning at $\omega$.

    $v_{\text{along}} = R\dot{\theta}, \quad v_{\text{around}} = R\omega\sin\theta$

    The bead is $R\sin\theta$ from the axis.

  2. Write the kinetic energy.

    $T = \tfrac{1}{2}mR^2(\dot{\theta}^2 + \omega^2\sin^2\theta)$

    The two components are perpendicular.

  3. Write the potential energy.

    $U = -mgR\cos\theta$

    Height measured from the hoop's center.

  4. Differentiate the Lagrangian with respect to the angle.

    $\dfrac{\partial\mathcal{L}}{\partial\theta} = mR^2\omega^2\sin\theta\cos\theta - mgR\sin\theta$

    Both $T$ and $U$ depend on $\theta$.

  5. Apply Lagrange's equation.

    $mR^2\ddot{\theta} = mR^2\omega^2\sin\theta\cos\theta - mgR\sin\theta$

    $\partial\mathcal{L}/\partial\dot{\theta} = mR^2\dot{\theta}$.

  6. Simplify the equation of motion.

    $\ddot{\theta} = \sin\theta\left(\omega^2\cos\theta - \dfrac{g}{R}\right)$

    Divide by $mR^2$.

  7. Find the off-axis equilibrium for $R = 0.20$ m and $\omega = 10$ rad/s.

    $\cos\theta = \dfrac{9.8}{0.20 \times 100} = 0.49 \Rightarrow \theta = 60.7°$

    It exists because $\omega^2 = 100 > g/R = 49$.

19. Your turn: a pendulum of length $L$ has $\mathcal{L} = \tfrac{1}{2}mL^2\dot{\phi}^2 + mgL\cos\phi$. Find its equation of motion.

  1. Differentiate with respect to the angle.

    $\dfrac{\partial\mathcal{L}}{\partial\phi} = -mgL\sin\phi$

    The generalized force is a torque.

  2. Differentiate with respect to the angular velocity and then time.

    $\dfrac{d}{dt}\dfrac{\partial\mathcal{L}}{\partial\dot{\phi}} = mL^2\ddot{\phi}$

    The generalized momentum is an angular momentum.

  3. Your turn: work this step out. Its working is at the end of the packet.

    Set them equal.

20. Guided practice

An Atwood machine hangs masses $m_1 = 8$ kg and $m_2$ over a light frictionless pulley, with $x$ the distance $m_1$ has descended. Lagrange's equation gives which acceleration?

21. Guided practice

Complete the worked solution: a puck of mass $3$ kg on a frictionless table is tied to a spring of stiffness $k = 3$ N/m anchored at the origin, so $\mathcal{L} = \tfrac{1}{2}m(\dot{r}^2 + r^2\dot{\phi}^2) - \tfrac{1}{2}kr^2$. At $r = 3$ m with $\dot{\phi} = 3$ rad/s, find $p_\phi$ in kg m²/s, $\partial\mathcal{L}/\partial r$ in N, and $\ddot{r}$ in m/s².

  1. Differentiate the Lagrangian with respect to the angular velocity.

    $p_\phi = \dfrac{\partial\mathcal{L}}{\partial\dot{\phi}} = mr^2\dot{\phi} =$ p

    The generalized momentum of an angle is an angular momentum.

  2. Differentiate the Lagrangian with respect to the radius.

    $\dfrac{\partial\mathcal{L}}{\partial r} = mr\dot{\phi}^2 - kr =$ f

    A centrifugal-looking term from the kinetic energy, and the spring force.

  3. Divide by the mass for the radial acceleration.

    $\ddot{r} = \dfrac{1}{m}\dfrac{\partial\mathcal{L}}{\partial r} =$ a

    Lagrange's equation for $r$: $\partial\mathcal{L}/\partial r = m\ddot{r}$.

  4. Check the radial equation against Newton's law in polar form.

    $m(\ddot{r} - r\dot{\phi}^2) = -kr$

    Lagrange's equation produced the centripetal term automatically.

22. Guided practice

Match each name to its definition.

$T - U$$\partial\mathcal{L}/\partial\dot{q}$$\partial\mathcal{L}/\partial q$$\partial\mathcal{L}/\partial q = \frac{d}{dt}\partial\mathcal{L}/\partial\dot{q}$
Lagrangian
generalized momentum
generalized force
Lagrange's equation

23. Practice

A bead of mass $4$ kg slides without friction on a straight rod that spins in a horizontal plane at a steady $\omega = 2$ rad/s. Its Lagrangian is $\mathcal{L} = \tfrac{1}{2}m(\dot{r}^2 + \omega^2r^2)$. When $r = 5$ m and $\dot{r} = 2$ m/s, fill in $\partial\mathcal{L}/\partial r$ in N, $\partial\mathcal{L}/\partial\dot{r}$ in kg m/s, and $\ddot{r}$ in m/s².

value
$\partial\mathcal{L}/\partial r$ (N)
$\partial\mathcal{L}/\partial\dot{r}$ (kg m/s)
$\ddot{r}$ (m/s²)

24. Practice

A particle of unit mass has Lagrangian $\mathcal{L} = \tfrac{1}{2}\dot{x}^2 - x^4 + 6x^2$. Use Lagrange's equation to write its acceleration $\ddot{x}$ as a formula in $x$.

Answer:

25. Practice

An Atwood machine hangs $5$ kg and $3$ kg over a pulley that is a uniform disk of mass $4$ kg, turning with the string without slipping. Taking $g = 10$ m/s², what is the acceleration of the masses, in m/s²?

Answer: m/s² for the hanging masses

26. Somewhere new

A restored steam engine at a museum in Michigan has a flyball governor. Model each ball as a bead on a vertical hoop of radius $0.2$ m spinning about its vertical diameter at $10$ rad/s. At what angle from the downward vertical do the balls ride, in degrees, with $g = 9.8$ m/s²?

Answer: degrees from the vertical

27. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

28. Test question

A particle of unit mass has Lagrangian $\mathcal{L} = \tfrac{1}{2}\dot{x}^2 - 4x^4 + 4x^2$. Use Lagrange's equation to write its acceleration $\ddot{x}$ as a formula in $x$.

Answer:

29. What you can do now

You can use Lagrange's equations. Explain to someone why the tension in an Atwood machine's string never appears in the Lagrangian solution.

Working for the steps left to you

19. Your turn: a pendulum of length $L$ has $\mathcal{L} = \tfrac{1}{2}mL^2\dot{\phi}^2 + mgL\cos\phi$. Find its equation of motion., step 3

$\ddot{\phi} = -\dfrac{g}{L}\sin\phi$

The pendulum equation, with no tension in sight.