Research Article

On the Extension of Sarrus’ Rule to Matrices: Development of New Method for the Computation of the Determinant of Matrix

Algorithm 1

function answer = GMethod(A,part)
%% Developed by Sobamowo M. Gbeminiyi************************************
%% GMethod stands for Gbeminiyis 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.
%% This code was extracted from [31, 3842]
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