Algorithms for the Computing Determinants in Commutative Rings
aa r X i v : . [ c s . S C ] N ov Algorithms for the Computing Determinants inCommutative Rings ∗ Gennadi I. Malaschonok
Abstract
Two known computation methods and one new computation method for matrixdeterminant over an integral domain are discussed. For each of the methods weevaluate the computation times for different rings and show that the new methodis the best.
Among the set of known algorithms for the determinant computation, there is asubset, which allows us to carry out computations within the commutative ringgenerated by the coefficients of the system. Recently, interest in these algorithmsgrew due to computer algebra computations. These algorithms may be used (a) tofind determinant of the matrix with numerical coefficients, (b) to find determinantof the matrix over the rings of polynomials with one or many variables over theintegers or over the reals, (c) to find determinant of the matrix over finite fields andetc.The first effective method for calculation of the matrix determinant with numer-ical coefficients was introduced by Dodgson [1]. Further this method was used in[2] – [4]. Another method (one-pass method) was proposed by the author [5].Here will be proposed more effective combined method for calculation of thematrix determinant over an integral domain.Let A = ( a ij ), i = 1 . . . n, j = 1 . . . n , be the given matrix of order n over anintegral domain R . δ k = | a ij | , i, j = 1 . . . k, k = 1 . . . n, denote corner minors of the matrix A of order k , δ kij denotes minors obtained aftera substitution in the minors δ k of the column i for the column j of the matrix A , k = 1 . . . n , i = 1 . . . k , j = 1 . . . n .We examine these three algorithms, assuming that all corner minors δ k , k =1 . . . n −
1, of the matrix A are different from zero and zero divisors. For each of thealgorithms we evaluate: ∗ This is English version of the paper in: Diskretnaya Matematika, , No.4, 1995, 68–76. .The general computing time, taking into consideration only arithmetic operationsand assuming moreover, the execution time for multiplication, division and addi-tion/subtraction of two operands, the first of which is a minor of order i and thesecond one, a minor of order j , will be M ij , D ij , A ij correspondingly.2. The exact number of operations of multiplications, division and addition/subtrac-tion over the matrix coefficient.3. The number of operations of multiplication/division (M), when R = R [ x . . . x r ]is a ring of polynomials with r variables with real coefficients and only one computerword is required for storing any one of the coefficients.4. The number of operations of multiplication/division ( M Z ), when R = Z [ x . . . x r ]is a ring of polynomials with r variables with integer coefficients and these coefficientare stored in as many computer words as are needed.5. The number of operations of multiplication/division ( M M ), when R = Z [ x . . . x r ]is a ring of polynomials with r variables with integer coefficients, but for computa-tion the modular method is applied, which is based on the remainder theorem. Dodgson’s algorithm [1], [2] consists of n − a ij = a a ij − a j a i , i = 2 . . . n, j = 2 . . . m, which surround the corner element a . At the k -th step, k = 2 . . . n −
1, andaccording to the formula a k +1 ij = ( a kkk a kij − a kik a kkj ) /a k − k − ,k − ,i = k + 1 . . . n, j = k + 1 . . . m, all the minors a k +1 ij of order k + 1 are computed, which are formed by surroundingthe corner minor δ k by row i and column j , that is the minors which are formed bythe elements, located at the intersection of row 1 . . . k, i and of columns 1 . . . k , j .Obviously, a nnj = δ nnj , j = n . . . m , holds.Corner minors δ k = a kkk , k = 1 . . . n − , must be different from zero and zerodivisors. In order to do so, they can be controlled by choice of the pivot row orcolumn.Let us evaluate the computing time of the algorithm T D = n − X k =1 T Dk .T D = ( n − (2 M + A ), T Dk = ( n − i ) (2 M k,k + A k, k + D k,k − ), k = 2 . . . n − T Dk denote the computing time of the k step for Dodgson’s algorithm. One-pass algorithm
Dodgson’s algorithm makes zero elements under the main diagonal of the matrix.One-pass algorithm [5] makes diagonalisation of the coefficient matrix minor-by-minor and step-by-step.This algorithm consists of n − δ j = a a j − a a j , j = 2 . . . n, δ j = a j a − a j a , j = 3 . . . n. In the k -th step, k = 2 . . . n − , the minors of order k + 1 are computed accordingto the formulae δ k +1 k +1 ,j = a k +1 ,k +1 δ kkk − k X p =1 a k +1 ,p δ kpj , j = k + 1 . . . n,δ k +1 ij = δ k +1 k +1 ,k +1 δ ki,j − δ k +1 k +1 ,j δ ki,k +1 δ kk,k , i = 1 . . . k, j = k + 2 . . . n. In this way, at the k -th step the coefficients of the first k + 1 rows of the matrix takepart. Corner minors δ k can be controlled by the choice of the pivot row or column.The general computing time of the one-pass algorithm is T D = (2 n − M , + A , ) ,T Dk = ( n − k )(( k +1) M k, + kA k +1 ,k +1 )+ k ( n − k − M k,k +1 + A k +1 , k +1 + D k +1 ,k ) ,k = 2 , . . . , n − , T D = P n − k =1 T Dk .T Ok denote the computing time of the k step for one-pass algorithm. We can get more effective algorithm if we will combine one-pass algorithm (it willbe first part) and Dodgson’s algorithm (it will be the second part).We shell make diagonalisation of the first part (upper part) of the matrix andthen we shall make zero elements under the main diagonal of the second part (lowerpart) of the matrix.In the first part we will execute r − δ j = a a j − a a j , j = 2 . . . n,δ j = a j a − a j a , j = 3 . . . n. In the k -th step, k = 2 . . . r − , the minors of order k + 1 are computed δ k +1 k +1 ,j = a k +1 ,k +1 δ kkk − k X p =1 a k +1 ,p δ kpj , j = k + 1 . . . n, k +1 ij = δ k +1 k +1 ,k +1 δ ki,j − δ k +1 k +1 ,j δ ki,k +1 δ kk,k , i = 1 , . . . k, j = k + 2 . . . n. Then, in the r step, we can compute all minors a r +1 ij of the order r + 1 , whichare formed by surrounding the corner minor δ rrr of order r by row i and column j ( i > r, j > r ) δ r +1 i,j = a i,r +1 δ rrr − r X p =1 a i,p δ rpj , i, j = r + 1 , . . . , n. In the second part we will execute last n − r − a k +1 ij = a kkk a kij − a kik a kkj a k − k − ,k − , k = r + 2 . . . n − , i, j = k + 1 , . . . , n. Obviously, a kkk = δ k , k = 2 . . . n , holds and a kkk is the matrix determinant.Here we have n − r maybe equal to 2 , , . . . , n − . We will have one-pass algorithm if r will be equal n − . The computing time of this algorithm is T = n − X k =1 T k T r = ( n − r ) (( r + 1) M r, + rA r +1 ,r +1 ) , T k = T Ok for k = 1 . . . r − T k = T Dk for k = r + 1 . . . n − T Ok and T Dk denote the computing time of the k -th step forone-pass algorithm and Dodgson’s algorithm correspondingly. We have now n − N m , divisions N d and additions/subtractions N a , which are neces-sary for calculation of the matrix determinant. Moreover, we will not make anyassumptions regarding the computational complexity of these operations; that iswe will consider that during the execution of the whole computational process, allmultiplications of the coefficients are the same, as are the same all divisions and alladditions/subtractions.The quantity of operations, necessary for Combined algorithm with arbitrary r will be N ra = (2 n − n + n ) / ,N rm = (4 n − n − r + 9 r n − rn − rn + 4 r ) / ,N rd = (2 n − n − n + 12 − r + 9 r n − r − rn + 3 rn + r ) / . t is easy to see, the most effective algorithm is combined algorithm with r = n/ n is odd and r = ( n + 1) / n is even ( n > N m N d Dodgson’s (4 n − n + 2 n ) /
6) (2 n − n + 13 n − / n − n ) / n − n − n + 12) / n − n − (8 + 3 v ) n + 6 v ) /
24 (3 n − n − (18 − v ) n + r = ( n + v ) / − v ) / v = 0 if n is odd and v = 1 if n is even ( n > N a ) operations is the same for these three algorithms N Da = N Oa = N Ca = (2 n − n + n ) / . If we evaluate quantity of operations, considering only the third power, then weobtain the evaluation N Dm : N Om : N Cm = 16 : 12 : 11, N Dd : N Od : N Cd = 8 : 4 : 3 . If we evaluate according to the general quantity of multiplication and divi-sion operations, considering only the third power, then we obtain the evaluation12 n /
12 : 8 n /
12 : 7 n / . So, according to this evaluation, combined algorithm is to be preferred. [ x . . . x s ] Let R be the ring of polynomials of s variables over an integral domain and let ussuppose that every element a ij of the matrix A is a polynomial of degree p in eachvariable a ij = p X u =0 p X v =0 . . . p X w =0 a uv...w x u x v . . . x wr . Then it is possible to define, how much time is required for the execution of thearithmetic operations over polynomials which are minors of order i and j of thematrix AA ij = ( jp + 1) s a ij ,M ij = ( ip + 1) s ( jp + 1) s ( m ij + a i + j,i + j ) ,D ij = ( ip − jp + 1) s ( d ij + ( jp + 1) s ( m i − j,j + a ii )) . Here we assume, that the classical algorithms for polynomial multiplication anddivision are used. And besides, we consider that the time necessary for executionof the arithmetic operations of the coefficients of the polynomials is m ij , d ij , a ij ,for the operations of multiplication, division and addition/subtraction, respectively,when the first operand is coefficient of the polynomial, which is a minor of order i ,and the second – of order j .Let us evaluate the computing time for each of the n − n one computer word. We will assume that a ij = 0 , m ij = d ij = 1 , A ij = 0, M ij = i s j s p s , D ij = ( i − j ) s j s p s , P n − k =1 i p = n p +1 / ( p + 1) − n p / O ( n p − ), andwe will consider only the leading terms in n and r : M ( r ) = 3 p s (cid:18) n s +3 (2 s + 1)(2 s + 2)(2 s + 3) − r s (cid:18) r s + 3 − r n + s + 12 s + 2 + nr n + 12 s + 72 s + 1 − n (cid:19)(cid:19) We have M D = M ( r ) for r = 0, M O = M ( r ) for r = n , M O = M D (2 s + 1) / .M O and M D denote the computing time for one-pass algorithm and Dodgson’salgorithm.It is easy to see, the most effective algorithm is combined algorithm with r best = n/ − s/ O ( n − ). For n, r >> s > r best = n/ [ x . . . x s ] , standard case As before we suppose that every coefficient of the matrix is a polynomial. However,the coefficients of these polynomials are now integers and each one of these coeffi-cients a ijuv...w is stored in l computer words. Then, the coefficients of the polynomial,which is a minor of order i , are integers of length il of computing words.Under the assumption that classical algorithms are used for the arithmeticoperations on these long integers, we obtain: a ij = 2 jla , m ij = ijl ( m + 2 a ), d ij = ( il − jl + 1)( d + jl ( m + 2 a )), where a, m, d - are the execution time of thesingle-precision operations of addition/subtraction, multiplication, and division.Assuming that a = 0 , m = d = 1 , we obtain the following evaluation of the exe-cution times of polynomial operations: M ij = ijl ( ijp ) s , D ij = ( i − j ) s +1 j s +1 l p s , A ij = 0 . In this way, the evaluation of the computing time will be the same as that forthe ring R = R [ x , x . . . x s ], if we replace everywhere s by s + 1 and p s by lp s .Therefore, the most effective algorithm is combined algorithm with r best = n/ − s/ / O ( n − ) . For n, r >> s > r best = n/ [ x . . . x s ] , modular case Let us evaluate the time for the solution of the same problem, for the ring ofpolynomials with s variables with integer coefficients R = Z [ x . . . x s ], when themodular method is applied – based on the remainder theorem. In this case wewill not take into consideration the operations for transforming the problem in themodular form and back again. t suffices to define the number of moduli, since the exact quantity of operationson the matrix elements for the case of a finite field has already been obtained insection 5.We will consider that every prime modulus m i is stored in exactly one computerword, so that, in order to be able to recapture the polynomial coefficients, whichare minors of order n , the n ( l + log( np ) / m i ) moduli are needed, what is easyto see due to Hadamar’s inequality.Further, we need up moduli for each unknown x j , which appears with maxi-mal degree np . There are s such unknowns, and therefore, in all, µ = psn ( l +log( np ) / m i ) moduli are needed.If we now make use of the table in section 4, denote the time for modularmultiplication by m and the time for modular division by d , then not consideringaddition/subtraction and considering only leading terms in n , we obtain : M DM = (16 m + 8 d ) ν, M OM = (12 m + 4 d ) ν, M CM = (11 m + 3 d ) ν, where ν = µn / . We see, Dodgson’s method is better than the one-pass method for non-modularcomputation in polynomial rings, and one-pass method is better than Dodgson’smethod in other cases, but combined method with r = n/ References [1]
C. L. Dodgson.
Condensation of determinants, being a new and brief methodfor computing their arithmetic values,
Proc. Royal Soc. Lond.
A. 15 , 1866,150–155.[2]
F.V. Waugh, P.S. Dwyer.
Compact computation of the inverse of a matrix ,The Annals of Math. Statistics, V. , N 3, 1945, 256 - 271.[3] E. H. Bareiss.
Sylvester’s Identity and Multistep Integer-Preserving GaussianElimination , Math. Comp. (103), 1968, 565–578.[4] G. I. Malaschonok.
On the solution of a linear equation system over commu-tative rung,
Math. Notes of the Acad. Sci. USSR,
Vol. 42,
N.4, 1987, 543–548.[5]
G. I. Malaschonok.
A new solution method for linear equation systems overthe commutative ring , Int. Algebraic Conf., Theses on the ring theory, algebrasand modules, Novosibirsk, Aug. 21-26, 1989, 82., Int. Algebraic Conf., Theses on the ring theory, algebrasand modules, Novosibirsk, Aug. 21-26, 1989, 82.