You are on page 1of 6

Applied Mathematics Letters 26 (2013) 913–918

Contents lists available at SciVerse ScienceDirect

Applied Mathematics Letters


journal homepage: www.elsevier.com/locate/aml

Symbolic algorithm for solving comrade linear systems based


on a modified Stair-Diagonal Approach
A.A. Karawia ∗
Computer Science Unit, Deanship of Educational Services, Qassim University, P.O. Box 6595, Buraidah 51452, Saudi Arabia

article info abstract


Article history: Recently, a new approach called Stair-Diagonal was used for solving a tridiagonal system by
Received 2 August 2012 Jawad [A.J. Jawad, A. Yildirim, A. Biswas, Solving a tri-diagonal system of size N equations
Received in revised form 4 October 2012 by Stair-Diagonal Approach, Adv. Sci. Eng. Med. 4 (2012) 171–175]. In this paper, we
Accepted 5 October 2012
developed a Stair-Diagonal Approach in order to remove the cases where the Stair-Diagonal
Approach fails. Also, we describe a symbolic computational algorithm for solving comrade
Keywords:
linear systems based on a modified Stair-Diagonal Approach. The computational cost of our
Comrade matrices
Tridiagonal matrices
algorithm is O(n2 ). The algorithm is implementable to a Computer Algebra System (CAS)
Sherman–Morrison–Woodbury formula such as MAPLE, MATLAB and MATHEMATICA. Three examples are presented for the sake of
Computer algebra systems (CAS) illustration.
© 2013 Elsevier Ltd. All rights reserved.

1. Introduction

We consider the solution of comrade linear systems of the form CX = B, where X = (x1 , x2 , . . . , xn )t , B = (b1 ,
b2 , . . . , bn )t are vectors of length n and C is an n-by-n comrade matrix given by
 β1 1 
− 0 0 ··· ··· ··· ··· 0 0
 α1 α1 
 γ β2 1 
 2 − 0 ··· ··· ··· ··· 0 0

 α2 α2 α2
 

γ3 β3 1
 
 0 − 0 ··· ··· ··· 0 0
 
α3 α3 α3

 
 . ..
 . .. .. .. .. .. .. .. ..

 . . . . . . . . . .


 . ..
 . .. .. .. .. .. .. .. ..

 . . . . . . . . . .

, n ≥ 3.

C =
 .. .. .. .. .. .. .. .. .. .. (1.1)
 . . . . . . . . . .


 .. .. .. .. .. .. .. .. .. ..
 
 . . . . . . . . . .


.. .. γn−2 βn−2
 
 1 
 0 0 0 . . 0 − 0 

 αn−2 αn−2 αn−2 

 γn−1 βn−1 1

 0 0 0 ··· ··· ··· 0 −
 
αn−1 αn−1 αn−1

 
γn − a2

−a 4 −a 3 −βn − a1

an an − 1 an − 2
− − − ··· ··· ···
αn αn αn αn αn αn αn
∗ Home address: Mathematics Department, Faculty of Science, Mansoura University, Mansoura 35516, Egypt.
E-mail addresses: abibka@mans.edu.eg, kraoieh@qu.edu.sa.

0893-9659/$ – see front matter © 2013 Elsevier Ltd. All rights reserved.
http://dx.doi.org/10.1016/j.aml.2012.10.019
914 A.A. Karawia / Applied Mathematics Letters 26 (2013) 913–918

The comrade matrix (1.1) is a generalization of the companion matrix and is associated with a polynomial expressed as a
linear combination of an arbitrary orthogonal basis. This matrix appears frequently in many areas of science and engineering,
for example in linear multivariable systems theory [1], Computing the Greatest Common Divisor of Polynomials [2] and
division of generalized polynomials [3].
Now, multiplying CX = B by the diagonal matrix D = diag(α1 , α2 , . . . , αn ) from the left then we obtain the following
linear system:

CX = B (1.2)
where
−β 1 0 0 ··· ··· ··· ··· 0 0

1
γ2 −β2 1 0 ··· ··· ··· ··· 0 0
γ3
 
 0 −β3 1 0 ··· ··· ··· 0 0 
.. .. .. .. .. .. .. .. .. ..
 
. . . . . . . .
 
 . . 
.. ..
 
 .. .. .. .. .. .. .. .. 
 . . . . . . . . . . 
