LagrangeEquations - Maple Help

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 $\mathrm{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

$\mathrm{Typesetting}:-\mathrm{_Hold}\left(\left[\mathrm{%diff}\left(\mathrm{%diff}\left(L,{\mathrm{v_}}_{i}\right),t\right)\right]\right)=\mathrm{Typesetting}:-\mathrm{_Hold}\left(\left[\mathrm{%diff}\left(L,{\mathrm{r_}}_{i}\right)\right]\right)$

 where $\frac{{\partial }}{{\partial }{\stackrel{\to }{r}}_{i}}L$ formally represents the derivative with respect to the coordinates of the ${i}^{\mathrm{th}}$ particle, equal to the Gradient when working in Cartesian coordinates; $\frac{{\partial }}{{\partial }{\stackrel{\to }{v}}_{i}}L$ represents the equivalent operation, replacing each coordinate by the corresponding velocity, i.e. its derivative with respect to $t$, and $\frac{{ⅆ}}{{ⅆ}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}_{\mathrm{\mu }}\left(x,y,z,t\right)$, there are then four coordinates, one for each of the values of the index $\mathrm{\mu }$, and there are four parameters $\left(x,y,z,t\right)$.
 • 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\left(t\right)$, 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

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{mathematicalnotation}=\mathrm{true},\mathrm{coordinates}=\mathrm{cartesian}\right)$
 ${}\mathrm{Systems of spacetime coordinates are:}{}\left\{X=\left(x{,}y{,}z{,}t\right)\right\}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{coordinatesystems}}{=}\left\{{X}\right\}{,}{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}\right]$ (1)

The Lagrangian of a one-dimensional oscillator - small oscillations

 > $L≔\frac{1{\left(\frac{ⅆ}{ⅆt}x\left(t\right)\right)}^{2}}{2}-\frac{1k{x\left(t\right)}^{2}}{2}$
 ${L}{≔}\frac{{\stackrel{{\mathbf{.}}}{{x}}{}\left({t}\right)}^{{2}}}{{2}}{-}\frac{{k}{}{{x}{}\left({t}\right)}^{{2}}}{{2}}$ (2)

The corresponding Lagrange equation gives Newton's second law, a 2nd order linear ODE for $x\left(t\right)$

 > $\mathrm{LagrangeEquations}\left(L,x\right)$
 $\stackrel{{\mathbf{..}}}{{x}}{}\left({t}\right){+}{x}{}\left({t}\right){}{k}{=}{0}$ (3)

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 $\mathrm{\omega }$

 > $\mathrm{CompactDisplay}\left(\mathrm{φ}\left(t\right)\right)$
 ${\mathrm{\phi }}{}\left({t}\right){}{\mathrm{will now be displayed as}}{}{\mathrm{\phi }}$ (4)
 > $L≔\frac{1m\left(-2\left(\frac{ⅆ}{ⅆt}\mathrm{φ}\left(t\right)\right)al\mathrm{ω}\mathrm{sin}\left(\mathrm{ω}t-\mathrm{φ}\left(t\right)\right)+{\left(\frac{ⅆ}{ⅆt}\mathrm{φ}\left(t\right)\right)}^{2}{l}^{2}+2\mathrm{cos}\left(\mathrm{φ}\left(t\right)\right)gl\right)}{2}$
 $\frac{{1}}{{2}}{}{m}{}\left({-}{2}{}\left({\mathrm{diff}}{}\left({\mathrm{φ}}{}\left({t}\right){,}{t}\right)\right){}{a}{}{l}{}{\mathrm{ω}}{}{\mathrm{sin}}{}\left({\mathrm{ω}}{}{t}{-}{\mathrm{φ}}{}\left({t}\right)\right){+}{\left({\mathrm{diff}}{}\left({\mathrm{φ}}{}\left({t}\right){,}{t}\right)\right)}^{{2}}{}{{l}}^{{2}}{+}{2}{}{\mathrm{cos}}{}\left({\mathrm{φ}}{}\left({t}\right)\right){}{g}{}{l}\right)$ (5)

