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

$\frac{{ⅆ}}{{ⅆ}t}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}\frac{{\partial }}{{\partial }{\stackrel{\to }{v}}_{i}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}L=\frac{{\partial }}{{\partial }{\stackrel{\to }{r}}_{i}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}L$

 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}{2}{\mathrm{diff}\left(x\left(t\right),t\right)}^{2}-\frac{1}{2}k{x\left(t\right)}^{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)$
 ${x}{}\left({t}\right){}{k}{+}\stackrel{{\mathbf{..}}}{{x}}{}\left({t}\right){=}{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{\phi }\left(t\right)\right)$
 ${\mathrm{\phi }}{}\left({t}\right){}{\mathrm{will now be displayed as}}{}{\mathrm{\phi }}$ (4)
 > $L≔\frac{1}{2}m\left(-2\mathrm{diff}\left(\mathrm{\phi }\left(t\right),t\right)al\mathrm{\omega }\mathrm{sin}\left(\mathrm{\omega }t-\mathrm{\phi }\left(t\right)\right)+{\mathrm{diff}\left(\mathrm{\phi }\left(t\right),t\right)}^{2}{l}^{2}+2\mathrm{cos}\left(\mathrm{\phi }\left(t\right)\right)gl\right)$
 ${L}{≔}\frac{{m}{}\left({-}{2}{}\stackrel{{\mathbf{.}}}{{\mathrm{\phi }}}{}{a}{}{l}{}{\mathrm{\omega }}{}{\mathrm{sin}}{}\left({\mathrm{\omega }}{}{t}{-}{\mathrm{\phi }}\right){+}{{\stackrel{{\mathbf{.}}}{{\mathrm{\phi }}}}^{{}}}^{{2}}{}{{l}}^{{2}}{+}{2}{}{\mathrm{cos}}{}\left({\mathrm{\phi }}\right){}{g}{}{l}\right)}{{2}}$ (5)