,
 
C = .. .. .. .. .. .. .. .. .. .. (1.3)

 . . . . . . . . . .


 .. .. .. .. .. .. .. .. .. .. 
. . . . . . . . . .
 
 
.. ..
 
. . γn−2
 
 0 0 0 0 −βn−2 1 0 
0 0 0 ··· ··· ··· 0 γn−1 −βn−1 1
 
−a n −a n − 1 −a n − 2 ··· ··· ··· − a4 −a 3 γn − a2 −βn − a1
and B = (α1 b1 , α2 b2 , . . . , αn bn ) . Since the transformation does not lose generality for solving the original systems, i.e. it
t

keeps the same solution as the original systems, we consider the solution of the above linear systems (1.2).
This linear system appears frequently in many areas of science and engineering, for example in parallel computing,
telecommunication system analysis and in solving differential equations using finite differences. Finding the solution of
such a linear system is usually required in these fields. This problem has been investigated by many authors (see for in-
stance, [4,5]). Computational approaches for finding the solution of comrade linear system of form CX = B are given in [4,5].
In [4, Algorithm 2.1], the author assumed the conditions µi ̸= 0, i = 1, 2, . . . , n. In [4, Algorithm 2.2], the symbolic algo-
rithm is given and no conditions are imposed but the matrix C is assumed to be a non-singular matrix.
The paper is organized as follows: In Section 2, a modified Stair-Diagonal Approach for solving a tridiagonal linear system
is presented. A new symbolic computational algorithm based on a modified Stair-Diagonal Approach for solving a comrade
linear system is constructed in Section 3. In Section 4, three illustrative examples are given. Conclusions of the work are
given in Section 5.

2. Modified Stair-Diagonal Approach

Many authors studied the solution of sparse linear systems, for example in [6] a new modification of the Rojo method for
solving symmetric circulant five-diagonal systems of linear equations is given. In [7], the authors are use a Stair-Diagonal
Approach for solving a tridiagonal linear system of size n equations. For the convenience of the reader we are going to restate
a result presented in it as follows:
Let
AX = b (2.1)
where A = (aij )1≤i,j≤n , aij = 0 for |i − j| ≥ 2 is a general tridiagonal matrix, X = (x1 , x2 , . . . , xn ) and b = (b1 , b2 , . . . , bn )t .
t

Apply the following four steps:


i = 2, 4, 6, . . . , n − 1

ai,i−1 if n is odd
1. Ri = Ri − R for where Ri represents ith Row,
ai−1,i−1 i−1
i = 2, 4, 6, . . . , n if n is even,
ai,i+1 i = 2, 4, 6, . . . , n − 1 if n is odd
2. Ri = Ri − ai+1,i+1
Ri+1 for i = 2, 4, 6, . . . , n − 2 if n is even
i = n − 3, n − 5, . . . , 2

ai,i+2 if n is odd
3. Ri = Ri − Ri+2 for
ai+2,i+2
i = n − 2, n − 4, . . . , 2 if n is even
ai,i−2 i = 4, 6, 8, . . . , n − 1 if n is odd
4. Ri = Ri − R
ai−2,i−2 i−2
for i = 4, 6, 8, . . . , n if n is even.

Back substitution step: Calculate the unknown variables from:

if i = 2, 4, . . . , n − 1 and n is odd
 
 ai,n+1
if i = 2, 4, . . . , n and n is even


ai , i
xi = (2.2)
if i = 1, 3, . . . , n and n is odd

 ai,n+1 − ai,i−1 xi−1 − ai,i+1 xi+1
if i = 1, 3, . . . , n − 1 and n is even.


ai , i
A.A. Karawia / Applied Mathematics Letters 26 (2013) 913–918 915

The computational cost of the Stair-Diagonal Approach is (22n − 27) operations. As can be easily seen, it breaks down
unless the conditions ai,i ̸= 0 are satisfied for all i = 1, 2, . . . , n. So the following symbolic algorithm is developed in order
to remove the cases where the numeric Stair-Diagonal Approach fails.

