LEq2 := proc (LagrFce, var::vector,dvar::vector,indep::name) local i,j,N,res; #the generation of the Lagrange equations or constants # of motion IM (for cyclic variables) for the Lagrange # function LagrFce and vector of generalized coordinates # var and velocities dvar and independent variable indep N:=vectdim(var); for i to N do res[i]:=simplify(sdiff(LagrFce,var[i])); if res[i]=0 then res[i] := cname('IM',var[i]) = sdiff(LagrFce, dvar[i]) else res[i] := 0 = diff(sdiff(LagrFce, dvar[i]), indep) - res[i] fi; od; {seq(simplify(res[i]), i=1..N)} end;