Physics[LagrangeEquations] - compute the Lagrange equations or the EnergyMomentum tensor corresponding to a given Lagrangian
|
Calling Sequence
|
|
LagrangeEquations(L, F)
|
|
Parameters
|
|
L
|
-
|
any algebraic expressions representing a Lagrangian; there are no restrictions to the differentiation order of the derivatives of the coordinates or fields
|
F
|
-
|
a name indicating the coordinate, without the coordinate's dependency, or a set or list of them in the case of a system with many degrees of freedom. NOTE : F can also be EnergyMomentum, with or without two spacetimeindices. If so, the output is the conserved energy-momentum tensor of the physical model represented by L
|
|
|
|
|
Description
|
|
•
|
LagrangeEquations receives an expression representing a Lagrangian and returns a sequence of Lagrange equations, of the form , with as many equations as coordinates are indicated in the list or set F. In the case of only one degree of freedom (one coordinate), F can also be the coordinate itself, and the output consists of a single Lagrange equation. While the coordinates in are functions, the coordinates in F shall be passed as names, without their dependency. For example, in the case of one single parameter and a coordinate , pass . It is expected that these names appear in the Lagrangian consistently, always with the same functionality.
|
•
|
In addition to handling Lagrangians with standard functions and their derivatives, LagrangeEquations handles Lagrangians involving tensors and vectors of the Physics package, as well as derivatives using vectorial and tensorial differential operators (see Nabla, d_ and D_).
|
•
|
LagrangeEquations operates by constructing the action as the integral of over a closed region of the space spanned by the parameters ,
|
|
and equating to 0 its functional derivative with respect to each
|
|
It is assumed that on the boundary of . The functional derivative is computed using Fundiff, so LagrangeEquations automatically handles 1st and higher derivatives of the coordinates in the Lagrangian.
|
•
|
The output of LagrangeEquations in the classical case where the Lagrangian depends on 1st order derivatives of and there is only one parameter is thus the same as
|
|
where represents the derivative of with respect to the velocity . Note that in more general cases the number of parameters can be many. For example, in electrodynamics, the "coordinate" is a tensor field , representing four coordinates, one for each of the values of the index , and there are four parameters .
|
•
|
In a realistic model, the action integral is invariant under coordinate transformations. For that, must be a scalar, and when there is more than one parameter, a scalar density. This condition on is particularly relevant in general relativity, where the "coordinate" of the model is the metric field , the space and time coordinates are the parameters and the spacetime is curved. Hence, has the factor involving the determinant of the metric , represented in Maple using the inert metric command %g_[determinant]. Likewise, for any model, additional requirements concerning the invariance properties of the coordinates or fields involved restrict the classes of admissible Lagrangians. The LagrangeEquations command does not check these invariance conditions and the equations returned assume all those conditions are satisfied.
|
•
|
In the case of general relativity, as discussed in Chapter 8 of ref.[3], the conditions on mentioned in the previous paragraph restrict the dependence of the Lagrangian to derivatives of the metric of order not greater than two. When depends only on 1st order derivatives of the metric (this can sometimes be achieved by adding a total derivative to a Lagrangian originally depending on 2nd order derivatives, see the Examples section), constructing the action integral and taking the functional derivative is equivalent to using the standard formula
|
|
When depends on 2nd order derivatives of the metric, the equivalent formula would be
|
|
However, this formula does not discard total derivatives which would require additional assumptions to be eliminated, namely that on the corresponding boundary integrals of the action integral the variation of the metric vanishes. If that assumption is made, this formula can be rewritten (see ref[3] Chapter 8) in terms of the Riemann tensor and covariant derivatives as follows
|
|
As is standard, the LagrangeEquations command makes that assumption, and in the case of general relativity, for computationally efficiency, and taking into account that the Lagrangian cannot depend on derivatives of the metric of order higher than 2, the above are the formulas used instead of constructing the action integral and functionally differentiating.
|
•
|
As shown at the end of the Examples section, the Einstein equations can as well be derived in steps, constructing the action integral and equating to zero its functional derivative with respect to the metric . In doing so, total derivatives are automatically discarded by Fundiff, and the compact form in terms of the Ricci tensor is obtained after a few further tensor substitutions.
|
•
|
In both flat and curved spacetimes, and for Lagrangians representing any physical model (scalar field, electromagnetic field, etc.), the energy-momentum tensor , also called stress-energy tensor, can be computed taking the functional derivative of the action integral according to
|
|
This energy-momentum tensor, represented in Maple by the EnergyMomentum command, can be computed by calling LagrangeEquations with the keyword EnergyMomentum or in indexed form EnergyMomentum[a, b] where a and b are expected to be spacetime indices. The formula above assumes the signature to have the timelike component positive, so either ---+ (default Physics signature) or +---. If the signature has a negative timelike component as in +++- or -+++, the right-hand side of this formula above is multiplied by -1. To use the output of LagrangeEquations as the definition of the EnergyMomentum tensor, you can use the Define command - see the Examples section.
|
|
|
Examples
|
|
>
|
Setup(mathematicalnotation = true, coordinates = cartesian);
|
| |
| |
| (1) |
LagrangeEquations can be used in general in the context of variational principles; below are examples of its use in typical areas of Physics.
|
Classical Mechanics
|
|
The Lagrangian of a one-dimensional oscillator - small oscillations
>
|
L := 1/2*diff(x(t), t)^2 - 1/2*k*x(t)^2;
|
The corresponding Lagrange equation gives Newton's second law, a 2nd order linear ODE for
>
|
LagrangeEquations(L, x);
|
The Lagrangian of a pendulum of mass and length where the suspension point moves uniformly over a vertical circumference centered at the origin, with a constant frequency
>
|
CompactDisplay(phi(t));
|
| (4) |
>
|
L := 1/2*m*(-(2*diff(phi(t), t))*a*l*omega*sin(omega*t - phi(t)) + diff(phi(t), t)^2*l^2 + (2*cos(phi(t)))*g*l);
|
| (5) |
The Lagrange equations
>
|
LagrangeEquations(L, phi);
|
| (6) |
|
|
Relativistic Mechanics
|
|
In relativistic mechanics the Lagrangian of a free particle is proportional to the interval . Dividing by , where is the proper time, the Lagrangian can be expressed in terms of the 4-velocity
>
|
L__rm := -m * diff(X[mu](tau), tau) * diff(X[~mu](tau), tau);
|
The corresponding Lagrange equation reflects the absence of acceleration
>
|
LagrangeEquations(L__rm, X[~mu]);
|
In steps, the action is
>
|
S__rm := Intc(L__rm, tau);
|
| (9) |
Equating to 0 its functional derivative with respect to the SpaceTimeVector,
>
|
Fundiff(S__rm, X[mu](sigma)) = 0;
|
| (10) |
This equation can also be computed directly from geometrical considerations as the geodesic for the current (Minkowski) metric
>
|
Geodesics(tensornotation);
|
|
|
Electrodynamics
|
|
Maxwell equations can be derived as the Lagrange equations for the corresponding Lagrangian. For this purpose, define the 4D electromagnetic potential and current and , and it is useful to define them directly as functions of the coordinates by indicating the functionality on the right-hand side of the defining equations:
>
|
Define(A[mu] = A[mu](X), J[mu] = J[mu](X));
|
| |
| (13) |
This form of definition tells the system that both and are functions of so that you don't need to specify the dependency. Define the electromagnetic field tensor in terms of derivatives of
>
|
F[mu, nu] = d_[mu](A[nu]) - d_[nu](A[mu]);
|
The Lagrangian (see ref.1, section 28):
>
|
L__EM := - F[mu, nu]^2/(16*Pi) - A[mu]*J[mu];
|
| (15) |
The two terms above have the same sign, the one of the timelike component of the signature in use (+++-).
The corresponding Lagrange equations
>
|
LagrangeEquations(L__EM, A);
|
| (16) |
These equations can be rewritten in the usual form, in terms of the 4-divergence of the electromagnetic field tensor :
| (18) |
Isolate the second derivative of from the output (10) of LagrangeEquations and substitute into this expression (12) for the 4-divergence of
>
|
isolate((16), d_[mu](d_[~alpha](A[~mu])));
|
| (19) |
>
|
Substitute((19), (18));
|
The energy-momentum tensor can be computed as the Lagrange equations taking the metric as the coordinate, not equating to 0 the result, but multiplying by . For that purpose, pass EnergyMomentum, with or without spacetime indices as an extra argument. Note however that the sector of the Lagrangian to be passed when computing the energy-momentum tensor may depend on physical considerations. For example, in electrodynamics, the action for the whole system has three terms, one for the free particles, another for their interaction with the electromagnetic field (2nd term in , assuming and don't depend on the positions or velocities of the particles even if they are charged) and the one that determines the electromagnetic field itself (1st term in ).
The energy-momentum tensor is then computed variating the action as a function of the coordinates of the particles but without variating or the trajectories of the particles which satisfy the equations of motion. Hence only the part of the Lagrangian that involves the electromagnetic tensor field is considered for computing (see ref.[1], sections 28 and 32)
>
|
L__F := select(has, L__EM, F);
|
| (21) |
>
|
LagrangeEquations(L__F, EnergyMomentum[mu, nu]);
|
| (22) |
To compute using the above as the definition for , you can use the Define command
| |
| (23) |
After that, the system will know about the symmetry properties and components of
>
|
EnergyMomentum[definition];
|
| (24) |
|
|
Quantum Mechanics
|
|
Schrodinger's equation, can also be derived from a Lagrangian, expressed in terms of a complex field and an external potential . To use vectorial operators like the Gradient and Laplacian load the Physics:-Vectors package
| (25) |
>
|
interface(imaginaryunit = i);
|
Set the real objects of the problem
>
|
CompactDisplay((psi, V)(X));
|
| |
| (27) |
>
|
Setup(realobjects = {h, m, V(X)});
|
| (28) |
The Lagrangian
>
|
L := 1/(2*m) * h^2 * Norm(%Gradient(psi(X)))^2 + 1/2*i*h*(diff(conjugate(psi(X)), t) * psi(X) - diff(psi(X), t) * conjugate(psi(X))) + V(X)*abs(psi(X))^2;
|
| (29) |
Taking as the coordinate,
>
|
LagrangeEquations(L, psi);
|
| (30) |
Make the Laplacian explicit
>
|
(Laplacian = %Laplacian)(psi(X));
|
>
|
simplify((30), {(31)});
|
| (32) |
Schrodinger's equation as usually presented in textbooks, with the time derivative isolated
>
|
i * h * isolate((32), diff(psi(X), t));
|
| (33) |
The Lagrangian of a quantum system including a term representing the atom-atom interaction between identical particles results in Gross-Pitaevskii equation
>
|
Setup(realobjects = G);
|
| (34) |
>
|
L__GP := L + G*abs(psi(X))^4/2;
|
| (35) |
The Gross-Pitaevskii equation
>
|
LagrangeEquations(L__GP, psi);
|
| (36) |
As for Schrodinger's equation, make the Laplacian explicit
>
|
simplify((36), {(31)});
|
| (37) |
The standard form of the Gross-Pitaevskii equation with the time derivative of isolated
>
|
i*h*isolate((37), diff(psi(X), t));
|
| (38) |
|
|
Classical Field Theory
|
|
The model in classical field theory and corresponding field equations
>
|
CompactDisplay(Phi(X));
|
| (39) |
>
|
L := 1/2*d_[mu](Phi(X))*d_[mu](Phi(X)) - m^2/2*Phi(X)^2 + lambda/4*Phi(X)^4;
|
| (40) |
Lagrange's equations
>
|
LagrangeEquations(L, Phi);
|
The energy-momentum tensor can be computed as the Lagrange equations taking the metric as the coordinate, not equating to 0 the result, but multiplying by . For that purpose, you can use the energymomentum keyword
>
|
LagrangeEquations(L, EnergyMomentum[mu, nu]);
|
| (42) |
To compute using the above as the definition for , you can use the Define command
| |
| (43) |
After that, the system will know about the symmetry properties and components of
>
|
EnergyMomentum[definition];
|
| (44) |
| (45) |
The case of a scalar field in a curved spacetime is treated the same way. Set for instance an arbitrary metric
| |
| |
| |
| |
| (46) |
For the action to be a scalar, the Lagrangian density now needs to be multiplied by the square root of the determinant of the metric
>
|
L := sqrt(-%g_[determinant]) * L;
|
| (47) |
The Lagrange equations
>
|
LagrangeEquations(L, Phi);
|
| (48) |
Comparing with the result for the same Lagrangian in a flat spacetime, we see the only difference is that the dAlembertian is now expressed in terms of covariant derivatives D_.
The EnergyMomentum tensor is computed in the same way as when the spacetime is flat
>
|
LagrangeEquations(L, EnergyMomentum[mu, nu]);
|
| (49) |
|
|
General Relativity
|
|
Einstein's equations too can be derived from a variational principle, and the problem concerns the case of a non-flat spacetime with metric , as for instance the arbitrary metric set lines above. In the Lagrangian formulation, the coordinates of the problem are the components of the metric , and the parameters are the spacetime coordinates. The simplest case is that of Einstein's equation in vacuum, for which the Lagrangian density is expressed in terms of the trace of the Ricci tensor by
>
|
L := sqrt(-%g_[determinant]) * Ricci[alpha, ~alpha];
|
Einstein's equations in vacuum:
>
|
LagrangeEquations(L, g_[~mu, ~nu]);
|
| (51) |
where in the above instead of passing as second argument, we passed to get the equations using those free indices. The tensorial equation computed is also the definition of the Einstein tensor
>
|
Einstein[~mu, ~nu, definition];
|
| (52) |
The Lagrangian used above to compute Einstein's equations contains first and second derivatives of the metric. To see that, rewrite it in terms of Christoffel symbols
>
|
L__C := convert(L, Christoffel);
|
| (53) |
Recalling the definition
>
|
Christoffel[definition];
|
| (54) |
in the two terms containing derivatives of Christoffel symbols contain second order derivatives of . Nonetheless, it is always possible to add a total spacetime derivative to without changing Einstein's equations (assuming the variation of the metric in the corresponding boundary integrals vanishes), and in that way, in the particular case of , obtain a Lagrangian involving only 1st order derivatives. The total derivative, expressed using the inert command to see it before the differentiation operation is performed, is
>
|
TD := %d_[alpha](g_[~mu, ~nu]*sqrt(-%g_[determinant])*(-Christoffel[~alpha, mu, nu] + g_[~alpha, mu]*Christoffel[~beta, nu, beta]));
|
Adding this term to , performing the differentiation operation and simplifying we get
>
|
L__CTD := Simplify(L__C) + TD;
|
>
|
eval(L__CTD, %d_ = d_);
|
| (57) |
>
|
L__1 := Simplify((57));
|
| (58) |
which is a Lagrangian depending only on 1st order derivatives of the metric through Christoffel symbols. As expected, the equations of motion resulting from this Lagrangian are the same Einstein equations computed in (45)
>
|
LagrangeEquations(L__1, g_[~mu, ~nu]);
|
| (59) |
Note that is no just after discarding the terms involving derivatives of Christoffel symbols. To see that, split into the two terms containing or not derivatives of Christoffel
>
|
L__22, L__11 := selectremove(has, expand(L__C), d_);
|
| (60) |
The total derivative TD is not just but
>
|
TD = - L__22 - 2*L__11;
|
To verify this, take the left-hand side minus the right-hand side, evaluate the inert derivative and simplify
| (63) |
That said, it is also true that results in the Lagrangian , and since the equations of movement don't depend on the sign of the Lagrangian, for this Lagrangian adding the term happens to be equivalent to just discarding the terms involving derivatives of Christoffel symbols.
Finally, it is also possible to compute Einstein's equations from first principles, constructing the action,
| (65) |
and equating to zero the functional derivative with respect to the metric. To avoid displaying the resulting large expression, end the input line with ":"
>
|
EE__unsimplified := Fundiff(S, g_[alpha, beta]) = 0:
|
Simplifying this result, we get an expression in terms of Christoffel symbols and its derivatives
>
|
EEC := Simplify(EE__unsimplified);
|
| (66) |
To rewrite this expression in terms of the Ricci tensor, consider its definition
| (67) |
Rewrite this definition in terms of covariant derivatives D_, simplify and isolate one of them
| (68) |
| (69) |
>
|
C_to_Ricci := isolate((69), D_[alpha](Christoffel[~alpha, mu, nu]));
|
| (70) |
Analogously, derive an expression to rewrite covariant derivatives using the Riemann tensor
>
|
Riemann[~alpha, beta, mu, nu, definition];
|
| (71) |
| (72) |
| (73) |
>
|
C_to_Riemann := isolate((73), D_[mu](Christoffel[~alpha, beta, nu]));
|
| (74) |
Substitute these two equations, in sequence, into Einstein's equations expressed in terms of Christoffel symbols derived lines above
>
|
Substitute(C_to_Riemann, C_to_Ricci, EEC);
|
| (75) |
Simplify to arrive at the traditional compact form
| (76) |
|
|
|
See Also
|
|
CompactDisplay, conjugate, d_, D_, dAlembertian, Fundiff, Geodesics, Gradient, isolate, Laplacian, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics[*], Ricci, Riemann, Setup, Simplify, simplify/siderels, Substitute, VariationalCalculus:-EulerLagrange, Vectors
|
|
References
|
|
|
[1] Landau, L.D., and Lifshitz, E.M. The Classical Theory of Fields, Course of Theoretical Physics Volume 2, fourth revised English edition. Elsevier, 1975.
|
|
[2] Ohanian, H.C., and Ruffini, R. Gravitation and Spacetime, third edition. Cambridge, 2013
|
|
[3] Lovelock, D., and Rund, H. Tensors, Differential Forms and Variational Principles, Dover, 1989.
|
|
|
Compatibility
|
|
•
|
The Physics[LagrangeEquations] command was introduced in Maple 2023.
|
•
|
The Physics[LagrangeEquations] command was updated in Maple 2025.
|
|
|