Variational Derivation of the Field Equations

The variational route to the Einstein equations is the modern foundation of classical gravity. Instead of postulating the field equations by analogy with Newton, one postulates a single scalar quantity — an action — and demands that the spacetimes nature actually realizes be its stationary points. This is the same principle that turns the Lagrangian of a particle into its equation of motion and the Maxwell Lagrangian into Maxwell's equations, now applied with the metric itself as the dynamical field. The payoff is not merely elegance. Writing gravity as a variational principle makes its deepest structural facts transparent: why the field equations are second order, why the source must be a symmetric conserved tensor, and why energy-momentum conservation is guaranteed rather than assumed. The total action splits into a geometric part and a matter part, S=116πG∫M(R−2Λ)−g d4x+Smatter[gμν,ψ]S = \frac{1}{16\pi G}\int_{\mathcal{M}}(R-2\Lambda)\sqrt{-g}\,\mathrm{d}^4x + S_{\mathrm{matter}}[g_{\mu\nu},\psi]. The gravitational Lagrangian is the Ricci scalar RR — the simplest non-trivial diffeomorphism invariant one can build from the metric — plus the cosmological constant. Demanding δS=0\delta S = 0 under an arbitrary variation of the inverse metric gμνg^{\mu\nu} requires just three ingredients: the variation of the volume element −g\sqrt{-g}, the variation of the curvature RR, and the variational definition of the stress-energy tensor from SmatterS_{\mathrm{matter}}. The first two assemble into the Einstein tensor; the third supplies the source. A famous subtlety — that δRμν\delta R_{\mu\nu} is a pure boundary term — is the seed of the whole Gibbons-Hawking-York story. This is the article where the postulated Einstein equation of its sibling becomes a derived consequence of a one-line action.