Algorithm 2.1. To find the solution of the tridiagonal linear system of (2.1) using the modified Stair-Diagonal Approach.
Let ai,i+1 = 1 for i = 1, 2, . . . , n − 1, di = ai,i for i = 1, 2, . . . , n, γi = ai+1,i
for i = 1, 2, . . . , n − 1 and γ1 = 0.
INPUT order of the matrix n and the components di , bi , i = 1, 2, . . . , n and γi ,
i = 2, 3, . . . , n.
OUTPUT The solution vector x = (x1 , x2 , . . . , xn )t .
Step 1: If n is odd then set z = n − 3 else set z = n − 2.
For i = 1, 2, . . . , n
If di = 0 then set di = t (t is just a symbolic name),
γ
Compute d2 = d2 − d2 , if d2 = 0 then set d2 = t,
1
γ b
Compute b2 = b2 − d2 1 ,
1
Set γ2 = 0,
For i = 4, 6, . . . , z + 2
γ
Compute di = di − d i , if di = 0 then set di = t,
i−1
γi bi−1
Compute bi = bi − di−1
,
γi γi−1
Compute Lui−2 = − di−1
,
Set γi = 0.
Step 2: If n is odd then set w = n − 1 else set w = n − 2.
For i = 2, 4, . . . , w
γ
Compute di = di − di+1 , if di = 0 then set di = t,
i+1
bi+1
Compute bi = bi − di+1
,
If i < n − 1 then set Lui−1 = d−1 .
i+1

Step 3: For i = z , z − 2, . . . , 2
Lui Lui−1
Compute di = di − di+2
, if di = 0 then set di = t,
Lui−1 bi+2
Compute bi = bi − di+2
,
Set Lui−1 = 0.

Step 4: For i = 4, 6, . . . , z + 2
Lu 2 bi−2
Compute bi = bi − i− di−2
,
Set Lui−2 = 0.
b2 x2
Step 5: Compute x2 = d2
and compute x1 = b1 − d1
,
For i = 4, 6, . . . , z + 2,
b bi−1 −γi−1 xi−2 −xi
Compute xi = di and compute xi−1 = di−1
.
i
bn −γn xn−1 bn
If n is odd then compute xn = dn
else compute xn = dn
.
Step 6: Substitute t = 0 in all expressions of the solution vector xi , i = 1, 2, . . . , n.
The symbolic Algorithm 2.1 will be referred to as the STMSDA algorithm. The computational cost of the STMSDA
algorithm is 14n − 25 operations if n is odd and 14n − 17 operations if n is even.
In the next section, we give an efficient symbolic computational algorithm using modified Stair-Diagonal Approach for
evaluating the solution of the comrade linear systems.

3. Symbolic computational algorithm using a modified Stair-Diagonal Approach

In this section we shall focus on the construction of new symbolic computational algorithms for computing the solution
of comrade linear system based on modified Stair-Diagonal Approach.
The coefficient matrix of (1.3) is closely related to a tridiagonal matrix in that the matrix can be split as a tridiagonal
matrix and a rank-one matrix of the form:
C = T + en r t (3.1)
where ei is the ith unit vector, i.e. the ith entry is one and others are all zeros, r = (−an , −an−1 , . . . , −a2 , −a1 ) and
t
916 A.A. Karawia / Applied Mathematics Letters 26 (2013) 913–918

−β 1 0 0 ··· ··· ··· ··· 0 0



1
 γ2 −β2 1 0 ··· ··· ··· ··· 0 0 
 0 γ3 −β3 1 0 ··· ··· ··· 0 0 
 . .. .. .. .. .. .. .. .. ..
 
 .. . . . . . . . .

.
 . ..
 
 .. .. .. .. .. .. .. .. .. 
. . . . . . . . .

.
 
 ..
T = ..
.
..
.
..
.
..
.
..
.
..
.
..
.
..
.
.. (3.2)
 . .


 . ..
 . .. .. .. .. .. .. .. ..

 . . . . . . . . . .


.. ..
 
. . γn−2
 
 0 0 0 0 −βn−2 1 0 
0 0 0 ··· ··· ··· 0 γn−1 −βn−1 1
 
0 0 0 ··· ··· ··· 0 0 γn −βn
From (1.2) and (3.1), we have

(I + T −1 en r t )X = T −1 B. (3.3)
Using (3.3) and the Sherman–Morrison–Woodbury formula [8, p. 50], we have the solution of linear system (1.2) after
simple calculations:
 
rt z
x=z− y, such that 1 + r t y ̸= 0, (3.4)
1 + rt y

