Mathematica Asked by Gabriel Sandoval on August 5, 2021
I want to program the Euler-Lagrange equations for continuous systems.
But in this formulation I have to compute the derivative of the Lagrangian with respect to all the derivatives of the generalized coordinate.
$$partial_ileft(dfrac{partial mathcal{L}}{partial (partial_iphi) } right) = dfrac{partial mathcal L}{partial phi }$$
For example, for a field $phi=phi(x,t)$
$$dfrac{partial }{partial t}dfrac{partial mathcal L}{partial dotphi}+dfrac{partial }{partial x}dfrac{partial mathcal L}{partial phi’}=dfrac{partialmathcal L}{partial phi}$$
Where $dotphi=dfrac{partialphi}{partial t }$ and $phi’=dfrac{partial phi}{partial x }$
I have tried with something like this
D[L, D[ϕ, t]] + D[L, D[ϕ, x]] = D[L,ϕ]
But of course, it returns an error because of the variable with respect the derivative is taken.
It is straightforward. Let us take a Lagrangian
L = 1/2 D[y[x, t], t]^2 - 1/(2 c^2) D[y[x, t], x]^2 + 1/2 y[x, t]^2;
We need to load the package:
Needs["VariationalMethods`"]
Now, this gives the variational derivative:
VariationalD[L, y[x, t], {x, t}]
and this yields the Euler equation:
EulerEquations[L, y[x, t], {x, t}]
Have fun!
Correct answer by Alexei Boulbitch on August 5, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP