Euler-Lagrange equations and partial derivatives



Here is a similar calculation that uses pdiff:

 (%i1) load(pdiff)$

 (%i4) de1 : diff(p(t),t) = at(-diff(ham(p,q),q), [p = p(t), q = q(t)]);
 (%o4) p[(1)](t)=-ham[(0,1)](p(t),q(t))

 (%i5) de2 : diff(q(t),t) = at(diff(ham(p,q),p), [p = p(t), q = q(t)]);
 (%o5) q[(1)](t)=ham[(1,0)](p(t),q(t))

 (%i6) [de1, de2], ham(p,q) := p^2 / 2 + p*q + V(q);
 (%o6) [p[(1)](t)=-V[(1)](q(t))-p(t),q[(1)](t)=q(t)+p(t)]

Barton


maxima-bounces at math.utexas.edu wrote on 04/22/2010 03:17:52 PM:

> [image removed] 
> 
> Re: [Maxima] Euler-Lagrange equations and partial derivatives
> 
> dlakelan 
> 
> to:
> 
> maxima
> 
> 04/22/2010 03:17 PM
> 
> Sent by:
> 
> maxima-bounces at math.utexas.edu
> 
> 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);
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima