lagrangian (mech9),peter.vlasschaert@gmail.com, 03/08/2017
example : constraint lagrangian.
disk rolling down (inclined plane with angle  alpha)
constraint : disk rolling without slipping
x        = distance along inclined plane    (x)
θ        = ' see figure 1'                                  (theta)
=>    x=R*θ  => f(x,θ)= x-R*θ    'one constraint' =>  find :λ
q=general coordinates   (qi ,i=1,2)  here x,θ
q_t= time derivative from general coordinates.(qi_t,i=1,2) here x_t,θ_t
given :disc                                  : I = 1/2*M*R^2
             length inclined plane   : l1

assume(R>0,M>0,g>0);
depends(lag,[x,θ,x_t,θ_t],[θ,x,x_t,θ_t],t);

constraint : 'rolling without slipping'

f1:x=R*θ;

f:part(f1,1)-part(f1,2);

eK1:1/2*M*(x_t)^2+1/2*I*(θ_t)^2;
p1:I = 1/2*M*R^2;
eK:ev(eK1,p1);
eP:M*g*(l1-x)*sin(α);

lag:eK-eP;

=>   " Euler-Lagrange equation (qi,i=1,2)  "

p1:constraint(lag,q,q_t):=diff(lag,q)-diff(diff(lag,q_t),t)+λ*diff(f,q);

Euler-Lagrange equation(x,x_t)

p2:constraint(lag,x,x_t)=0;
p21:ev(p2,x_t=diff(x,t),θ_t=diff(θ,t));

Euler-Lagrange equation(θ,θ_t)

p3:constraint(lag,θ,θ_t)=0;
p31:ev(p3,x_t=diff(x,t),θ_t=diff(θ,t));

How to solve for   'λ'

p41:p21;
p42:p31;
p43:f1;

1e)  remove θ from 'p42'

a)  diff   'f1' ,two times for time

p5:solve(f1,θ);
p6:part(p5,1);
p7:diff(part(p6,1),t,2)=diff(part(p6,2),t,2);

b) subst 'p7' in 'p42'

p8:ev(p42,p7);

c) use 'p41' and 'p8' solve for λ ( = constraint multiplier)

p9:part(solve(p8, diff(x,t,2)),1);
p10:ev(p41,p9);
p11:part(solve(p10,λ),1);

?  find : diff(x,t,2)

p12:ev(p9,p11);

find x= x(t)

p121:ode2(p12,x,t);

find : x_t = diff(x,t) 

p121:x_t=diff(part(p121,2),t);

?  find : diff(θ,t,2)

p13:ev(p42,p11);
p14:part(solve(p13,diff(θ,t,2)),1);

find θ = θ(t)

p141:ode2(p14,θ,t)$
p142:ev(p141,%k1=%k3,%k2=%k4);

find : θ_t = diff(θ,t) 

p1421:θ_t=diff(part(p142,2),t);