Advanced maths

Hermite normal form calculator for an integer matrix

Compute an exact column Hermite normal form, retaining a full unimodular transformation and explicit treatment of rank-deficient integer generators.

Your numbers

Columns are lattice generators. Use 1–6 equal-length rows and 1–6 columns, with integer entries within ±10⁶.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Hermite normal form gives a canonical basis for the integer column lattice generated by a matrix. This page uses integer column operations, processing pivots from the lower rows upward and reducing entries to the right of each positive pivot. It retains the complete unimodular transformation U, so the original generator matrix can be multiplied by U to reproduce the full transformed matrix. Leading zero columns are removed only from the compact H output, not from the transformation evidence.

THE FORMULAA*U=[0 | H], where U is an integer unimodular matrix and H contains the independent column-lattice generators in column Hermite convention.

A worked example

For A=[[2,4,6],[1,2,3]], every column is an integer multiple of (2,1). The column lattice therefore has rank one, and H is the single column [[2],[1]]. There are two leading zero columns in A*U. Rational row reduction could detect the same rank, but would not by itself establish which integer vectors generate exactly the original lattice or provide a unimodular column transformation.

Good to know

Accepts integer matrices with 1–6 rows and columns and input entries within ±10⁶. Rectangular and rank-deficient matrices are supported, including an all-zero matrix with rank zero. Intermediate integer entries are bounded by 512 bits. The convention is column HNF with a full square right transformation U; a row-HNF convention may produce a different-looking matrix. This is not a Smith invariant-factor calculation or a real-valued numerical matrix factorization.

Unimodular operations preserve integer combinations in both directions

A square integer matrix is unimodular when its determinant is +1 or −1. Its inverse is also integral, so multiplying the generator matrix by it preserves the lattice of integer column combinations in both directions. An arbitrary invertible rational transformation would preserve a rational span but could change the integer lattice. For example, dividing a generator by two can add points that were never present in the original integer combinations.

The algorithm records swaps, integer reductions and two-column GCD combinations. It checks A*U exactly and checks det(U)=±1 before returning the result. When some original columns are dependent, zero columns appear at the front of the full transformed matrix. The remaining columns form H, and the number of those columns is the lattice rank. The full transformation still has the original number of columns, so no discarded dependency is hidden by changing U’s dimensions.

Three dependent column generators collapse to one canonical integer lattice generatorA: (2,1),(4,2),(6,3)H: (2,1)A·U = [0 | 0 | H]Rank 1; det(U) = ±1
The columns (2,1), (4,2), (6,3) generate the same rank-one lattice as (2,1). The full unimodular column transformation creates two leading zero columns, while H retains the independent column (2,1).

The LLL lattice basis reduction calculator with steps preserves an integer row lattice while seeking a reduced basis; unlike Hermite form, that basis is not canonical.

The declared side and pivot convention are part of the answer

Some references use row generators and left multiplication instead. Transposing a problem can relate these viewpoints, but comparing the raw displayed matrices without checking conventions can make two correct calculations appear inconsistent. This page labels its columns as generators, uses positive pivots and reduces the appropriate right-side entries into their pivot residue ranges. The independent reference fixtures use that same canonical column convention.

Smith normal form permits transformations on both sides and exposes invariant factors of an integer module. Hermite form preserves a different one-sided relation and therefore answers a different question. Likewise, a numerical orthogonal basis may describe a real subspace accurately while failing to generate the same integer points. Use the compact H for a canonical generator basis and the full A*U record to inspect the exact integer equivalence, especially when the input rank is deficient.

A few questions, answered

What is returned for an all-zero matrix?

The rank is zero and H has no independent columns. The full transformed matrix remains zero and U remains an inspectable unimodular transformation of the original column count.

Can fractions be entered as matrix entries?

No. This page studies an integer lattice. Scaling a rational matrix to integers changes the coordinate scale and should be done explicitly before interpreting its lattice.

Find your calculator

Start typing to explore the library.