lagrangian (mech2),peter.vlasschaert@gmail.com, 25/07/2017
pendulum(l=length,theta=deviation),'single degree q1=q' of freedom.(nonlinear,linear)

kill(all)$
depends(lag,[q,q_t],[q,q_t],t);
/*  ' (=prime),prevent evalution of the equation */
p1:'diff(lag,q)-'diff(diff(lag,q_t),t)=0;

potential Energy (=pE),kinetic Energy(=kE)

given :

assumption :variables 'physics'

depends(theta,t);

assume(l>0,m>0,g>0);

pE1:m*g*l*(1-cos(theta));
kE1:1/2*m*l^2*(diff(theta,t))^2;

conversion : q,q_t

pE:ev(pE1,theta=q);
kE:ev(kE1,diff(theta,t)=q_t);

definition : Lagrangian =kinetic Energy -potential Energy

p2:lag=kE-pE;

no evalution of differentation operators

p3:ev(p1,p2);

 evalution of differentation operators

p4:ev(p3,diff);

definition : acceleration (velocity=q_t,position=q)

p5:diff(q_t,t)=diff(q,t,2);

p6:ev(p4,p5);

p7:factor(p6);
p8:part(p7,1,1,3)=rhs(p7);
p81:ratcoef(part(p8,1),rhs(p5));
p82:part(p8,1,1);
p83:part(p8,1,2);
p84:rhs(p5)=-p83/p81;

solve : differential equation second order (= ode2)

only get two implicit expressions q(t),nonlinear

p9:ode2(p8,q,t);

menu -> Get series ->Expression :    sin(x)

p10:taylor(sin(x), x, 0, 8);

small angles theta: q=theta

p11:part(p10,1);

solve : differential equation second order (= ode2)

only get one explicit expression:q(t),linear

p12:sin(q)=subst(q, x, p11);

p13:ev(p8,p12);

p14:ode2(p13,q,t);