Key takeaways
  • The Einstein field equations follow from extremizing one action S=Sgrav+SmatterS = S_{\mathrm{grav}} + S_{\mathrm{matter}} with respect to the inverse metric gμνg^{\mu\nu}, with the Einstein-Hilbert Lagrangian RR as the gravitational part.
  • Varying ∫−g R d4x\int\sqrt{-g}\,R\,\mathrm{d}^4x produces the Einstein tensor Gμν=Rμν−12gμνRG_{\mu\nu}=R_{\mu\nu}-\tfrac12 g_{\mu\nu}R; the awkward δRμν\delta R_{\mu\nu} piece is a total covariant divergence (the Palatini identity) that integrates to a boundary term.
  • The matter action defines the source variationally, Tμν=−2−gδSmatterδgμνT_{\mu\nu}=-\frac{2}{\sqrt{-g}}\frac{\delta S_{\mathrm{matter}}}{\delta g^{\mu\nu}}, automatically delivering a symmetric tensor coupled to geometry.
  • Stationarity δS=0\delta S=0 yields Gμν+Λgμν=8πG TμνG_{\mu\nu}+\Lambda g_{\mu\nu}=8\pi G\,T_{\mu\nu} (with c=1c=1); the coupling 8πG8\pi G is fixed not by the variation but by the Newtonian limit.
  • Diffeomorphism invariance of SmatterS_{\mathrm{matter}} forces ∇μTμν=0\nabla^\mu T_{\mu\nu}=0 on-shell (Noether's second theorem), and the contracted Bianchi identity gives ∇μGμν=0\nabla^\mu G_{\mu\nu}=0 off-shell, so conservation is automatic, not imposed.
  • The leftover boundary term must be cancelled by the Gibbons-Hawking-York term to make the variational problem well posed when the metric is fixed on the boundary.
  • Key idea: treat the metric as the dynamical field and write a single scalar action; the Euler-Lagrange equation δS/δgμν=0\delta S/\delta g^{\mu\nu}=0 IS the Einstein equation, with the source emerging from δSmatter/δgμν\delta S_{\mathrm{matter}}/\delta g^{\mu\nu} rather than being inserted by hand.
The core insight

Treat the metric as the dynamical field and write a single scalar action; the Euler-Lagrange equation from δS/δgμν=0\delta S/\delta g^{\mu\nu}=0 IS the Einstein equation, with the source TμνT_{\mu\nu} emerging from δSmatter/δgμν\delta S_{\mathrm{matter}}/\delta g^{\mu\nu} rather than being inserted by hand.

Where this lives today

The action principle is not a historical relic — it is the working language of every frontier of gravitational physics. Every proposed alternative to Einstein gravity is written down as an action first and varied second: f(R)f(R) models, scalar-tensor and Horndeski theories, and Lovelock gravity in higher dimensions are all defined by their Lagrangians, and the variational method is the only systematic way to extract their field equations and check for pathologies like ghost modes. In quantum gravity the action is the theory: the gravitational path integral ∫Dg eiS[g]/ℏ\int\mathcal{D}g\,e^{iS[g]/\hbar} sums over geometries weighted by the Einstein-Hilbert action, and the Euclidean version — where the on-shell action equals the free energy — is how Gibbons and Hawking computed black-hole entropy, a calculation that requires the boundary term this article's stray divergence anticipates. That same on-shell action underlies holographic renormalization in the AdS/CFT correspondence, where boundary terms carry the physical data of a dual field theory. And the Noether logic that makes ∇μTμν=0\nabla^\mu T_{\mu\nu}=0 automatic is the direct ancestor of the covariant phase-space methods used to define energy, angular momentum, and entropy for black holes and gravitational-wave sources measured by LIGO and Virgo. When a numerical relativist writes down a modified-gravity waveform, they begin exactly where this article does: with an action and a variation.

The physical picture

Think of the action as a machine that assigns a single number to every conceivable configuration of the universe — each candidate spacetime geometry together with the matter living on it. Most of those configurations are not physical; they are geometries nature would never realize. The variational principle is the rule that selects the real ones: nature picks the configuration at which the number is stationary, meaning a small change in the metric anywhere produces no first-order change in SS. Because the metric can be varied independently at every point, "stationary at every point" is not one condition but one condition per spacetime event — and that infinite family of pointwise conditions is precisely a field equation. The first figure makes this abstract statement concrete: the physical spacetime sits at the bottom of the action landscape, where the slope vanishes.

Figure
The action assigns one number S to each candidate spacetime geometry; nature selects the geometry where S is stationary, δS = 0, and that single stationarity condition is exactly the Einstein equation G_μν + Λ g_μν = 8πG T_μν
The variational principle: S[g] is stationary at the physical spacetime space of metrics g_μν (schematic) action S[g] δS = 0 physical spacetime nearby geometry: δS ≠ 0 G_μν + Λ g_μν = 8πG T_μν

Why the Ricci scalar, and not some other invariant? Because RR is the simplest diffeomorphism-invariant scalar you can build from the metric and its derivatives that is not a constant. A Lagrangian must be a scalar (so the action is coordinate-independent), and among scalars RR contains the fewest derivatives — it depends on the metric and its first and second derivatives, no higher. That single fact dictates the entire character of general relativity: the field equations come out second order in the metric, and the object that appears is GμνG_{\mu\nu} rather than some higher-curvature tensor. Choose a more elaborate Lagrangian, such as f(R)f(R) or RμνRμνR_{\mu\nu}R^{\mu\nu}, and you get fourth-order equations and, generically, extra propagating degrees of freedom. Einstein gravity is the minimal choice. The second reason to love the variational picture is that it turns a coincidence into a theorem. The matter action is a scalar, so it is unchanged when you relabel the coordinates — this is diffeomorphism invariance, the gauge symmetry of gravity. Just as the gauge invariance of electromagnetism forces charge conservation, invariance of SmatterS_{\mathrm{matter}} under an infinitesimal coordinate flow forces energy-momentum conservation, ∇μTμν=0\nabla^\mu T_{\mu\nu}=0, whenever the matter fields obey their own equations of motion. And this dovetails exactly with the geometry: the contracted Bianchi identity guarantees ∇μGμν=0\nabla^\mu G_{\mu\nu}=0 as a pure identity. The field equation sets these two divergence-free tensors proportional, so the two conservation statements are one and the same. The coupling constant that fixes their proportionality is the last thing the second figure pins down.

Figure
Fixing the coupling: the weak-field, slow-motion limit collapses the time-time Einstein equation to the Newtonian Poisson equation ∇²Φ = 4πG ρ, which forces the constant to be 8πG and Einstein's coupling κ = 8πG/c⁴ ≈ 2.08×10⁻⁴³ per newton
The Newtonian limit fixes the coupling constant 8πG G_μν + Λ g_μν = (8πG/c⁴) T_μν weak field g_00 = −(1 + 2Φ/c²), v ≪ c, Λ → 0 G_00 → (2/c²) ∇²Φ T_00 → ρ c² keep only the time-time component match both sides ∇²Φ = 4πG ρ (Newton recovered) κ = 8πG/c⁴ ≈ 2.08×10⁻⁴³ N⁻¹

The core equations

The starting point is the total action. It is the sum of a purely geometric Einstein-Hilbert-plus-cosmological piece, normalized by 1/16πG1/16\pi G, and a matter action SmatterS_{\mathrm{matter}} built from all non-gravitational fields ψ\psi coupled to the metric. The dynamical variable throughout is the metric; gravity lives in the geometry, not in a field on a fixed stage.

S=116πG∫M(R−2Λ)−g d4x+Smatter[gμν,ψ](1)S = \frac{1}{16\pi G}\int_{\mathcal{M}}(R-2\Lambda)\sqrt{-g}\,\mathrm{d}^4x + S_{\mathrm{matter}}[g_{\mu\nu},\psi] \qquad (1)

where: RR — Ricci scalar R=gμνRμνR=g^{\mu\nu}R_{\mu\nu}, a scalar built from the metric and its first and second derivatives; Λ\Lambda — cosmological constant, units of inverse length squared; gg — determinant of gμνg_{\mu\nu}, so −g d4x\sqrt{-g}\,\mathrm{d}^4x is the invariant 4-volume; GG — Newton's constant, with c=1c=1; SmatterS_{\mathrm{matter}} — action of all matter fields ψ\psi coupled to the metric. Reading it: one scalar number per geometry, and demanding it be stationary in gμνg^{\mu\nu} will produce everything below. Varying SS needs the variation of the volume element. Jacobi's formula for the determinant, together with the identity relating δgμν\delta g_{\mu\nu} to δgμν\delta g^{\mu\nu}, gives a compact result. Note the crucial minus sign: it is there because we vary the inverse metric.

δ−g=−12−g gμν δgμν(2)\delta\sqrt{-g} = -\tfrac{1}{2}\sqrt{-g}\,g_{\mu\nu}\,\delta g^{\mu\nu} \qquad (2)

where: δgμν\delta g^{\mu\nu} — variation of the inverse metric, our chosen dynamical field; gμνg_{\mu\nu} — the metric, which supplies the trace. Reading it: a change in the metric rescales the local volume in proportion to its trace against the metric. The variation of the Ricci scalar has two parts. One is the "obvious" piece Rμν δgμνR_{\mu\nu}\,\delta g^{\mu\nu}; the other, gμνδRμνg^{\mu\nu}\delta R_{\mu\nu}, looks dangerous but is in fact a total covariant divergence by the Palatini identity, so it contributes only on the boundary.

δR=Rμν δgμν+∇μvμ,vμ=gρσδΓμρσ−gμσδΓλσλ(3)\delta R = R_{\mu\nu}\,\delta g^{\mu\nu} + \nabla_\mu v^\mu,\qquad v^\mu = g^{\rho\sigma}\delta\Gamma^\mu{}_{\rho\sigma}-g^{\mu\sigma}\delta\Gamma^\lambda{}_{\sigma\lambda} \qquad (3)

where: RμνR_{\mu\nu} — Ricci tensor; δΓλμν\delta\Gamma^\lambda{}_{\mu\nu} — variation of the Christoffel symbols, which is a genuine tensor even though Γ\Gamma is not; vμv^\mu — the total-derivative vector whose divergence carries all the boundary dependence. Reading it: only the RμνR_{\mu\nu} piece survives in the bulk; the rest is a boundary term. The matter action defines the source. There is no need to guess the stress-energy tensor for each kind of matter — it is defined as the response of SmatterS_{\mathrm{matter}} to a change in the metric, and this definition delivers a symmetric tensor automatically.

Tμν≡−2−gδSmatterδgμν=−2 δLmδgμν+gμνLm(4)T_{\mu\nu} \equiv -\frac{2}{\sqrt{-g}}\frac{\delta S_{\mathrm{matter}}}{\delta g^{\mu\nu}} = -2\,\frac{\delta \mathcal{L}_m}{\delta g^{\mu\nu}} + g_{\mu\nu}\mathcal{L}_m \qquad (4)

where: Lm\mathcal{L}_m — matter Lagrangian density (a scalar), with Smatter=∫Lm−g d4xS_{\mathrm{matter}}=\int\mathcal{L}_m\sqrt{-g}\,\mathrm{d}^4x; TμνT_{\mu\nu} — symmetric stress-energy tensor sourcing the geometry. Reading it: differentiate the matter Lagrangian with respect to the metric and you have the source, guaranteed symmetric. Assembling the three pieces and demanding stationarity for arbitrary δgμν\delta g^{\mu\nu} gives the field equations. The cosmological term appears because −2Λ-2\Lambda in the Lagrangian, hit by the volume variation, produces +Λgμν+\Lambda g_{\mu\nu}.

Gμν+Λgμν=8πG Tμν(5)G_{\mu\nu} + \Lambda g_{\mu\nu} = 8\pi G\,T_{\mu\nu} \qquad (5)

where: Gμν=Rμν−12gμνRG_{\mu\nu}=R_{\mu\nu}-\tfrac12 g_{\mu\nu}R — Einstein tensor; 8πG8\pi G — coupling constant fixed by the Newtonian limit, not by the variation. Reading it: geometry on the left, matter on the right, set equal at every event. Finally, the derivation delivers a consistency theorem for free. The Einstein tensor is identically divergence-free (contracted Bianchi identity), so the field equation forces the source to be divergence-free too — energy-momentum is conserved as a consequence, not a postulate.

∇μGμν=0  ⟹  ∇μTμν=0(6)\nabla^\mu G_{\mu\nu} = 0 \;\Longrightarrow\; \nabla^\mu T_{\mu\nu} = 0 \qquad (6)

where: ∇μGμν\nabla^\mu G_{\mu\nu} — divergence of the Einstein tensor, vanishing identically off-shell. Reading it: the two sides of (5) are compatible; the field equations are not over-determined.

Derivation AFrom the Einstein-Hilbert action to the field equations

The goal is to carry out the full variation of the total action (1) with respect to the inverse metric gμνg^{\mu\nu} and read off the Euler-Lagrange equation. We need three inputs already in hand — the volume variation (2), the curvature variation (3), and the definition of the source (4) — and one physical input, the boundary condition that lets us discard the total-derivative term. Assembling them and demanding δS=0\delta S=0 for an arbitrary bulk variation forces the integrand's coefficient to vanish pointwise, which is the Einstein equation. The result is Gμν+Λgμν=8πG TμνG_{\mu\nu}+\Lambda g_{\mu\nu}=8\pi G\,T_{\mu\nu}.

Step 1. Expand the gravitational variation by the product rule: δ ⁣∫(R−2Λ)−g d4x=∫[ δR −g+(R−2Λ) δ−g ] d4x\delta\!\int(R-2\Lambda)\sqrt{-g}\,\mathrm{d}^4x = \int[\,\delta R\,\sqrt{-g} + (R-2\Lambda)\,\delta\sqrt{-g}\,]\,\mathrm{d}^4x. Why: the Lagrangian is a product of the scalar R−2ΛR-2\Lambda and the density −g\sqrt{-g}, and each factor carries its own metric dependence, so both must be varied.

Step 2. Substitute the two variations. Using δR=Rμν δgμν+∇μvμ\delta R = R_{\mu\nu}\,\delta g^{\mu\nu} + \nabla_\mu v^\mu and δ−g=−12−g gμν δgμν\delta\sqrt{-g}=-\tfrac12\sqrt{-g}\,g_{\mu\nu}\,\delta g^{\mu\nu}, the gravitational variation becomes ∫[ Rμν δgμν+∇μvμ−12(R−2Λ)gμν δgμν ]−g d4x\int[\,R_{\mu\nu}\,\delta g^{\mu\nu} + \nabla_\mu v^\mu - \tfrac12(R-2\Lambda)g_{\mu\nu}\,\delta g^{\mu\nu}\,]\sqrt{-g}\,\mathrm{d}^4x. Why: this collects everything into a single integrand multiplying δgμν\delta g^{\mu\nu}, plus the lone total-derivative term that must be dealt with separately.

Step 3. Discard the boundary term. By Stokes' theorem ∫∇μvμ−g d4x=∮∂Mvμnμ∣h∣ d3y\int\nabla_\mu v^\mu\sqrt{-g}\,\mathrm{d}^4x = \oint_{\partial\mathcal{M}} v^\mu n_\mu\sqrt{|h|}\,\mathrm{d}^3y, which vanishes when δgμν\delta g^{\mu\nu} and its first derivatives vanish on ∂M\partial\mathcal{M}. Why: the awkward gμνδRμνg^{\mu\nu}\delta R_{\mu\nu} piece never touches the bulk field equation; its fate is entirely a boundary matter, and cancelling it properly is the job of the Gibbons-Hawking-York term.

Step 4. Collect the gravitational coefficient. The surviving bulk integrand is 116πG(Rμν−12gμνR+Λgμν) δgμν−g\frac{1}{16\pi G}(R_{\mu\nu}-\tfrac12 g_{\mu\nu}R + \Lambda g_{\mu\nu})\,\delta g^{\mu\nu}\sqrt{-g}, where the combination −2Λ⋅(−12gμν)=+Λgμν-2\Lambda\cdot(-\tfrac12 g_{\mu\nu})=+\Lambda g_{\mu\nu} produces the cosmological term. Why: the first two curvature terms are exactly the Einstein tensor GμνG_{\mu\nu}, so the geometry has organized itself into the divergence-free object demanded by consistency.

Step 5. Add the matter variation. By the definition (4), δSmatter=∫δSmatterδgμν δgμν d4x=−12∫Tμν δgμν−g d4x\delta S_{\mathrm{matter}}=\int\frac{\delta S_{\mathrm{matter}}}{\delta g^{\mu\nu}}\,\delta g^{\mu\nu}\,\mathrm{d}^4x = -\tfrac12\int T_{\mu\nu}\,\delta g^{\mu\nu}\sqrt{-g}\,\mathrm{d}^4x. Why: this is precisely why the stress-energy tensor is defined with that factor of −2-2 — so that when it meets the gravitational side, the constants line up into 8πG8\pi G.

Step 6. Demand stationarity. Setting the total coefficient of δgμν\delta g^{\mu\nu} to zero gives 116πG(Gμν+Λgμν)−12Tμν=0\frac{1}{16\pi G}(G_{\mu\nu}+\Lambda g_{\mu\nu}) - \tfrac12 T_{\mu\nu}=0; multiplying through by 16πG16\pi G yields Gμν+Λgμν=8πG TμνG_{\mu\nu}+\Lambda g_{\mu\nu}=8\pi G\,T_{\mu\nu}. Why: because δgμν\delta g^{\mu\nu} is arbitrary in the bulk, the fundamental lemma of the calculus of variations lets us strip the integral and the variation, leaving a pointwise tensor equation. *Verified: reproduces Wald (1984) Appendix E and Carroll §4.3. The factor 8πG8\pi G is fixed independently by the Newtonian limit, as in the second figure.*

Go deeper · Derivation B · 1 minThe Palatini identity and why the extra term is a boundary term
Derivation BThe Palatini identity and why the extra term is a boundary term

The goal here is to justify the single most surprising claim of the main derivation: that gμνδRμνg^{\mu\nu}\delta R_{\mu\nu}, which looks like a genuine contribution to the field equations, is really a total covariant divergence and therefore only a boundary term. Establishing this rests on the fact that although the Christoffel symbols are not tensors, their variation is, so covariant derivatives of δΓ\delta\Gamma make sense. We compute δRμν\delta R_{\mu\nu} in terms of δΓ\delta\Gamma, contract with the metric, and use metric compatibility to pull the metric inside the derivative. The result is gμνδRμν=∇μvμg^{\mu\nu}\delta R_{\mu\nu}=\nabla_\mu v^\mu.

Step 1. Recognize that δΓλμν\delta\Gamma^\lambda{}_{\mu\nu} is a tensor. The difference of two connections transforms homogeneously, and δΓ\delta\Gamma is an infinitesimal such difference. Why: this is what licenses writing ∇λ(δΓλμν)\nabla_\lambda(\delta\Gamma^\lambda{}_{\mu\nu}) at all — covariant derivatives act on tensors, and δΓ\delta\Gamma qualifies even though Γ\Gamma does not.

Step 2. Write the Palatini identity δRμν=∇λ(δΓλμν)−∇ν(δΓλμλ)\delta R_{\mu\nu}=\nabla_\lambda(\delta\Gamma^\lambda{}_{\mu\nu})-\nabla_\nu(\delta\Gamma^\lambda{}_{\mu\lambda}). This follows by varying the Ricci tensor's definition Rμν=∂λΓλμν−∂νΓλμλ+ΓΓ−ΓΓR_{\mu\nu}=\partial_\lambda\Gamma^\lambda{}_{\mu\nu}-\partial_\nu\Gamma^\lambda{}_{\mu\lambda}+\Gamma\Gamma-\Gamma\Gamma and reorganizing the pieces into covariant derivatives. Why: the non-covariant ∂Γ\partial\Gamma and quadratic ΓΓ\Gamma\Gamma terms conspire so that the variation is manifestly a difference of two covariant divergences.

Step 3. Contract with the metric and use metric compatibility ∇λgμν=0\nabla_\lambda g^{\mu\nu}=0 to move gμνg^{\mu\nu} through the covariant derivatives: gμνδRμν=∇λ(gμνδΓλμν)−∇ν(gμνδΓλμλ)g^{\mu\nu}\delta R_{\mu\nu}=\nabla_\lambda(g^{\mu\nu}\delta\Gamma^\lambda{}_{\mu\nu})-\nabla_\nu(g^{\mu\nu}\delta\Gamma^\lambda{}_{\mu\lambda}). Why: metric compatibility is exactly the property of the Levi-Civita connection that lets the metric slide inside ∇\nabla, which is what turns the contraction into a clean divergence.

Step 4. Rename dummy indices to read off gμνδRμν=∇μvμg^{\mu\nu}\delta R_{\mu\nu}=\nabla_\mu v^\mu with vμ=gρσδΓμρσ−gμσδΓλσλv^\mu=g^{\rho\sigma}\delta\Gamma^\mu{}_{\rho\sigma}-g^{\mu\sigma}\delta\Gamma^\lambda{}_{\sigma\lambda}. Integrated against −g\sqrt{-g}, this is a boundary integral by the divergence theorem. Why: because it is a pure divergence it cannot contribute to the local field equation — it only tells you what must be fixed, or subtracted, on ∂M\partial\mathcal{M}, which is the origin of the Gibbons-Hawking-York term. *Verified: matches the Palatini computation in Wald Appendix E and Carroll §4.3; the vector vμv^\mu is the one whose flux the GHY term is designed to cancel.*

Go deeper · Derivation C · 1 minConservation of stress-energy from diffeomorphism invariance
Derivation CConservation of stress-energy from diffeomorphism invariance

The goal is to show that ∇μTμν=0\nabla^\mu T_{\mu\nu}=0 is not an extra assumption but a theorem — Noether's second theorem applied to the gauge symmetry of gravity. The input is that SmatterS_{\mathrm{matter}} is a scalar, hence invariant under an infinitesimal coordinate change (a diffeomorphism) generated by any vector field ξμ\xi^\mu. Under such a flow the metric changes by its Lie derivative while, on-shell, the matter fields contribute nothing. Equating the induced change of the action to zero for arbitrary ξμ\xi^\mu forces the divergence of the source to vanish, in exact parallel with the Bianchi identity for the geometry.

Step 1. Vary the matter action under a diffeomorphism. With the matter fields on-shell, only the metric variation survives: δSmatter=∫δSmatterδgμν δgμν d4x=−12∫Tμν δgμν−g d4x\delta S_{\mathrm{matter}}=\int\frac{\delta S_{\mathrm{matter}}}{\delta g^{\mu\nu}}\,\delta g^{\mu\nu}\,\mathrm{d}^4x=-\tfrac12\int T_{\mu\nu}\,\delta g^{\mu\nu}\sqrt{-g}\,\mathrm{d}^4x. Why: the Euler-Lagrange equations for ψ\psi kill the δψ\delta\psi terms, so the change of the action is entirely carried by how the metric responds to the coordinate flow.

Step 2. Insert the metric's response. Under xμ→xμ+ξμx^\mu\to x^\mu+\xi^\mu the inverse metric changes by δgμν=−Lξgμν=∇μξν+∇νξμ\delta g^{\mu\nu}=-\mathcal{L}_\xi g^{\mu\nu}=\nabla^\mu\xi^\nu+\nabla^\nu\xi^\mu. Why: an active diffeomorphism drags the metric along the flow, and the Lie derivative of the inverse metric is precisely this symmetrized covariant gradient of the generator.

Step 3. Use the symmetry of TμνT_{\mu\nu} to combine the two terms: δSmatter=−∫Tμν∇μξν−g d4x\delta S_{\mathrm{matter}}=-\int T_{\mu\nu}\nabla^\mu\xi^\nu\sqrt{-g}\,\mathrm{d}^4x. Why: because TμνT_{\mu\nu} is symmetric, contracting it against the symmetric combination ∇μξν+∇νξμ\nabla^\mu\xi^\nu+\nabla^\nu\xi^\mu just doubles a single term and cancels the factor of one-half.

Step 4. Integrate by parts and drop the boundary term for compactly supported ξν\xi^\nu: δSmatter=∫(∇μTμν) ξν−g d4x\delta S_{\mathrm{matter}}=\int(\nabla^\mu T_{\mu\nu})\,\xi^\nu\sqrt{-g}\,\mathrm{d}^4x. Why: moving the derivative off ξ\xi and onto TT exposes exactly the divergence ∇μTμν\nabla^\mu T_{\mu\nu} as the coefficient of an arbitrary vector field.

Step 5. Invoke invariance. Since SmatterS_{\mathrm{matter}} is a scalar, δSmatter=0\delta S_{\mathrm{matter}}=0 for every ξν\xi^\nu, and arbitrariness forces ∇μTμν=0\nabla^\mu T_{\mu\nu}=0. Why: this is Noether's second theorem — a local (gauge) symmetry yields an identity, not just a global charge — and it matches ∇μGμν=0\nabla^\mu G_{\mu\nu}=0 so the field equations are self-consistent. *Verified: equivalent to MTW §21.3 and the Noether-theorem treatment in Wald §E.1.*

Limiting cases

Each row specializes or truncates the action and reads off what survives.

CaseResultMeaning
VacuumRμν=0R_{\mu\nu}=0Set Smatter=0S_{\mathrm{matter}}=0 and Λ=0\Lambda=0. Tracing Gμν=0G_{\mu\nu}=0 in four dimensions gives R=0R=0, hence Rμν=0R_{\mu\nu}=0 — Ricci-flat, as in the Schwarzschild geometry.
With cosmological constantGμν+Λgμν=0G_{\mu\nu}+\Lambda g_{\mu\nu}=0The −2Λ-2\Lambda term gives vacuum de Sitter (Λ>0\Lambda>0) or anti-de Sitter (Λ<0\Lambda<0); Λ\Lambda acts as a vacuum energy with Tμνvac=−Λ8πGgμνT^{\mathrm{vac}}_{\mu\nu}=-\frac{\Lambda}{8\pi G}g_{\mu\nu}.
Weak field, Newtonian∇2Φ=4πGρ\nabla^2\Phi=4\pi G\rhoLinearizing g00=−(1+2Φ)g_{00}=-(1+2\Phi) in the slow-motion limit reduces the time-time equation to Poisson's equation, which is what fixes the coupling 8πG8\pi G.
Palatini (first-order)Γλμν=12gλρ(∂μgνρ+∂νgμρ−∂ρgμν)\Gamma^\lambda{}_{\mu\nu}=\tfrac12 g^{\lambda\rho}(\partial_\mu g_{\nu\rho}+\partial_\nu g_{\mu\rho}-\partial_\rho g_{\mu\nu})Varying metric and connection independently forces Γ\Gamma to be Levi-Civita and returns the same Einstein equations — for pure GR the two formalisms agree.
f(R)f(R) gravityf′Rμν−12fgμν+(gμν□−∇μ∇ν)f′=8πGTμνf'R_{\mu\nu}-\tfrac12 f g_{\mu\nu}+(g_{\mu\nu}\Box-\nabla_\mu\nabla_\nu)f'=8\pi G T_{\mu\nu}Replacing RR by f(R)f(R) gives fourth-order equations with an extra scalar mode; Einstein gravity is the special case f(R)=R−2Λf(R)=R-2\Lambda.

Worked examples

1 · The cosmological constant as vacuum energy (fully worked)

A constant term in any matter Lagrangian gravitates. Show that adding a uniform energy density ρvac\rho_{\mathrm{vac}} is variationally identical to a cosmological constant, then use the observed value Λ≈1.1×10−52 m−2\Lambda\approx1.1\times10^{-52}\ \mathrm{m^{-2}} to compute the vacuum energy density it represents and compare with the naive quantum-field-theory estimate.

Step 1. Start from the identification. Moving the Λ\Lambda term to the right-hand side of the field equation, Gμν=8πG Tμν−Λgμν=8πG(Tμν+Tμνvac)G_{\mu\nu}=8\pi G\,T_{\mu\nu}-\Lambda g_{\mu\nu}=8\pi G(T_{\mu\nu}+T^{\mathrm{vac}}_{\mu\nu}) with Tμνvac=−Λ8πGgμνT^{\mathrm{vac}}_{\mu\nu}=-\frac{\Lambda}{8\pi G}g_{\mu\nu}. A perfect-fluid vacuum has Tμνvac=−ρvac gμνT^{\mathrm{vac}}_{\mu\nu}=-\rho_{\mathrm{vac}}\,g_{\mu\nu} (equation of state p=−ρp=-\rho), so Λ=8πG ρvac\Lambda=8\pi G\,\rho_{\mathrm{vac}} in geometric units. The variational lesson is that a constant added to Lm\mathcal{L}_m multiplies −g\sqrt{-g} and therefore does source gravity — you cannot subtract off the zero of energy.

Step 2. Restore SI units and compute the energy density. The vacuum energy density is εΛ=Λc48πG\varepsilon_\Lambda=\dfrac{\Lambda c^4}{8\pi G}. Plugging in Λ=1.1×10−52 m−2\Lambda=1.1\times10^{-52}\ \mathrm{m^{-2}}, c4=8.08×1033 m4 s−4c^4=8.08\times10^{33}\ \mathrm{m^4\,s^{-4}}, and 8πG=1.68×10−98\pi G=1.68\times10^{-9},

εΛ=(1.1×10−52)(8.08×1033)1.68×10−9≈5.3×10−10 J m−3.\varepsilon_\Lambda=\frac{(1.1\times10^{-52})(8.08\times10^{33})}{1.68\times10^{-9}}\approx\mathbf{5.3\times10^{-10}\ \mathrm{J\,m^{-3}}}.

Equivalently a mass density ρΛ=εΛ/c2≈5.9×10−27 kg m−3\rho_\Lambda=\varepsilon_\Lambda/c^2\approx\mathbf{5.9\times10^{-27}\ \mathrm{kg\,m^{-3}}} — a few hydrogen atoms per cubic metre, and about 70% of the cosmic critical density.

Step 3. Compare with the quantum estimate. Summing zero-point energies up to the Planck scale gives a vacuum density of order εP∼c7/(ℏG2)≈4.6×10113 J m−3\varepsilon_{\mathrm{P}}\sim c^7/(\hbar G^2)\approx4.6\times10^{113}\ \mathrm{J\,m^{-3}}. The ratio is

εPεΛ≈4.6×101135.3×10−10≈10123.\frac{\varepsilon_{\mathrm{P}}}{\varepsilon_\Lambda}\approx\frac{4.6\times10^{113}}{5.3\times10^{-10}}\approx\mathbf{10^{123}}.

This 120-odd order-of-magnitude mismatch is the cosmological constant problem — the worst quantitative prediction in physics. The variational derivation is what makes the problem inescapable: because every constant in Lm\mathcal{L}_m couples to −g\sqrt{-g}, quantum vacuum energy must gravitate exactly like Λ\Lambda, and no field redefinition can hide it. Λ=8πGρvac\Lambda=8\pi G\rho_{\mathrm{vac}}, εΛ≈5.3×10−10 J m−3\varepsilon_\Lambda\approx5.3\times10^{-10}\ \mathrm{J\,m^{-3}}, discrepancy ∼10123\sim10^{123}.

2 · Reading off the stress-energy of a scalar field

Apply the variational recipe (4) to a single real scalar field with Lagrangian Lm=−12gμν∂μϕ ∂νϕ−V(ϕ)\mathcal{L}_m=-\tfrac12 g^{\mu\nu}\partial_\mu\phi\,\partial_\nu\phi-V(\phi), and check that the recipe reproduces the familiar energy density.

Step 1. Differentiate the Lagrangian with respect to the inverse metric. Only the kinetic term depends on gμνg^{\mu\nu}, and δLmδgμν=−12∂μϕ ∂νϕ\dfrac{\delta\mathcal{L}_m}{\delta g^{\mu\nu}}=-\tfrac12\partial_\mu\phi\,\partial_\nu\phi. The potential V(ϕ)V(\phi) does not contain the metric, so it contributes nothing at this step.

Step 2. Assemble the tensor using (4), Tμν=−2δLmδgμν+gμνLmT_{\mu\nu}=-2\dfrac{\delta\mathcal{L}_m}{\delta g^{\mu\nu}}+g_{\mu\nu}\mathcal{L}_m:

Tμν=∂μϕ ∂νϕ−gμν ⁣(12gρσ∂ρϕ ∂σϕ+V).T_{\mu\nu}=\partial_\mu\phi\,\partial_\nu\phi-g_{\mu\nu}\!\left(\tfrac12 g^{\rho\sigma}\partial_\rho\phi\,\partial_\sigma\phi+V\right).

It is manifestly symmetric, with no need for the ad-hoc "symmetrization" that the canonical Noether tensor requires — a structural bonus of the Hilbert definition.

Step 3. Check the energy density. In a local inertial frame with signature (−+++)(-{+}{+}{+}), the time-time component is

T00=(∂0ϕ)2−g00 ⁣(12gρσ∂ρϕ ∂σϕ+V)=12ϕ˙2+12(∇ϕ)2+V,T_{00}=(\partial_0\phi)^2-g_{00}\!\left(\tfrac12 g^{\rho\sigma}\partial_\rho\phi\,\partial_\sigma\phi+V\right)=\tfrac12\dot\phi^2+\tfrac12(\nabla\phi)^2+V,

the expected kinetic-plus-gradient-plus-potential energy density, positive for a normal field. The recipe hands back TμνT_{\mu\nu} with T00=12ϕ˙2+12(∇ϕ)2+VT_{00}=\tfrac12\dot\phi^2+\tfrac12(\nabla\phi)^2+V. For a spatially uniform, slowly rolling field the kinetic and gradient terms drop out and Tμν→−VgμνT_{\mu\nu}\to-V g_{\mu\nu} — a scalar field frozen at the bottom of its potential acts exactly like a cosmological constant with ρvac=V\rho_{\mathrm{vac}}=V, the mechanism behind inflation and quintessence, and the direct link back to Example 1.

Physics of the portrait

The variational derivation has a specific author. While Einstein was assembling the field equations from physical and geometric reasoning through the autumn of 1915, the mathematician David Hilbert, working in Göttingen and in close correspondence with him, arrived at the same equations from a single action principle — the first person to do so, and the reason the gravitational action bears his name.

Origins · 2 minDavid Hilbert and how this was discovered
DH
David Hilbert
1862–1943 · the action principle for gravitation

David Hilbert was the leading mathematician of his generation, presiding over Göttingen as it became the world's centre of mathematics and mathematical physics. In 1915 he was deep in an ambitious programme to axiomatize physics, and Einstein's still-unfinished general relativity was his target. Einstein visited Göttingen that June to lecture on his struggling theory, and through the autumn the two exchanged letters as both closed in on the final equations. Hilbert's approach was characteristically structural: rather than reason physically about sources and conservation, he posited that the laws of gravitation and matter should both follow from a single variational principle, an "world function" whose stationary points are the physical fields. Taking the gravitational Lagrangian to be the Ricci scalar RR — the natural scalar invariant of the metric — he derived the field equations by variation, and submitted his paper "Die Grundlagen der Physik" on 20 November 1915, five days before Einstein presented Gμν=8πG TμνG_{\mu\nu}=8\pi G\,T_{\mu\nu} to the Prussian Academy on 25 November. The near-simultaneity provoked a lasting priority debate, but the historical record is generous to both: Hilbert consistently credited the physical theory to Einstein and never claimed the field equations as his own, and modern scholarship (Corry, Renn, and Stachel, 1997) shows Hilbert's printed proofs were revised into their final explicit form only after Einstein's paper. What is not in dispute is the method. Hilbert gave general relativity the form it still wears in every textbook — a theory derived from an action — and with it the machinery that connects the symmetries of that action to conservation laws, a connection his Göttingen colleague Emmy Noether would make into a theorem three years later.

History
1900
— Hilbert poses his 23 problems, the sixth calling for the axiomatization of physics
1915
— Hilbert derives the field equations from the action ∫R√−g and submits "Die Grundlagen der Physik"
1915
— Einstein presents the field equations to the Prussian Academy in November
1918
— Noether proves her two theorems linking symmetries of the action to conservation laws
1972
— York introduces the boundary term needed for a well-posed gravitational action

Going further

Texts. Misner, Thorne & Wheeler, Gravitation, §21.2 (Hilbert's action principle) and §21.3 · Wald, General Relativity, Appendix E and §E.1 (variational derivation and the GHY term) · Carroll, Spacetime and Geometry, §4.3 (the Einstein equations from an action) · Hartle, Gravity, Ch. 21 · Schutz, A First Course in General Relativity, Ch. 8 · Hilbert, Die Grundlagen der Physik, Nachr. Ges. Wiss. Göttingen (1915).

Provenance. Equations and conventions follow Wald (1984) Appendix E, Carroll (2004) §4.3, and MTW §21.2-21.3, with signature (−+++)(-{+}{+}{+}) and c=1c=1. A verifier should recompute: (1) δ−g=−12−g gμνδgμν\delta\sqrt{-g}=-\tfrac12\sqrt{-g}\,g_{\mu\nu}\delta g^{\mu\nu} from Jacobi's formula; (2) the Palatini identity δRμν=∇λδΓλμν−∇νδΓλμλ\delta R_{\mu\nu}=\nabla_\lambda\delta\Gamma^\lambda{}_{\mu\nu}-\nabla_\nu\delta\Gamma^\lambda{}_{\mu\lambda} and gμνδRμν=∇μvμg^{\mu\nu}\delta R_{\mu\nu}=\nabla_\mu v^\mu; (3) that collecting terms gives Gμν+Λgμν=8πGTμνG_{\mu\nu}+\Lambda g_{\mu\nu}=8\pi G T_{\mu\nu}; (4) the diffeomorphism argument giving ∇μTμν=0\nabla^\mu T_{\mu\nu}=0. The worked numbers use Λ=1.1×10−52 m−2\Lambda=1.1\times10^{-52}\ \mathrm{m^{-2}}, G=6.674×10−11G=6.674\times10^{-11}, c=2.998×108c=2.998\times10^8, giving εΛ≈5.3×10−10 J m−3\varepsilon_\Lambda\approx5.3\times10^{-10}\ \mathrm{J\,m^{-3}}, κ=8πG/c4≈2.08×10−43 N−1\kappa=8\pi G/c^4\approx2.08\times10^{-43}\ \mathrm{N^{-1}}, and a QFT-to-observation ratio ∼10123\sim10^{123}; the scalar-field TμνT_{\mu\nu} matches the standard result. The factor 8πG8\pi G is the Newtonian-limit value (cross-check Carroll §4.2).

Prerequisites. The Einstein-Hilbert Action · The Einstein Tensor · The Stress-Energy Tensor · The Variational Stress-Energy Tensor. Leads to. The Einstein Field Equations · The Gibbons-Hawking-York Boundary Term · Local Conservation of Energy-Momentum · The Cosmological Constant.

Ask the tutor: Ask me to carry out the δ−g\delta\sqrt{-g} or Palatini step in full index detail, to derive the f(R)f(R) field equations by re-running the variation, or to show exactly how the Gibbons-Hawking-York term cancels the leftover boundary flux.

Why vary the inverse metric g^μν rather than the metric g_μν?

It is purely a matter of convenience, not physics — the two give identical field equations. Varying gμνg^{\mu\nu} makes the algebra slightly cleaner because R=gμνRμνR=g^{\mu\nu}R_{\mu\nu} wears its gμνg^{\mu\nu} explicitly, so δR\delta R produces RμνδgμνR_{\mu\nu}\delta g^{\mu\nu} directly. The price is a scattering of minus signs: δ−g\delta\sqrt{-g} picks up a minus, and the stress-energy tensor is defined with Tμν=−2−gδSm/δgμνT_{\mu\nu}=-\frac{2}{\sqrt{-g}}\delta S_m/\delta g^{\mu\nu}. Had you varied gμνg_{\mu\nu} instead, those signs would flip and Tμν=+2−gδSm/δgμνT^{\mu\nu}=+\frac{2}{\sqrt{-g}}\delta S_m/\delta g_{\mu\nu}. The one unforgivable error is to mix conventions inside a single calculation, which reliably produces an Einstein equation with the wrong sign.

Does the variational derivation prove that 8πG is the right coupling?

No, and this is a subtle and important point. The variation only fixes the structure of the equation — that the geometric tensor Gμν+ΛgμνG_{\mu\nu}+\Lambda g_{\mu\nu} is proportional to TμνT_{\mu\nu}. The overall constant is set by how you normalize the Einstein-Hilbert action, and there is nothing in the variation itself that says the normalization must be 1/16πG1/16\pi G. The physical input comes from outside: you demand that the weak-field, slow-motion limit reproduce Newton's law of gravity, ∇2Φ=4πGρ\nabla^2\Phi=4\pi G\rho, and that requirement forces the coefficient to be exactly 8πG8\pi G (with c=1c=1). The second figure traces that reduction. So the action fixes the form; the Newtonian limit fixes the number.

What is the Gibbons-Hawking-York term and why does this derivation flag it?

The standard derivation discards a boundary term, ∮∂Mvμnμ∣h∣ d3y\oint_{\partial\mathcal{M}}v^\mu n_\mu\sqrt{|h|}\,\mathrm{d}^3y, on the grounds that both δgμν\delta g^{\mu\nu} and its first derivatives vanish on the boundary. But that is two conditions, and in a well-posed variational problem you should only be allowed to fix the field (δg=0\delta g=0), not its derivative. The Einstein-Hilbert action alone therefore does not give a genuinely stationary point for fixed boundary metric — the derivative variation leaves a residue. The Gibbons-Hawking-York term SGHY=18πG∮K∣h∣ d3yS_{\mathrm{GHY}}=\frac{1}{8\pi G}\oint K\sqrt{|h|}\,\mathrm{d}^3y, built from the extrinsic curvature KK of the boundary, is precisely engineered to cancel that residue. It is indispensable in Hamiltonian formulations and in computing black-hole entropy from the Euclidean action.

Why is the Ricci scalar the right choice for the gravitational Lagrangian?

Because it is the simplest scalar that does the job. The action must be a coordinate-invariant scalar, so its Lagrangian must be built from curvature invariants. The lowest one you can form from the metric that is not a constant is the Ricci scalar RR, which involves only up to second derivatives of the metric. Any richer choice — R2R^2, RμνRμνR_{\mu\nu}R^{\mu\nu}, or a general f(R)f(R) — introduces higher derivatives, which by Ostrogradsky's theorem generically bring extra, often unstable, degrees of freedom. Choosing RR (plus the constant Λ\Lambda) is the unique way to get second-order field equations for the metric alone. This is why Einstein gravity is the minimal, most economical curvature theory, and why deviations from it are so tightly constrained by experiment.

Is the Palatini formalism a different theory of gravity?

For pure general relativity, no — it is the same theory reached by a different route. In the Palatini (first-order) approach you treat the metric gμνg_{\mu\nu} and the connection Γλμν\Gamma^\lambda{}_{\mu\nu} as independent variables and vary both. Varying the connection yields an algebraic equation whose solution is precisely the Levi-Civita connection, forcing Γ\Gamma to be built from the metric after all. Substituting that back, the metric variation returns the standard Einstein equations. So for the Einstein-Hilbert action the metric and Palatini formalisms are equivalent. They part ways only for more general Lagrangians such as f(R)f(R), where Palatini and metric variations give genuinely different field equations — a useful diagnostic when studying modified gravity.

How does this connect to the article that simply postulates the field equations?

It is the same equation reached from opposite directions. The sibling article on the Einstein field equations motivates Gμν+Λgμν=8πGTμνG_{\mu\nu}+\Lambda g_{\mu\nu}=8\pi G T_{\mu\nu} physically — as the unique divergence-free, second-order tensor equation with the right Newtonian limit — and takes it as a postulate. This article shows that the very same equation drops out of a one-line action by a mechanical variation, with the source, its symmetry, and its conservation all supplied automatically. The variational route is more economical and more powerful for generalization, but the postulational route makes the physical content vivid. Mature understanding holds both pictures at once: the field equation is simultaneously the simplest consistent tensor law and the Euler-Lagrange equation of the simplest curvature action.

Before this

Where this leads