where y = T −1 en and z = T −1 B.
The above systems can be efficiently solved by a modified Stair-Diagonal Approach. Now we formulate a second result.
It is a symbolic computational algorithm to compute the solution of the comrade linear system of (1.2).

Algorithm 3.1. To find the solution of the comrade linear system of (1.2) using the modified
Stair-Diagonal Approach.
INPUT order of the matrix n and the components di = −βi , γi , ri = −an−i+1 ,
i = 1, 2, . . . , n, and γ1 = 0,
OUTPUT The solution vector x = (x1 , x2 , . . . , xn )t .
Step 1: Solve the tridiagonal linear system Ty = en using the STMSDA algorithm.
Step 2: Solve the tridiagonal  system Tz = B using the STMSDA algorithm.
 linear
rt z
Step 3: Compute x = z − 1 +r t y
y.

The symbolic Algorithm 3.1 will be referred to as SCMSDA. The computational cost of the SCMSDA algorithm is 4n2 +
29n − 50 operations if n is odd and 4n2 + 29n − 34 operations if n is even. On the other hand, in [4, Algorithm 2.2] and
[5, Algorithm 1], the computational costs are 14n − 16 and 4n2 + 18n − 16 respectively.

4. Illustrative examples

In this section we give three examples for the sake of illustration.

Example 4.1. Solve the following comrade linear system of size 7


 1 1   1 
− 0 0 0 0 0
 2 2   2 
 3 2 1   2 

 3 − 0 0 0 0   
3 3    3 
  
 x1

 1 −3 1  3 
 0 − 0 0 0  x 
  2  1 


 1 −1 −1  x3   
 2 4 1     −1 
−  x4  =  1  (4.1)
 0 0 0 0     
5 5 5

  x5   
3 6 1     −6 
x

 0 0 0 − 0  6  
 2 2 2
 x  1 
  7  
 2 5 1   −13 
 0 0 0 0 −  
 7 

7 7 7
 
   
1 1 2 4 3 4−1 −3 − 1 −50
− − − − −
3 3 3 3 3 3 3 3
by using the SCMSDA algorithm.
A.A. Karawia / Applied Mathematics Letters 26 (2013) 913–918 917

Table 1
Errors and CPU times in seconds for our Proposed Algorithm, Algorithm 2.2 [4], and Algorithm 1 [5] when
n = 500, 5000, 10000, and 50000.
n ε = ∥x − x̄∥∞ and CPU time
Proposed algorithm Algorithm 2.2 [4] Algorithm 1 [5]

500 8.8818 × 10−16 0.0261 4.2188 × 10−15 0.0112 1.4211 × 10−14 0.0081
5 000 1.4211 × 10−14 0.0843 1.2501 × 10−13 0.0198 2.2737 × 10−13 0.0433
10 000 1.1367 × 10−13 0.1506 1.2501 × 10−13 0.0311 2.2738 × 10−13 0.0476
50 000 4.5475 × 10−13 0.6437 1.4132 × 10−12 0.1033 4.8422 × 10−13 0.0525

Solution:
−1 1 0 0 0 0 0 
3 −2 1 0 0 0 0
 0 1 −3 1 0 0 0 
• T = 0 , and B = (1, 2, −3, −5, −12, −13, −50)t .
 0 0 2 −4 1 0

 0 0 0 3 −6 1 0 
0 0 0 0 2 −5 1
0 0 0 0 0 4 −3
• β = (−1, −2, −3, −4, −6, −5, −3)t , γ = (0, 3, 1, 2, 3, 2, 4)t and r = (−1, −1, −2, −4, −3, −1, −1)t .
83 t
• Step 1: y = STMSDA(β, γ , e7 ) = 708 , 708 , − 708 , − 177 , − 354 , − 59 , − 177
 1 1 1 1 7 6

.
761 2141 672 5638 t
(β, γ , B) = 708 , 708 , 2177 , , , ,
 655 1363 
• Step 2: z = STMSDA
  708 177 354 59 177
.
rt z
• Step 3: x = z − 1+r t y
y = (1, 2, 3, 4, 5, 6, 7)t .

Example 4.2. Solve the following comrade linear system of size 4


 1 1

− 0 0
 2 2  
0

 3 1
 
 x1  4 
