Linear Algebra

Smith Normal Form

Use integer row and column moves to reveal a matrix’s divisibility invariants.

By Riano · Published · Updated · Report a correction

Smith Normal Form

The Smith Normal Form (SNF) reveals the divisibility invariants of an integer matrix. Unlike eigenvalues, which involve roots and rational or real numbers, the SNF operates entirely within the integers. By using only unimodular row and column operations (operations that are invertible over the integers, corresponding to matrices with determinant ±1), any integer matrix A can be reduced to a diagonal matrixD.

Worked Example

Consider the "Full rank" matrix A = [2, 2; 4, 0]. We want to find invertible integer matrices U and V such that U A V = D, where D is diagonal and D1,1 divides D2,2.

  1. Start with D = A. The top-left element is 2.
  2. We clear the rest of the first row using column operations. Since 2 divides 2 (top right), we subtract 1 × Column 1 from Column 2. This updates D to [2, 0; 4, -4].
  3. Next, we clear the rest of the first column using row operations. Since 2 divides 4 (bottom left), we subtract 2 × Row 1 from Row 2. This updates D to [2, 0; 0, -4].
  4. We multiply Row 2 by -1 to ensure the invariants are positive. D is now [2, 0; 0, 4].
  5. Since 2 divides 4, the divisibility condition is satisfied. The invariants are 2 and 4. The determinant is the product of the invariants (up to sign), here 2 × 4 = 8, which corresponds to the magnitude of the original determinant -8.

Experiment

You can interactively explore the algorithm trace for various base matrices. Open the Smith Normal Form module to trace the integer transformations.

  1. Select the Matrix control and choose Coprime invariant.
  2. Observe the final invariants on the result cards. For this matrix, the invariants are 2 and 2, meaning the first invariant completely divides the second.
  3. Move the Trace step slider slowly from left to right to see how the unimodular row operations (U) and column operations (V) are accumulated to clear the off-diagonal entries while preserving the integer lattice structure.
  4. Change the Matrix to Rank one. Notice that the second invariant becomes 0, indicating a drop in rank over the integers.

Limitations

This module is designed strictly for 2 × 2 integer matrices. While the Smith Normal Form algorithm generalizes to matrices of any dimension and over any Principal Ideal Domain (PID), such as polynomials over a field, the interactive tracing here is bounded to two dimensions for visual clarity and straightforward layout on the canvas. The transformation lattice illustrates only two dimensions.

References

The SageMath documentation serves as a robust primary reference for computational linear algebra over the integers.

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Smith Normal Form module.

Try Smith Normal Form on Riano →

More in Linear Algebra