1
$\begingroup$

If i have the Lagrange density function $$L(x,\dot{x}) = \frac{1}{2}x^2+ \frac{1}{2}\dot{x}^2,$$

The Euler-Lagrange equation is very simple by

$$ \frac{d}{dt}\frac{\partial L}{\partial \dot{x}} - \frac{\partial L}{\partial x} = 0$$

In this example, E-L equation is $\ddot{x}-x=0.$

Can i do this in MMA symbol computation? I know i can use and D to take derivative, so i define l=0.5x^2+0.5x'^2 as Lagrange density function, and then Diff[D[l,x']]-D[l,x], the result seems not right, maybe i need define l as a function of t?

I have no experience in symbolic calculations. Can you share some interesting examples? in MMA SE, seems not much symbol computation topic.

And any comments very much appreciate!

$\endgroup$
3
$\begingroup$
Needs["VariationalMethods`"]
ClearAll[x, t]
L = 1/2*x[t]^2 + 1/2*x'[t]^2;
EulerEquations[L, x[t], t]

$$ x(t)-x''(t)=0 $$

can i realize it by ’ and ‘D’?

Sure. You could always apply the definition yourself. The above command just makes it easier.

 D[D[L, x'[t]], t] - D[L, x[t]] == 0

$$ x''(t)-x(t)=0 $$

$\endgroup$
1
  • $\begingroup$ Big shot, amazing! Thank you, by the way, can i realize it by and ‘D’? It is more general, suppose E-L have some different definition, and didn’t have EulerEquations. $\endgroup$
    – Ben
    Nov 25 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.