The Lagrange equations

 > $\mathrm{LagrangeEquations}\left(L,\mathrm{φ}\right)$
 ${m}{}{l}{}\left({a}{}{{\mathrm{ω}}}^{{2}}{}{\mathrm{cos}}{}\left({\mathrm{ω}}{}{t}{-}{\mathrm{φ}}{}\left({t}\right)\right){-}{\mathrm{sin}}{}\left({\mathrm{φ}}{}\left({t}\right)\right){}{g}{-}\left({\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{φ}}{}\left({t}\right){,}{t}\right){,}{t}\right)\right){}{l}\right){=}{0}$ (6)

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

 > $\mathrm{Define}\left({A}_{\mathrm{μ}}\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{{A}}_{{\mathrm{\mu }}}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{\mathrm{\sigma }}}_{{\mathrm{\mu }}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{X}}_{{\mathrm{\mu }}}\right\}$ (7)
 > $\mathrm{CompactDisplay}\left(A\left(X\right)\right)$
 ${A}{}\left({x}{,}{y}{,}{z}{,}{t}\right){}{\mathrm{will now be displayed as}}{}{A}$ (8)

The electromagnetic field tensor

 > ${F}_{\mathrm{μ},\mathrm{ν}}≔{\mathrm{d_}}_{\mathrm{μ}}\left({A}_{\mathrm{ν}}\left(X\right)\right)-{\mathrm{d_}}_{\mathrm{ν}}\left({A}_{\mathrm{μ}}\left(X\right)\right)$
 ${{\mathrm{d_}}}_{{\mathrm{μ}}}{}\left({{A}}_{{\mathrm{ν}}}{}\left({X}\right){,}\left[{X}\right]\right){-}{{\mathrm{d_}}}_{{\mathrm{ν}}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}\left[{X}\right]\right)$ (9)

The Lagrangian

 > $L≔{F}_{\mathrm{μ},\mathrm{ν}}^{2}$
 $\left({{\mathrm{d_}}}_{{\mathrm{μ}}}{}\left({{A}}_{{\mathrm{ν}}}{}\left({X}\right){,}\left[{X}\right]\right){-}{{\mathrm{d_}}}_{{\mathrm{ν}}}{}\left({{A}}_{{\mathrm{μ}}}{}\left({X}\right){,}\left[{X}\right]\right)\right){}\left({{\mathrm{d_}}}_{{\mathrm{~mu}}}{}\left({{A}}_{{\mathrm{~nu}}}{}\left({X}\right){,}\left[{X}\right]\right){-}{{\mathrm{d_}}}_{{\mathrm{~nu}}}{}\left({{A}}_{{\mathrm{~mu}}}{}\left({X}\right){,}\left[{X}\right]\right)\right)$ (10)

Maxwell equations in 4D tensorial notation

 > $\mathrm{LagrangeEquations}\left(L,A\right)$
 ${-}{4}{}{\mathrm{dAlembertian}}{}\left({{A}}_{{\mathrm{~alpha}}}{}\left({X}\right){,}\left[{X}\right]\right){+}{4}{}{{\mathrm{d_}}}_{{\mathrm{μ}}}{}\left({{\mathrm{d_}}}_{{\mathrm{~alpha}}}{}\left({{A}}_{{\mathrm{~mu}}}{}\left({X}\right){,}\left[{X}\right]\right){,}\left[{X}\right]\right){=}{0}$ (11)

