Physics[LagrangeEquations] - compute the Lagrange equations for 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
Description
LagrangeEquations receives an expression representing a Lagrangian and returns a sequence of Lagrange equations, of the form expression=0, 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.
The formula in the traditional case where the Lagrangian depends on 1st order derivatives of the coordinates and there is only one parameter, t, is
ⅆⅆt∂∂v→iL=∂∂r→iL
where ∂∂r→iL formally represents the derivative with respect to the coordinates of the ith particle, equal to the Gradient when working in Cartesian coordinates; ∂∂v→iL represents the equivalent operation, replacing each coordinate by the corresponding velocity, i.e. its derivative with respect to t, and ⅆⅆt represents the total derivative with respect to t, the parameter parametrizing the coordinates. Note that in more general cases the number of parameters can be many. For example, in electrodynamics, the "coordinate" is a tensor field Aμ⁡x,y,z,t, there are then four coordinates, one for each of the values of the index μ, and there are four parameters x,y,z,t.
The second argument F indicates the coordinates without their dependency, passed as names. For example, in the case of one single parameter t and a coordinate q⁡t, pass q. It is expected that these names appear in the Lagrangian consistently, always with the same functionality.
LagrangeEquations can handle tensors and vectors of the Physics package as well as derivatives using vectorial differential operators (see d_ and Nabla), works by performing functional differentiation (see Fundiff), and handles 1st, and higher order derivatives of the coordinates in the Lagrangian automatically. Unlike the similar command VariationalCalculus:-EulerLagrange, LagrangeEquations does not return first integrals.
Examples
with⁡Physics:
Setup⁡mathematicalnotation=true,coordinates=cartesian
⁢Systems of spacetime coordinates are:⁢X=x,y,z,t
_______________________________________________________
coordinatesystems=X,mathematicalnotation=true
The Lagrangian of a one-dimensional oscillator - small oscillations
L≔12⁢diff⁡x⁡t,t2−12⁢k⁢x⁡t2
L≔x.⁡t22−k⁢x⁡t22
The corresponding Lagrange equation gives Newton's second law, a 2nd order linear ODE for x⁡t
LagrangeEquations⁡L,x
x⁡t⁢k+x..⁡t=0
The Lagrangian of a pendulum of mass m and length l where the suspension point moves uniformly over a vertical circumference centered at the origin, with a constant frequency ω
CompactDisplay⁡φ⁡t
φ⁡t⁢will now be displayed as⁢φ
L≔12⁢m⁢−2⁢diff⁡φ⁡t,t⁢a⁢l⁢ω⁢sin⁡ω⁢t−φ⁡t+diff⁡φ⁡t,t2⁢l2+2⁢cos⁡φ⁡t⁢g⁢l
L≔m⁢−2⁢φ.⁢a⁢l⁢ω⁢sin⁡ω⁢t−φ+φ.2⁢l2+2⁢cos⁡φ⁢g⁢l2
The Lagrange equations
LagrangeEquations⁡L,φ
m⁢l⁢a⁢ω2⁢cos⁡t⁢ω−φ−sin⁡φ⁢g−φ..⁢l=0
The Maxwell equations can be derived as Lagrange equations as follows. For simplicity, consider Maxwell equations in vacuum. Define first a tensor representing the 4D electromagnetic field potential
Define⁡Aμ
Defined objects with tensor properties
Aμ,γμ,σμ,∂μ,gμ,ν,εα,β,μ,ν,Xμ
CompactDisplay⁡A⁡X
A⁡x,y,z,t⁢will now be displayed as⁢A
The electromagnetic field tensor
Fμ,ν≔d_μ⁡Aν⁡X−d_ν⁡Aμ⁡X
Fμ,ν≔∂μ⁡Aν−∂ν⁡Aμ
The Lagrangian
L≔Fμ,ν2
L≔∂μ⁡Aν−∂ν⁡Aμ⁢∂⁢μ⁢μ⁡A⁢ν⁢ν−∂⁢ν⁢ν⁡A⁢μ⁢μ
Maxwell equations in 4D tensorial notation
LagrangeEquations⁡L,A
−4⁢□⁡A⁢α⁢α+4⁢∂μ⁡∂⁢α⁢α⁡A⁢μ⁢μ=0
The Lagrangian of a quantum system of identical particles (bosons) can be expressed in terms of the a complex field ψ⁡X, an external potential V⁡X and a term G⁢12⁢ψ4 representing the atom-atom interaction. Set first the realobjects of the problem
with⁡Vectors
&x,`+`,`.`,Assume,ChangeBasis,ChangeCoordinates,CompactDisplay,Component,Curl,DirectionalDiff,Divergence,Gradient,Identify,Laplacian,∇,Norm,ParametrizeCurve,ParametrizeSurface,ParametrizeVolume,Setup,Simplify,`^`,diff,int
interface⁡imaginaryunit=i
I
macro⁡h=ℏ:
Setup⁡realobjects=G,h,m,t,V⁡x,y,z,t
realobjects=ℏ,G,m,φ,r,ρ,t,θ,x,y,z,V⁡X
CompactDisplay⁡ψ⁡X,V⁡X
ψ⁡x,y,z,t⁢will now be displayed as⁢ψ
V⁡x,y,z,t⁢will now be displayed as⁢V
The Lagrangian is
L≔12⁢−h⁢i⁢diff⁡conjugate⁡ψ⁡X,t⁢ψ⁡X⁢m+h⁢Norm⁡%Gradient⁡ψ⁡X2+−G⁢abs⁡ψ⁡X4+diff⁡ψ⁡X,t⁢i⁢conjugate⁡ψ⁡X⁢h−2⁢V⁡x,y,z,t⁢abs⁡ψ⁡X2⁢m⋅1m
L≔−ℏ⁢ⅈ⁢ψ&conjugate0;t⁢ψ⁢m+ℏ⁢∇ψ2+−G⁢ψ4+ⅈ⁢ψ.⁢ψ&conjugate0;⁢ℏ−2⁢V⁢ψ2⁢m2⁢m
Taking ψ as the coordinate, the Lagrange equation is the so-called the Gross-Pitaevskii equation (GPE),
LagrangeEquations⁡L,ψ
ψ⁡X&conjugate0;x,x⁢ℏ2+ψ⁡X&conjugate0;y,y⁢ℏ2+ℏ2⁢ψ⁡X&conjugate0;z,z−2⁢m⁢G⁢ψ&conjugate0;2⁢ψ+ⅈ⁢ψ&conjugate0;t⁢ℏ+ψ&conjugate0;⁢V2⁢m=0
Make the Laplacian explicit
Laplacian=%Laplacian⁡ψ⁡X
ψx,x+ψy,y+ψz,z=∇2ψ
simplify⁡conjugate⁡,
2⁢ⅈ⁢ℏ⁢ψ.⁢m+ℏ2⁢∇2ψ−2⁢m⁢ψ⁢G⁢ψ&conjugate0;⁢ψ+V2⁢m=0
The standard form of the Gross-Pitaevskii equation has the time derivative of ψ isolated
i⁢h⁢isolate⁡,diff⁡ψ⁡X,t
ⅈ⁢ψ.⁢ℏ=−ℏ2⁢∇2ψ+2⁢m⁢ψ⁢G⁢ψ&conjugate0;⁢ψ+V2⁢m
The λ⁢Φ4 model in classical field theory and corresponding field equations
CompactDisplay⁡Φ⁡X
Φ⁡x,y,z,t⁢will now be displayed as⁢Φ
L≔12⁢d_μ⁡Φ⁡X⁢d_μ⁡Φ⁡X−m22⁢Φ⁡X2+λ4⁢Φ⁡X4
L≔∂μ⁡Φ⁢∂⁢μ⁢μ⁡Φ2−m2⁢Φ22+λ⁢Φ44
LagrangeEquations⁡L,Φ
Φ3⁢λ−Φ⁢m2−□⁡Φ=0
See Also
CompactDisplay, conjugate, d_, dAlembertian, Fundiff, isolate, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics[*], Setup, simplify/siderels, VariationalCalculus:-EulerLagrange
Compatibility
The Physics[LagrangeEquations] command was introduced in Maple 2023.
For more information on Maple 2023 changes, see Updates in Maple 2023.
Download Help Document