---
title: Lagrange's equations
heading: Equations of motion from energy alone, for pendulums, hoops and circuits
eyebrow: B1 · Lesson 46 · Lagrange's equations
xp: 40
---

::: hook
Newton's laws need every force, constraint forces included: the tension in a pendulum string, the push of a track, the normal force of a hoop. **Lagrange's method** skips them. Write the kinetic and potential energies in whatever coordinates describe the system naturally (an angle, a distance along a track, a charge), form $L = T - V$, and a single rule produces the equations of motion. The constraint forces never appear. The same rule describes circuits, with charge as the coordinate, which is why it's the standard tool for electromechanical systems like motors, speakers and MEMS sensors.
:::

::: play
- A bead slides on a vertical hoop of radius 0.1 m that spins about its vertical axis at Ω.
- Below $\Omega = \sqrt{g/R} = 9.9$ rad/s the bead rests at the bottom. Above it, the bottom becomes unstable and the bead rises to a new equilibrium where $\cos\theta = \frac{g}{R\Omega^2}$.
- The readouts give the equilibrium angle and the frequency of small oscillations about it, both found from the Lagrangian without ever computing the hoop's force on the bead.
:::

```sim plot
view: graph
x: W = 0..30
y: theta = 0..90
plot: acos(1 - step(W - 9.9)*(1 - 9.8/(0.1*W^2 + 1e-9)))*180/pi | label: equilibrium angle (degrees) | samples: 600
readout: angle at 15 rad per s, degrees = acos(9.8/(0.1*225))*180/pi | digits: 3
readout: small-oscillation frequency there, rad per s = 15*sqrt(1 - (9.8/(0.1*225))^2) | digits: 3
```

::: predict
## The Lagrangian of an LC circuit is $\frac12L\dot q^2 - \frac{q^2}{2C}$. What equation does Lagrange's rule give?

- [x] $L\ddot q + \frac qC = 0$: the circuit oscillates at $\frac{1}{\sqrt{LC}}$
- [ ] $L\dot q + \frac qC = 0$: exponential decay
- [ ] $\ddot q = 0$: constant current
- [ ] Nothing: Lagrange's method is only for mechanics

::: reveal
$L\ddot q + \frac qC = 0$. Here the inductor's energy plays the role of kinetic energy and the capacitor's the role of potential energy, and the rule gives exactly Kirchhoff's voltage law. Mass maps to inductance and spring stiffness to $\frac1C$, the analogy of lesson 43, derived rather than assumed.
:::
:::

::: nameit
## The recipe

1. Choose **generalized coordinates** $q_i$, as many as the system's degrees of freedom, that automatically satisfy the constraints.
2. Write the kinetic energy T and potential energy V in terms of the $q_i$ and $\dot q_i$.
3. Form the **Lagrangian** $L = T - V$.
4. For each coordinate, $\frac{d}{dt}\frac{\partial L}{\partial\dot q_i} - \frac{\partial L}{\partial q_i} = 0$.

Constraint forces that do no work never enter. Dissipation and driving forces can be added on the right-hand side as generalized forces.

## Conservation laws

- If L doesn't depend on some $q_i$ (a **cyclic** coordinate), its momentum $p_i = \frac{\partial L}{\partial\dot q_i}$ is conserved.
- If L doesn't depend explicitly on time, the energy $\sum\dot q_ip_i - L$ is conserved.

## Small oscillations

At an equilibrium $q_0$ (where $\frac{\partial V}{\partial q} = 0$), expand to second order: $T \approx \frac12M\dot q^2$ and $V \approx \frac12V''(q_0)(q - q_0)^2$. The oscillation frequency is $\omega = \sqrt{V''(q_0)/M}$, stable if $V'' > 0$.

## Circuits

With charges as coordinates, inductors contribute $\frac12L\dot q^2$ to T, capacitors $\frac{q^2}{2C}$ to V, and resistors a dissipative force $-R\dot q$. Coupled electromechanical systems, such as a capacitor plate on a spring, put both kinds of term in one Lagrangian.
:::

::: example
## Derive the Atwood machine's acceleration with Lagrange's method.

::: solution
1. **Choose a coordinate.** One is enough: the distance $x$ that $m_2$ has descended.
2. **Kinetic and potential energy.**
   $$\begin{aligned} T &= \frac12(m_1 + m_2)\dot x^2 \\ V &= -m_2gx + m_1gx \end{aligned}$$
3. **The Lagrangian.**
   $$\begin{aligned} L &= \frac12(m_1 + m_2)\dot x^2 \\ &\quad + (m_2 - m_1)gx \end{aligned}$$
4. **Apply the rule.**
   $$(m_1 + m_2)\ddot x - (m_2 - m_1)g = 0$$
   so
   $$\ddot x = \frac{(m_2 - m_1)g}{m_1 + m_2}$$
5. **What it saved.** The string tension never appeared; with Newton's method it would have needed two equations and an elimination.