The Lagrangian of a quantum system of identical particles (bosons) can be expressed in terms of the a complex field $\mathrm{\psi }\left(X\right)$, an external potential $V\left(X\right)$ and a term $G\frac{1}{2}{\left|\mathrm{\psi }\right|}^{4}$ representing the atom-atom interaction. Set first the realobjects of the problem

 > $\mathrm{with}\left(\mathrm{Vectors}\right)$
 $\left[{\mathrm{&x}}{,}{\mathrm{+}}{,}{\mathrm{.}}{,}{\mathrm{Assume}}{,}{\mathrm{ChangeBasis}}{,}{\mathrm{ChangeCoordinates}}{,}{\mathrm{CompactDisplay}}{,}{\mathrm{Component}}{,}{\mathrm{Curl}}{,}{\mathrm{DirectionalDiff}}{,}{\mathrm{Divergence}}{,}{\mathrm{Gradient}}{,}{\mathrm{Identify}}{,}{\mathrm{Laplacian}}{,}{\nabla }{,}{\mathrm{Norm}}{,}{\mathrm{ParametrizeCurve}}{,}{\mathrm{ParametrizeSurface}}{,}{\mathrm{ParametrizeVolume}}{,}{\mathrm{Setup}}{,}{\mathrm{Simplify}}{,}{\mathrm{^}}{,}{\mathrm{diff}}{,}{\mathrm{int}}\right]$ (12)
 > $\mathrm{interface}\left(\mathrm{imaginaryunit}=i\right)$
 ${I}$ (13)
 > $\mathrm{macro}\left(h=\mathrm{ℏ}\right):$
 > $\mathrm{Setup}\left(\mathrm{realobjects}=\left\{h,G,m,t,V\left(x,y,z,t\right)\right\}\right)$
 $\left[{\mathrm{realobjects}}{=}\left\{{\mathrm{\hslash }}{,}{G}{,}{m}{,}{\mathrm{\phi }}{,}{r}{,}{\mathrm{\rho }}{,}{t}{,}{\mathrm{\theta }}{,}{x}{,}{y}{,}{z}{,}{V}{}\left({X}\right)\right\}\right]$ (14)
 > $\mathrm{CompactDisplay}\left(\mathrm{ψ}\left(X\right),V\left(X\right)\right)$
 ${\mathrm{\psi }}{}\left({x}{,}{y}{,}{z}{,}{t}\right){}{\mathrm{will now be displayed as}}{}{\mathrm{\psi }}$
 ${V}{}\left({x}{,}{y}{,}{z}{,}{t}\right){}{\mathrm{will now be displayed as}}{}{V}$ (15)

The Lagrangian is

 > $L≔\frac{1\left(-h\left(i\left(\frac{\partial }{\partial t}\stackrel{&conjugate0;}{\mathrm{ψ}\left(X\right)}\right)\mathrm{ψ}\left(X\right)m+h{\mathrm{Norm}\left(\mathrm{%Gradient}\left(\mathrm{ψ}\left(X\right)\right)\right)}^{2}\right)+\left(-G{\left|\mathrm{ψ}\left(X\right)\right|}^{4}+\left(\frac{\partial }{\partial t}\mathrm{ψ}\left(X\right)\right)i\stackrel{&conjugate0;}{\mathrm{ψ}\left(X\right)}h-2V\left(x,y,z,t\right){\left|\mathrm{ψ}\left(X\right)\right|}^{2}\right)m\right)\cdot 1}{2m}$
 $\frac{{1}}{{2}}{}\frac{{-}{\mathrm{\hslash }}{}\left({i}{}\left({\mathrm{diff}}{}\left({\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){,}{t}\right)\right){}{\mathrm{ψ}}{}\left({X}\right){}{m}{+}{\mathrm{\hslash }}{}{{\mathrm{Norm}}{}\left({\mathrm{%Gradient}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right)\right)}^{{2}}\right){+}\left({-}{G}{}{{\mathrm{abs}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right)}^{{4}}{+}{i}{}\left({\mathrm{diff}}{}\left({\mathrm{ψ}}{}\left({X}\right){,}{t}\right)\right){}{\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){}{\mathrm{\hslash }}{-}{2}{}{V}{}\left({X}\right){}{{\mathrm{abs}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right)}^{{2}}\right){}{m}}{{m}}$ (16)

Taking $\mathrm{\psi }$ as the coordinate, the Lagrange equation is the so-called the Gross-Pitaevskii equation (GPE),

 > $\mathrm{LagrangeEquations}\left(L,\mathrm{ψ}\right)$
 $\frac{{1}}{{2}}{}\frac{\left({\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){,}{x}\right){,}{x}\right)\right){}{{\mathrm{\hslash }}}^{{2}}{+}\left({\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){,}{y}\right){,}{y}\right)\right){}{{\mathrm{\hslash }}}^{{2}}{+}{{\mathrm{\hslash }}}^{{2}}{}\left({\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){,}{z}\right){,}{z}\right)\right){-}{2}{}\left({G}{}{{\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right)}^{{2}}{}{\mathrm{ψ}}{}\left({X}\right){+}{i}{}\left({\mathrm{diff}}{}\left({\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){,}{t}\right)\right){}{\mathrm{\hslash }}{+}{\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){}{V}{}\left({X}\right)\right){}{m}}{{m}}{=}{0}$ (17)

