Finding the correct pivot in Smith normal form

In Wikipedia's example of SNF$(xI-A)$, the purpose is to determine whether two matrices over a field are similar by computing the Smith normal forms of their characteristic matrices. The field might, for example, be the rational numbers. In that case, the elements of the characteristic matrix live in the ring of polynomials with rational coefficients. The units in this ring, i.e. the elements that have inverses, are the nonzero rational numbers. So in this case you are allowed to multiply rows or columns by nonzero rational numbers. You just can't multiply rows or columns by polynomials of nonzero degree, since they don't have inverses in the ring. But you would be allowed, for example, to multiply row 1 of the matrix by $1/2$. Then, by adding a suitable multiple of column 2 to column 1, and a suitable multiple of row 1 to row 2, you can obtain the result Wikipedia gives, up to permutation.

In general, the operations you are allowed to do are

  1. Permute rows.
  2. Multiply a row by a unit (invertible element) of the ring. (In the ring of integers this means only $\pm1$, but in a ring of polynomials over a field, it could be any nonzero field element.)
  3. Add a multiple of an row to another row.
  4. Do any of the corresponding column operations.

Note that you cannot always clear the first row and column in a single pass. In a Euclidean domain, you can, by suitable row operations, bring the GCD of the first column into the (1,1) position and clear the remainder of the column. Then by suitable column operations, you can bring the GCD of the first row into the (1,1) position and clear the remainder of the row. But at that point the first column may no longer be cleared, so you may have to repeat the process. It is guaranteed that, in finitely many steps, you will end up with both the first row and column cleared. (Think about why.) By an iterative process, you eventually reach diagonal form. The diagonal elements may not satisfy the divisibility requirements of the SNF, however. That can always be fixed by suitable operations involving pairs of diagonal elements. For example, $$ \begin{aligned} \begin{bmatrix} 18 & 0\\0 & 30 \end{bmatrix}&\sim \begin{bmatrix} 18 & 18\\0 & 30 \end{bmatrix}\sim \begin{bmatrix} 18 & 18\\-18 & 12 \end{bmatrix}\sim \begin{bmatrix} 36 & 18\\-6 & 12 \end{bmatrix}\sim \begin{bmatrix} 0 & 90\\-6 & 12 \end{bmatrix}\sim \begin{bmatrix} 0 & 90\\-6 & 0 \end{bmatrix}\\ &\sim\begin{bmatrix} -6 & 0\\0 & 90 \end{bmatrix} \sim\begin{bmatrix} 6 & 0\\0 & 90 \end{bmatrix} \end{aligned} $$


To answer your Question 1: We don't divide by $2$ or any other non-unit in $\mathbb{Z}$ because division by $2$ is not a $\mathbb{Z}$-map from $\mathbb{Z}$ to itself. In fact, we are not permitted to multiply by a non-unit as well, because multiplication by $m$ is not an invertible $\mathbb{Z}$-map unless $m = \pm 1$.

Your SNF computation seems fine, and you get the correct invariant factors.