| LIB "jacobson.lib";
ring R=(0,m,M,L1,L2,m1,m2,g), D, lp; // two pendula example
matrix P[3][4]=m1*L1*D^2,m2*L2*D^2,(M+m1+m2)*D^2,-1,
m1*L1^2*D^2-m1*L1*g,0,m1*L1*D^2,0,0,
m2*L2^2*D^2-m2*L2*g,m2*L2*D^2,0;
list s=smith(P,1); // returns a list with 3 entries
print(s[2]); // a diagonal form, close to the Smith form
==> (L1*L2*m2*g^2-L2^2*m2*g^2),0, 0, 0,
==> 0, (L2),0, 0,
==> 0, 0, (g^2),0
print(s[1]); // U, left transformation matrix
==> 0, (-L2*m2)/(L1*m1), 1,
==> (-L2),(M*L2+L2*m1)/(L1*m1),1,
==> 0, 1/(L1*m1), 0
list t = divideUnits(s);
print(t[2]); // the Smith form of the matrix P
==> 1,0,0,0,
==> 0,1,0,0,
==> 0,0,1,0
print(t[1]); // U', modified left transformation matrix
==> 0, -1/(L1^2*m1*g^2-L1*L2*m1*g^2),1/(L1*L2*m2*g^2-L2^2*m2*g^2),
==> -1,(M+m1)/(L1*m1), 1/(L2),
==> 0, 1/(L1*m1*g^2), 0
|