Montante's method
From Wikipedia, the free encyclopedia
Montante's Method is a linear algebra method to calculate solutions to systems of linear equations, and finding matrix inverses, adjoints and determinants. It is named after its discoverer René Mario Montante.
Its main feature is working exclusively using integer arithmetic for integer matrices, which allows for exact results in computer implementations.
[edit] History
The method was developed in 1973 by René Mario Montante Pardo, from the Department of Mechanical and Electric Engineering of the Universidad Autónoma de Nuevo León, in Monterrey,México.
[edit] Method
The method is pivot-based, working through the matrix main diagonal and rewriting the matrix iteratively by using 2x2 determinants based on elements and pivot rows and columns. If the original matrix is integer, the method works using integers until the final step, yielding at worst rational results.
This is a pseudo-code implementation of a linear system solver for Ax = B using Montante's method:
Algorithm MontanteLinearSolver Input: An nxn+1 matrix M holding . Output: An nxn+1 matrix holding where In is the identity matrix of order n d is a scalar and is the solution p0 ← 1 foreach t in 1 .. n pt ← mtt foreach i in 1 .. n except t foreach j in t+1 .. n mij ← ( pt * mij - mit * mtj ) / pt-1 mkt ← 0 forall k ≠ t mkk ← p forall k ≤ t return M
- "←" is a loose shorthand for "changes to". For instance, "largest ← item" means that the value of largest changes to the value of item.
- "return" terminates the algorithm and outputs the value that follows.
And an implementation in Ruby
def montante_solve( a ) nr = a.size nc = nr+1 # a must be n x n+1 m = Array.new # work on a copy (0 ... nr).each do |k| m[k] = Array.new(a[k]) end p_pre = 1 # The previous pivot for t in ( 0 ... nr ) do p = m[t][t] # The current pivot (0 .. t).each do |k| m[k][k] = p end for i in 0 ... nr do for j in (t+1) ... nc do m[i][j] = ( p * m[i][j] - m[i][t] * m[t][j] ) / p_pre if i!=t end end p_pre = p (0 ... nr).each do |k| m[k][t] = 0 end end return m end a = [ [2,-1,-3, 1, 3], [1, 1,-2,-2, 2], [3,-2, 1,-1,-2], [1,-1, 1, 3, 1] ] p montante_solve( a )
[edit] Walkthrough
Given the following linear equation system with integer coefficients
The augmented matrix (including the results column) is:
First iteration: keep the first row (pivot row) as-is and zero-out all but the first elements in the pivot column;
The current pivot p1 = 2 at a11 (the upper-leftmost cell), and the "previous" pivot p0 is 1.
Each of the elements in the rest of the matrix (except the pivot row and pivot column) are obtained by the formula
Thus
Second iteration: the new pivot is p2 = 3 at
Keep the second (pivot) row as-is, zero-out the second column except the diagonal element, replace all previous pivot elements with p2. Then apply the determinant formula to the remaining elements, which form a submatrix holding columns 3 to 5 and lines 1, 3 and 4.
Third iteration: as before, with pivot p3 = 16 at .
Fourth iteration:
The solution to system (1) is then: