# Lagrangian Mechanics: From the Principle of Least Action to the Euler-Lagrange Equations

> From Hamilton's principle we derive the Euler-Lagrange equations, show that L = T - U reproduces Newton's laws, and prove covariance under any change of generalized coordinates.
> https://rikai.mugen-giken.com/en/physics/mechanics/lagrangian-mechanics

## 0. Key points

- The equations of motion of mechanics do not come from a balance of forces at each instant. They come from the condition that a single number attached to the **path as a whole** — the action — be stationary. This is Hamilton's principle.
- The necessary and sufficient condition for the action to be stationary is the **Euler–Lagrange equations**, obtained from the fundamental lemma of the calculus of variations (<Ref to="lem-fundamental" />).
- If in Cartesian coordinates we take $L = T - U$ (kinetic energy minus potential energy), the Euler–Lagrange equations are precisely Newton's equations of motion (<Ref to="thm-newton-equivalence" />). The two are restatements of the same content.
- The real power of the Lagrangian formulation lies in its **covariance**. The equations do not change shape under an arbitrary change of coordinates (<Ref to="thm-covariance" />). Polar coordinates, angular variables and constrained systems can therefore be treated mechanically, without our having to discover centrifugal terms or tensions for ourselves.
- If a coordinate is absent from the Lagrangian (a cyclic coordinate), the conjugate generalized momentum is conserved (<Ref to="prop-cyclic" />). If the Lagrangian does not depend explicitly on time, the energy function is conserved (<Ref to="prop-energy" />). This is the entrance to the general principle that symmetries generate conservation laws.

---

## 1. Motivation: what is inconvenient about the Newtonian formulation

Newton's equation of motion $m_i \ddot{\boldsymbol{r}}_i = \boldsymbol{F}_i$ is correct, and in principle universal. Indeed, as we saw in [Foundations of Newtonian mechanics](/en/physics/mechanics/newtonian-mechanics), once the forces are given, the motion of $N$ point masses is completely determined by $3N$ second-order ordinary differential equations (<Ref to="physics/mechanics/newtonian-mechanics#prop-uniqueness" text="uniqueness of the solution of the initial value problem" />). Nevertheless there were three clear reasons why mechanics from the eighteenth century onwards looked for another formulation.

**First, constraint forces get in the way.** Write a point mass hung on a string of length $\ell$ (a simple pendulum) in Cartesian coordinates $(x, y)$. With the tension $S$ of the string as an unknown function we obtain the system

$$
m\ddot{x} = -S\frac{x}{\ell}, \qquad m\ddot{y} = -S\frac{y}{\ell} - mg, \qquad x^2 + y^2 = \ell^2
$$

There are three unknown functions $x, y, S$ and three equations, so it can be solved. But **the only thing we really want to know is one swing angle**, and we are forced to drag along a tension $S$ we have no interest in. Worse, $S$ is "whatever force is needed at each moment to keep the string from stretching"; it is not a function given in advance. A quantity whose value we can determine only after solving the motion sits inside the equations.

If instead we set $x = \ell\sin\theta,\ y = -\ell\cos\theta$ and compute, then, as we shall see later, only the single equation

$$
\ddot{\theta} = -\frac{g}{\ell}\sin\theta
$$

survives, and $S$ disappears completely. If we could build the constraint in from the start, not as an "extra force" but as "there are fewer usable coordinates", matters ought to become far simpler.

**Second, the equations change shape when the coordinates change.** The concise form $\boldsymbol{F} = m\boldsymbol{a}$ is peculiar to Cartesian coordinates. In plane polar coordinates $(r,\theta)$ the components of the acceleration are

$$
a_r = \ddot{r} - r\dot{\theta}^2, \qquad a_\theta = r\ddot{\theta} + 2\dot{r}\dot{\theta}
$$

so that a centrifugal term $-r\dot\theta^2$ and a Coriolis term $2\dot r\dot\theta$ appear. They arise because the basis vectors $\boldsymbol{e}_r, \boldsymbol{e}_\theta$ themselves vary in time; the derivation is not hard, but it has to be redone from scratch for every coordinate system. To handle spherical, cylindrical, oblique and rotating coordinates systematically, we need a framework in which **the equations of motion come out by the same procedure in any coordinates**.

**Third, it does not connect to anything outside mechanics.** In geometrical optics Fermat's principle (1662) was already known: light chooses, among the paths joining two points, one whose transit time is stationary. "Compare whole paths as candidates, and the one that makes a certain quantity stationary is realized" is a manner of speaking utterly unlike the local language of an equation of motion. Maupertuis (1744) and Euler (1744) noticed that this language works in mechanics as well, and Lagrange developed the machinery of the variational calculus in his *Mécanique analytique* (1788). Hamilton (1834–35) put it into its present form — fix the times and positions at both ends and make $\int (T - U)\,dt$ stationary — and Jacobi gave it the name "Hamilton's principle". This formulation carries over unchanged to electromagnetic fields, continuous media, relativity and even the path integral of quantum mechanics. The Newtonian formulation has no such generality.

In this article we first organize constraints and generalized coordinates (§2), derive the Euler–Lagrange equations from the stationarity of the action (§3), check that $L = T - U$ is equivalent to Newton's equations (§4), prove covariance — the heart of the matter — and put it to work on examples (§5), and finally look at the relation with conservation laws (§6).

<Figure caption="The architecture of mechanics starting from Hamilton's principle">
<Mermaid code={`flowchart TD
  A["Hamilton's principle<br/>the action S is stationary"] --> B["variation δS = 0<br/>(fundamental lemma of the calculus of variations)"]
  B --> C["Euler-Lagrange equations"]
  C --> D["Cartesian coordinates and L = T - U<br/>→ Newton's equations of motion"]
  C --> E["arbitrary generalized coordinates<br/>→ the form does not change (covariance)"]
  C --> F["cyclic coordinates, time translation<br/>→ conserved quantities"]`} />
</Figure>

---

## 2. Preliminaries: constraints, generalized coordinates, configuration space

<Definition id="def-holonomic" title="Holonomic constraints and generalized coordinates">
Let $\boldsymbol{r}_1, \ldots, \boldsymbol{r}_N \in \mathbb{R}^3$ be the positions of $N$ point masses. A constraint that can be written, by means of finitely many $C^2$ functions $f_1, \ldots, f_m$, in the form

$$
f_a(\boldsymbol{r}_1, \ldots, \boldsymbol{r}_N, t) = 0 \qquad (a = 1, \ldots, m)
$$

is called a **holonomic constraint**. If, moreover, the set of all configurations satisfying these constraints can be expressed by $n = 3N - m$ parameters $q = (q^1, \ldots, q^n)$ as

$$
\boldsymbol{r}_i = \boldsymbol{r}_i(q^1, \ldots, q^n, t) \qquad (i = 1, \ldots, N)
$$

with the $\boldsymbol{r}_i$ of class $C^2$ and, at each instant, one-to-one, then $q^1, \ldots, q^n$ are called **generalized coordinates** of the system and $n$ its number of **degrees of freedom**. The case in which $\boldsymbol{r}_i$ does not depend explicitly on $t$ is called **scleronomic** (time-independent), and the case in which it does, **rheonomic** (time-dependent).
</Definition>

Generalized coordinates need not have the dimension of length. They may be angles, or areas, or the sum of two angles. They mean nothing more than "a set of independent variables necessary and sufficient to specify a configuration uniquely". The region in which the $n$ quantities $q$ range is called the **configuration space**, and the motion of the system is represented by a single curve $t \mapsto q(t)$ in it.

