In mathematics, the Bareiss algorithm, named after
Erwin Bareiss, is an
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
to calculate the
determinant
In mathematics, the determinant is a Scalar (mathematics), scalar-valued function (mathematics), function of the entries of a square matrix. The determinant of a matrix is commonly denoted , , or . Its value characterizes some properties of the ...
or the
echelon form of a
matrix with
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
entries using only integer arithmetic; any
divisions that are performed are guaranteed to be exact (there is no
remainder
In mathematics, the remainder is the amount "left over" after performing some computation. In arithmetic, the remainder is the integer "left over" after dividing one integer by another to produce an integer quotient ( integer division). In a ...
). The method can also be used to compute the determinant of matrices with (approximated)
real entries, avoiding the introduction of any round-off errors beyond those already present in the input.
Overview
Determinant
In mathematics, the determinant is a Scalar (mathematics), scalar-valued function (mathematics), function of the entries of a square matrix. The determinant of a matrix is commonly denoted , , or . Its value characterizes some properties of the ...
definition has only multiplication, addition and subtraction operations. Obviously the determinant is integer if all matrix entries are integer. However actual computation of the determinant using the definition or
Leibniz formula is impractical, as it requires O(''n!'') operations.
Gaussian elimination
In mathematics, Gaussian elimination, also known as row reduction, is an algorithm for solving systems of linear equations. It consists of a sequence of row-wise operations performed on the corresponding matrix of coefficients. This method can a ...
has O(''n''
3) complexity, but introduces division, which results in round-off errors when implemented using floating point numbers.
Round-off errors can be avoided if all the numbers are kept as integer fractions instead of floating point. But then the size of each element grows in size exponentially with the number of rows.
Bareiss brings up a question of performing an integer-preserving elimination while keeping the magnitudes of the intermediate coefficients reasonably small. Two algorithms are suggested:
# Division-free algorithm — performs matrix reduction to triangular form without any division operation.
# Fraction-free algorithm — uses division to keep the intermediate entries smaller, but due to the
Sylvester's Identity the transformation is still integer-preserving (the division has zero remainder).
For completeness Bareiss also suggests fraction-producing multiplication-free elimination methods.
The algorithm
The program structure of this algorithm is a simple triple-loop, as in the standard Gaussian elimination. However in this case the matrix is modified so that each
entry contains the leading principal
minor []
. Algorithm correctness is easily shown by induction on .
* Input: — an -square matrix
assuming its leading principal minors []
are all non-zero.
* Let ''M''
0,0 1 (Note: ''M''
0,0 is a special variable)
* For from 1 to −1:
** For from +1 to :
*** For from +1 to :
**** Set
*** Set ''M''
i,k 0
* Output: The matrix is modified
in-place,
each
entry contains the leading minor []
,
entry contains the determinant of the original .
If the assumption about principal minors turns out to be false, e.g. if
−1,−1 = 0 and some
,−1 ≠ 0 ( = ,...,) then we can exchange the −1-th row with the -th row and change the sign of the final answer.
Analysis
During execution of the Bareiss algorithm, every integer that is computed is the determinant of a submatrix of the input matrix. This allows, using the
Hadamard inequality, to bound the size of these integers. Otherwise, the Bareiss algorithm may be viewed as a variant of
Gaussian elimination
In mathematics, Gaussian elimination, also known as row reduction, is an algorithm for solving systems of linear equations. It consists of a sequence of row-wise operations performed on the corresponding matrix of coefficients. This method can a ...
and needs roughly the same number of arithmetic operations.
It follows that, for an ''n'' × ''n'' matrix of maximum (absolute) value 2
''L'' for each entry, the Bareiss algorithm runs in
O(''n''3) elementary operations with an O(''n''
''n''/2 2
''nL'') bound on the absolute value of intermediate values needed. Its
computational complexity is thus O(''n''
5''L''
2 (log(''n'')
2 + ''L''
2)) when using elementary arithmetic or O(''n''
4''L'' (log(''n'') + ''L'') log(log(''n'') + ''L''))) by using
fast multiplication.
References
{{DEFAULTSORT:Bareiss Algorithm
Determinants
Numerical linear algebra
Exchange algorithms
Computer algebra