Euler-Lagrange equations and partial derivatives



On 04/22/2010 12:22 PM, dlakelan wrote:

> In Euler-Lagrange equations we need to mix these things.
>
> diff(partdiff(foo, bardot),t) - partdiff(foo,bar) = 0
>
> where only the "diff" should take total derivatives, and the
> non-existent partdiff should do partials only. Unfortunately it is not
> easily possible (or at least not obvious how) to mix partials and total
> derivatives in maxima. Does anyone have any suggestions about how to go
> about it?

Here is my attempt to solve this problem. I first save the dependencies, 
then remove all dependencies, calculate the partials (via diff) and then 
replace the dependencies and calculate the total derivative with respect 
to the time variable. Is there anything that can go wrong in removing 
and replacing the dependencies? Is this function referentially 
transparent? (ie. has no externally apparent side effects?)

EuLagEquations(expr,var,vardot,t) :=
block([deps:copylist(dependencies), term1, term2],
   print(deps),
   remove(all,dependency),
   term1: diff(expr,vardot), term2: -diff(expr,var),
   for i in deps do (print(i),depends(op(i),args(i))),
   diff(term1,t)+term2=0);