The Lagrange equations

 > $\mathrm{LagrangeEquations}\left(L,\mathrm{\phi }\right)$
 ${m}{}{l}{}\left({a}{}{{\mathrm{\omega }}}^{{2}}{}{\mathrm{cos}}{}\left({t}{}{\mathrm{\omega }}{-}{\mathrm{\phi }}\right){-}{\mathrm{sin}}{}\left({\mathrm{\phi }}\right){}{g}{-}\stackrel{{\mathbf{..}}}{{\mathrm{\phi }}}{}{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\left[\mathrm{\mu }\right]\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\left[\mathrm{\mu },\mathrm{\nu }\right]≔\mathrm{d_}\left[\mathrm{\mu }\right]\left(A\left[\mathrm{\nu }\right]\left(X\right)\right)-\mathrm{d_}\left[\mathrm{\nu }\right]\left(A\left[\mathrm{\mu }\right]\left(X\right)\right)$
 ${{F}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{≔}{{\partial }}_{{\mathrm{\mu }}}{}\left({{A}}_{{\mathrm{\nu }}}\right){-}{{\partial }}_{{\mathrm{\nu }}}{}\left({{A}}_{{\mathrm{\mu }}}\right)$ (9)

The Lagrangian

 > $L≔{F\left[\mathrm{\mu },\mathrm{\nu }\right]}^{2}$
 ${L}{≔}\left({{\partial }}_{{\mathrm{\mu }}}{}\left({{A}}_{{\mathrm{\nu }}}\right){-}{{\partial }}_{{\mathrm{\nu }}}{}\left({{A}}_{{\mathrm{\mu }}}\right)\right){}\left({{\partial }}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}{}\left({{A}}_{\phantom{{}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\nu }}}\right){-}{{\partial }}_{\phantom{{}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\nu }}}{}\left({{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}\right)\right)$ (10)

Maxwell equations in 4D tensorial notation

 > $\mathrm{LagrangeEquations}\left(L,A\right)$
 ${-}{4}{}{\mathrm{\square }}{}\left({{A}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}\right){+}{4}{}{{\partial }}_{{\mathrm{\mu }}}{}\left({{\partial }}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}}^{\phantom{{}}{\mathrm{\alpha }}}{}\left({{A}}_{\phantom{{}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\mu }}}\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{\hslash }\right):$
 > $\mathrm{Setup}\left(\mathrm{realobjects}=\left\{G,h,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{\psi }\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{\frac{1}{2}\left(-h\left(i\mathrm{diff}\left(\mathrm{conjugate}\left(\mathrm{\psi }\left(X\right)\right),t\right)\mathrm{\psi }\left(X\right)m+h{\mathrm{Norm}\left(\mathrm{%Gradient}\left(\mathrm{\psi }\left(X\right)\right)\right)}^{2}\right)+\left(-G{\mathrm{abs}\left(\mathrm{\psi }\left(X\right)\right)}^{4}+\mathrm{diff}\left(\mathrm{\psi }\left(X\right),t\right)i\mathrm{conjugate}\left(\mathrm{\psi }\left(X\right)\right)h-2V\left(x,y,z,t\right){\mathrm{abs}\left(\mathrm{\psi }\left(X\right)\right)}^{2}\right)m\right)\cdot 1}{m}$
 ${L}{≔}\frac{{-}{\mathrm{\hslash }}{}\left({i}{}{\stackrel{{&conjugate0;}}{{\mathrm{\psi }}}}_{{t}}{}{\mathrm{\psi }}{}{m}{+}{\mathrm{\hslash }}{}{‖{\nabla }{\mathrm{\psi }}‖}^{{2}}\right){+}\left({-}{G}{}{\left|{\mathrm{\psi }}\right|}^{{4}}{+}{i}{}\left(\stackrel{{\mathbf{.}}}{{\mathrm{\psi }}}\right){}\stackrel{{&conjugate0;}}{{\mathrm{\psi }}}{}{\mathrm{\hslash }}{-}{2}{}{V}{}{\left|{\mathrm{\psi }}\right|}^{{2}}\right){}{m}}{{2}{}{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{\psi }\right)$
 $\frac{{\stackrel{{&conjugate0;}}{{\mathrm{\psi }}{}\left({X}\right)}}_{{x}{,}{x}}{}{{\mathrm{\hslash }}}^{{2}}{+}{\stackrel{{&conjugate0;}}{{\mathrm{\psi }}{}\left({X}\right)}}_{{y}{,}{y}}{}{{\mathrm{\hslash }}}^{{2}}{+}{{\mathrm{\hslash }}}^{{2}}{}{\stackrel{{&conjugate0;}}{{\mathrm{\psi }}{}\left({X}\right)}}_{{z}{,}{z}}{-}{2}{}{m}{}\left({G}{}{{\stackrel{{&conjugate0;}}{{\mathrm{\psi }}}}^{{}}}^{{2}}{}{\mathrm{\psi }}{+}{i}{}{\stackrel{{&conjugate0;}}{{\mathrm{\psi }}}}_{{t}}{}{\mathrm{\hslash }}{+}\stackrel{{&conjugate0;}}{{\mathrm{\psi }}}{}{V}\right)}{{2}{}{m}}{=}{0}$ (17)

Make the Laplacian explicit

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

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

 > $ih\mathrm{isolate}\left(,\mathrm{diff}\left(\mathrm{\psi }\left(X\right),t\right)\right)$
 ${i}{}\left(\stackrel{{\mathbf{.}}}{{\mathrm{\psi }}}\right){}{\mathrm{\hslash }}{=}\frac{{-}{{\mathrm{\hslash }}}^{{2}}{}\left({{\nabla }}^{{2}}{\mathrm{\psi }}\right){+}{2}{}{m}{}{\mathrm{\psi }}{}\left({G}{}\stackrel{{&conjugate0;}}{{\mathrm{\psi }}}{}{\mathrm{\psi }}{+}{V}\right)}{{2}{}{m}}$ (20)

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

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

Compatibility

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