<Example id="ex-dof" title="Counting degrees of freedom">
- Simple pendulum in a plane: $N = 1$, one constraint $x^2 + y^2 = \ell^2$ (two if we include $z = 0$). Degrees of freedom $n = 1$. The generalized coordinate is the swing angle $\theta$.
- Double pendulum in a plane: $N = 2$, constraints from the two string lengths. Degrees of freedom $n = 2$. The generalized coordinates are the two swing angles $\theta_1, \theta_2$.
- Two weights over a fixed pulley (Atwood's machine): the sum of the heights of the weights is constant, so $n = 1$. It suffices to take the height $x$ of one of them as the coordinate.
- A rigid body in space: as a consequence of the constraint that all distances between constituent points be constant, $n = 6$ (3 for the centre of mass, 3 for the orientation).
</Example>

<Remark id="rem-nonholonomic">
A constraint of the form $f(\boldsymbol{r}, \dot{\boldsymbol{r}}, t) = 0$, involving velocities and not integrable into a relation among positions alone, is called a **nonholonomic constraint**. A ball rolling without slipping, or a skate that does not slide sideways, are examples. In this article we treat holonomic constraints only. For nonholonomic systems, applying Hamilton's principle directly produces the wrong equations, so take care; the correct treatment goes through d'Alembert's principle, touched on in the Appendix.
</Remark>

We also assume that the constraints are "smooth", that is, that the constraint forces do no work on displacements compatible with the constraints. The tension of a string does no work on displacements perpendicular to the string, and the normal reaction of a smooth surface does no work on displacements along the surface. This assumption (**ideal constraints**) is the reason the constraint forces will later drop out of the equations.

---

## 3. The action functional and the Euler-Lagrange equations

<Definition id="def-action" title="The Lagrangian and the action functional">
A $C^2$ function $L(q, \dot q, t)$ of a point $q = (q^1,\ldots,q^n)$ of configuration space, a velocity $\dot q = (\dot q^1, \ldots, \dot q^n)$ and the time $t$ is called a **Lagrangian**. Fix a time interval $[t_1, t_2]$ and the endpoint values $q(t_1) = q_{(1)},\ q(t_2) = q_{(2)}$. On the set of all $C^2$ curves $q: [t_1,t_2] \to \mathbb{R}^n$ satisfying these conditions, the functional

$$
S[q] = \int_{t_1}^{t_2} L\bigl(q(t), \dot q(t), t\bigr)\, dt
$$

is called the **action functional**, and its value the **action**.
</Definition>

$S$ is not a function assigning a number to a number; it is a map assigning **one number to one curve**. Searching for "the curve minimizing $S$" should be thought of as the infinite-dimensional version of the school problem "find the $x$ minimizing $f(x)$". Even in the infinite-dimensional version, at an extremum a condition corresponding to "the first derivative vanishes" holds. The next definition states it precisely.

<Definition id="def-variation" title="Variation and stationary paths">
Take a $C^2$ curve $q$ and a $C^2$ function $\eta: [t_1,t_2] \to \mathbb{R}^n$ vanishing at both endpoints (that is, $\eta(t_1) = \eta(t_2) = 0$). For a real number $\varepsilon$ put $q_\varepsilon = q + \varepsilon\eta$; then $q_\varepsilon$ satisfies the same endpoint conditions. The quantity

$$
\delta S[q;\eta] := \left.\frac{d}{d\varepsilon} S[q + \varepsilon \eta]\right|_{\varepsilon = 0}
$$

is called the **first variation** of $S$. If $\delta S[q;\eta] = 0$ for every such $\eta$, then $q$ is called a **stationary path** of $S$.
</Definition>

<Figure caption="The true path with fixed endpoints, and a comparison path obtained by displacing it">
<svg viewBox="0 0 480 250" width="100%" role="img" aria-label="The true path with fixed endpoints and a comparison path displaced from it by a variation">
  <g fill="none" stroke="currentColor" stroke-width="1.2" opacity="0.45">
    <line x1="45" y1="225" x2="458" y2="225" />
    <line x1="45" y1="225" x2="45" y2="28" />
  </g>
  <path d="M 80 185 C 180 65 300 45 420 95" fill="none" stroke="var(--sl-color-accent)" stroke-width="2.6" />
  <path d="M 80 185 C 170 135 290 125 420 95" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="6 5" opacity="0.8" />
  <line x1="239" y1="78" x2="239" y2="131" stroke="currentColor" stroke-width="1.3" />
  <circle cx="80" cy="185" r="4.5" fill="currentColor" />
  <circle cx="420" cy="95" r="4.5" fill="currentColor" />
  <text x="52" y="209" font-size="12" fill="currentColor">(t₁, q₁)</text>
  <text x="386" y="80" font-size="12" fill="currentColor">(t₂, q₂)</text>
  <text x="248" y="110" font-size="12" fill="currentColor">εη(t)</text>
  <text x="264" y="52" font-size="12" fill="var(--sl-color-accent)">true motion q(t)</text>
  <text x="112" y="180" font-size="12" fill="currentColor">comparison path q + εη</text>
  <text x="462" y="229" font-size="12" fill="currentColor">t</text>
  <text x="34" y="26" font-size="12" fill="currentColor">q</text>
</svg>
</Figure>

The tool that translates the stationarity condition into a differential equation is the following lemma. It says "if an integral always vanishes then the integrand vanishes" — a statement that looks obvious but does require proof.

<Lemma id="lem-fundamental" title="Fundamental lemma of the calculus of variations">
Let $g: [t_1, t_2] \to \mathbb{R}$ be continuous. If

$$
\int_{t_1}^{t_2} g(t)\,\eta(t)\, dt = 0
$$

holds for every $C^1$ function $\eta: [t_1,t_2] \to \mathbb{R}$ with $\eta(t_1) = \eta(t_2) = 0$, then $g(t) = 0$ throughout $[t_1, t_2]$.
</Lemma>

<Proof of="lem-fundamental">
We prove the contrapositive. Suppose $g(t_0) \neq 0$ for some $t_0 \in [t_1,t_2]$; without loss of generality $g(t_0) > 0$ (if $g(t_0) < 0$, replace $g$ by $-g$, and note that $\int (-g)\eta\,dt = 0$ also follows from the hypothesis).

Since $g$ is continuous, for $\varepsilon_0 = g(t_0)/2 > 0$ there is $\rho > 0$ such that $|t - t_0| \le \rho$ and $t \in [t_1,t_2]$ imply $|g(t) - g(t_0)| < \varepsilon_0$, and hence

$$
g(t) > g(t_0) - \frac{g(t_0)}{2} = \frac{g(t_0)}{2} > 0 .
$$

If $t_0$ is an endpoint we may shrink $\rho$ so that the interval $I = [t_0 - \rho, t_0 + \rho]$ is contained in $[t_1,t_2]$ (if $t_0 = t_1$, take $[t_1, t_1 + 2\rho]$, and similarly shift the centre in the other cases). Thus we may assume $I = [c - \rho, c + \rho] \subset [t_1, t_2]$ with $g > g(t_0)/2$ on $I$.

Take as comparison function

$$
\eta(t) = \begin{cases} \bigl(\rho^2 - (t - c)^2\bigr)^2 & (t \in I) \\ 0 & (t \notin I)\end{cases}
$$

Then $\eta$ is positive in the interior of $I$ and $0$ outside $I$, and since $\eta'(t) = -4(t-c)\bigl(\rho^2 - (t-c)^2\bigr)$ vanishes at $t = c \pm \rho$, the function $\eta$ is $C^1$ on all of $[t_1,t_2]$. It also satisfies $\eta(t_1) = \eta(t_2) = 0$ at the endpoints (the same holds when $I$ contains an endpoint, because $\eta$ and its derivative vanish at the ends of $I$).

For this $\eta$, substituting $u = t - c$,

$$
\int_{-\rho}^{\rho} (\rho^2 - u^2)^2\, du = \int_{-\rho}^{\rho}(\rho^4 - 2\rho^2u^2 + u^4)\,du = 2\left(\rho^5 - \frac{2}{3}\rho^5 + \frac{1}{5}\rho^5\right) = \frac{16}{15}\rho^5 > 0
$$

and therefore

$$
\int_{t_1}^{t_2} g\,\eta\, dt = \int_{I} g\,\eta\,dt > \frac{g(t_0)}{2}\cdot \frac{16}{15}\rho^5 > 0 ,
$$

contradicting the hypothesis $\int g\eta\,dt = 0$. Hence $g$ vanishes identically.
</Proof>

<Theorem id="thm-euler-lagrange" title="The Euler-Lagrange equations">
Let $L(q,\dot q, t)$ be a $C^2$ Lagrangian and $q: [t_1,t_2] \to \mathbb{R}^n$ a $C^2$ curve. A necessary and sufficient condition for $q$ to be a stationary path of the action $S[q] = \int_{t_1}^{t_2} L(q,\dot q,t)\,dt$ with fixed endpoints is that

$$
\frac{d}{dt}\frac{\partial L}{\partial \dot q^k}\bigl(q(t),\dot q(t),t\bigr) - \frac{\partial L}{\partial q^k}\bigl(q(t),\dot q(t),t\bigr) = 0 \qquad (k = 1,\ldots,n)
$$

hold on $[t_1,t_2]$. This system of $n$ equations is called the **Euler–Lagrange equations**.
</Theorem>

<Proof of="thm-euler-lagrange">
Let $\eta$ be an arbitrary $C^2$ function with $\eta(t_1) = \eta(t_2) = 0$, and put $\Phi(\varepsilon) = S[q + \varepsilon\eta]$.

**Step 1: interchanging differentiation and integration.** The integrand $\varphi(\varepsilon, t) = L\bigl(q(t) + \varepsilon\eta(t), \dot q(t) + \varepsilon\dot\eta(t), t\bigr)$ is $C^1$ in $(\varepsilon,t)$, because $L$ is $C^2$ and $q, \eta$ are $C^2$. Its derivative $\partial\varphi/\partial\varepsilon$ is continuous on the compact set $[-1,1]\times[t_1,t_2]$, hence uniformly continuous and bounded there, so differentiation and integration may be interchanged. By the chain rule,

$$
\Phi'(0) = \int_{t_1}^{t_2} \sum_{k=1}^{n}\left( \frac{\partial L}{\partial q^k}\eta^k + \frac{\partial L}{\partial \dot q^k}\dot\eta^k \right) dt .
$$

Here all partial derivatives are evaluated at $(q(t),\dot q(t),t)$.

**Step 2: integration by parts.** Since $q$ is $C^2$ and $L$ is $C^2$, the function $t \mapsto \partial L/\partial \dot q^k$ is $C^1$, and we may integrate by parts (<Ref to="mathematics/calculus/integration-and-ftc#thm-by-parts" text="integration by parts" />):

$$
\int_{t_1}^{t_2} \frac{\partial L}{\partial \dot q^k}\dot\eta^k\, dt = \left[ \frac{\partial L}{\partial \dot q^k}\eta^k \right]_{t_1}^{t_2} - \int_{t_1}^{t_2} \frac{d}{dt}\left(\frac{\partial L}{\partial \dot q^k}\right)\eta^k\, dt .
$$

**Here we use the fixed-endpoint condition $\eta(t_1) = \eta(t_2) = 0$**, which kills the first term. This is why Hamilton's principle fixes the endpoints. Hence

$$
\delta S[q;\eta] = \Phi'(0) = \int_{t_1}^{t_2} \sum_{k=1}^{n} \left( \frac{\partial L}{\partial q^k} - \frac{d}{dt}\frac{\partial L}{\partial \dot q^k} \right)\eta^k\, dt .
$$

**Step 3: sufficiency.** If the Euler–Lagrange equations hold, the parenthesis above vanishes for every $k$ and every $t$, so $\delta S = 0$; that is, $q$ is a stationary path.

**Step 4: necessity.** Conversely, suppose $q$ is a stationary path. Fix one $k$ and restrict to those $\eta$ whose components other than $\eta^k$ vanish identically. Then for every $C^2$ (hence $C^1$) function $\eta^k$ vanishing at both endpoints,

$$
\int_{t_1}^{t_2} g_k(t)\,\eta^k(t)\,dt = 0, \qquad g_k(t) := \frac{\partial L}{\partial q^k} - \frac{d}{dt}\frac{\partial L}{\partial \dot q^k}
$$

holds, and $g_k$ is continuous. The comparison function $\eta$ used in the proof of <Ref to="lem-fundamental" /> is in fact only $C^1$; but running the same argument with $\bigl(\rho^2-(t-c)^2\bigr)^3$ produces a $C^2$ comparison function, and since $\int_{-\rho}^{\rho}(\rho^2-u^2)^3du = \frac{32}{35}\rho^7 > 0$ the conclusion is unchanged. Hence $g_k \equiv 0$, that is, the $k$-th Euler–Lagrange equation holds. As $k$ was arbitrary, all of them hold.
</Proof>

<Remark id="rem-stationary">
Hamilton's principle is often called the "principle of least action", but the correct word is **stationary**, not least. Let us check this on the one-dimensional harmonic oscillator $L = \frac12 m\dot x^2 - \frac12 m\omega^2 x^2$. The second variation is

$$
\left.\frac{d^2}{d\varepsilon^2}S[x+\varepsilon\eta]\right|_{\varepsilon=0} = \int_{t_1}^{t_2}\bigl(m\dot\eta^2 - m\omega^2\eta^2\bigr)\,dt
$$

(since $L$ is quadratic in $x,\dot x$, the terms of order $\varepsilon^2$ come out directly). Put $T = t_2 - t_1$ and take $\eta(t) = \sin\bigl(\pi(t-t_1)/T\bigr)$. Then $\int_{t_1}^{t_2}\eta^2dt = T/2$ and $\int_{t_1}^{t_2}\dot\eta^2 dt = (\pi/T)^2\, T/2$, so the second variation equals

$$
\frac{mT}{2}\left(\frac{\pi^2}{T^2} - \omega^2\right).
$$

If $T > \pi/\omega$ (a time longer than half a period) this is negative, and the true motion admits perturbations that **increase** the action. So it is a saddle point, not a minimum. The name "least action" is therefore historical; the correct statement is $\delta S = 0$.
</Remark>

---

## 4. Hamilton's principle and the Lagrangian $L = T - U$

So far $L$ has been "some $C^2$ function". To put physics in, we must specify what $L$ is. That is the content of the following principle.

<Axiom id="ax-hamilton" title="Hamilton's principle">
Consider a system of point masses subject to ideal holonomic constraints, whose forces derive from a potential $U(\boldsymbol{r}_1,\ldots,\boldsymbol{r}_N,t)$. Choose generalized coordinates $q = (q^1,\ldots,q^n)$, express the kinetic energy $T$ and the potential energy $U$ as functions of $q, \dot q, t$, and put

$$
L(q,\dot q,t) = T(q,\dot q,t) - U(q,t) .
$$

Then the motion $q(t)$ actually followed by a system that is in the configuration $q_{(1)}$ at time $t_1$ and in the configuration $q_{(2)}$ at time $t_2$ is the one that, among all paths satisfying these endpoint conditions, makes the action $S[q] = \int_{t_1}^{t_2} L\,dt$ stationary.
</Axiom>

Why a difference, one may ask — $T - U$ rather than the energy $T + U$? The honest answer is "because that choice yields the correct equations of motion", and the next theorem is exactly that statement. A physical reading is available too: to make the action small one wants both to keep the kinetic energy small (move slowly) and to linger where the potential is high, and the stationarity condition for $T - U$ is the compromise between these two demands.

<Theorem id="thm-newton-equivalence" title="Equivalence with Newton's equations">
Consider an unconstrained system of $N$ point masses ($n = 3N$, with the Cartesian coordinates $\boldsymbol{r}_1,\ldots,\boldsymbol{r}_N$ taken as generalized coordinates). Let the masses be $m_i > 0$, let the potential $U(\boldsymbol{r}_1,\ldots,\boldsymbol{r}_N,t)$ be a $C^2$ function, and put

$$
L = T - U = \sum_{i=1}^{N} \frac{1}{2}m_i |\dot{\boldsymbol{r}}_i|^2 - U(\boldsymbol{r}_1,\ldots,\boldsymbol{r}_N,t) .
$$

Then for a $C^2$ curve $t\mapsto (\boldsymbol{r}_1(t),\ldots,\boldsymbol{r}_N(t))$ the following are equivalent.

1. It satisfies the Euler–Lagrange equations for $L$.
2. It satisfies $m_i\ddot{\boldsymbol{r}}_i = -\nabla_i U$ for every $i$ (Newton's equations of motion).
</Theorem>

<Proof of="thm-newton-equivalence">
We compute for the $\alpha$-th component of $\boldsymbol{r}_i = (x_i^1, x_i^2, x_i^3)$.

Since $U$ does not depend on the velocities,

$$
\frac{\partial L}{\partial \dot x_i^\alpha} = \frac{\partial}{\partial \dot x_i^\alpha}\left(\frac{1}{2}m_i\sum_{\beta=1}^{3}(\dot x_i^\beta)^2\right) = m_i \dot x_i^\alpha .
$$

Hence $\dfrac{d}{dt}\dfrac{\partial L}{\partial \dot x_i^\alpha} = m_i\ddot x_i^\alpha$. On the other hand $T$ does not depend on the positions, so

$$
\frac{\partial L}{\partial x_i^\alpha} = -\frac{\partial U}{\partial x_i^\alpha} = (-\nabla_i U)^\alpha .
$$

Substituting these into the equations of <Ref to="thm-euler-lagrange" />, the Euler–Lagrange equations become

$$
m_i \ddot x_i^\alpha + \frac{\partial U}{\partial x_i^\alpha} = 0 \iff m_i\ddot x_i^\alpha = -\frac{\partial U}{\partial x_i^\alpha}
$$

which, as $i$ and $\alpha$ range over their values, is precisely Newton's equation $m_i\ddot{\boldsymbol{r}}_i = -\nabla_i U$. Each equivalence is an identity componentwise, so both implications hold.
</Proof>

Thus Hamilton's principle has, at least for unconstrained systems under conservative forces, **the same content** as Newton's laws (<Ref to="physics/mechanics/newtonian-mechanics#ax-second-law" text="the second law (the law of motion)" />). We have not introduced new physics; we have acquired another way of writing the same physics. The value appears beyond this point — when constraints are present, and when the coordinates are not Cartesian.

<Example id="ex-atwood" title="Atwood's machine">
A massless string passes over a fixed pulley of negligible mass and size, with weights of masses $m_1, m_2$ hanging from its ends. The total length $\ell$ of the string is constant, so if $x$ denotes the height of one weight (measured downwards from the pulley), the other is at $\ell - x$, and there is one degree of freedom. Since the string is inextensible the speeds are common, both equal to $\dot x$, and therefore

$$
T = \frac{1}{2}(m_1 + m_2)\dot x^2, \qquad U = -m_1 g x - m_2 g(\ell - x).
$$

Dropping the constant term,

$$
L = \frac{1}{2}(m_1+m_2)\dot x^2 + (m_1 - m_2) g x .
$$

Since $\partial L/\partial \dot x = (m_1+m_2)\dot x$ and $\partial L /\partial x = (m_1-m_2)g$, the Euler–Lagrange equation is

$$
(m_1+m_2)\ddot x = (m_1 - m_2) g \quad\Longrightarrow\quad \ddot x = \frac{m_1 - m_2}{m_1 + m_2}\, g .
$$

In the Newtonian formulation we would have had to write down the two equations $m_1\ddot x = m_1 g - S$ and $m_2\ddot x = S - m_2 g$ with the string tension $S$ as an unknown, and then eliminate $S$. In the Lagrangian formulation $S$ never appears in the first place. This is no accident: under the assumption of ideal constraints, constraint forces make no contribution to the action (see the Appendix).
</Example>

The Lagrangian is not unique. The following property will be essential later, when we treat Noether's theorem.

<Proposition id="prop-gauge" title="The ambiguity by a total derivative">
Let $F(q,t)$ be a $C^3$ function and put

$$
L'(q,\dot q, t) = L(q,\dot q,t) + \frac{d}{dt}F(q,t) = L(q,\dot q,t) + \sum_{l=1}^{n}\frac{\partial F}{\partial q^l}\dot q^l + \frac{\partial F}{\partial t} .
$$

Then the Euler–Lagrange equations for $L'$ coincide exactly with those for $L$. Moreover, for a nonzero constant $c$, the Euler–Lagrange equations for $cL$ also coincide with those for $L$.
</Proposition>

<Proof of="prop-gauge">
The Euler–Lagrange operator $E_k(L) := \dfrac{\partial L}{\partial q^k} - \dfrac{d}{dt}\dfrac{\partial L}{\partial \dot q^k}$ is linear in $L$, so it suffices to show that $E_k(G) = 0$ for $G := \sum_l (\partial F/\partial q^l)\dot q^l + \partial F/\partial t$.

$G$ is of first degree in $\dot q$, and the coefficients $\partial F/\partial q^l$ do not depend on $\dot q$, so

$$
\frac{\partial G}{\partial \dot q^k} = \frac{\partial F}{\partial q^k}, \qquad
\frac{d}{dt}\frac{\partial G}{\partial \dot q^k} = \sum_{l}\frac{\partial^2 F}{\partial q^l \partial q^k}\dot q^l + \frac{\partial^2 F}{\partial t\, \partial q^k}.
$$

On the other hand, differentiating $G$ partially with respect to $q^k$,

$$
\frac{\partial G}{\partial q^k} = \sum_{l}\frac{\partial^2 F}{\partial q^k \partial q^l}\dot q^l + \frac{\partial^2 F}{\partial q^k\, \partial t}.
$$

Since $F$ is $C^3$, the order of the second partial derivatives may be interchanged (<Ref to="mathematics/calculus/multivariable-differentiation#thm-schwarz" text="Schwarz's theorem" />), so the two right-hand sides agree. Hence $E_k(G) = 0$.

As for $cL$, we have $E_k(cL) = c\,E_k(L)$, and since $c \neq 0$, $E_k(cL) = 0 \iff E_k(L) = 0$.
</Proof>

---

## 5. Why it handles generalized coordinates so well: covariance

Here is the heart of the Lagrangian formulation. Newton's equations changed shape under a change of coordinates; the Euler–Lagrange equations do not. We first isolate a technical identity that will be used twice in the proof.

<Lemma id="lem-dot-cancellation" title="Cancellation of dots and interchange of derivatives">
Let $q^k = q^k(Q^1,\ldots,Q^n, t)$ be $C^2$ functions, and define the velocity along them by

$$
\dot q^k = \sum_{a=1}^{n} \frac{\partial q^k}{\partial Q^a}\dot Q^a + \frac{\partial q^k}{\partial t}
$$

(so that $\dot q^k$ is regarded as a function of $(Q,\dot Q,t)$). Then

$$
\text{(i)}\quad \frac{\partial \dot q^k}{\partial \dot Q^a} = \frac{\partial q^k}{\partial Q^a}, \qquad\qquad
\text{(ii)}\quad \frac{\partial \dot q^k}{\partial Q^a} = \frac{d}{dt}\left(\frac{\partial q^k}{\partial Q^a}\right),
$$

where $d/dt$ denotes the total derivative along $Q = Q(t)$.
</Lemma>

<Proof of="lem-dot-cancellation">
(i) In the expression for $\dot q^k$, the quantities $\partial q^k/\partial Q^a$ and $\partial q^k/\partial t$ are functions of $(Q,t)$ alone and do not depend on $\dot Q$. Hence $\dot q^k$ is a first-degree polynomial in $\dot Q^1,\ldots,\dot Q^n$, and partial differentiation with respect to $\dot Q^a$ leaves its coefficient $\partial q^k/\partial Q^a$.

(ii) Compute the left-hand side. Differentiating partially with respect to $Q^a$ (holding the $\dot Q^b$ fixed as independent variables),

$$
\frac{\partial \dot q^k}{\partial Q^a} = \sum_{b}\frac{\partial^2 q^k}{\partial Q^a \partial Q^b}\dot Q^b + \frac{\partial^2 q^k}{\partial Q^a \partial t}.
$$

Now compute the right-hand side. Since $\partial q^k/\partial Q^a$ is a function of $(Q,t)$, the chain rule gives

$$
\frac{d}{dt}\left(\frac{\partial q^k}{\partial Q^a}\right) = \sum_b \frac{\partial^2 q^k}{\partial Q^b \partial Q^a}\dot Q^b + \frac{\partial^2 q^k}{\partial t\, \partial Q^a}.
$$

Since $q^k$ is $C^2$, Schwarz's theorem says the second partial derivatives do not depend on the order, and the two expressions agree.
</Proof>

<Theorem id="thm-covariance" title="Covariance of the Euler-Lagrange equations">
Let $q = q(Q,t)$ be a $C^3$ point transformation whose Jacobian matrix $J = \bigl(\partial q^k/\partial Q^a\bigr)_{k,a}$ is invertible at each instant. For a Lagrangian $L(q,\dot q,t)$ define

$$
\tilde L(Q,\dot Q, t) := L\Bigl(q(Q,t),\ \dot q(Q,\dot Q,t),\ t\Bigr), \qquad
\dot q^k = \sum_a \frac{\partial q^k}{\partial Q^a}\dot Q^a + \frac{\partial q^k}{\partial t} .
$$

Then, for a $C^2$ curve $t\mapsto Q(t)$ and the corresponding $q(t) = q(Q(t),t)$,

$$
E_a(\tilde L) = \sum_{k=1}^{n} E_k(L)\, \frac{\partial q^k}{\partial Q^a}, \qquad
E_k(L) := \frac{\partial L}{\partial q^k} - \frac{d}{dt}\frac{\partial L}{\partial \dot q^k}
$$

holds. In particular, $q(t)$ satisfies the Euler–Lagrange equations for $L$ if and only if $Q(t)$ satisfies the Euler–Lagrange equations for $\tilde L$.
</Theorem>

<Proof of="thm-covariance">
Throughout, the partial derivatives of $L$ are evaluated at $(q(Q,t), \dot q(Q,\dot Q,t), t)$.

**Step 1: $\partial\tilde L/\partial Q^a$.** By the chain rule,

$$
\frac{\partial \tilde L}{\partial Q^a} = \sum_k \left( \frac{\partial L}{\partial q^k}\frac{\partial q^k}{\partial Q^a} + \frac{\partial L}{\partial \dot q^k}\frac{\partial \dot q^k}{\partial Q^a} \right).
$$

**Step 2: $\partial\tilde L/\partial \dot Q^a$.** Since $q^k$ does not depend on $\dot Q$, only the terms passing through $\dot q^k$ survive, and part (i) of <Ref to="lem-dot-cancellation" /> gives

$$
\frac{\partial \tilde L}{\partial \dot Q^a} = \sum_k \frac{\partial L}{\partial \dot q^k}\frac{\partial \dot q^k}{\partial \dot Q^a} = \sum_k \frac{\partial L}{\partial \dot q^k}\frac{\partial q^k}{\partial Q^a}.
$$

**Step 3: the time derivative.** By the product rule,

$$
\frac{d}{dt}\frac{\partial \tilde L}{\partial \dot Q^a} = \sum_k \left[ \left(\frac{d}{dt}\frac{\partial L}{\partial \dot q^k}\right)\frac{\partial q^k}{\partial Q^a} + \frac{\partial L}{\partial \dot q^k}\, \frac{d}{dt}\left(\frac{\partial q^k}{\partial Q^a}\right) \right].
$$

**Step 4: taking the difference.** Subtract Step 3 from Step 1. By part (ii) of <Ref to="lem-dot-cancellation" />, the second term of Step 1 and the second term of Step 3 are equal and cancel, leaving

$$
E_a(\tilde L) = \frac{\partial \tilde L}{\partial Q^a} - \frac{d}{dt}\frac{\partial \tilde L}{\partial \dot Q^a}
= \sum_k \left( \frac{\partial L}{\partial q^k} - \frac{d}{dt}\frac{\partial L}{\partial \dot q^k} \right) \frac{\partial q^k}{\partial Q^a}
= \sum_k E_k(L)\frac{\partial q^k}{\partial Q^a}.
$$

**Step 5: the equivalence.** This says that the vector $\bigl(E_a(\tilde L)\bigr)_a$ is obtained from $\bigl(E_k(L)\bigr)_k$ by multiplication with the transpose $J^{\mathsf{T}}$ of the Jacobian matrix. By hypothesis $J$ is invertible, hence so is $J^{\mathsf{T}}$, and

$$
J^{\mathsf{T}} \bigl(E_k(L)\bigr) = 0 \iff \bigl(E_k(L)\bigr) = 0 .
$$

Therefore "$E_a(\tilde L) = 0$ for all $a$" and "$E_k(L)=0$ for all $k$" are equivalent.
</Proof>

The practical meaning of this theorem is simple. **It is enough to write down the kinetic and potential energies in whatever coordinates one likes.** Centrifugal and Coriolis forces come out automatically once the differentiations are performed. Let us verify this in turn.

<Example id="ex-polar" title="Central-force motion in plane polar coordinates">
Let a point mass $m$ move in a plane under a central-force potential $U(r)$. From $x = r\cos\theta$ and $y = r\sin\theta$,

$$
\dot x = \dot r\cos\theta - r\dot\theta\sin\theta, \qquad \dot y = \dot r \sin\theta + r\dot\theta\cos\theta,
$$

$$
\dot x^2 + \dot y^2 = \dot r^2(\cos^2\theta+\sin^2\theta) + r^2\dot\theta^2(\sin^2\theta+\cos^2\theta) + 2r\dot r\dot\theta(-\cos\theta\sin\theta + \sin\theta\cos\theta) = \dot r^2 + r^2\dot\theta^2 .
$$

Hence

$$
L = \frac{1}{2}m\bigl(\dot r^2 + r^2\dot\theta^2\bigr) - U(r).
$$

The Euler–Lagrange equation for $r$ follows from $\partial L/\partial \dot r = m\dot r$ and $\partial L/\partial r = m r\dot\theta^2 - U'(r)$:

$$
m\ddot r = m r\dot\theta^2 - U'(r).
$$

The first term on the right is the centrifugal force. Note that it appeared merely from computing $\partial L/\partial r$, with no differentiation of vectors.

For $\theta$ we have $\partial L/\partial\theta = 0$ and $\partial L/\partial\dot\theta = m r^2\dot\theta$, so

$$
\frac{d}{dt}\bigl(m r^2\dot\theta\bigr) = 0 .
$$

That is, $\ell := m r^2\dot\theta$ is constant. This is nothing but the angular momentum about the origin, so conservation of angular momentum (<Ref to="physics/mechanics/central-forces#thm-angular-momentum" text="conservation of angular momentum under a central force" />) has come out in one line. Substituting it into the equation for $r$ to eliminate $\dot\theta = \ell/(mr^2)$ gives

$$
m\ddot r = \frac{\ell^2}{m r^3} - U'(r) = -\frac{d}{dr}\left( U(r) + \frac{\ell^2}{2m r^2} \right)
$$

which agrees with the equation obtained using the effective potential in [Planetary motion and central forces](/en/physics/mechanics/central-forces) (<Ref to="physics/mechanics/central-forces#prop-radial-equation" text="reduction to a one-dimensional radial problem" />). There the derivation used vector analysis; here we merely wrote down $T$ and $U$ and differentiated partially.
</Example>

<Example id="ex-pendulum" title="The simple pendulum: the constraint force disappears">
Let us return to the simple pendulum of §1. With $x = \ell\sin\theta$ and $y = -\ell\cos\theta$ ($y$ positive upwards, the pivot at the origin) we have $\dot x^2 + \dot y^2 = \ell^2\dot\theta^2$, so

$$
T = \frac{1}{2}m\ell^2\dot\theta^2, \qquad U = mgy = -mg\ell\cos\theta, \qquad L = \frac{1}{2}m\ell^2\dot\theta^2 + mg\ell\cos\theta .
$$

Since $\partial L/\partial\dot\theta = m\ell^2\dot\theta$ and $\partial L/\partial\theta = -mg\ell\sin\theta$,

$$
m\ell^2\ddot\theta = -mg\ell\sin\theta \quad\Longrightarrow\quad \ddot\theta = -\frac{g}{\ell}\sin\theta .
$$

The tension $S$ appeared nowhere. That is because the constraint of constant string length was fully used up at the outset, in the form "the configuration is described by $\theta$ alone".

If $S$ is needed, it can be recovered after solving by returning to the Newtonian formulation. The equation of motion along the string (the centripetal direction) gives $S - mg\cos\theta = m\ell\dot\theta^2$, that is, $S = m\ell\dot\theta^2 + mg\cos\theta$. The Lagrangian formulation only "removes" constraint forces; it does not "lose" them.
</Example>

<Example id="ex-rotating-hoop" title="A bead on a hoop forced to rotate about a vertical axis">
Let a hoop (a circular wire) of radius $a$ be forced by an external device to rotate at constant angular velocity $\omega$, with one of its diameters kept coincident with the vertical axis. A bead of mass $m$ slides smoothly on the hoop. The position of the bead is determined by the single angle $\theta$ measured from the lowest point of the hoop, so there is one degree of freedom. However, the relation to Cartesian coordinates,

$$
x = a\sin\theta\,\cos\omega t, \qquad y = a\sin\theta\,\sin\omega t, \qquad z = -a\cos\theta ,
$$

**depends explicitly on time** (a rheonomic constraint). Computing the velocity,

$$
\dot x = a\dot\theta\cos\theta\cos\omega t - a\omega\sin\theta\sin\omega t, \qquad
\dot y = a\dot\theta\cos\theta\sin\omega t + a\omega\sin\theta\cos\omega t, \qquad
\dot z = a\dot\theta \sin\theta .
$$

Expanding $\dot x^2 + \dot y^2$, the cross terms cancel because the $\cos\omega t\sin\omega t$ contributions have opposite signs, leaving

$$
\dot x^2 + \dot y^2 = a^2\dot\theta^2\cos^2\theta + a^2\omega^2\sin^2\theta,
$$

and adding $\dot z^2 = a^2\dot\theta^2\sin^2\theta$,

$$
|\dot{\boldsymbol{r}}|^2 = a^2\dot\theta^2 + a^2\omega^2\sin^2\theta .
$$

Therefore

$$
L = \frac{1}{2}m a^2\dot\theta^2 + \frac{1}{2}ma^2\omega^2\sin^2\theta + mga\cos\theta .
$$

From $\partial L/\partial\dot\theta = ma^2\dot\theta$ and $\partial L/\partial\theta = ma^2\omega^2\sin\theta\cos\theta - mga\sin\theta$, the Euler–Lagrange equation is

$$
a\ddot\theta = \sin\theta\,\bigl(a\omega^2\cos\theta - g\bigr).
$$

The equilibria ($\ddot\theta = 0$ and $\dot\theta = 0$) are $\theta = 0, \pi$ together with the $\theta$ satisfying $\cos\theta = g/(a\omega^2)$. The latter exists only when $a\omega^2 > g$. So while the rotation is slow the bead stays at the lowest point, but once $\omega$ exceeds the critical value $\sqrt{g/a}$ the lowest point becomes unstable and the bead moves to a new equilibrium lifted to the side. This bifurcation emerged without introducing any fictitious force (centrifugal force) of the rotating frame.
</Example>

---

## 6. Cyclic coordinates, the energy function, and conservation laws

<Definition id="def-momentum" title="Generalized momenta and cyclic coordinates">
For a Lagrangian $L(q,\dot q,t)$, the quantity

$$
p_k := \frac{\partial L}{\partial \dot q^k} \qquad (k = 1,\ldots,n)
$$

is called the **generalized momentum conjugate** to the coordinate $q^k$. If for some $k$ the Lagrangian does not depend explicitly on $q^k$ (that is, $\partial L/\partial q^k \equiv 0$), then $q^k$ is called a **cyclic coordinate**.
</Definition>

A generalized momentum need not be a momentum. In <Ref to="ex-polar" /> the momentum conjugate to $\theta$ was $m r^2\dot\theta$, that is, an angular momentum. If $q^k$ is an angle then $p_k$ is an angular momentum; if it is a length, an ordinary momentum. The dimensions vary with the dimension of $q^k$.

<Proposition id="prop-cyclic" title="The conserved quantity attached to a cyclic coordinate">
If $q^k$ is a cyclic coordinate, then along every solution of the Euler–Lagrange equations $p_k = \partial L/\partial\dot q^k$ is a constant independent of time.
</Proposition>

<Proof of="prop-cyclic">
By <Ref to="thm-euler-lagrange" />, along a solution

$$
\frac{d p_k}{dt} = \frac{d}{dt}\frac{\partial L}{\partial \dot q^k} = \frac{\partial L}{\partial q^k} = 0
$$

(the last equality being the definition of a cyclic coordinate). Hence $p_k$ is constant.
</Proof>

<Definition id="def-energy-function" title="The energy function">
For a Lagrangian $L(q,\dot q,t)$, the quantity

$$
h(q,\dot q,t) := \sum_{k=1}^{n}\dot q^k \frac{\partial L}{\partial \dot q^k} - L
$$

is called the **energy function** (Jacobi's integral).
</Definition>

<Proposition id="prop-energy" title="Conservation of the energy function">
If $L$ does not depend explicitly on time ($\partial L/\partial t \equiv 0$), then $h$ is constant along every solution of the Euler–Lagrange equations. In general, along a solution, $\dfrac{dh}{dt} = -\dfrac{\partial L}{\partial t}$.
</Proposition>

<Proof of="prop-energy">
Differentiate $h$ with respect to time along a solution $q(t)$. By the product rule,

$$
\frac{dh}{dt} = \sum_k \left( \ddot q^k \frac{\partial L}{\partial\dot q^k} + \dot q^k\frac{d}{dt}\frac{\partial L}{\partial \dot q^k} \right) - \frac{dL}{dt}.
$$

On the other hand, the total derivative of $L$ along the solution is, by the chain rule,

$$
\frac{dL}{dt} = \sum_k \left( \frac{\partial L}{\partial q^k}\dot q^k + \frac{\partial L}{\partial \dot q^k}\ddot q^k \right) + \frac{\partial L}{\partial t}.
$$

Taking the difference, the terms containing $\ddot q^k$ cancel and

$$
\frac{dh}{dt} = \sum_k \dot q^k\left( \frac{d}{dt}\frac{\partial L}{\partial \dot q^k} - \frac{\partial L}{\partial q^k} \right) - \frac{\partial L}{\partial t}.
$$

The parenthesis vanishes along a solution by <Ref to="thm-euler-lagrange" />, so $dh/dt = -\partial L/\partial t$. In particular, if $\partial L/\partial t \equiv 0$ then $dh/dt = 0$.
</Proof>

<Corollary id="cor-energy-total" title="When the energy function is the mechanical energy">
Suppose the constraints are scleronomic ($\boldsymbol{r}_i = \boldsymbol{r}_i(q)$ contains no explicit $t$) and that $U = U(q)$ depends explicitly neither on the velocities nor on the time. Then $h = T + U$, and this quantity is conserved.
</Corollary>

<Proof of="cor-energy-total">
Since $\boldsymbol{r}_i$ does not depend explicitly on $t$, we have $\dot{\boldsymbol{r}}_i = \sum_k (\partial \boldsymbol{r}_i/\partial q^k)\dot q^k$, so

$$
T = \sum_i \frac{1}{2}m_i|\dot{\boldsymbol{r}}_i|^2 = \frac{1}{2}\sum_{k,l} a_{kl}(q)\,\dot q^k \dot q^l, \qquad a_{kl}(q) = \sum_i m_i \frac{\partial \boldsymbol{r}_i}{\partial q^k}\cdot\frac{\partial \boldsymbol{r}_i}{\partial q^l}
$$

so that $T$ is a homogeneous quadratic form in $\dot q$. Consequently

$$
\sum_k \dot q^k \frac{\partial T}{\partial \dot q^k} = \sum_k \dot q^k \sum_l a_{kl}\dot q^l = 2T
$$

(which amounts to verifying <Ref to="physics/mechanics/noethers-theorem#lem-euler" text="Euler's theorem on homogeneous functions" /> by direct computation). Since $U$ does not depend on $\dot q$, we have $\partial L/\partial \dot q^k = \partial T/\partial \dot q^k$, and

$$
h = \sum_k \dot q^k \frac{\partial T}{\partial \dot q^k} - (T - U) = 2T - T + U = T + U .
$$

Moreover neither $\boldsymbol{r}_i$ nor $U$ contains $t$ explicitly, hence neither does $L$, and by <Ref to="prop-energy" /> the quantity $h$ is conserved.
</Proof>

<Example id="ex-rotating-hoop-energy" title="What is conserved is h, not T + U">
Return to the rotating hoop of <Ref to="ex-rotating-hoop" />. Since $L$ contains no explicit $t$, <Ref to="prop-energy" /> tells us that $h$ is conserved. Computing it explicitly, with $\partial L/\partial \dot\theta = ma^2\dot\theta$,

$$
h = ma^2\dot\theta^2 - L = \frac{1}{2}ma^2\dot\theta^2 - \frac{1}{2}ma^2\omega^2\sin^2\theta - mga\cos\theta .
$$

The mechanical energy, on the other hand, is

$$
T + U = \frac{1}{2}ma^2\dot\theta^2 + \frac{1}{2}ma^2\omega^2\sin^2\theta - mga\cos\theta
$$

which differs from $h$ in the sign of the $\sin^2\theta$ term. The two do not agree, and it is $h$ that is conserved. That $T + U$ is not conserved is physically obvious as well, since the external device that keeps the hoop rotating at constant angular velocity does work on the bead. This is a concrete instance of the conclusion of <Ref to="cor-energy-total" /> breaking down once the "scleronomic" hypothesis is dropped.
</Example>

<Aside type="tip">
Cyclic coordinates and time translation both have the shape "$L$ is invariant under the change of some variable". Generalizing this observation gives Noether's theorem (<Ref to="physics/mechanics/noethers-theorem#thm-noether" text="Noether's theorem (point-transformation version)" />): to each continuous symmetry there corresponds a conserved quantity. See [Symmetries and conservation laws (Noether's theorem)](/physics/mechanics/noethers-theorem) for details. Furthermore, if one promotes $p_k = \partial L/\partial \dot q^k$ to an independent variable and takes $(q,p)$ as the fundamental variables, then $h$ becomes the Hamiltonian and the $n$ second-order equations turn into $2n$ first-order equations (<Ref to="physics/mechanics/hamiltonian-mechanics#thm-canonical-equations" text="Hamilton's canonical equations" />). That is [Hamiltonian mechanics](/physics/mechanics/hamiltonian-mechanics).
</Aside>

---

## 7. Exercises

<Exercise id="exr-incline" difficulty="Easy">
A point mass $m$ slides down a smooth incline of angle $\alpha$. Taking as coordinate the distance $s$ measured down along the incline, construct the Lagrangian and find the equation of motion. What happens to the normal reaction?

<Solution>
The speed along the incline is $\dot s$, so $T = \frac{1}{2}m\dot s^2$. The height drops by $s\sin\alpha$ from the reference level, so $U = -mgs\sin\alpha$ and therefore

$$
L = \frac{1}{2}m\dot s^2 + mg s\sin\alpha .
$$

Since $\partial L/\partial \dot s = m\dot s$ and $\partial L/\partial s = mg\sin\alpha$, the Euler–Lagrange equation is

$$
m\ddot s = mg\sin\alpha \quad\Longrightarrow\quad \ddot s = g\sin\alpha .
$$

The normal reaction does not appear in the equation. The constraint of not leaving the incline was used up in the form "the configuration is determined by $s$ alone", exactly as with the tension in <Ref to="ex-pendulum" />. If its value is needed, the Newtonian equation in the direction normal to the incline (where the acceleration is $0$) gives $N = mg\cos\alpha$.
</Solution>
</Exercise>

<Exercise id="exr-parabola" difficulty="Standard">
A bead of mass $m$ slides along a smooth parabola $y = kx^2$ ($k > 0$, with $y$ vertically upwards) fixed in a vertical plane. Let $g$ be the acceleration due to gravity.

1. Taking $x$ as the generalized coordinate, write down the Lagrangian and derive the equation of motion.
2. Find the angular frequency of small oscillations about the origin.

<Solution>
**1.** From the constraint $y = kx^2$ we get $\dot y = 2kx\dot x$, so

$$
T = \frac{1}{2}m(\dot x^2 + \dot y^2) = \frac{1}{2}m\bigl(1 + 4k^2x^2\bigr)\dot x^2, \qquad U = mgy = mgkx^2 .
$$

Hence

$$
L = \frac{1}{2}m\bigl(1+4k^2x^2\bigr)\dot x^2 - mgkx^2 .
$$

Compute the partial derivatives.

$$
\frac{\partial L}{\partial \dot x} = m\bigl(1+4k^2x^2\bigr)\dot x, \qquad
\frac{d}{dt}\frac{\partial L}{\partial \dot x} = m\bigl(1+4k^2x^2\bigr)\ddot x + 8mk^2 x\dot x^2 ,
$$

$$
\frac{\partial L}{\partial x} = 4mk^2 x\dot x^2 - 2mgkx .
$$

Substituting into <Ref to="thm-euler-lagrange" /> and rearranging,

$$
m(1+4k^2x^2)\ddot x + 8mk^2x\dot x^2 - 4mk^2x\dot x^2 + 2mgkx = 0,
$$

$$
\bigl(1+4k^2x^2\bigr)\ddot x + 4k^2 x\dot x^2 + 2gk\,x = 0 .
$$

**2.** When $x$ and $\dot x$ are small, dropping the terms $4k^2x^2\ddot x$ and $4k^2x\dot x^2$ of second order and higher leaves

$$
\ddot x + 2gk\,x = 0
$$

so the angular frequency is $\omega = \sqrt{2gk}$. Let us check this. The radius of curvature of $y = kx^2$ at the origin is $R = \bigl(1+(y')^2\bigr)^{3/2}/|y''| = 1/(2k)$, which agrees with the pendulum formula $\omega = \sqrt{g/R}$.
</Solution>
</Exercise>

<Exercise id="exr-rotating-rod" difficulty="Standard">
In a horizontal plane, a straight smooth rod through the origin is forced to rotate at constant angular velocity $\omega$. A bead of mass $m$ is threaded on the rod. Take the distance $r$ from the origin as the generalized coordinate.

1. Find the Lagrangian and the equation of motion, and write down the general solution.
2. Find the energy function $h$, show that it is conserved, and show that $T + U$ is not.

<Solution>
**1.** The position is $x = r\cos\omega t$, $y = r\sin\omega t$. Setting $\theta = \omega t$ and $\dot\theta = \omega$ in the computation of <Ref to="ex-polar" /> gives $\dot x^2+\dot y^2 = \dot r^2 + r^2\omega^2$. Since the motion is in a horizontal plane the gravitational potential is constant, and we may take $U = 0$. Hence

$$
L = \frac{1}{2}m\bigl(\dot r^2 + r^2\omega^2\bigr).
$$

Since $\partial L/\partial \dot r = m\dot r$ and $\partial L/\partial r = mr\omega^2$,

$$
m\ddot r = m r\omega^2 \quad\Longrightarrow\quad \ddot r = \omega^2 r .
$$

This is an equation of hyperbolic rather than trigonometric type, with general solution

$$
r(t) = A e^{\omega t} + B e^{-\omega t}
$$

($A, B$ being constants fixed by the initial conditions). If $A \neq 0$ then $r$ grows exponentially. The bead is flung outwards along the rod, in accordance with everyday intuition.

**2.** The energy function is

$$
h = \dot r\frac{\partial L}{\partial \dot r} - L = m\dot r^2 - \frac{1}{2}m(\dot r^2 + r^2\omega^2) = \frac{1}{2}m\bigl(\dot r^2 - r^2\omega^2\bigr).
$$

Since $L$ contains no explicit $t$, <Ref to="prop-energy" /> gives that $h$ is conserved. We can also check it directly: using the equation of motion $\ddot r = \omega^2 r$,

$$
\frac{dh}{dt} = m\dot r\ddot r - m\omega^2 r\dot r = m\dot r(\omega^2 r) - m\omega^2 r\dot r = 0 .
$$

On the other hand $T + U = T = \frac{1}{2}m(\dot r^2 + r^2\omega^2)$ becomes, along the solution $r = Ae^{\omega t}$ (with $B=0$), equal to $\frac{1}{2}m(A^2\omega^2 e^{2\omega t} + A^2\omega^2 e^{2\omega t}) = mA^2\omega^2 e^{2\omega t}$, which grows and so is not conserved. The reason is that the device keeping the rod rotating at constant angular velocity does work on the bead. Because the constraint depends explicitly on time (it is rheonomic), <Ref to="cor-energy-total" /> does not apply, and we are in the same situation as in <Ref to="ex-rotating-hoop-energy" />.
</Solution>
</Exercise>

<Exercise id="exr-double-pendulum" difficulty="Hard">
Consider a double pendulum in a vertical plane. A light rod of length $\ell_1$ joins the pivot to a point mass $m_1$, and a light rod of length $\ell_2$ joins that mass to a point mass $m_2$. Let $\theta_1, \theta_2$ be the angles measured from the downward vertical. Construct the Lagrangian and derive the two equations of motion.

<Solution>
The positions are

$$
\begin{aligned}
x_1 &= \ell_1\sin\theta_1, & y_1 &= -\ell_1\cos\theta_1, \\
x_2 &= \ell_1\sin\theta_1 + \ell_2\sin\theta_2, & y_2 &= -\ell_1\cos\theta_1 - \ell_2\cos\theta_2 .
\end{aligned}
$$

Differentiate and compute the squared speeds. From $\dot x_1 = \ell_1\dot\theta_1\cos\theta_1$ and $\dot y_1 = \ell_1\dot\theta_1\sin\theta_1$ we get $v_1^2 = \ell_1^2\dot\theta_1^2$. Next,

$$
\dot x_2 = \ell_1\dot\theta_1\cos\theta_1 + \ell_2\dot\theta_2\cos\theta_2, \qquad
\dot y_2 = \ell_1\dot\theta_1\sin\theta_1 + \ell_2\dot\theta_2\sin\theta_2
$$

so that, using the addition formula $\cos\theta_1\cos\theta_2+\sin\theta_1\sin\theta_2 = \cos(\theta_1-\theta_2)$,

$$
v_2^2 = \ell_1^2\dot\theta_1^2 + \ell_2^2\dot\theta_2^2 + 2\ell_1\ell_2\dot\theta_1\dot\theta_2\cos(\theta_1-\theta_2).
$$

Therefore

$$
T = \frac{1}{2}(m_1+m_2)\ell_1^2\dot\theta_1^2 + \frac{1}{2}m_2\ell_2^2\dot\theta_2^2 + m_2\ell_1\ell_2\dot\theta_1\dot\theta_2\cos(\theta_1-\theta_2),
$$

$$
U = m_1 g y_1 + m_2 g y_2 = -(m_1+m_2)g\ell_1\cos\theta_1 - m_2 g\ell_2\cos\theta_2,
$$

$$
L = T - U .
$$

**The equation for $\theta_1$.** We abbreviate $\Delta = \theta_1 - \theta_2$.

$$
\frac{\partial L}{\partial \dot\theta_1} = (m_1+m_2)\ell_1^2\dot\theta_1 + m_2\ell_1\ell_2\dot\theta_2\cos\Delta,
$$

$$
\frac{d}{dt}\frac{\partial L}{\partial\dot\theta_1} = (m_1+m_2)\ell_1^2\ddot\theta_1 + m_2\ell_1\ell_2\ddot\theta_2\cos\Delta - m_2\ell_1\ell_2\dot\theta_2\sin\Delta\,(\dot\theta_1-\dot\theta_2),
$$

$$
\frac{\partial L}{\partial\theta_1} = -m_2\ell_1\ell_2\dot\theta_1\dot\theta_2\sin\Delta - (m_1+m_2)g\ell_1\sin\theta_1 .
$$

Taking the difference, the terms quadratic in $\dot\theta$ are

$$
-m_2\ell_1\ell_2\sin\Delta\,(\dot\theta_1\dot\theta_2 - \dot\theta_2^2) + m_2\ell_1\ell_2\dot\theta_1\dot\theta_2\sin\Delta = m_2\ell_1\ell_2\dot\theta_2^2\sin\Delta .
$$

Dividing throughout by $\ell_1$,

$$
(m_1+m_2)\ell_1\ddot\theta_1 + m_2\ell_2\ddot\theta_2\cos\Delta + m_2\ell_2\dot\theta_2^2\sin\Delta + (m_1+m_2)g\sin\theta_1 = 0 .
$$

**The equation for $\theta_2$.** Similarly,

$$
\frac{\partial L}{\partial\dot\theta_2} = m_2\ell_2^2\dot\theta_2 + m_2\ell_1\ell_2\dot\theta_1\cos\Delta,
$$

$$
\frac{d}{dt}\frac{\partial L}{\partial\dot\theta_2} = m_2\ell_2^2\ddot\theta_2 + m_2\ell_1\ell_2\ddot\theta_1\cos\Delta - m_2\ell_1\ell_2\dot\theta_1\sin\Delta\,(\dot\theta_1 - \dot\theta_2),
$$

$$
\frac{\partial L}{\partial\theta_2} = +m_2\ell_1\ell_2\dot\theta_1\dot\theta_2\sin\Delta - m_2 g\ell_2\sin\theta_2
$$

(note that $\partial\cos\Delta/\partial\theta_2 = +\sin\Delta$). The terms of the difference quadratic in $\dot\theta$ are

$$
-m_2\ell_1\ell_2\sin\Delta\,(\dot\theta_1^2 - \dot\theta_1\dot\theta_2) - m_2\ell_1\ell_2\dot\theta_1\dot\theta_2\sin\Delta = -m_2\ell_1\ell_2\dot\theta_1^2\sin\Delta
$$

so that, dividing throughout by $m_2\ell_2$,

$$
\ell_2\ddot\theta_2 + \ell_1\ddot\theta_1\cos\Delta - \ell_1\dot\theta_1^2\sin\Delta + g\sin\theta_2 = 0 .
$$

**Checks.** Letting $m_2 \to 0$, the first equation becomes $\ell_1\ddot\theta_1 + g\sin\theta_1 = 0$, which agrees with the equation of the simple pendulum (<Ref to="ex-pendulum" />). In the small-oscillation limit ($\theta_i$ and $\dot\theta_i$ small, $\cos\Delta \approx 1$, $\sin\Delta \approx 0$, and the $\dot\theta^2$ terms negligible as second order) we obtain the linear system

$$
(m_1+m_2)\ell_1\ddot\theta_1 + m_2\ell_2\ddot\theta_2 + (m_1+m_2)g\theta_1 = 0, \qquad
\ell_2\ddot\theta_2 + \ell_1\ddot\theta_1 + g\theta_2 = 0
$$

to which the theory of normal modes applies. Compared with solving the problem in the Newtonian formulation, with the tensions in the two rods among the unknowns, this is far more mechanical.
</Solution>
</Exercise>

---

## References

- L. D. Landau and E. M. Lifshitz, *Mechanics*, 3rd revised ed. — Chapter I, "The equations of motion". The classic standard reference for a development starting from the principle of least action.
- H. Goldstein, C. Poole, J. Safko, *Classical Mechanics*, 3rd ed., Addison-Wesley, 2002 — Chapter 1, "Survey of the Elementary Principles", and Chapter 2, "Variational Principles and Lagrange's Equations". The derivation from d'Alembert's principle and the derivation from a variational principle are placed side by side.
- V. I. Arnold, *Mathematical Methods of Classical Mechanics*, 2nd ed., Springer, 1989 — Part II, "Lagrangian Mechanics". Covariance and configuration space are treated rigorously in the language of manifolds.
- I. M. Gelfand, S. V. Fomin, *Calculus of Variations*, Dover, 2000 — Chapter 1. The mathematical treatment of the fundamental lemma of the calculus of variations and of the Euler–Lagrange equations.
- Yamamoto Yoshitaka and Nakamura Kōichi, *Kaiseki Rikigaku I* (Analytical Mechanics I), Asakura Shoten, 1998 (in Japanese) — Chapters 1 and 2. Careful treatment of constraints, the principle of virtual work, and generalized coordinates.
- J.-L. Lagrange, *Mécanique analytique*, Paris, 1788 — the primary source.

---

## Appendix: Derivation from d'Alembert's principle

**Why another derivation is needed.** Hamilton's principle is beautiful, but it is laid down as an axiom, handed down from above. Lagrange himself started not from a variational principle but from the principle of virtual work, a generalization of the balance of forces. Following that route makes clear *why* the constraint forces disappear. It is also the correct starting point when nonholonomic constraints are to be treated.

**Virtual displacements and d'Alembert's principle.** Moving the configuration infinitesimally, with the time $t$ held fixed and within the range allowed by the constraints at that instant, is called a **virtual displacement** $\delta\boldsymbol{r}_i$. When the constraints are ideal (the constraint forces $\boldsymbol{R}_i$ do no work on virtual displacements), $\sum_i \boldsymbol{R}_i\cdot\delta\boldsymbol{r}_i = 0$. Multiplying Newton's equation $m_i\ddot{\boldsymbol{r}}_i = \boldsymbol{F}_i + \boldsymbol{R}_i$ (where $\boldsymbol{F}_i$ is the applied force) by $\delta\boldsymbol{r}_i$ and summing, the constraint-force term drops out and we obtain

$$
\sum_{i=1}^{N}\bigl(\boldsymbol{F}_i - m_i\ddot{\boldsymbol{r}}_i\bigr)\cdot\delta\boldsymbol{r}_i = 0 .
$$

This is **d'Alembert's principle**. The constraint forces disappear at this one step, and here too lies the reason why tensions and normal reactions never appear in the Lagrangian formulation.

**Rewriting in generalized coordinates.** With $\boldsymbol{r}_i = \boldsymbol{r}_i(q,t)$, a virtual displacement is a displacement at fixed time, so $\delta\boldsymbol{r}_i = \sum_k (\partial\boldsymbol{r}_i/\partial q^k)\,\delta q^k$ (no term $\partial\boldsymbol{r}_i/\partial t$ enters). Since the $\delta q^k$ may be chosen independently, d'Alembert's principle can be written, for each $k$, as

$$
Q_k - \sum_i m_i\ddot{\boldsymbol{r}}_i\cdot\frac{\partial\boldsymbol{r}_i}{\partial q^k} = 0, \qquad Q_k := \sum_i \boldsymbol{F}_i\cdot\frac{\partial \boldsymbol{r}_i}{\partial q^k} .
$$

The quantity $Q_k$ is called a **generalized force**.

**Expressing the acceleration term through the kinetic energy.** Here <Ref to="lem-dot-cancellation" /> comes into play. For $\boldsymbol{r}_i = \boldsymbol{r}_i(q,t)$ we have (i) $\partial\dot{\boldsymbol{r}}_i/\partial\dot q^k = \partial\boldsymbol{r}_i/\partial q^k$ and (ii) $\partial\dot{\boldsymbol{r}}_i/\partial q^k = \frac{d}{dt}(\partial\boldsymbol{r}_i/\partial q^k)$ (simply read $Q$ in the lemma as $q$, and $q$ as $\boldsymbol{r}_i$). By the product rule we split

$$
\sum_i m_i\ddot{\boldsymbol{r}}_i\cdot\frac{\partial\boldsymbol{r}_i}{\partial q^k}
= \sum_i\left[ \frac{d}{dt}\left( m_i\dot{\boldsymbol{r}}_i\cdot\frac{\partial\boldsymbol{r}_i}{\partial q^k} \right) - m_i\dot{\boldsymbol{r}}_i\cdot\frac{d}{dt}\frac{\partial\boldsymbol{r}_i}{\partial q^k} \right]
$$

and substituting (i) and (ii) this becomes

$$
= \frac{d}{dt}\left( \sum_i m_i\dot{\boldsymbol{r}}_i\cdot\frac{\partial\dot{\boldsymbol{r}}_i}{\partial \dot q^k} \right) - \sum_i m_i\dot{\boldsymbol{r}}_i\cdot\frac{\partial \dot{\boldsymbol{r}}_i}{\partial q^k}
= \frac{d}{dt}\frac{\partial T}{\partial \dot q^k} - \frac{\partial T}{\partial q^k}
$$

where $T = \sum_i \frac12 m_i|\dot{\boldsymbol{r}}_i|^2$, the last equality being the chain rule $\partial T/\partial u = \sum_i m_i \dot{\boldsymbol{r}}_i \cdot \partial\dot{\boldsymbol{r}}_i/\partial u$ (with $u$ either $q^k$ or $\dot q^k$).

**Conclusion.** Altogether, d'Alembert's principle in generalized coordinates reads

$$
\frac{d}{dt}\frac{\partial T}{\partial \dot q^k} - \frac{\partial T}{\partial q^k} = Q_k \qquad (k=1,\ldots,n).
$$

If moreover the forces derive from a potential $U(q,t)$, that is $Q_k = -\partial U/\partial q^k$, then since $U$ does not depend on $\dot q$ we have $\partial U/\partial\dot q^k = 0$, and putting $L = T - U$ gives

$$
\frac{d}{dt}\frac{\partial L}{\partial \dot q^k} - \frac{\partial L}{\partial q^k} = 0 .
$$

These are the same equations as in <Ref to="thm-euler-lagrange" />. In other words, the Euler–Lagrange equations can be derived from Newton's laws and the assumption of ideal constraints alone, without adopting a variational principle as an axiom. Hamilton's principle may then be placed as a rereading of these equations as the statement that the action is stationary.
