Nearly Pentadiagonal Linear Systems: A. A. Karawia and S. A. El-Shehawy
Nearly Pentadiagonal Linear Systems: A. A. Karawia and S. A. El-Shehawy
Nearly Pentadiagonal Linear Systems: A. A. Karawia and S. A. El-Shehawy
= K a ,
2 3
( , , , , )
n
t b b b = K b ,
3 4
( , , , )
n
b b b =
% % % %
K b and
1 2
( , , , )
n
d d d = K d . When considering the system (1) it is advantageous to
introduce three additional vectors
1 2
( , , , )
n
c c c = K c ,
1 2
( , , , )
n
e e e = K e and
Nearly Pentadiagonal Linear Systems
91
1 2
( , , , )
n
f f f = K f . These vectors are related to the vectors % a , a , d , b and
%
b .
The current paper is organized as follows. In Section 2, the main results are
given. Illustrative examples are presented in Section 3. In Section 4, a conclusion is
given.
2. Main Results
In this section we are going to formulate a new computational and symbolic
algorithms for solving general nearly pentadiagonal linear systems of the form (1).
To do this, we begin by considering the LU decomposition [1] of the matrix A in
the form:
3
1
4
2
2
4
1
3
3
1 1 1
2
2 2
3
3 3 3
4
4
2
1
1
1 0 0 0 0 0 0 0
0 0 0 0
1 0 0 0 0 0 0
0 0 0 0 0
1 0 0 0 0
0 0 0 0
0 1 0 0 0
0 0 0
0
0 1 0 0
0 1 0
0 0 1
=
%
%
%
%
L
% L
L
L
L M
% L M
L M
M O O O O O O O M
M O O O O O O O
M L L
M L L L
L L L
n
n
n
n
n
n
b
c
b
c
b
n c
b
n c
t
n c
c e a s
f
c e e
f
c e a
f
c e
A
f
f
f f
4 4
2 2 2
1 1
0
0
0 0 0
0 0 0
0 0 0 0 0
% L M
M O O O O O O O M
M O O O O O O O
% M L L
M L L L
L L L
n n n
n n
n
a
c e a
c e
c
(3)
From (3) we obtain
2
1
2 2 1
1 2 2
1 2 1
if 1
if 2
, if 3(1) 1
if ,
=
= =
%
% %
%
i
i
i b
i i i i n c
n n n n
d i
d f e i
c
d f e a a e i n
d f a f e i n
(4)
where
A. A. Karawia and S. A. El-Shehawy
92
3
1
1
2 2 1
2 2
3 3
1
if 1
if 2
if
if 3
if 4(1) 1,
i n
b
n n c
i i i
a i
a f a i
e a f a i n
a a f e i
a f a i n
= =
%
%
%
%
(5)
and
3
2
1
2
3
3 2
1
3 1 2 1
( ) / if 1
if 2
( ) / if 3(1) 1
( ) / if .
n
i
i
n
t
n n n c
b
c
i
b
i i c
t
n n n n c
b e c i
i
f
b c i n
b a f e c i n
=
=
%
%
%
(6)
It is not difficult to prove that the LU decomposition (3) exists only if
0
i
c , 1(1) 1 i n = . Moreover, a general nearly pentadiagonal linear system (1)
possesses a unique solution if, in addition, 0
n
c . On the other hand, the
determinant of the matrix A is given by:
1
det( ) ,
n
i
i
A c
=
=
(7)
and this shows the importance of the vector c [4].
We may now formulate the following results.
2.1 Algorithm To solve the general nearly pentadiagonal linear system (1), we may
proceed as follows:
step 1: Set
1 1
c d = .
step 2: If
1
0 c = , then OUTPUT(the method is fails); STOP.
step 3: Set
2
1
1 1 1 2
, , , ,
b
n c
a s b t e a f = = = = and
2 2 2 1
c d f e = .
Nearly Pentadiagonal Linear Systems
93
step 4: If
2
0 c = , then OUTPUT(the method is fails); STOP.
step 5: Set
2 2 2 1 2 2
,
n n
e a f a e a f a = = % % , and
2 n
a e = % .
step 6: For 3, 4, , 1 i n = K Compute
2
2 1
( ) /
i
i
b
i i i i c
f b e c
=
%
,
2
1 2
=
%
%
i
i
b
i i i i i c
c d f e a ,
If 0
i
c = , then OUTPUT(the method is fails); STOP,
If 3 i = , then
2
1
i
i
b
i i i i n c
e a f a a
=
%
% else
1 i i i i
e a f a
= % .
step 7: Compute
1
3
1 3 2
( ) /
n
b
n n n c
f b e c
=
%
,
3
3 1 2 1
( ) /
n
t
n n n n n c
f b a f e c
= % ,
1 2 1 n n n n n
c d f a f e
= % ,
step 8: Set
1 1 2 2 2 1
, z y z y f z = = .
step 9: For 3, 4, , 1 i n = K Compute
2
1 2
i
i
b
i i i i i c
z y f z z
=
%
.
step 10: Set
3
1 1 2 3
n
t
n n n n n n c
z y f z f z z
= .
step 11: Compute the solution vector x using
1 1
1
1
,
n n n n
n n
z z e x
n n c c
x x
= = ,
For 2, 3, , 2 i n n = K Compute
1 2 i i i i i
i
z e x a x
i c
x
+ +
=
%
,
A. A. Karawia and S. A. El-Shehawy
94
Set
1 1 2 1 3 4
1
1
z e x a x s x
c
x
=
%
.
The new algorithm 2.1 will be referred to as KNPENTA algorithm.
KNPENTA algorithm for solving the nearly pentadiagonal system (1) is generally
preferable because the conditions 0, 1(1)
i
c i n = are sufficient for its validity.
The advantage of the vector c is now clear.
The following symbolic algorithm is developed in order to remove the
cases where the numeric algorithm KNPENTA fails.
2.2 Algorithm To solve the general nearly pentadiagonal linear system (1), we may
proceed as follows:
step 1: Set
1 1
c d = .
step 2: Set
1
c x = and
1
d x = ( x is just a symbolic name) whenever
1
0 c = .
step 3: Set
n
a s = ,
1
b t = ,
1 1
e a = ,
2
1
2
b
c
f = , and
2 2 2 1
c d f e = .
step 4: Set
2
c x = whenever
2
0 c = .
step 5: Set
2 2 2 1 2 2
,
n n
e a f a e a f a = = % % , and
2 n
a e = % .
step 6: For 3, 4, , 1 i n = K Compute
2
2 1
( ) /
i
i
b
i i i i c
f b e c
=
%
,
1 2 2
i
i
b
i i i i i c
c d f e a
=
%
% ,
Set
i
c x = whenever 0
i
c = ,
If 3 i = , then
2
1
i
i
b
i i i i n c
e a f a a
=
%
% else
1 i i i i
e a f a
= % .
step 7: Compute
1
3
1 3 2
( ) /
n
b
n n n c
f b e c
=
%
,
3
3 1 2 1
( ) /
n
t
n n n n n c
f b a f e c
= % ,
Nearly Pentadiagonal Linear Systems
95
1 2 1 n n n n n
c d f a f e
= % ,
Set
n
c x = whenever 0
n
c = .
step 8: Set
1 1 2 2 2 1
, z y z y f z = = .
step 9: For 3, 4, , 1 i n = K Compute
2
1 2
i
i
b
i i i i i c
z y f z z
=
%
.
step 10: Set
3
1 1 2 3
n
t
n n n n n n c
z y f z f z z
= .
step 11: Compute the solution vector x using
1 1
1
1
,
n n n n
n n
z z e x
n n c c
x x
= = ,
For 2, 3, , 2 i n n = K Compute
1 2 i i i i i
i
z e x a x
i c
x
+ +
=
%
,
Set
1 1 2 1 3 4
1
1
z e x a x s x
c
x
=
%
.
step 12: Substitute 0 x = in all expressions of the solution vector. n i x
i
,..., 2 , 1 , =
The symbolic algorithm 2.2 will be referred to as KSNPENTA algorithm.
In [3], Claerbout showed that the two-dimensional Laplacian operator, which
appears in 3-D finite-difference migration, has the form of pentadiagonal matrix. If
we choose 4, 1(1)
i
d i n = = , 0 s t = = and 1,
i i i i
a b a b i = = = =
%
% , we
can obtain it.
3. Illustrative Examples
In this section we are going to give illustrative examples.
Example 3.1 Solve the nearly pentadiagonal linear system of size 10 given by
A. A. Karawia and S. A. El-Shehawy
96
1
2
3
4
5
6
7
8
9
10
3 1 3 5 0 0 0 0 0 0
2 2 1 2 0 0 0 0 0 0
3 4 5 5 1 0 0 0 0 0
0 3 2 1 1 3 0 0 0 0
0 0 6 1 2 5 1 0 0 0
0 0 0 3 3 2 7 5 0 0
0 0 0 0 8 1 12 3 4 0
0 0 0 0 0 2 5 3 1 20
0 0 0 0 0 0 3 11 21 3
0 0 0 0 0 0 2 4 9 31
x
x
x
x
x
x
x
x
x
x
30
13
35
27
69
18
38
280
328
247
=
(8)
by using the KNPENTA algorithm and KSNPENTA algorithm.
Solution
(a) The implementation of the KNPENTA algorithm gives:
1
3 c = (Step 1).
2
1 1 2 3
5, 2, 1,
n
a b e f
= = = = and
4
2 3
c = (Step 3).
16
2 3
3,
n
e e = = and
16
2 3
a = % (Step 5).
9 253 105 368
4012 204567
3 4 5 6 7 8 9 4 35 184 2271 101 186433
[ , , , , , , ] [ , 1, , , , , ] f f f f f f f
= ,
1313
35 552 757 14341 4112262
3 4 5 6 7 8 9 4 35 92 1514 303 186433
[ , , , , , , ] [ , 1, , , , , ]
= c c c c c c c and
1393 1371 3532041
934 26873
3 4 5 6 7 8 9 35 184 2271 101 186433
[ , , , , , , ] [12, 2, , , , , ] e e e e e e e
= (Step 6).
91736 1203361
1 186433 4112262
, ,
n
f f
= = and
701215
19866 n
c = (Step 7).
1 2
[ , ] [30, 33] z z = (Step 8).
317 8609 11475 238883 138311 129996
3 4 5 6 7 8 9 4 35 184 4542 303 14341
32 [ , , , , , , ] [ , , , , , , ] = z z z z z z z (Step 9).
Nearly Pentadiagonal Linear Systems
97
3506075
10 9933
z = (Step 10).
1 2 3 4 5 6 7 8 9 10
[ , , , , , , , , , ] [1, 2, 3, 4, 5, 6, 7, 8, 9,10] = x x x x x x x x x x (Step 11).
Also the determinant of A is det( ) 145151505 A = by using (7).
(b) The implementation of the KSNPENTA algorithm gives:
_ : ( , , , , , ) [1, 2, 3, 4, 5, 6, 7, 8, 9,10]
T
nearly penta X b b d a a y = =
%
% .
Example 3.2 Solve the nearly pentadiagonal linear system of size given by
1
2
3
4
5
6
7
0 3 1 5 0 0 0 13
9 1 4 2 0 0 0 9
7 6 2 3 7 0 0 41
0 5 2 3 1 11 0 52
0 0 2 4 1 6 1 54
0 0 0 3 4 5 1 27
0 0 0 4 13 6 1 44
w
w
w
w
w
w
w
=
(9)
by using the KNPENTA algorithm and KSNPENTA algorithm.
Solution
(a) The implementation of the KNPENTA algorithm gives:
The method is break down since
1 1
0 c d = = .
(b) The implementation of the KSNPENTA algorithm gives:
A. A. Karawia and S. A. El-Shehawy
98
-73002
3998p+36501
1018p-36501
3998p+36501
5(646p-36501)
3998p+36501
3(8320p+36501)
: ( , , , , , )
3998p+36501
2(6385p+36501)
3998p+36501
12(2133p+12167)
3998p+36501
2(21917p-109503)
3998p+36501
nearly_penta W b b d a a y
= =
%
%
0
2
1
5
3 .
2
4
6
p =
=
Also the determinant of coefficients matrix equals -73002 and for more details about
how to call this procedure, see Appendix 1.
4. Conclusion
The computational algorithm KNPENTA described here is very effective,
provided that optimal LU factorization is used, because the conditions
0, 1(1)
i
c i n = are sufficient for its validity. The symbolic algorithm
KSNPENTA is developed in order to remove the cases where the computational
algorithm KNPENTA fails. The symbolic algorithm KSNPENTA is competitive
with the computational algorithm KNPENTA for solving a nearly pentadiagonal
linear system which appears in many applications.
Appendix 1. A Maple procedure for solving a nearly pentadiagonal linear system
> # A Maple Procedure.
> # To compute the solution of a general nearly pentadiagonal Linear system.
> restart:
> with(linalg,vector,vectdim):
> nearly-penta:=proc(bb::vector,b::vector, d::vector,a::vector,aa::vector,y::vector)
local i,j,k,n; global T,e,c,f,z,X;
n:=vectdim(d):e:=array(1..n):c:=array(1..n):
f:=array(1..n):z:=array(1..n):X:=array(1..n):
Nearly Pentadiagonal Linear Systems
99
#components of the vectors e, c, and f #
c[1]:=d[1]:if c[1]=0 then c[1]:=x; d[1]:=x;fi: e[1]:=a[1]:f[2]:=simplify(b[2]/c[1]):
c[2]:=simplify(d[2]-e[1]*f[2]):if c[2]=0 then c[2]:=x;fi:
e[2]:=simplify(a[2]-f[2]*aa[1]):e[n]:=simplify(aa[2]-f[2]*a[n]): aa[2]:=e[n]:
for i from 3 to n-1 do
f[i]:=simplify((b[i]-bb[i]*e[i-2]/c[i-2])/c[i-1]):
if i=3 then e[i]:=simplify(a[i]-f[i]*aa[i-1]-bb[i]*a[n]/c[i-2]); else
e[i]:=simplify(a[i]-f[i]*aa[i-1]);
fi:
c[i]:=simplify(d[i]-bb[i]*aa[i-2]/c[i-2]-e[i-1]*f[i]); if c[i]=0 then c[i]:=x; fi:
end do:
f[1]:=simplify((bb[n]-b[1]*e[n-3]/c[n-3])/c[n-2]):
f[n]:=simplify((b[n]-b[1]*aa[n-3]/c[n-3]-f[1]*e[n-2])/c[n-1]):
c[n]:=simplify(d[n]-f[1]*aa[n-2]-e[n-1]*f[n]):if c[n]=0 then c[n]:=x; fi:
# To compute the vector Z #
z[1]:=y[1]:z[2]:=y[2]-f[2]*z[1]:i:=i:
for i from 3 to n-1 do
z[i]:=simplify(y[i]-bb[i]*z[i-2]/c[i-2]-f[i]*z[i-1]):
end do:
z[n]:=simplify(y[n]-f[n]*z[n-1]-f[1]*z[n-2]-b[1]*z[n-3]/c[n-3]):
# To compute the Solution of the system X. #
X[n]:=z[n]/c[n]:i:=i:
X[n-1]:=simplify((z[n-1]-e[n-1]*X[n])/c[n-1]):
for i from n-2 by -1 to 2 do
X[i]:=simplify((z[i]-e[i]*X[i+1]-aa[i]*X[i+2])/c[i]):
end do:
X[1]:=simplify((z[1]-e[1]*X[2]-aa[1]*X[3]-a[n]*X[4])/c[i]):
# To compute the determinant T #
T:=subs(x=0,simplify(product(c[r],r=1..n)));
eval(X):
end:
> # Call no. 1 for the procedure nearly penta. #
> x:=x:
> aa:=aa:=vector([3,2,1,3,1,-5,-4,20]);
aa := [3, 2, 1, 3, 1, -5, -4, 20]
>a:=vector([-1,1,5,1,5,7,3,1,3,5]);
a:=[-1,1,5,1,5,7,3,1,3,5]
> d:=vector([3,2,5,1,2,2,12,3,21,31]);
d:=[3,2,5,1,2,2,12,3,21,31]
> b:=vector([-2,-2,-4,-2,1,-3,1,5,11,-9]);
b:=[-2,-2,-4,-2,1,-3,1,5,11,-9]
> bb:=vector([0,0,3,3,6,3,-8,2,3,4]);
bb:=[0,0,3,3,6,3,-8,2,3,4]
> y:=vector([30,13,35,27,69,18,38,280,328,247]);
A. A. Karawia and S. A. El-Shehawy
100
y:=[30,13,35,27,69,18,38,280,328,247]
> X:=nearly penta(bb,b,d,a,aa,y);
X := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
T
> T;
-145151505
> # End of call no. 1. #
> # Call no. 2 for the procedure nearly penta. #
> a:=vector([3,4,3,1,6,1,5]);
a:=[3,4,3,1,6,1,5]
> d:=vector([0,1,2,-3,1,5,1]);
d:=[0,1,2,-3,1,5,1]
> b:=vector([-4,9,-6,2,4,-4,6]);
b:=[-4,9,-6,2,4,-4,6]
> aa:=vector([-1,2,7,11,1,0,0]);
aa:=[-1,2,7,11,1,0,0]
> bb:=vector([0,0,-7,5,2,3,13]);
bb:=[0,0,-7,5,2,3,13]
> y:=vector([13,9,41,52,54,27,44]);
y:=[13,9,41,52,54,27,44]
> W:=nearly_penta(d,a,a_,b,b_,y);
> T;
-73002
> p:=0:X:=map(eval,op(W));
X := [-2, 1, 5, 3, 2, 4, 6]
T
> # End of call no. 2. #
5. Acknowledgement
This work has been supported by the Deanship of Scientific Research at Qassim
University. The authors would like to thank the committee of the journal and the
referees for their constructive comments.
6. References
[1] Allen, M. B. and Isaacson,E. L. Numerical Analysis for Applied Science, Wiley-
Interscience, John Wiley & Sons, 1997.
Nearly Pentadiagonal Linear Systems
101
[2] Cheney, W. and Kincaid, D. Numerical Mathematics and Computing (Second
Edition), Wadsworth, Inc., 1985.
[3] Claerbout, J, F. Imaging the earths interior, Blackwell Scientific Publications,
1985.
[4] El-Mikkawy, M. E. A. "A Fast Algorithm for Evaluating nth Order tridiagonal
Determinants". J. Comput. Appl. Math., Vol. 166(2004), pp. 581-584.
[5] El-Mikkawy, M. E. A. and Rahmo, D. Symbolic algorithm for inverting cyclic
pentadiagonal matrices recursively-Derivation and implementation.
Computers & Mathematics with Applications, Vol. 59, Issue 4, (2010), pp.
1386-1396.
[6] LeVeque, R. J., Finite Difference Methods for Differential Equations, University
of Washington, 2006.
http://www.imsc.res.in/_rjoy/WWW/research/numerics/assets/am585winter06.pdf
[7] Karawia, A. A. A computational algorithm for solving periodic penta-diagonal
linear systems. Applied Mathematics and Computation, Vol. 174, Issue 1,
(2006), pp. 613-618.
[8] Sogabe, T. New algorithms for solving periodic tridiagonal and periodic
pentadiagonal linear systems. Applied Mathematics and Computation, Vol.
202, Issue 2, (2008), pp. 850-856.
[9] Stone, H. L. "Iterative Solution of Implicit Approximations of Multidimensional
Partial Differential equations". SIAM J. Numer. Anal., Vol. 5, No. 3(1968),
pp. 530-558.
[10] Zhao, X. and Huang, T. On the inverse of a general pentadiagonal matrix.
Applied Mathematics and Computation, Vol. 202, Issue 2, (2008), pp. 639-
646.
A. A. Karawia and S. A. El-Shehawy
102
. * . **
* ,.. ,.. :.- - .,.,.... .... :... - ,,... ....,
** ..,,. ,.. .., - ,... .,.s - ,,... ....,
: .... . . . .... _, . . (
. .-,. ..- _ .. ..,., .-.. ,,... _. _; _. _.| . ..;
,. ... ,... .,_.. . .... ..,., ..| .-.., .; ,.. _ _.. _,..
,... .<...,.. .... ; .... _,.,.. ..,., .