**Answer:** $\ddot x = \frac{(m_2 - m_1)g}{m_1 + m_2}$, with $m_2$ descending.
:::
:::

::: example
## A bead slides on a hoop of radius 0.1 m spinning at 15 rad/s about its vertical diameter. Where does it rest, and how fast does it oscillate about that point?

::: solution
1. **Kinetic and potential energy.** With θ measured from the bottom,
   $$\begin{aligned} T &= \frac12mR^2(\dot\theta^2 + \Omega^2\sin^2\theta) \\ V &= -mgR\cos\theta \end{aligned}$$
2. **Effective potential.**
   $$-\frac12mR^2\Omega^2\sin^2\theta - mgR\cos\theta$$
   stationary where
   $$\sin\theta(R\Omega^2\cos\theta - g) = 0$$
3. **Where it rests.** Since $R\Omega^2 = 22.5$ m/s² exceeds $g$, the bottom is unstable and the bead sits at
   $$\cos\theta = \frac{9.8}{22.5}, \quad \theta = 64.2°$$
4. **Oscillation frequency.** Expanding the effective potential there gives
   $$\begin{aligned} \omega &= \Omega\sin\theta \\ &= 13.5\ \text{rad/s} \end{aligned}$$
5. **Slower spins.** Below $\Omega = \sqrt{g/R} = 9.9$ rad/s, only the bottom is stable.

**Answer:** the bead rests at 64.2° from the bottom and oscillates about it at 13.5 rad/s.
:::
:::

::: example
## A 1 kg mass on a 100 N/m spring hangs vertically. Use the Lagrangian to find the equilibrium and the oscillation frequency.

::: solution
1. **The Lagrangian.** With $x$ measured downward from the spring's natural length,
   $$L = \frac12\dot x^2 - \left(\frac12 \cdot 100x^2 - 9.8x\right)$$
2. **Apply the rule.**
   $$\ddot x + 100x - 9.8 = 0$$
3. **Equilibrium and frequency.** Equilibrium is at $x = 0.098$ m, and about it
   $$\ddot u + 100u = 0$$
   so ω = 10 rad/s, unchanged by gravity.
4. **What gravity does.** Gravity only shifts the equilibrium; it adds no stiffness, which is why a vertical spring oscillates at the same frequency as a horizontal one.

**Answer:** the equilibrium is 0.098 m below the natural length, and the mass oscillates at 10 rad/s.
:::
:::

::: check
given: m1 = 1 | 2; m2 = 3 | 5
answer: (m2 - m1)*9.8/(m1 + m2)
unit: m/s^2
tolerance: 0.5%

## What acceleration does Lagrange's method give for an Atwood machine with {m1} kg and {m2} kg?

::: right
Right. $\frac{(m_2 - m_1)g}{m_1 + m_2}$, with no tension needed.
:::

::: misses
- [(m2 - m1)*9.8/m2] The whole system's inertia, $m_1 + m_2$, resists.
- [any] $\frac{\partial L}{\partial x} = (m_2 - m_1)g$ and the inertia is $m_1 + m_2$.
:::
:::

::: check
kind: parts
given: R = 0.1 | 0.2; W = 12 | 20

## A bead on a hoop of radius {R} m spinning at {W} rad/s.

::: part
answer: acos(9.8/(R*W^2))*180/pi
unit: °
tolerance: 0.5%

### At what angle from the bottom does it rest?

::: misses
- [any] Where $R\Omega^2\cos\theta = g$.
:::
:::

::: part
answer: W*sqrt(1 - (9.8/(R*W^2))^2)
unit: rad/s
tolerance: 0.5%

### At what angular frequency does it oscillate about that point?

::: misses
- [any] $\Omega\sin\theta_0$.
:::
:::
:::

::: check
given: R = 0.05 | 0.2 | 0.5
answer: sqrt(9.8/R)
unit: rad/s
tolerance: 0.5%

## Above what spin rate does the bottom of a hoop of radius {R} m stop being stable for the bead?

::: right
Right. $\sqrt{g/R}$, where the centrifugal effect overcomes gravity's restoring pull at the bottom.
:::

::: misses
- [9.8/R] Take the square root.
- [any] Small oscillations at the bottom have $\omega^2 = \frac gR - \Omega^2$.
:::
:::

::: check
given: L = 1 | 10; C = 1 | 100
answer: 1/sqrt(L*1e-3*C*1e-6)
unit: rad/s
tolerance: 0.5%

## An LC circuit has L = {L} mH and C = {C} µF. At what angular frequency does Lagrange's equation say it oscillates?

::: right
Right. $\frac{1}{\sqrt{LC}}$: inductance acts as mass and $\frac1C$ as stiffness.
:::

::: misses
- [1/(L*1e-3*C*1e-6)] Take the square root.
- [any] $L\ddot q + \frac qC = 0$.
:::
:::

::: check
kind: parts
given: k = 50 | 200; m = 0.5 | 2

