A good way to understand the laws of motion is not to memorize a separate equation for each situation, but to notice there is really only one trick, and every equation of motion is what falls out when you apply it. That sounds like an exaggeration. It isn’t. I’m going to take the trick apart in front of you, use it to derive Newton’s law, then run the very same steps to get the equation for a field spread through space, and once more for a field living in curved spacetime. Three arenas that look nothing alike in a textbook, one move that never changes. Try something as we go: before I write the next line, guess it. If the trick really is this general, you should be able to see the physics coming before the algebra confirms it.
Stated before any symbols get in the way, the trick goes like this. You take every history the world could possibly have, every path a particle might follow and every way a field might wave, and to each one you attach a single number. You call that number the action.1The action is a functional: unlike an ordinary function, which eats a number and returns a number, it eats an entire history $q_r(t)$ and returns a single number $S$. Its units are energy multiplied by time. The name and the idea run back through Maupertuis, Euler, Lagrange, and Hamilton across the eighteenth and nineteenth centuries. Then you make one demand: the history nature actually chooses is the one for which the number does not change, to first order, when you wiggle the history a little. Carry out that demand honestly and it hands you the equation of motion. That’s the whole engine. What follows is just running it in three arenas and watching it do the same job every time.
Start with the simplest arena there is, a single particle moving along a path. To say where the particle is at each moment, give its coordinates $q_r(t)$, where the label $r$ runs over as many numbers as you need to pin it down.2The label $r$ collects what are called generalized coordinates. For one particle in three dimensions it runs over $1,2,3$; for $N$ particles it runs to $3N$; and it need not be a Cartesian position at all, since an angle or any other convenient parameter works just as well. The derivation never cares which you choose. The action is a running total of a quantity $L$, the Lagrangian, tallied all along the path from a starting time to a finishing time:
$$ S = \int_{t_1}^{t_2} L(q_r, \dot q_r, t)\, dt. $$
The Lagrangian is allowed to depend on where the particle is, on how fast it is going, and possibly on the time itself, and on nothing else. Hold onto that restriction a little harder than usual; it’s doing more work than it looks like. Ask yourself what would go wrong if $L$ were also allowed to depend on the acceleration $\ddot q_r$. Keep that question in your pocket. We’ll come back to it right after the equation falls out, and the answer isn’t a footnote you can skip.3If $L$ depended on $\ddot q_r$ as well, the variation would generically produce a fourth-order equation, $\frac{\partial L}{\partial q_r} – \frac{d}{dt}\frac{\partial L}{\partial \dot q_r} + \frac{d^2}{dt^2}\frac{\partial L}{\partial \ddot q_r} = 0$, since integrating the acceleration term by parts twice brings down two extra time derivatives. Generically, but not always: a degenerate dependence on $\ddot q_r$, or a piece of $L$ that is itself a total time derivative, can bring the order back down. Ostrogradski showed in 1850 that a genuinely non-degenerate higher-derivative theory carries a Hamiltonian unbounded below, energy extractable without limit, a real instability rather than a mathematical curiosity, which is why most fundamental Lagrangians avoid the non-degenerate case. General relativity is itself a caveat worth knowing: the Einstein–Hilbert density does contain second derivatives of the metric, but they arrange themselves into a special boundary-term structure that keeps the resulting field equations second order. And when we later move to fields, this same restriction usually reappears as $\mathcal L$ depending only on $\phi_A$ and its first spacetime derivatives. It is the safe, common choice, not a law of nature the way the Euler–Lagrange equation itself is.
Time for the actual move. Take the true path, whatever it happens to be, and nudge it aside by a small amount:
$$ q_r(t) \longmapsto q_r(t) + \varepsilon\, \eta_r(t). $$
The function $\eta_r(t)$ is the shape of the nudge, an arbitrary bend you are free to invent, and $\varepsilon$ is a small knob that controls how hard you push. There is exactly one string attached. The nudge has to vanish at the two ends,
$$ \eta_r(t_1) = 0, \qquad \eta_r(t_2) = 0, $$
which says in plain words that you may bend the path however you like in the middle, but the particle must start where it started and arrive where it arrived. That condition will come back later, much enlarged, and recognizing it when it does is half of the whole story.
To say the action is stationary is to say that as you turn the knob $\varepsilon$ up through zero, the action does not move, to first order:
$$ \left.\frac{dS}{d\varepsilon}\right|_{\varepsilon=0} = 0. $$
This is the precise version of the loose phrase about wiggling the path.4Stationary is the honest word, not least. The true history is guaranteed only to be a critical point of the action, where the first-order change vanishes, and depending on the problem it may be a minimum, a maximum, or a saddle. The traditional name “principle of least action” is therefore a mild historical misnomer, a point Feynman was fond of making. What is always true is that the action does not change to first order, which is exactly the condition $dS/d\varepsilon|_{0}=0$. Differentiating is straightforward: pull the derivative inside the integral sign, apply the chain rule, and remember that when the path wiggles, its velocity wiggles too, at the rate $\dot\eta_r$:5Pulling the derivative $d/d\varepsilon$ inside the integral sign is itself a small theorem, not a free move. It requires $L$ and its first derivatives to be continuous in $\varepsilon$ near $\varepsilon=0$ and the path $q_r(t)$ to be differentiable on $[t_1,t_2]$; under those mild smoothness conditions, differentiation under the integral sign (a form of the Leibniz integral rule) is justified. Physics almost never worries about this, and it almost never needs to, but it is worth knowing the fine print exists.
$$ \left.\frac{dS}{d\varepsilon}\right|_{0} = \int_{t_1}^{t_2} \sum_r \left[ \frac{\partial L}{\partial q_r}\, \eta_r + \frac{\partial L}{\partial \dot q_r}\, \dot\eta_r \right] dt. $$
The whole difficulty of this subject lives inside that bracket, and so does the solution. The nudge $\eta_r$ appears bare in the first term but differentiated in the second, as $\dot\eta_r$. I’d like to factor it out and declare that whatever multiplies it must vanish, except I can’t: the nudge is wearing two different outfits. Integration by parts fixes this. It’s really the only idea in the whole business: it peels the derivative off the nudge and lays it onto everything else:
$$ \frac{\partial L}{\partial \dot q_r}\, \dot\eta_r = \frac{d}{dt}\!\left( \frac{\partial L}{\partial \dot q_r}\, \eta_r \right) – \frac{d}{dt}\!\left( \frac{\partial L}{\partial \dot q_r} \right)\eta_r. $$
Substitute this back. The first piece is a total time derivative, so when you integrate it from $t_1$ to $t_2$ it collapses to its values at the two endpoints, and the rest gathers into a single bracket multiplying the bare nudge:
$$ \delta S = \int_{t_1}^{t_2} \sum_r \left[ \frac{\partial L}{\partial q_r} – \frac{d}{dt}\!\left(\frac{\partial L}{\partial \dot q_r}\right) \right]\eta_r\, dt \;+\; \sum_r \left[ \frac{\partial L}{\partial \dot q_r}\, \eta_r \right]_{t_1}^{t_2}. $$
The endpoint term now removes itself. It’s the nudge evaluated at the two ends, and we agreed at the outset that the nudge is zero there. So it’s gone:
$$ \left[ \frac{\partial L}{\partial \dot q_r}\, \eta_r \right]_{t_1}^{t_2} = 0. $$
What is left is an integral of some bracket multiplied by the nudge, and it has to equal zero not for one clever choice of nudge but for every nudge you could ever draw. A fixed function that integrates to zero against absolutely every wiggle has nowhere to hide. It must be zero at every point.6This is the fundamental lemma of the calculus of variations, and it is worth stating carefully. If $f(t)$ is continuous on $[t_1,t_2]$ and $\int_{t_1}^{t_2} f(t)\,\eta(t)\,dt = 0$ for every smooth $\eta$ that vanishes at the two endpoints, then $f(t)=0$ everywhere on the interval. The argument is by contradiction: if $f$ were nonzero, say positive, at some interior point $t_0$, continuity guarantees $f$ stays positive on some small interval around $t_0$; choosing an $\eta$ that bulges upward only inside that interval and is zero elsewhere forces the integral to be strictly positive, contradicting the assumption that it is zero for every such $\eta$. Therefore the bracket vanishes on its own:
$$ \boxed{\; \frac{d}{dt}\!\left( \frac{\partial L}{\partial \dot q_r} \right) – \frac{\partial L}{\partial q_r} = 0. \;} $$
This is the Euler–Lagrange equation, and it came out of exactly three steps. You wiggled the path. You integrated by parts to move the derivative off the wiggle. You threw away the endpoint term because you had pinned the wiggle down. Photograph the shape of that equation and keep it in your wallet: a time derivative of the derivative of $L$ with respect to the velocity, minus the derivative of $L$ with respect to the position. In a moment we’ll meet its identical twin. As promised, only $\ddot q_r$ ever entered the story, through the single time derivative acting on $\partial L/\partial \dot q_r$. The acceleration you were tempted to add to $L$ at the very start never got the chance to appear twice over, which is exactly what keeps this equation second order and well behaved.
Before we go anywhere bigger, let me convince you the equation is not an empty formality by feeding it the most ordinary situation in physics. One particle, three dimensions, and the Lagrangian everyone meets first, kinetic energy minus potential energy:
$$ L = \tfrac{1}{2} m\left(\dot x_1^2 + \dot x_2^2 + \dot x_3^2\right) – V(x_1, x_2, x_3, t). $$
The derivative of $L$ with respect to a velocity is the momentum in that direction, and its time derivative is mass times acceleration:
$$ \frac{\partial L}{\partial \dot x_r} = m \dot x_r, \qquad \frac{d}{dt}\!\left(\frac{\partial L}{\partial \dot x_r}\right) = m \ddot x_r. $$
The derivative of $L$ with respect to a position is minus the slope of the potential in that direction:
$$ \frac{\partial L}{\partial x_r} = -\frac{\partial V}{\partial x_r}. $$
Put both into the box, rearrange, and out falls
$$ \boxed{\; m \ddot x_r = -\frac{\partial V}{\partial x_r} = F_r. \;} $$
That is $F = ma$, with the force revealed as minus the gradient of the potential.7If the force depends on velocity, as the magnetic force does, it cannot be written as minus the gradient of an ordinary potential $V(x)$. The remedy is a velocity-dependent potential $U(x,\dot x,t)$, but the generalized force it produces is $Q_r = \frac{d}{dt}\!\left(\frac{\partial U}{\partial \dot q_r}\right) – \frac{\partial U}{\partial q_r}$, not simply $-\partial U/\partial q_r$; the extra total-time-derivative piece is exactly what lets $U$ generate a velocity-dependent force at all. The full Lorentz force on a charge comes out of exactly this construction, with $L = \frac12 m\mathbf v^2 + q\mathbf A\cdot\mathbf v – q\Phi$. We didn’t assume Newton’s law anywhere; we wrote down a single scalar, kinetic minus potential, demanded its running total be stationary, and Newton’s law came out the far end with no further input. The principle of stationary action isn’t a decorative restatement of Newtonian mechanics sitting politely beside it. It contains Newtonian mechanics, and, as we’re about to see, a great deal that Newton never wrote down.
Here’s the real leap, so take it slowly. For the particle, the thing with a life of its own was a position that depends on time, $q_r(t)$. We now hand that starring role to a field: a number $\phi_A$ that has a value at every point of spacetime at once,
$$ \phi_A = \phi_A(x^\mu), \qquad x^0 = ct,\; x^1 = x,\; x^2 = y,\; x^3 = z. $$
The lower label $A$ is a roster, telling you which field you mean when there are several of them.8The label $A$ simply counts the independent components of whatever field you are studying. A single real scalar has one, a complex scalar has effectively two, the electromagnetic potential $A_\mu$ has four, and the metric of general relativity has ten. What follows never cares what the count is. The upper index $\mu$, running from $0$ to $3$, is a compass, telling you which of the four spacetime directions you are differentiating along. I will write $\partial_\mu$ for the derivative along direction $\mu$, so that the single symbol $\partial_\mu \phi_A$ gathers up how fast the field is changing in time and in each of the three directions of space, all in one stroke.
Only one thing about the action has to change, and for a simple reason. The particle’s action was a total along a one-dimensional path through time. A field is not at a point, it is everywhere, so its action must be a total over a whole slab of spacetime:
$$ S = \int_\Omega \mathcal L\left(\phi_A, \partial_\mu \phi_A, x^\mu\right) d^4x. $$
The script $\mathcal L$ is a Lagrangian density, meaning an amount of action packed into each little box of spacetime volume, and $d^4x = dx^0\,dx^1\,dx^2\,dx^3$ is the size of the box.9There is a factor of $c$ hiding in $x^0 = ct$, which makes $d^4x = c\,dt\,d^3x$. You can absorb that constant into the definition of $\mathcal L$, or you can set $x^0 = t$ and carry the factors of $c$ explicitly. Either way it is bookkeeping: a constant multiplying the whole action never changes which history makes the action stationary, so it cannot affect the equation of motion. Set this next to the particle line by line and the correspondence is almost embarrassing. Where the particle had $L$, the field has a density $\mathcal L$. Where the particle’s Lagrangian leaned on the velocity $\dot q_r$, the field’s density leans on the spacetime gradient $\partial_\mu \phi_A$. Where the particle summed $dt$ along a line, the field sums $d^4x$ over a region. It’s the same skeleton with one dimension traded for four. If you’ve really absorbed the particle derivation, you can already write down the field equation before I derive it. Try it.
Wiggle the field, and pin the wiggle not at two endpoints but on the entire boundary of the region:
$$ \phi \longmapsto \phi + \varepsilon\, \eta, \qquad \eta = 0 \text{ on } \partial\Omega. $$
I’ll carry a single field through the algebra to keep the symbols uncluttered; the case of many fields costs nothing, and I’ll collect that dividend at the end.10With several fields $\phi_A$, you introduce an independent nudge $\eta_A$ for each and run the same variation. Because the nudges are independent, the demand that the total variation vanish for all of them at once splits into one Euler–Lagrange equation per field. This is why the several-field case, which looks more general, is not any harder. The pinning condition is worth a second look. For the particle I froze the two endpoints of the path; for the field I freeze the entire boundary surface of the spacetime slab. But a boundary is a boundary. The two endpoints of the particle were nothing more than the boundary of a one-dimensional interval, and this is the same condition, promoted from the ends of a line to the skin of a four-dimensional region.
Demand stationarity, run the chain rule exactly as we did for the particle, and note that when the field wiggles its gradient wiggles at the rate $\partial_\mu \eta$:
$$ \delta S = \int_\Omega \left[ \frac{\partial \mathcal L}{\partial \phi}\, \eta + \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)}\, \partial_\mu \eta \right] d^4x. $$
There is the same obstacle we already know how to beat. The nudge is bare in the first term and differentiated in the second, so it cannot yet be factored out. Reach for the same tool. Integration by parts, now carried out in spacetime, lifts the derivative off the nudge:
$$ \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)}\, \partial_\mu \eta = \partial_\mu\!\left[ \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)}\, \eta \right] – \partial_\mu\!\left[ \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)} \right] \eta. $$
The first piece is a four-dimensional divergence, and integrating a divergence over a region converts it into a flux through the boundary of that region. That conversion is the divergence theorem:
$$ \int_\Omega \partial_\mu V^\mu\, d^4x = \int_{\partial\Omega} V^\mu\, d\Sigma_\mu. $$
It’s easy to read past this without noticing what’s actually going on. The endpoint term from the particle case and this new surface term aren’t just analogous; they’re the same theorem. When we integrated a total time derivative from $t_1$ to $t_2$ and collapsed it to its values at the two ends, we were using the fundamental theorem of calculus. And the fundamental theorem of calculus is nothing but the divergence theorem in a single dimension, with the two endpoints playing the part of the boundary.11In one dimension the divergence theorem is just the fundamental theorem of calculus: $\int_{t_1}^{t_2}\frac{dF}{dt}\,dt = F(t_2)-F(t_1)$. The boundary of the interval $[t_1,t_2]$ is the two-point set $\{t_1,t_2\}$, and the signs in $F(t_2)-F(t_1)$ are just the outward orientation of that boundary: $+1$ at $t_2$, where the outward direction agrees with increasing $t$, and $-1$ at $t_1$, where it opposes it. Both the one-dimensional and the four-dimensional statements are special cases of the general Stokes theorem, which says that integrating a derivative over a region equals integrating the original object over the region’s boundary. Raise the number of dimensions from one to four, and the boundary of an interval fattens into a boundary surface; the evaluation at two endpoints swells into a flux through that surface. One theorem, read once in one dimension and once in four. The endpoint term and the surface term aren’t cousins. They’re the same creature at two different sizes.
And the surface term dies for the same reason its one-dimensional ancestor did. We pinned the nudge to zero on the boundary, so the flux through the boundary is zero, and the surface term is gone. What survives is an integral of a bracket multiplied by an arbitrary nudge, which forces the bracket to vanish:
$$ \boxed{\; \partial_\mu\!\left( \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)} \right) – \frac{\partial \mathcal L}{\partial \phi} = 0. \;} $$
Lay this beside the particle’s equation and the resemblance is not a resemblance, it is a template with the words swapped. Where the particle had the time derivative $d/dt$, the field has the spacetime divergence $\partial_\mu$. Where the particle differentiated $L$ with respect to the velocity, the field differentiates $\mathcal L$ with respect to the gradient. Where the particle differentiated with respect to position, the field differentiates with respect to the field value. The equation did not change its shape at all. It only learned to count in four directions where before it counted in one.
Let’s feed this field equation its own simplest case, the way we fed Newton to the particle equation, and see what nature’s plainest field does. Take the density
$$ \mathcal L = \tfrac{1}{2}\, \partial_\mu \phi\, \partial^\mu \phi – \tfrac{1}{2}\, \mu^2 \phi^2, $$
where $\partial^\mu = \eta^{\mu\nu}\partial_\nu$ is the gradient with its index raised by the Minkowski metric, and the constant $\mu$ sets a scale we will read off in a moment.12Apologies for the notation: $\mu$ is doing double duty here, as a spacetime index in $\partial_\mu$ and as the mass constant. Both usages are completely standard, and context keeps them apart, but it is worth flagging so you are not caught off guard. The derivative of the density with respect to the field is
$$ \frac{\partial \mathcal L}{\partial \phi} = -\mu^2 \phi, $$
and the derivative with respect to the gradient comes out clean, because each of the two gradient factors in the first term contributes equally:
$$ \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)} = \partial^\mu \phi. $$
Drop both into the boxed field equation and you get
$$ \partial_\mu \partial^\mu \phi + \mu^2 \phi = 0, \qquad\text{or, more compactly,}\qquad \boxed{\; \Box \phi + \mu^2 \phi = 0. \;} $$
The symbol $\Box = \partial_\mu \partial^\mu$ is the wave operator, the four-dimensional relative of the Laplacian, and written out in ordinary time and space it reads
$$ \frac{1}{c^2}\frac{\partial^2 \phi}{\partial t^2} – \nabla^2 \phi + \frac{m^2 c^2}{\hbar^2}\, \phi = 0. $$
This is the Klein–Gordon equation, the simplest relativistic wave equation a single scalar field can obey, and the constant we called $\mu$ has turned out to be $\mu = mc/\hbar$, an inverse length fixed by the mass.13The constant works out to $\mu = mc/\hbar$, so its reciprocal $1/\mu = \hbar/mc$ is the reduced Compton wavelength of a particle of mass $m$, the natural length scale the mass sets. Throughout I use the signature $(+,-,-,-)$, so that $\partial_\mu\partial^\mu = \frac{1}{c^2}\partial_t^2 – \nabla^2$; with the opposite convention a sign flips, but no physics does. Set the mass to zero and the last term disappears, leaving
$$ \Box \phi = 0, $$
which is the plain wave equation. Calling this “the equation that carries light and sound” is only loosely right: light obeys Maxwell’s vector equations and sound is a pressure disturbance in matter, neither one a single scalar field, but individual components of both do satisfy an equation of exactly this mathematical form, which is part of why the wave equation feels so universal. So the field arena, handed its simplest Lagrangian, produces a wave, in parallel with the particle arena, which handed its simplest Lagrangian produced Newton.
What turned my own picture of these two arenas from “similar” into “the same” is a special case, though it takes a little bookkeeping to come out clean. Suppose the field is lazy and refuses to vary through space, depending on time alone, $\phi = \phi(t)$. Every spatial derivative is now zero, and integrating $\mathcal L$ over the now-irrelevant spatial directions just multiplies it by the coordinate volume $V$ of the region, so the effective, particle-like Lagrangian is $L_{\rm eff} = \int d^3x\, \mathcal L = V\mathcal L$; the constant $V$ divides straight out of the resulting equation of motion and never touches it. There is a second bit of bookkeeping too: with $x^0=ct$, the time part of the spacetime derivative is $\partial_0\phi = \frac{1}{c}\dot\phi$, not $\dot\phi$ itself, so the factors of $c$ only disappear cleanly if you set $x^0=t$ from the start or carry them through by hand. Small thing, easy to trip on. Do that, and the boxed field equation collapses into
$$ \frac{d}{dt}\!\left( \frac{\partial L_{\rm eff}}{\partial \dot\phi} \right) – \frac{\partial L_{\rm eff}}{\partial \phi} = 0, $$
which is the particle’s Euler–Lagrange equation in every structural respect, with $L_{\rm eff}$ standing in for $L$. So the field equation is not an analogy of the particle equation. It is a generalization that contains the particle equation exactly, as the special case in which nothing depends on where you are, once the volume factor and the coordinate convention have been tracked honestly rather than waved away. Peel away the three dimensions of space and the field remembers that it was the same law all along.
The last arena is curved spacetime: a metric $g_{\mu\nu}(x)$ now sets how distances and times are measured, and it changes from place to place. Two things change in the passage from flat to curved, one about how you measure volume and one about how you differentiate. Neither, it turns out, touches the move itself.
The first change is the volume of the little box. On flat spacetime the box had volume $d^4x$; on a curved manifold the correct, coordinate-independent volume is $\sqrt{-g}\, d^4x$, where $g$ is the determinant of the metric.14For a Lorentzian metric the determinant $g$ is negative, so $-g$ is positive and $\sqrt{-g}$ is real. The combination $\sqrt{-g}\,d^4x$ is the invariant four-volume, the same number in every coordinate system. In flat Minkowski coordinates the metric determinant is $-1$, so $\sqrt{-g}=1$ and the invariant volume reduces to the ordinary $d^4x$, which is why the flat-space derivation never had to mention it. The second change is that the plain derivative $\partial_\mu$ ought to be promoted to the covariant derivative $\nabla_\mu$, the derivative that accounts for the bending of the coordinates. For a scalar field these two happen to coincide, $\nabla_\mu \phi = \partial_\mu \phi$, which is a small mercy I am going to accept gratefully.15Two facts are doing quiet work here. First, a scalar field has no indices for the connection to act on, so $\nabla_\mu\phi = \partial_\mu\phi$; the first place the two derivatives part ways is a vector, where $\nabla_\mu V^\nu = \partial_\mu V^\nu + \Gamma^\nu{}_{\mu\lambda}V^\lambda$. Second, the divergence identity $\nabla_\mu V^\mu = \frac{1}{\sqrt{-g}}\partial_\mu(\sqrt{-g}\,V^\mu)$ used two lines below follows from the contracted Christoffel symbol $\Gamma^\lambda{}_{\mu\lambda} = \partial_\mu \ln\sqrt{-g}$. To keep the notation consistent from here on, the density should be understood as depending on the covariant derivative rather than the plain one,
$$ \boxed{\; \mathcal L = \mathcal L(\phi, \nabla_\mu \phi, x^\mu). \;} $$
For this scalar the two derivatives happen to coincide, which is why writing $\partial_\mu\phi$ in its place cost us nothing above, but it is $\nabla_\mu\phi$ that is the geometrically correct object, and it is the one that generalizes once the field stops being a scalar. The action reads
$$ S = \int_\Omega \mathcal L\, \sqrt{-g}\; d^4x. $$
Run the move a third time: wiggle the field, pin it on the boundary, demand stationarity, integrate by parts, this time with the covariant product rule. The one step with any right to go wrong is the boundary term. The curvature has to show up somewhere, after all, and if not there, it must be hiding elsewhere. It is. It sits in plain sight, inside a small identity:
$$ \nabla_\mu V^\mu = \frac{1}{\sqrt{-g}}\, \partial_\mu\!\left( \sqrt{-g}\, V^\mu \right). $$
The identity doesn’t make two copies of $\sqrt{-g}$ literally cancel; what it does is convert the covariant divergence $\nabla_\mu V^\mu$, sitting inside the honest curved-space measure $\sqrt{-g}\,d^4x$, into an ordinary coordinate divergence $\partial_\mu(\sqrt{-g}\,V^\mu)$ against the flat measure $d^4x$. That ordinary coordinate divergence is exactly the object the flat-space divergence theorem already knows how to turn into a boundary flux. So the boundary piece becomes an ordinary flux, which vanishes because the nudge vanishes on the boundary. Same death, same reason, third time in a row; the curvature never got a chance to spoil the argument because it was absorbed into the very identity that lets the divergence theorem apply at all. What survives is
$$ \boxed{\; \nabla_\mu\!\left( \frac{\partial \mathcal L}{\partial(\nabla_\mu \phi)} \right) – \frac{\partial \mathcal L}{\partial \phi} = 0, \;} $$
and, if you prefer to see the metric factor out in the open,
$$ \frac{1}{\sqrt{-g}}\, \partial_\mu\!\left[ \sqrt{-g}\, \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)} \right] – \frac{\partial \mathcal L}{\partial \phi} = 0. $$
Feed in the same free scalar density used in flat spacetime, now built from the curved metric instead of the flat one,
$$ \mathcal L = \tfrac{1}{2}\, g^{\mu\nu}\partial_\mu\phi\,\partial_\nu\phi – \tfrac{1}{2}\, \mu^2 \phi^2, $$
and the two derivatives you need are exactly the flat-space ones with $\eta^{\mu\nu}$ replaced by $g^{\mu\nu}$:
$$ \frac{\partial \mathcal L}{\partial \phi} = -\mu^2 \phi, \qquad \frac{\partial \mathcal L}{\partial(\partial_\mu \phi)} = g^{\mu\nu}\partial_\nu\phi. $$
Drop both into the boxed curved-space equation and out comes the curved-space Klein–Gordon equation:
$$ \boxed{\; \frac{1}{\sqrt{-g}}\, \partial_\mu\!\left( \sqrt{-g}\, g^{\mu\nu}\partial_\nu\phi \right) + \mu^2 \phi = 0. \;} $$
This is the third arena’s own famous equation, and it completes the parallel exactly: the particle gave Newton, the flat field gave Klein–Gordon, and the curved field gives this, the same Klein–Gordon equation with the flat metric $\eta^{\mu\nu}$ replaced by the curved $g^{\mu\nu}$ and a $\sqrt{-g}$ riding inside the derivative to keep the divergence covariant. Set $g_{\mu\nu}\to\eta_{\mu\nu}$, so that $\sqrt{-g}\to1$, and it collapses straight back to the flat equation we already derived, exactly as it must.
There is a subtlety in that last line. It looks as though the equation has forgotten that the metric depends on position, but it hasn’t forgotten at all. The factor $\sqrt{-g}$ depends only on where you are, never on the field or on the field’s gradient, so when you differentiate the density with respect to the field, the $\sqrt{-g}$ is not a variable to be differentiated but a bystander riding along inside the explicit coordinate dependence. It’s luggage the field carries, not a control the field can turn. That is precisely why it can sit inside the derivative in one line and outside it in the next without contradiction.
I leaned, twice now, on the field being a scalar, and I owe you the reason it mattered. When the field carries indices of its own, when it is a vector or a tensor rather than a plain number, the covariant derivative stops being equal to the plain derivative, the connection terms that measure the bending of the coordinates come out of hiding, and the bookkeeping grows real teeth.16For a vector or tensor field you must differentiate the density with respect to $\nabla_\mu\phi_A$ with its indices intact, and the resulting Euler–Lagrange operator carries extra connection terms. The Maxwell and Proca equations, and the linearized equations for a metric perturbation, all come out this way. The scalar spares us those terms without hiding the essential move. The scalar is the clean room in which you can watch the move work with nothing extra clinging to it. It is the right place to learn the pattern before the extra machinery arrives.
So what did we actually do? We wrote an action for a particle, demanded it be stationary, and Newton’s law came out. We wrote an action for a field, demanded it be stationary, and a wave came out. We wrote an action for a field in curved spacetime, demanded it be stationary, and the curved-space wave equation came out. Three arenas that share no furniture, and in every one of them the derivation was the same three motions: wiggle the history, integrate by parts to move the derivative off the wiggle, and discard the boundary term because the wiggle was pinned down there.
The many-field dividend I promised earlier is now free. If there are many fields $\phi_A$ instead of one, you introduce an independent nudge for each and run the same variation, and because the nudges are independent, each field simply hands you its own copy of the boxed equation. Nothing in the three steps ever asked how many fields were present. The move does not become harder when the world becomes more complicated. It only becomes longer to write down.
There’s a second dividend here, one I’ve been quietly setting up all along and haven’t cashed in yet. We discarded the boundary term every single time because we forced the nudge to vanish there. It is tempting to think that if you refuse to force it, say by choosing $\eta_r=\dot q_r$, the shift generated by letting time flow forward, the endpoint term $\left[\partial L/\partial\dot q_r\,\dot q_r\right]_{t_1}^{t_2}$ is itself the conserved energy. It isn’t. That guess is missing a piece, and the route to what actually is conserved goes through the Lagrangian’s own total time derivative along the true trajectory:
$$ \frac{dL}{dt} = \sum_r \frac{\partial L}{\partial q_r}\dot q_r + \sum_r \frac{\partial L}{\partial \dot q_r}\ddot q_r + \frac{\partial L}{\partial t}. $$
Now use the Euler–Lagrange equation itself, $\partial L/\partial q_r = \frac{d}{dt}(\partial L/\partial \dot q_r)$, to trade the first term for a total time derivative. The right-hand side collapses into a single derivative:
$$ \frac{d}{dt}\left( \sum_r \dot q_r\, \frac{\partial L}{\partial \dot q_r} – L \right) = -\frac{\partial L}{\partial t}. $$
So whenever $L$ carries no explicit time dependence, the quantity in parentheses is exactly conserved:
$$ \boxed{\; E = \sum_r \dot q_r\, \frac{\partial L}{\partial \dot q_r} – L. \;} $$
This is the energy, or in Hamiltonian language, $H$. It needed both the momentum-like piece $\dot q_r\,\partial L/\partial\dot q_r$ and the compensating $-L$; the boundary term alone, without subtracting $L$, is not a conserved quantity at all, which is exactly the trap the naive guess above falls into.17This is the shadow of Noether’s theorem falling across the same calculation we already did, though done correctly it requires varying time itself alongside the coordinates rather than treating $\eta_r=\dot q_r$ as an ordinary fixed-time nudge. In the field case the analogous argument, built from a spacetime translation, produces the canonical energy–momentum tensor $T^\mu{}_\nu = \frac{\partial \mathcal L}{\partial(\partial_\mu\phi_A)}\,\partial_\nu\phi_A – \delta^\mu{}_\nu\,\mathcal L$, with $\partial_\mu T^\mu{}_\nu=0$ the local conservation law for the field’s energy and momentum; it reduces to $\partial^\mu\phi\,\partial_\nu\phi – \delta^\mu{}_\nu\mathcal L$ only for the specific free-scalar density used earlier, since that is the one case where $\partial\mathcal L/\partial(\partial_\mu\phi)=\partial^\mu\phi$. Momentum and angular momentum come from spacetime symmetries in exactly this family. Electric charge conservation is a genuine Noether current too, but it comes from an internal symmetry, a global phase rotation of the field, not from a spacetime translation, so it is not itself a component of $T^\mu{}_\nu$. The lesson survives the correction: a piece of the calculation you learned to throw away, tracked instead of discarded, is where every conservation law in physics comes from. That’s not a small aside. It may be the more important half of this entire trick, and it’s the subject for the next post.
None of this is a coincidence of notation. Every experimentally successful fundamental classical field theory currently known admits an action formulation. That’s why a single trick can reach from a bead on a wire all the way to a field in curved spacetime. The principle of stationary action is one sentence, that nature makes a certain total stationary, and the equation of motion is simply what that sentence looks like once you’ve carried out the wiggle without cheating. Newton’s law, the Klein–Gordon equation, and a scalar field threading its way through curved spacetime aren’t three laws that happen to rhyme. They’re one demand, put to three arenas, and answered by one move in each.
And if you ever get bold and let the metric itself be the thing you wiggle, instead of a fixed stage you have set the field upon, the same move hands you Einstein’s field equations for gravity.18The gravitational case takes the Einstein–Hilbert action $S = \frac{1}{2\kappa}\int R\,\sqrt{-g}\,d^4x$, where $R$ is the Ricci scalar built from the metric, and varies with respect to the metric $g^{\mu\nu}$ itself rather than a field living on top of it. Here “more careful boundary analysis” is not a figure of speech: the variation of $R$ produces terms containing derivatives of $\delta g_{\mu\nu}$, not just $\delta g_{\mu\nu}$ itself, so pinning $\delta g_{\mu\nu}=0$ on the boundary is not by itself enough to kill the boundary term. A well-posed variational principle needs the Gibbons–Hawking–York term added to the action to cancel the offending piece. With that included, the same wiggle-and-discard procedure yields Einstein’s field equations $G_{\mu\nu} = \kappa T_{\mu\nu}$. But that’s a story for another day, and it’s the same trick once more. When you’ve truly seen this move, you haven’t learned a drawer full of separate equations. You’ve learned one thing, and then watched it grow up.
References and Footnotes
- 1The action is a functional: unlike an ordinary function, which eats a number and returns a number, it eats an entire history $q_r(t)$ and returns a single number $S$. Its units are energy multiplied by time. The name and the idea run back through Maupertuis, Euler, Lagrange, and Hamilton across the eighteenth and nineteenth centuries. ↩︎
- 2The label $r$ collects what are called generalized coordinates. For one particle in three dimensions it runs over $1,2,3$; for $N$ particles it runs to $3N$; and it need not be a Cartesian position at all, since an angle or any other convenient parameter works just as well. The derivation never cares which you choose. ↩︎
- 3If $L$ depended on $\ddot q_r$ as well, the variation would generically produce a fourth-order equation, $\frac{\partial L}{\partial q_r} – \frac{d}{dt}\frac{\partial L}{\partial \dot q_r} + \frac{d^2}{dt^2}\frac{\partial L}{\partial \ddot q_r} = 0$, since integrating the acceleration term by parts twice brings down two extra time derivatives. Generically, but not always: a degenerate dependence on $\ddot q_r$, or a piece of $L$ that is itself a total time derivative, can bring the order back down. Ostrogradski showed in 1850 that a genuinely non-degenerate higher-derivative theory carries a Hamiltonian unbounded below, energy extractable without limit, a real instability rather than a mathematical curiosity, which is why most fundamental Lagrangians avoid the non-degenerate case. General relativity is itself a caveat worth knowing: the Einstein–Hilbert density does contain second derivatives of the metric, but they arrange themselves into a special boundary-term structure that keeps the resulting field equations second order. ↩︎
- 4Stationary is the honest word, not least. The true history is guaranteed only to be a critical point of the action, where the first-order change vanishes, and depending on the problem it may be a minimum, a maximum, or a saddle. The traditional name “principle of least action” is therefore a mild historical misnomer, a point Feynman was fond of making. What is always true is that the action does not change to first order, which is exactly the condition $dS/d\varepsilon|_{0}=0$. ↩︎
- 5Pulling the derivative $d/d\varepsilon$ inside the integral sign is itself a small theorem, not a free move. It requires $L$ and its first derivatives to be continuous in $\varepsilon$ near $\varepsilon=0$ and the path $q_r(t)$ to be differentiable on $[t_1,t_2]$; under those mild smoothness conditions, differentiation under the integral sign (a form of the Leibniz integral rule) is justified. Physics almost never worries about this, and it almost never needs to, but it is worth knowing the fine print exists. ↩︎
- 6This is the fundamental lemma of the calculus of variations, and it is worth stating carefully. If $f(t)$ is continuous on $[t_1,t_2]$ and $\int_{t_1}^{t_2} f(t)\,\eta(t)\,dt = 0$ for every smooth $\eta$ that vanishes at the two endpoints, then $f(t)=0$ everywhere on the interval. The argument is by contradiction: if $f$ were nonzero, say positive, at some interior point $t_0$, continuity guarantees $f$ stays positive on some small interval around $t_0$; choosing an $\eta$ that bulges upward only inside that interval and is zero elsewhere forces the integral to be strictly positive, contradicting the assumption that it is zero for every such $\eta$. ↩︎
- 7If the force depends on velocity, as the magnetic force does, it cannot be written as minus the gradient of an ordinary potential $V(x)$. The remedy is a velocity-dependent potential $U(x,\dot x,t)$, but the generalized force it produces is $Q_r = \frac{d}{dt}\!\left(\frac{\partial U}{\partial \dot q_r}\right) – \frac{\partial U}{\partial q_r}$, not simply $-\partial U/\partial q_r$; the extra total-time-derivative piece is exactly what lets $U$ generate a velocity-dependent force at all. The full Lorentz force on a charge comes out of exactly this construction, with $L = \frac12 m\mathbf v^2 + q\mathbf A\cdot\mathbf v – q\Phi$. ↩︎
- 8The label $A$ simply counts the independent components of whatever field you are studying. A single real scalar has one, a complex scalar has effectively two, the electromagnetic potential $A_\mu$ has four, and the metric of general relativity has ten. What follows never cares what the count is. ↩︎
- 9There is a factor of $c$ hiding in $x^0 = ct$, which makes $d^4x = c\,dt\,d^3x$. You can absorb that constant into the definition of $\mathcal L$, or you can set $x^0 = t$ and carry the factors of $c$ explicitly. Either way it is bookkeeping: a constant multiplying the whole action never changes which history makes the action stationary, so it cannot affect the equation of motion. ↩︎
- 10With several fields $\phi_A$, you introduce an independent nudge $\eta_A$ for each and run the same variation. Because the nudges are independent, the demand that the total variation vanish for all of them at once splits into one Euler–Lagrange equation per field. This is why the several-field case, which looks more general, is not any harder. ↩︎
- 11In one dimension the divergence theorem is just the fundamental theorem of calculus: $\int_{t_1}^{t_2}\frac{dF}{dt}\,dt = F(t_2)-F(t_1)$. The boundary of the interval $[t_1,t_2]$ is the two-point set $\{t_1,t_2\}$, and the signs in $F(t_2)-F(t_1)$ are just the outward orientation of that boundary: $+1$ at $t_2$, where the outward direction agrees with increasing $t$, and $-1$ at $t_1$, where it opposes it. Both the one-dimensional and the four-dimensional statements are special cases of the general Stokes theorem, which says that integrating a derivative over a region equals integrating the original object over the region’s boundary. ↩︎
- 12Apologies for the notation: $\mu$ is doing double duty here, as a spacetime index in $\partial_\mu$ and as the mass constant. Both usages are completely standard, and context keeps them apart, but it is worth flagging so you are not caught off guard. ↩︎
- 13The constant works out to $\mu = mc/\hbar$, so its reciprocal $1/\mu = \hbar/mc$ is the reduced Compton wavelength of a particle of mass $m$, the natural length scale the mass sets. Throughout I use the signature $(+,-,-,-)$, so that $\partial_\mu\partial^\mu = \frac{1}{c^2}\partial_t^2 – \nabla^2$; with the opposite convention a sign flips, but no physics does. ↩︎
- 14For a Lorentzian metric the determinant $g$ is negative, so $-g$ is positive and $\sqrt{-g}$ is real. The combination $\sqrt{-g}\,d^4x$ is the invariant four-volume, the same number in every coordinate system. In flat Minkowski coordinates the metric determinant is $-1$, so $\sqrt{-g}=1$ and the invariant volume reduces to the ordinary $d^4x$, which is why the flat-space derivation never had to mention it. ↩︎
- 15Two facts are doing quiet work here. First, a scalar field has no indices for the connection to act on, so $\nabla_\mu\phi = \partial_\mu\phi$; the first place the two derivatives part ways is a vector, where $\nabla_\mu V^\nu = \partial_\mu V^\nu + \Gamma^\nu{}_{\mu\lambda}V^\lambda$. Second, the divergence identity $\nabla_\mu V^\mu = \frac{1}{\sqrt{-g}}\partial_\mu(\sqrt{-g}\,V^\mu)$ used two lines below follows from the contracted Christoffel symbol $\Gamma^\lambda{}_{\mu\lambda} = \partial_\mu \ln\sqrt{-g}$. ↩︎
- 16For a vector or tensor field you must differentiate the density with respect to $\nabla_\mu\phi_A$ with its indices intact, and the resulting Euler–Lagrange operator carries extra connection terms. The Maxwell and Proca equations, and the linearized equations for a metric perturbation, all come out this way. The scalar spares us those terms without hiding the essential move. ↩︎
- 17This is the shadow of Noether’s theorem falling across the same calculation we already did, though done correctly it requires varying time itself alongside the coordinates rather than treating $\eta_r=\dot q_r$ as an ordinary fixed-time nudge. In the field case the analogous argument, built from a spacetime translation, produces the canonical energy–momentum tensor $T^\mu{}_\nu = \frac{\partial \mathcal L}{\partial(\partial_\mu\phi_A)}\,\partial_\nu\phi_A – \delta^\mu{}_\nu\,\mathcal L$, with $\partial_\mu T^\mu{}_\nu=0$ the local conservation law for the field’s energy and momentum; it reduces to $\partial^\mu\phi\,\partial_\nu\phi – \delta^\mu{}_\nu\mathcal L$ only for the specific free-scalar density used earlier, since that is the one case where $\partial\mathcal L/\partial(\partial_\mu\phi)=\partial^\mu\phi$. Momentum and angular momentum come from spacetime symmetries in exactly this family. Electric charge conservation is a genuine Noether current too, but it comes from an internal symmetry, a global phase rotation of the field, not from a spacetime translation, so it is not itself a component of $T^\mu{}_\nu$. ↩︎
- 18The gravitational case takes the Einstein–Hilbert action $S = \frac{1}{2\kappa}\int R\,\sqrt{-g}\,d^4x$, where $R$ is the Ricci scalar built from the metric, and varies with respect to the metric $g^{\mu\nu}$ itself rather than a field living on top of it. Here “more careful boundary analysis” is not a figure of speech: the variation of $R$ produces terms containing derivatives of $\delta g_{\mu\nu}$, not just $\delta g_{\mu\nu}$ itself, so pinning $\delta g_{\mu\nu}=0$ on the boundary is not by itself enough to kill the boundary term. A well-posed variational principle needs the Gibbons–Hawking–York term added to the action to cancel the offending piece. With that included, the same wiggle-and-discard procedure yields Einstein’s field equations $G_{\mu\nu} = \kappa T_{\mu\nu}$. ↩︎