jonathanrn

4 Reputation

0 Badges

16 years, 235 days

MaplePrimes Activity


These are replies submitted by jonathanrn

acer suggested another way to use the freeze thaw

thaw( value(subs( theta(t)=freeze(theta(t)),Diff(cos(theta(t)),theta(t)) ) ) );

this can easily be put into a procedure:

pdiff := proc( f,x )
        thaw( value(subs( x=freeze(x),Diff(f,x) ) ) );
end proc;
 

thanks

Is there eally no easier solution to this problem?  The freeze and thaw might work but it seems rather muddled an unsatisfying.
 

I disagree that this is not a typical situation.  I am doing lagrangian mechanics, so i frequently have many coordinates which depend on time.  In the euler-lagrange equation itself, it is neccessary to take the partial derivative with respect to a time dependent coordinate and then immediately take the derivitive of the result with respect to time.  The Euler-lagrange equations are differential equations so, it is important to keep time dependence in the final result.  I had been using the frontend command, but in the following example it has problems:

 

T:= m*(diff(r(t),t)^2+r(t)^2*diff(theta(t),t)^2)/2;                                         kinetic energy
T := (1/2)*m*((diff(r(t), t))^2+r(t)^2*(diff(theta(t), t))^2)


V:= m*g*r(t)*cos(theta(t));                                                                         potential energy
V := m*g*r(t)*cos(theta(t))


L:=T-V;                                                                                                       lagrangian
L := (1/2)*m*((diff(r(t), t))^2+r(t)^2*(diff(theta(t), t))^2)-m*g*r(t)*cos(theta(t))

The constraint is that g1=0:
g1:=r(t)-R;                                                                                            constraint for undertermined multipliers
g1 := r(t)-R


So our E-L equations are then:


frontend(diff,[L,r(t)])-diff( frontend(diff,[L,diff(r(t),t)]) ,t)+lambda(t)*frontend(diff,[g1,r(t)])=0;
frontend(diff,[L,theta(t)])-diff( frontend(diff,[L,diff(theta(t),t)]) ,t)+lambda(t)*frontend(diff,[g1,theta(t)])=0;


m*r(t)*(diff(theta(t), t))^2-m*g*cos(theta(t))-m*(diff(r(t), `$`(t, 2)))+lambda(t) = 0
-2*m*r(t)*(diff(theta(t), t))*(diff(r(t), t))-m*r(t)^2*(diff(theta(t), `$`(t, 2))) = 0

This frontend approach was working great, until i noticed that it freezes cos's and sin's. so:

             frontend(diff,[sin(theta(t),theta(t)]);

                       0

when it should be cos(theta(t)), instead of zero.

The frontend aproach was not incredibly elegant but i at least found it acceptable.  However, it doesn't work with trigonometric functions.  I will try the freeze-thaw method, but it seems very tedious.  Would there maybe be a way to program what I want into an operator or procedure?

Ideally i would like a simple diff command that can differentiate: with respect to time dependent coordinates and with respect to their first and second derivatives in time.  Does this exist in maple or would there be a way to create it?

Page 1 of 1