Fraction-free elimination
- Cost
- ring operations for an matrix of rank ; over with -bit entries the operands have bits, giving word operations for an matrix.
Let be an integral domain, such as , or , and an matrix over . Gaussian elimination over the fraction field creates quotients whose numerators and denominators grow; removing common factors needs gcd computations, which are expensive or unavailable. Fraction-free elimination keeps all entries in , uses only exact divisions, and bounds every intermediate entry by a minor of [Bar1968; NakTurWil1997]. It is the method of choice for small matrices over and for matrices over polynomial rings, where modular methods are less developed.
Generic version#
gr_mat_fflu implements the algorithm below over any ring with exact division, and gr_mat_det_fflu, gr_mat_rank_fflu, gr_mat_nonsingular_solve_fflu, gr_mat_nonsingular_solve_den_fflu and gr_mat_rref_den_fflu build on it. The specialised versions are separate implementations with the same structure:
fmpz_mat_ffluover chooses the first nonzero pivot, and while the entries fit in a word computes the updates in two-word arithmetic with a precomputed inverse of the previous pivot;fmpz_poly_mat_ffluandnmod_poly_mat_ffluover and choose, among the nonzero entries of the column, one of least degree and, over , with the smallest coefficients (fmpz_poly_mat_find_pivot_partial), which keeps the entries small;ca_mat_ffluover exact real and complex numbers chooses pivots with zero tests that may fail (linear algebra over exact numbers).
Bareiss' algorithm#
Input: .
Output: the rank , a row permutation, and the matrix described below; den .
- , , (pivot row), (column).
While and :
- find a row with ; if there is none, and continue; otherwise swap rows and ;
- , ;
- for all and : ;
- , .
- Return .
The divisions in step 2.3 are exact. This follows from Sylvester's identity.
Theorem 1. Assume that no row exchanges are needed and that the pivot columns are . After the pivots have been processed, for ,
the minor of formed by the leading rows and columns bordered by row and column . In particular is the leading principal minor of .
Proof. By induction on ; for the claim is . Suppose it holds before pivot is processed, and let be the leading submatrix of , with (1 if ), and . The four minors of that contain are, by induction, , , and , and Sylvester's determinant identity states
Hence the update of step 2.3 produces , which is the claim for .
With row exchanges, the same holds for the row-permuted matrix, and with skipped columns for the matrix restricted to the pivot columns and the column . Consequently every intermediate entry is a minor of : over it is bounded by Hadamard's inequality (Bounds), with about bits for -bit entries, and over its degree is at most times the largest degree. Gaussian elimination over without gcds would instead produce entries whose sizes grow exponentially with .
For a nonsingular matrix, the last pivot is , so fmpz_mat_det_bareiss returns den with the sign of the permutation. Each of the updates costs two multiplications and one exact division of minors, so over the cost is word operations for an matrix, that is with classical integer multiplication. This is competitive with the modular methods of Multimodular and p-adic linear algebra over the integers only for small (FLINT's crossovers are to 25).
The fraction-free LU decomposition#
FLINT stores the result in place, like an LU decomposition: the upper part of , from the pivot of each row on, holds the fraction-free echelon form , and below each pivot the entries of column are kept as they were when was chosen (step 2.3 does not change column ). Let be the lower triangular matrix formed by these columns, with the pivots on its diagonal.
Proposition 2. For a nonsingular matrix with row permutation ,
This is the fraction-free LU decomposition of [NakTurWil1997; Jef2010]. For the example of Example, with pivots , one checks .
Solving#
To solve for nonsingular , fmpz_mat_solve_fflu_precomp applies to the same fraction-free updates as step 2.3 (forward substitution: the column of the right-hand side is updated like a column of ), which yields the last column of the elimination of the augmented matrix , and then performs back substitution
where is the transformed right-hand side. The result is , which is integral by Cramer's rule since , so all divisions are exact. fmpz_mat_solve_fflu then fixes the sign, returning . For a rank-deficient the same procedure, with the non-pivot unknowns set to zero, either produces a candidate or meets an inexact division and reports failure; fmpz_mat_can_solve_fflu then checks the remaining equations exactly.
Reduced echelon form#
Let the first rows of the echelon form be up to a permutation of the columns, where is the upper triangular matrix of pivot columns, with the pivots on its diagonal. The reduced echelon form over the fraction field is in the original column order. Since is obtained from the pivot rows of by invertible row operations, , and is integral by Cramer's rule. fmpz_mat_rref_fflu and fmpz_poly_mat_rref compute it by back substitution with exact divisions by the pivots, one non-pivot column at a time, and set the pivot columns to times unit vectors. This is fraction-free Gauss–Jordan elimination [NakTurWil1997] restricted to the non-pivot columns, which are all that change.
Use in FLINT#
Referenced from#
- Linear algebra over exact numbers (algorithm)
- Gaussian elimination and LU decomposition (algorithm)
- Lattice reduction (LLL) (algorithm)
- Multimodular and p-adic linear algebra over the integers (algorithm)
- Linear algebra over generic rings and its specialisations (overview)
- Matrices of polynomials (algorithm)
- Computing determinants
fmpz_mat_fflu- Fraction-free elimination and echelon forms
- Solving linear systems over the rationals
- Determinants of polynomial matrices
- fmpz_poly_mat.h (module)
fmpz_poly_mat_fflu- LU decompositions and linear systems
nmod_poly_mat_fflu
References#
- [Bar1968] E. H. Bareiss, "Sylvester's identity and multistep integer-preserving Gaussian elimination", Mathematics of Computation 22 (1968), 565–578. https://doi.org/10.1090/S0025-5718-1968-0226829-0
- [NakTurWil1997] Nakos, George and Turner, Peter and Williams, Robert : Fraction-free algorithms for linear and polynomial equations, ACM SIGSAM Bull. 31 (1997) 3 11–19
- [Jef2010] D. J. Jeffrey, "LU factoring of non-invertible matrices", ACM Communications in Computer Algebra 44:1 (2010), 1–8. https://doi.org/10.1145/1838599.1838602
The FLINT team, “Fraction-free elimination,” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/algorithms/linear-algebra/fraction-free.html (generated 2026-11-02).
@misc{flint-doc-algorithms-linear-algebra-fraction-free,
author = {{The FLINT team}},
title = {{Fraction-free elimination}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/algorithms/linear-algebra/fraction-free.html},
note = {Generated 2026-11-02}
}