> with(linalg):

We calculate the Smith Normal Form of the matrix M by row and column operations.

> m:=matrix(3,3,[[1,3,4],[-1,2,4],[5,2,1]]);

m := matrix([[1, 3, 4], [-1, 2, 4], [5, 2, 1]])

> det(m);

9

> m:=addrow(m,3,2,-4);

m := matrix([[1, 3, 4], [-21, -6, 0], [5, 2, 1]])

> m:=addrow(m,3,1,-4);

m := matrix([[-19, -5, 0], [-21, -6, 0], [5, 2, 1]]...

> m:=addcol(m,3,2,-2);

m := matrix([[-19, -5, 0], [-21, -6, 0], [5, 0, 1]]...

> m:=addcol(m,3,1,-5);

m := matrix([[-19, -5, 0], [-21, -6, 0], [0, 0, 1]]...

> m:=addrow(m,2,1,-1);

m := matrix([[2, 1, 0], [-21, -6, 0], [0, 0, 1]])

> m:=addrow(m,1,2,6);

m := matrix([[2, 1, 0], [-9, 0, 0], [0, 0, 1]])

> m:=swaprow(m,1,2);

m := matrix([[-9, 0, 0], [2, 1, 0], [0, 0, 1]])

> m:=addcol(m,2,1,-2);

m := matrix([[-9, 0, 0], [0, 1, 0], [0, 0, 1]])

Now change the sign on -9 and move it to the bottom corner for strict SNF.

>