## A mass {m} kg hangs on a {k} N/m spring; L = $\frac12m\dot x^2 - \frac12kx^2 + mgx$.

::: part
answer: m*9.8/k
unit: m
tolerance: 0.5%

### Where is the equilibrium, below the natural length?

::: misses
- [any] Where $\frac{\partial V}{\partial x} = 0$.
:::
:::

::: part
answer: sqrt(k/m)
unit: rad/s
tolerance: 0.5%

### What is the oscillation frequency about it?

::: misses
- [any] Gravity shifts the equilibrium but adds no stiffness.
:::
:::
:::

::: check
kind: choice

## A system's Lagrangian doesn't depend on the angle φ, though it depends on $\dot\varphi$. What follows?

- [ ] φ stays constant
- [x] The momentum $\frac{\partial L}{\partial\dot\varphi}$ is conserved
- [ ] The energy is not conserved
- [ ] $\dot\varphi$ must be zero

::: right
Right. A cyclic coordinate gives a conserved momentum, here an angular momentum.
:::

::: misses
- [1] φ can change; its momentum can't.
- [3] Energy conservation depends on time, not on φ.
- [4] The system can rotate freely in φ.
:::
:::

::: check
kind: derivation
vars: m = 0.1..5, l = 0.2..3, t = -1..1, w = -3..3

## A pendulum of mass m and length l, with angle θ (write t) and angular velocity $\dot\theta$ (write w). Use g = 9.8.

::: step
answer: m*l^2*w^2/2 + m*9.8*l*cos(t)

### What is $L = T - V$, taking V = 0 at the pivot's height?
:::

::: step
answer: -9.8*sin(t)/l

### What angular acceleration does Lagrange's equation give?
:::

::: right
Right. $\ddot\theta = -\frac gl\sin\theta$, without the string tension appearing.
:::
:::

::: check
kind: python

## Write `hoop(R, W)` for a bead on a hoop of radius R spinning at W rad/s (g = 9.8). Return `(angle, omega)`: the stable equilibrium's angle from the bottom in degrees, and the small-oscillation angular frequency about it. Below the critical spin $\sqrt{g/R}$ the bead rests at the bottom with $\omega^2 = \frac gR - \Omega^2$; above it, $\cos\theta_0 = \frac{g}{R\Omega^2}$ and $\omega = \Omega\sin\theta_0$.

```python starter
import math

def hoop(R, W):
    return math.degrees(math.acos(9.8 / (R * W**2))), W

print(hoop(0.1, 15))
```

```python solution
import math

def hoop(R, W):
    if W**2 <= 9.8 / R:
        return 0.0, math.sqrt(9.8 / R - W**2)
    th = math.acos(9.8 / (R * W**2))
    return math.degrees(th), W * math.sin(th)

print(hoop(0.1, 15))
```

```python tests
import math
a, w = hoop(0.1, 15)
assert abs(a - 64.1793) < 1e-3 and abs(w - 13.5024) < 1e-3, f"At 15 rad/s the bead sits at 64.18° and oscillates at 13.50 rad/s; got {a:.4f} and {w:.4f}."
a0, w0 = hoop(0.1, 5)
assert a0 == 0 and abs(w0 - math.sqrt(73)) < 1e-9, f"At 5 rad/s it rests at the bottom with ω = √73 = 8.544 rad/s; got {a0} and {w0}."
a1, w1 = hoop(0.2, 0)
assert a1 == 0 and abs(w1 - 7) < 1e-9, "A hoop that doesn't spin is a pendulum: ω = √(g/R) = 7 rad/s."
```

::: right
Right. The oscillation frequency falls to zero at the critical spin from both sides: the bottom grows unstable just as the new equilibria appear, a pitchfork bifurcation.
:::
:::

::: explain
## Why don't constraint forces appear in Lagrange's equations?

::: model
Constraint forces, like a string's tension or a track's normal force, act perpendicular to the directions the system is allowed to move, so they do no work on any motion consistent with the constraints. Lagrange's method uses coordinates that move only in those allowed directions, so every possible displacement is one the constraint forces can't do work on. The equations come from how energy changes along those coordinates, and since the constraint forces contribute nothing to that, they drop out automatically. If you need them, as for checking whether a string goes slack, you can recover them afterward from Newton's laws.
:::
:::

::: practice

::: check
given: m1 = 0.5 | 4; m2 = 1 | 6
answer: (m2 - m1)*9.8/(m1 + m2)
unit: m/s^2
tolerance: 0.5%

## Atwood acceleration, {m1} and {m2} kg?

::: misses
- [any] $\frac{(m_2 - m_1)g}{m_1 + m_2}$.
:::
:::

::: check
given: L = 0.1 | 50; C = 0.01 | 10
answer: 1/sqrt(L*1e-3*C*1e-6)
unit: rad/s
tolerance: 0.5%

## LC angular frequency, {L} mH and {C} µF?

::: misses
- [any] $\frac{1}{\sqrt{LC}}$.
:::
:::
:::
