On the Extension of Sarrus’ Rule to n × n (n > 3) Matrices: Development of New Method for the Computation of the Determinant of 4 × 4 Matrix
Abstract
The determinant of a matrix is very powerful tool that helps in establishing properties of matrices. Indisputably, its importance in various engineering and applied science problems has made it a mathematical area of increasing significance. From developed and existing methods of finding determinant of a matrix, basketweave method/Sarrus’ rule has been shown to be the simplest, easiest, very fast, accurate, and straightforward method for the computation of the determinant of 3 × 3 matrices. However, its gross limitation is that this method/rule does not work for matrices larger than 3 × 3 and this fact is well established in literatures. Therefore, the state-of-the-art methods for finding the determinants of 4 × 4 matrix and larger matrices are predominantly founded on non-basketweave method/non-Sarrus’ rule. In this work, extension of the simple, easy, accurate, and straightforward approach to the determinant of larger matrices is presented. The paper presents the developments of new method with different schemes based on the basketweave method/Sarrus’ rule for the computation of the determinant of 4 × 4. The potency of the new method is revealed in generalization of the basketweave method/non-Sarrus’ rule for the computation of the determinant of n × n (n > 3) matrices. The new method is very efficient, very consistence for handy calculations, highly accurate, and fastest compared to other existing methods.
1. Introduction
Over the years, the subject, linear algebra has been shown to be the most fundamental component in mathematics as it presents powerful tools in wide varieties of areas from theoretical science to engineering, including computer science. Its important role and abilities in solving real life problems and in data clarification [1] have led it to be frequently applied in all the branches of science, engineering, social science, and management. During the applications and analysis in such areas of studies, a system of linear equations can be written in matrix form and solving the system of linear equations and the inversion of matrices is necessary which is mainly dependent on determinant (a real number or a function of the elements of an n × n matrix that yields a single number that well determines something about the matrix). Therefore, the importance of finding the determinant in linear algebra cannot be overemphasized as it does not only help in finding solution to systems of linear equations but it also helps determine whether the system has a unique solution and helps establish relationship and properties of matrices. Undoubtedly, the computation of such single number called the determinant is fundamental in linear algebra. It is one of the basic concepts in linear algebra which has major applications in various branches of engineering and applied science problems such as in the solutions systems of linear equations and also in finding the inverse of an invertible matrix. Also, many complicated expressions of electrical and mechanical systems can be conveniently handled by expressing them in “determinant form.” Therefore, it has become a mathematical area of increasing significance as the computation of the determinant of an n × n matrix A of numbers or polynomials is a classical problem and challenge for both numerical and symbolic methods. Consequently, various direct and nondirect methods such as butterfly method, Sarrus’ rule, triangle’s rule, Gaussian elimination procedure, permutation expansion or expansion by the elements of whatever row or column, pivotal or Chio’s condensation method, Dodgson’s condensation method, LU decomposition method, QR decomposition method, Cholesky decomposition method, Hajrizaj’s method, and Salihu and Gjonbalaj’s method [1–35] have been proposed for finding the determinant of n × n matrices. In the gamut of the methods or rules for finding the determinant of the n × n matrices, Sarrus’ rule (a method of finding the determinant of 3 × 3 matrices named after a French mathematician, Pierre Frédéric Sarrus (1798–1861)) has been shown to be the simplest, easiest, fastest, and very straightforward method. Although the wide range of applications of the rule for the computation of the determinant of 3 × 3 matrices is well established, it is grossly limited in applications since it cannot be used for finding the determinants of 4 × 4 matrices and larger matrices. Moreover, the combined idea of finding determinant of 2 × 2 matrices using butterfly method which is the conventional idea in all literatures and using Sarrus’ rule for finding the determinant of 3 × 3 matrices is termed basketweave method. However, the basketweave method does not work on matrices larger than 3 × 3 [1]. Therefore, for larger matrices, the computations of determinants are carried out by methods such as row reduction or column reduction, Laplace expansion method, Dodgson’s condensation method, Chio’s condensations, triangle’s rule, Gaussian elimination procedure, LU decomposition, QR decomposition, and Cholesky decomposition. However, these methods are not as simple, easy, fast, and very straightforward as basketweave method/Sarrus’ rule. Additionally, the cost of the computation of the determinant of a matrix of order n is about 2n3/3 arithmetic operations using Gauss elimination; if the order n of the matrix is large enough, then the computation is not feasible. Therefore, Rezaifar and Rezaee [1] developed a recursion technique to evaluate the determinant of a matrix. In their quests for establishing a new scheme for the generalization of Rezaifar and Rezaee’s procedure, Dutta and Pal [36] pointed out the limitation of Rezaifar and Rezaee’s procedure as it fails to evaluate the values of the determinants of matrices in some cases. Therefore, in this paper, a new method using different schemes based on Sarrus’ rule was developed to carry out the computation of the determinant of 4 × 4 matrices. The developed method is shown to be very quick, easy, efficient, very usable, and highly accurate. It creates opportunities to find other new methods based on Sarrus’ rule to compute determinants of higher orders. Also, the new approach has been shown to be applicable to the computation of determinants of larger matrices such as 5 × 5, 6 × 6, and all other n × n (n > 6) matrices.
2. Definition of Determinants
The determinant of n × n matrix square matrix A = [aij] is a real number or a function of the elements of the matrix which well determines something about the matrix. It determines whether the system has a unique solution and whether the matrix is singular or not.
The determinant of an n-order matrix will be called sum, which has n! different terms which will be formed of matrix A elements.
3. Existing Methods of Computation of Determinants
The easiest way to find the determinant of a matrix is to use a computer program which has been optimized so as to reduce the computational time and cost, but there are several ways to do it by hand [37–43]. Therefore, the computation of determinants of matrices has been carried out by some existing methods in literature such as basketweave method, butterfly method, Sarrus’ method, triangle’s rule, Gaussian elimination procedure, permutation expansion or Laplace expansion by the elements of whatever row or column, row reduction method, column reduction method, pivotal or Chio’s condensation method, Dodgson’s condensation method, LU decomposition method, QR decomposition method, Cholesky decomposition method, Hajrizaj’s method, Salihu and Gjonbalaj’s method, Rezaifar and Rezaee’s method, and Dutta and Pal’s method. The simplest among these methods is the basketweave method which could be stated as the combination of butterfly method for determinant computation of 2 × 2 matrices and Sarrus’ rule for determinant computation of 3 × 3 matrices.
3.1. The Butterfly Method
Example 1. Evaluate :
3.2. Sarrus’ Method
Example 2. Evaluate :
The use of Laplace cofactor expansion along either the row or column is a common method for the computation of the determinant of 3 × 3, 4 × 4, and 5 × 5 matrices. The evaluation of the determinant of an n × n matrix using the definition involves the summation of n! terms, with each term being a product of n factors. As n increases, this computation becomes too cumbersome. This drawback is not only peculiar to Laplace cofactor expansion method as other common methods developed in literatures also required additional computational cost and time for the computation of determinant. Therefore, in recent times, different techniques have been devised in literatures. However, these techniques are not as simple, easy, fast, and very straightforward as the basketweave method/Sarrus’ rule. Additionally, many of them come with relatively high computational cost and time.
4. The Development of the New Methods for the Computation of Determinants
Following the procedure, we have 4 × 4 matrices.
- (1)
In the first submatrix Afp, rewrite the 1st, 2nd, and 3rd columns on the right-hand side of matrix Afp (as columns 5, 6, and 7). To the resulting 4 × 7 augmented matrix, assign “+” to the leading element in the odd numbered columns and assign “−” sign to the leading element in the even numbered columns. This gives
() -
This is the first part of the solution of the computation of determinant of the given 4 × 4 matrix.
- (2)
In the second submatrix Asp, rewrite the 1st, 2nd, and 3rd columns on the right-hand side of matrix Asp ( as columns 5, 6, and 7). As in the first step, to the augmented matrix, assign “+” to the leading element in the odd numbered columns and assign “−” sign to the leading element in the even numbered columns and then apply Sarrus’ rule.
() -
This is the second part of the computation of determinant of the given 4 × 4 matrix.
- (3)
In the third submatrix Atp, rewrite the newest 1st, 2nd, and 3rd columns on the right-hand side of matrix Atp (as columns 5, 6, and 7). And again, to the augmented matrix, assign “+” to the leading element in the odd numbered columns and assign “−” sign to the leading element in the even numbered columns and then apply Sarrus’ rule.
() -
This is the third part of the computation of determinant of the given 4 × 4 matrix.
- (4)
For each of augmented matrices Aargfp, Aargsp, and Aargtp, apply Sarrus’ rule by adding the products along the four full diagonals that extend from upper left to lower right and subtract the products along the four full diagonals that extend from the lower left to the upper right. After finding the determinant of the augmented matrices Aargfp, Aargsp, and Aargtp, the addition of the results after applying Sarrus’ rule on the augmented matrices Aargfp, Aargsp, and Aargtp is the determinant of A. This is shown as follows:
()
5. Numerical Examples
In our numerical example, we investigate the workability, correctness, and efficiency of the use of the new method. We do this by first applying the other known and common methods such as expansion of cofactors method, pivotal condensation method, and the new method based on Sarrus’ rule.
Example 1. One has
Using Laplace Expansion of Cofactor Method. One has
Using Chio’s Pivotal Condensation Method. One has
Multiplying the second row by 6/13, D ← D(13/6) = −6(13/6) = −13:
Thus, detA = −13(1)(1)(0) = 0.
Using the New Method (Gbemi’s Method). One has
Example 2.
Using the Laplace Expansion of Cofactors Method. One has
Using the New Method (Gbemi’s Method). One has
6. Efficiency of the New Method
6.1. Asymptotic Analysis
In order to determine the efficiency of the method, an asymptotic analysis was carried out using big-O. The advantage of asymptotic analysis is that it is independent of the computer specifications. This will be used to compare the existing methods with the new method.
The conventional method in most texts and literatures is the Laplace expansion method which evaluates the determinant as a weighted sum of its submatrices. It is well established in literature that the run time of the Laplace expansion method for finding determinant is O(n!).
6.1.1. Run Time of New Method
The new method evaluates the determinant of a 4 × 4 matrix as an extension of Sarrus’ rule. Thus, for every diagonal, there are n items that are visited. Thus, the running time is O(n2). This can also be verified from the MATLAB program. There are two nested for loops which means an O(n2) algorithm.
6.1.2. Run Time of Other Variations of the New Method
Analyzing the other variations of the new method, the run time is O(n2).
7. Programming
This section presents the evaluation of the new approach (called the G-method) and its ability to be used in programming (i.e., as a subroutine for more applications); the program is written in MATLAB. Also, the MATLAB codes for Rezaifar and Rezaee [1] and Laplace expansion method are also presented as shown in Algorithm 1.
-
Algorithm 1
-
function answer = GMethod(A,part)
-
%% Developed by Sobamowo M. Gbeminiyi************************************
-
%% GMethod stands for Gbeminiyi’s method.
-
n = length(A);
-
sum1 = 0;
-
sum2 = 0;
-
for i = 1:1:n
-
sum3 = 1;
-
sum4 = 1;
-
for j = 1:1:n
-
sum3 = sum3*A(j,non_zero(mod(i+j-1,4),4));
-
sum4 = sum4*A(n - j + 1,non_zero(mod(i+j-1,4),4));
-
end
-
sum1 = sum1 + ((-1) ∧(i+1))*sum3;
-
sum2 = sum2 + ((-1) ∧(i))*sum4;
-
end
-
answer = (sum1 - sum2);
-
if part <= 2
-
answer = answer + GMethod([A(:,1),A(:,3:n),A(:,2)],part+1);
-
end
-
end
-
function answer = RMethod(m)
-
%% Developed by Omid Rezaifar.****************************************
-
%% RMethod stands for Rezaifar Method.
-
%% Developed by Omind Rezaifar.
-
n = length(m);
-
if n == 1
-
answer = m;
-
elseif n == 2
-
answer = m(1,1)*m(2,2) - m(1,2)*m(2,1);
-
else
-
m11 = m(2:n,2:n);
-
m1n = m(2:n,1:n -1);
-
mn1 = m(1:n -1,2:n);
-
mnn = m(1:n - 1, 1:n -1);
-
m11nn = m11(1:n -2, 1:n-2);
-
answer = RMethod(m11)*RMethod(mnn) - RMethod(m1n)*RMethod(mn1);
-
answer = answer / RMethod(m11nn);
-
end
-
end
-
function [answer] = ExpansionMethod(A)
-
%% Laplace Expansion Method ******************************************
-
%%
-
n = length(A);
-
if n==1
-
answer = A;
-
else
-
if n == 2
-
answer = A(1,1)*A(2,2) - A(1,2)*A(2,1);
-
else
-
answer = 0;
-
for i = 1:1:n
-
answer = answer + ((-1) ∧(1+i)*A(1,i))*ExpansionMethod([A(2:n,1:i - 1), A(2:n, i+1:n)]);
-
end
-
end
-
end
-
>> ExecutionTest1
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
Matrix Executed
-
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
∗∗∗∗∗∗∗∗Average Time per Execution For Laplace Expansion Method∗∗∗∗∗∗∗∗∗
-
Number of Executions = 1000
-
Total Time for Execution = 0.453
-
Average Time per Execution = 0.000453
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
>> ExecutionTest2
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
Matrix Executed
-
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
∗∗∗∗∗∗∗∗Average Time per Execution For Gbeminiyi Method (G-Method)∗∗∗∗∗∗∗∗∗∗∗
-
Number of Executions = 1000
-
Total Time for Execution = 0.218
-
Average Time per Execution = 0.000218
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
>> ExecutionTest3
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
Matrix Executed
-
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
-
∗∗∗∗∗∗∗∗Average Time per Execution For Rezaifar Method∗∗∗∗∗∗∗∗∗
-
Number of Executions = 1000
-
Total Time for Execution = 0.359
-
Average Time per Execution = 0.000359
-
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
8. Comparison with Existing Methods
The running time O(n2) is far better than O(n!) running time. This means that the G-method (the new method) is more efficient than the existing Laplace expansion method and other existing methods for the computation of 4 × 4 matrix. This fact was also illustrated with the execution time of the MATLAB code run on an Intel® Core™2 Duo CPU 2.00 GHz 4.00 GB (RAM) system. The codes for the Laplace expansion method and G-method were run with a test matrix.
In order to see the difference in execution time and speed of execution more efficiently, the algorithm has to be run many times. Therefore, the codes were run 1000 and 10,000 times on the same matrix, and the average execution time per problem is calculated. The results are shown in Tables 1 and 2.
Laplace expansion method | Rezaifar method | The new method (Gbemi’s method) | |
---|---|---|---|
Number of executions | 1,000 | 1,000 | 1,000 |
Total time for executions | 0.453 s | 0.359 s | 0.218 s |
Average time per execution | 0.00453 s | 0.00359 s | 0.00218 s |
Laplace expansion method | Rezaifar method | The new method (Gbemi’s method) | |
---|---|---|---|
Number of executions | 10,000 | 10, 000 | 10,000 |
Total time for executions | 4.197 s | 3.496 s | 1.766 s |
Average time per execution | 0.0004197 s | 0.003496 s | 0.0001766 s |
It can been seen from Tables 1 and 2 that the new method saves much time and the speed of running is faster than the Laplace expansion and Rezaifar’s methods. Although the recursive loops in Rezaifar’s method make it be used more in programming, if the division by zero appears during the computation of the determinant of a matrix, then the method fails to evaluate the value of the determinant unless rows are changed and as a result the determinant altered [1]. This shortcoming or limitation of Rezaifar’s method was also pointed out by Dutta and Pal [36]. However, the newly developed method (G-method) overcomes the limitation of Rezaifar’s method.
For the optimized MATLAB in-built method, for the 1000 number of executions, the total time for execution is 0.015 sec, while the average time per execution is 0.000015 sec. However, it has been pointed out that, commonly in machine programs which required some algorithm to find the determinant of matrices, Gaussian elimination or Gauss-Jordan method is used. This method is based on linear and unilateral approach to find the determinant [1]. It is hoped that if this newly developed algorithm is optimized, it will run faster than the MATLAB in-built method.
9. Conclusion and Future Works
In this paper, efficient techniques based on Sarrus’ rule for computation of the determinant of 4 × 4 matrices have been proposed. The techniques are shown to be very quick, easy, efficient, very usable, and highly accurate. The new method creates opportunities to find other new methods based on Sarrus’ rule to compute determinants of higher orders. Also, the new approach has been shown to be applicable to compute the determinants of larger matrices such as 5 × 5, 6 × 6, and all other n × n (n > 6) matrices. This will be presented in the second part of the paper.
Competing Interests
The author declares that there are no competing interests regarding the publication of this paper.