0 0

  x2  
 
 3 3 3 

 −1 −3 1
 x  = 
 3  (4.2)
 3
 0

−1  x 4 −18
  
 −1 −1

−4 −2 −3 − 2 −4 − 3
 5
5 5 5 5
by using the SCMSDA algorithm.
Solution:
−1 1 0 0

3 0 1 0
• T= 0 −1 −3 1
, and B = (0, 4, −3, −18)t .
0 0 −3 −4
• β = (−1, 0, −3, −4)t , γ = (0, 3, −1, −3)t and r = (−4, −2, −2, −3 )t .
3u+8 t  8 t
• Step 1: y = STMSDA(β, γ , e4 ) = 15u1+41 , 15u1+41 , − 15u
u +3
, − 15u , 41 , − 41 , − 41
  1 1 3

+41 +41  u=0
= 41 .
2(15u+37) 3(15u+43) t 
 30 30 74 129 t
• Step 2: z = STMSDA(β, γ , B) = 15u+41 , 15u+41 , 15u+41 , 15u+41 = 41 , 41 , 41 , 41 .
 30 30

 t  u=0

• Step 3: x = z − 1+r t y y = (1, 1, 1, 1) .


r z t

Example 4.3. We consider the following n × n comrade linear system in order to demonstrate the efficiency of Algorithm 3.1.
−3/2 1/2 0 ··· ··· ··· 0
  −2/2 
 x1 
..
.  x2  −1/2 
1/2 −3/2 1/2 0 0   −1/2 

 
1/2 −3/2 1/2
  x3  
0 0 0 ..
 
. .
    
 .. .. .. .. .. ..   ..  
    

. . . . . . .

  ..  =  .. .
    
.. .. .. .. ..  .  

. . . . . ..
 
 .  
    

.. .. .. .. .. ..   ..   . 
. . . . . .
 
 −1/2 
 0     
 xn−1
0 0 0 0 ··· ··· 0 1/2 −3/2 1/2 (n + 2)

−1/2 −1/2 −1/2 −1/2 ··· ··· −1/2 (1 − 1)/2 (−3 − 1)/2 xn −
2
It can be verified that the exact solution is x = (1, 1, . . . , 1)t . We used our Algorithm 3.1, Algorithm 2.2 [4], and
Algorithm 1 [5] to compute x̄. Results are given in Table 1 in which ε = ∥x − x̄∥∞ .
918 A.A. Karawia / Applied Mathematics Letters 26 (2013) 913–918

5. Conclusions

In this work new symbolic computational algorithms have been developed for computing the tridiagonal and comrade
linear systems based on the modified Stair-Diagonal Approach. The algorithms are reliable, computationally efficient and
remove the cases where the numeric algorithms fail.

Acknowledgments

The author would like to thank Prof. Dr M.E.A. El-Mikkawy and referees for several comments and suggestions.

References

[1] J. Maroulas, S. Barnett, Applications of the comrade matrix to linear multivariable systems theory, Internat. J. Control 28 (1978) 129–145.
[2] N. Aris, A. Abd Rahman, Computing the greatest common divisor of polynomials using the Comrade Matrix, in: Lecture Notes Series in Computer
Science, vol. 5081, 2008, pp. 87–96. Lecture Notes in Artificial Intelligence, Deepak Kapur (Ed.).
[3] S. Barnett, Division of generalized polynomials using the comrade matrix, Linear Algebra Appl. 60 (1984) 159–175.
[4] A.A. Karawia, Two algorithms for solving comrade linear systems, Appl. Math. Comput. 189 (2007) 291–297.
[5] T. Sogabe, Numerical algorithms for solving comrade linear systems based on tridiagonal solvers, Appl. Math. Comput. 198 (2008) 117–122.
[6] S. El-Sayed, I. Ivanov, M. Petkov, A new modification of the Rojo method for solving symmetric circulant five-diagonal systems of linear equations,
Comput. Math. Appl. 35 (1998) 35–44.
[7] A.J. Jawad, A. Yildirim, A. Biswas, Solving a tri-diagonal system of size N equations by Stair-Diagonal Approach, Adv. Sci. Eng. Med. 4 (2012) 171–175.
[8] G.H. Golub, C.F. Van Loan, Matrix Computations, third ed., The Johns Hopkins University Press, Baltimore, London, 1996.

You might also like