Dvojno nihalo
Rok Zitko, rok.zitko@ijs.si, marec 2011

r1=l{Sin[ϕ1[t]],-Cos[ϕ1[t]]};
r2p=l{Sin[ϕ2[t]],-Cos[ϕ2[t]]};
dr1=D[r1,t]
v1=dr1.dr1//Simplify
dr2p=D[r2p,t]
v2=(dr1+dr2p).(dr1+dr2p)//Simplify

T=1/2m v1+1/2 m v2//Simplify
V=m g (r1.{0,1}+(r1+r2p).{0,1})//Simplify
L=T-V

D[L,ϕ1'[t]]//Simplify
D[%,t]//Simplify

D[L,ϕ2'[t]]//Simplify
D[%,t]//Simplify

eq1=Simplify[D[D[L,ϕ1'[t]],t]-D[L,ϕ1[t]]];
eq2=Simplify[D[D[L,ϕ2'[t]],t]-D[L,ϕ2[t]]];
eq1=eq1//.{g->ω^2/l,l->1,m->1}
eq2=eq2//.{g->ω^2/l,l->1,m->1}

ω=1;
tmax=15;
sol=NDSolve[{eq1==0,eq2==0,ϕ1[0]==0,ϕ1'[0]==0,ϕ2[0]==Pi/4,ϕ2'[0]==0},{ϕ1[t],ϕ2[t]},{t,0,tmax}]

{ϕ1[t],ϕ2[t]}/.sol[[1]]
Plot[%,{t,0,tmax}]

L

D[L,ϕ1[t]]
D[L,ϕ1]

f[x]
D[f[x],f[x]]
D[f'[x],f[x]]
D[f[x],f]
D[f'[x],f]