Make the Laplacian explicit

 > $\left(\mathrm{Laplacian}=\mathrm{%Laplacian}\right)\left(\mathrm{ψ}\left(X\right)\right)$
 ${\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{ψ}}{}\left({X}\right){,}{x}\right){,}{x}\right){+}{\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{ψ}}{}\left({X}\right){,}{y}\right){,}{y}\right){+}{\mathrm{diff}}{}\left({\mathrm{diff}}{}\left({\mathrm{ψ}}{}\left({X}\right){,}{z}\right){,}{z}\right){=}{\mathrm{%Laplacian}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right)$ (18)
 > $\mathrm{simplify}\left(\stackrel{}{&conjugate0;},\left\{\right\}\right)$
 $\frac{{1}}{{2}}{}\frac{{2}{}{i}{}{\mathrm{\hslash }}{}\left({\mathrm{diff}}{}\left({\mathrm{ψ}}{}\left({X}\right){,}{t}\right)\right){}{m}{+}{{\mathrm{\hslash }}}^{{2}}{}{\mathrm{%Laplacian}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){-}{2}{}{m}{}{\mathrm{ψ}}{}\left({X}\right){}\left({G}{}{\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){}{\mathrm{ψ}}{}\left({X}\right){+}{V}{}\left({X}\right)\right)}{{m}}{=}{0}$ (19)

The standard form of the Gross-Pitaevskii equation has the time derivative of $\mathrm{\psi }$ isolated

 > $ih\mathrm{isolate}\left(,\frac{\partial }{\partial t}\mathrm{ψ}\left(X\right)\right)$
 ${i}{}\left({\mathrm{diff}}{}\left({\mathrm{ψ}}{}\left({X}\right){,}{t}\right)\right){}{\mathrm{\hslash }}{=}\frac{{1}}{{2}}{}\frac{{-}{{\mathrm{\hslash }}}^{{2}}{}{\mathrm{%Laplacian}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){+}{2}{}{m}{}{\mathrm{ψ}}{}\left({X}\right){}\left({G}{}{\mathrm{conjugate}}{}\left({\mathrm{ψ}}{}\left({X}\right)\right){}{\mathrm{ψ}}{}\left({X}\right){+}{V}{}\left({X}\right)\right)}{{m}}$ (20)

The $\mathrm{\lambda }{\mathrm{\Phi }}^{4}$ model in classical field theory and corresponding field equations

 > $\mathrm{CompactDisplay}\left(\mathrm{Φ}\left(X\right)\right)$
 ${\mathrm{\Phi }}{}\left({x}{,}{y}{,}{z}{,}{t}\right){}{\mathrm{will now be displayed as}}{}{\mathrm{\Phi }}$ (21)
 > $L≔\frac{1{\mathrm{d_}}_{\mathrm{μ}}\left(\mathrm{Φ}\left(X\right)\right){\mathrm{d_}}_{\mathrm{μ}}\left(\mathrm{Φ}\left(X\right)\right)}{2}-\frac{{m}^{2}{\mathrm{Φ}\left(X\right)}^{2}}{2}+\frac{\mathrm{λ}{\mathrm{Φ}\left(X\right)}^{4}}{4}$
 $\frac{{1}}{{2}}{}{{\mathrm{d_}}}_{{\mathrm{μ}}}{}\left({\mathrm{Φ}}{}\left({X}\right){,}\left[{X}\right]\right){}{{\mathrm{d_}}}_{{\mathrm{~mu}}}{}\left({\mathrm{Φ}}{}\left({X}\right){,}\left[{X}\right]\right){-}\frac{{1}}{{2}}{}{{m}}^{{2}}{}{{\mathrm{Φ}}{}\left({X}\right)}^{{2}}{+}\frac{{1}}{{4}}{}{\mathrm{λ}}{}{{\mathrm{Φ}}{}\left({X}\right)}^{{4}}$ (22)
 > $\mathrm{LagrangeEquations}\left(L,\mathrm{Φ}\right)$
 ${\mathrm{dAlembertian}}{}\left({\mathrm{Φ}}{}\left({X}\right){,}\left[{X}\right]\right){+}{\mathrm{Φ}}{}\left({X}\right){}\left({-}{{\mathrm{Φ}}{}\left({X}\right)}^{{2}}{}{\mathrm{λ}}{+}{{m}}^{{2}}\right){=}{0}$ (23)

Compatibility

 • The Physics[LagrangeEquations] command was introduced in Maple 2023.