0% found this document useful (0 votes)
134 views7 pages

Cyclic Triadiagonal Matrix

Good

Uploaded by

Abhiyan Paudel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views7 pages

Cyclic Triadiagonal Matrix

Good

Uploaded by

Abhiyan Paudel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

JOURNAL OF COMPUTATIONAL PHYSICS 19, 317-323 (1975)

Algorithms for the Solution of Cyclic Tridiagonal Systems

In this paper we consider several algorithms for the solution of the system
Ax = b, where A is an n x n “cyclic tridiagonal” matrix of the form

6, cl a1

a2 6, ~2

a3 b, ~3
A= . . .
. . .
. . .
an-1 bn-1 cn-1
-G a, b, _

and A is assumedto be diagonally dominant.


In the casewhere (zl = c, = 0, the matrix A is strictly tridiagonal, and algorithms
for the solution of such systemsare well known (e.g., [7, p. 1951).Cyclic tridiagonal
systems with a, # 0, c, # 0 arise in the finite-difference solution of elliptic
equations over domains with periodic boundary conditions, e.g., on a cylinder
or an annulus, both by direct methods [5] and by iterative methods such as SLOR
and ADI [8]; and in the successiveperipheral overrelaxation (SPOR) method on
the topologically equivalent caseof a square with a central hole [2]. They also arise
in working with splines on a periodic mesh [l].
We will consider primarily the most usual case in which A is a symmetric
circulant matrix. It is natural to scale the equations so that we have ai = ci = 1
and bi = h, 1 < i < n, where h is a constant with 1h I > 2. Also, we will generally
assumethat the systemhas to be solved a number of times with different right-hand
sides, so that any coefficients required by the solution algorithm can be precal-
culated and stored. In this situation, the standard method [7] for the corresponding
strictly tridiagonal system requires 2n additions and 2n multiplications per right-
hand side, and the storage of n precomputed coefficients. It is of course possible
to extend this method, based on Gaussian elimination, to the cyclic tridiagonal
case; an example is given by Evans and Atkinson [4]. The resulting algorithm
is, however, rather clumsy; even in the symmetric case it requires 4n additions
and 4n multiplications per right-hand side, and the storage of 3n precomputed
coefficients.
317
Copyright 0 1975 by Academic Press. Inc.
All rights of reproduction in any form reserved.
318 CLIVE TEMPERTON

We describe four algorithms for the symmetric circulant casein the form

1:
-#A 1 1’ -Yl
1 A 1 X2
1 h 1 x3
. . . (0
. .
. . .
1 x 1 X,-l
1 1 h 1. X?l

Three of them have appeared in the literature before, while the fourth seemsto be
new.
(a) Matrix factorization. Evans [3] has proposed a neat algorithm based on
the factorization A = pQQr, where t.~= X/(1 + CX~)
and (Y,Q are given by
a = (--h $. (A2 - 4)li”)/2, (2)
- 1 --Cd
--13( 1

Q= -“-f, 1 1.
. .
. .
. .
-a 1/

The solution vector x is thus found by first solving for an auxiliary vector y
given by
Qy = p-lb
and then solving Qrx = y.
The first stage of the algorithm is given by

~(1 - o?) y1 = b, + e-lb2 + Czb3 + 0.. + cx2b,-1 + ab,, (3)

yj = p-lbj + my<-.1, 2<i<n,

and the second stage by

xi = J’j + axj+1 ) n-l>i>l.


SOLUTION OF CYCLIC TRIDIAGONAL SYSTEMS 319

Using a nesting technique to compute the right-hand sides of (3) and (4), the
only coefficients which need to be precalculated are CL,01,and (1 - o?), and the
whole algorithm requires 4n additions and 5n multiplications for each right-hand
side. In some applications it would be possible to save one multiplication by
incorporating the constant multiplier p-l during the computation of the right-hand
side. Numerical stability is guaranteed by choosing the positive sign in Eq. (2) for
h > 2 and the negative sign for X < -2, so that we always have 1011< 1.
(b) CycZic reduction. In the direct method due to Hackney [5] for solving
Poisson’s equation on a rectangular mesh, extensive use is made of a cyclic reduc-
tion technique for solving systems of the form (1). In the following it is assumed
that n is a power of 2, say n = 2m; the algorithm can quite easily be extended to
the case n = 3 x 2”.
Consider any three consecutive equations from the system (1):

Xi-2 + hxi-l + Xi = bi-1,


Xi-1 + hxi + xi+l = bi,
xi + XX,+1+ Xi+2 = bt+lp

with the indices interpreted cyclically, i.e., x,+~ = xi . Multiplying the second
equation by --X and adding, we obtain

- b(l)
x.- I 2 + X(‘)x. i + x. a+2 - i 9

where h’l’ = 2 - X2,b\” = bi_l - hbi + bi+l .


We thus obtain a new system, of order n/2, with the same cyclic tridiagonal
structure as the original system. The process can now be repeated until after m
levels of recursion only one equation remains which can be solved for x1 . The
remainder of the solution can then be built up using a recursive back-solution
process. Details of the algorithm are given by Hackney in [5] and [6] and need
not be repeated here. The solution requires approximately 4n additions and 2n
multiplications for each right-hand side; only m auxiliary coefficients Aft) and
their reciprocals are used, and these can be precomputed if desired. The principal
disadvantages of the algorithm are that it can only handle systemsof order n = 2”,
or at best n = p x 2”’ for p small, and that its recursive structure, with indices
interpreted cyclically, makes the computation of storage addressesrather com-
plicated. As shown in [5], there is a possible compensating advantage for large n
in that it may be unnecessary to carry out all m levels of reduction in order to
obtain the required degree of accuracy.

5Wr9/3-6
320 CLIVE TEMPERTON

(c) The Ahlberg-Nilson- Walsh algorithm. If we let E be the tridiagonal matrix


obtained by deleting the last row and column of A, and define

f=
1
0

I-I
0
0
1
jiz x1
x2

X3

&-I

then the system (1) can be rewritten as


Eil + fx, = b, (5)
f=j; + Xx, = 6, . (6)
As the matrix E is tridiagonal, we can easily compute the vector v = E-%.
Equation (5) then becomes
iz = v - E-lfx, . (7)
Substituting in (6) gives a scalar equation for xn :
(X - f=E-lf) x, = b, - f= * v = b, - (q + IQ.
The remainder of the solution vector, i.e., Iz, can then be found from Eq. (7).
The algorithm requires approximately 3n additions and 3n multiplications for
each right-hand side, and (2n - 1) precomputed coefficients, namely (n - 1) for
the tridiagonal system v = E-lb, the constant (h - fTE-lf)-I, and the vector
E-lf which is needed to implement Eq. (7). Details of this algorithm are given
(for a general cyclic tridiagonal matrix) by Ahlberg, Nilson, and Walsh ([ 1, p. 151).
(d) Algorithm 4. The fourth algorithm presented here is based on a simple
idea: Suppose that, in Eq. (l), we already knew the value of x, . We could then
obtain the reduced system

x2

x3

:l =
*4
,
X,-l
XVI
.J
SOLUTION OF CYCLIC TRIDIAGONAL SYSTEMS 321

which could be solved, using the standard tridiagonal algorithm, in 2(n - 1)


additions and 2(n - 1) multiplications, using (n - 1) precomputed coefficients.
Let z = (zl , z2,..., z,) be the first row of the inverse matrix A-l. Then x1 is
given by the scalar product x1 = z . b, i.e.,

Xl = f zibi 3 (8)
i=l

which can be evaluated in (n - 1) additions and IZmultiplications, making a total


of (3n - 3) additions and (3n - 2) multiplications. But since A is a symmetric
circulant matrix, so too is A-l, and hence zi = z,,++~ , 2 < i < n. Let m = integer
part of (n + 1)/2. We can rewrite the summation (8) as

xl = z&l + f zi(bi + b,+z-i) if n is odd


i=2

or

~1 = zlbl + f zi(bi + bn+,-i) + %a+1 bm+1 if n is even.


id
We have thus reduced the total number of operations to approximately 3n
additions and 2.5n multiplications, and the number of precomputed coefficients
to approximately 1.5~~.Since the tridiagonal algorithm itself is stable with respect
to rounding errors, the only problem lies in the accurate determination of the
vector z. It is quite easy to show that
T
*if1 - u(ai + an-q,

where 01is given by Eq. (2) and


u = I/[(& + Cl) + X(1 + an)].
The four algorithms described above were all programmed with comparable
care in Assembler Language and run (in single precision) on an IBM 360/195.
Each was timed for four values of n; these were chosen to be powers of 2 in order
to accommodate the cyclic reduction algorithm. but it should be remembered that
the other three methods are subject to no such restrictions on n. The results are
presented in Table I, which shows that Algorithm 4 is about 25 % faster than the
matrix factorization scheme, with the two remaining algorithms intermediate in
speed. Cyclic reduction suffers from its more complicated structure for smaller
values of n.
The accuracy of the various schemeswas also compared for various values of n
and h. In each case, a hundred random vectors x were generated with entries in
322 CLIVE TEMPERTON

the range 0.0 < xi ,< 10.0, corresponding vectors b = Ax were computed, and
the four algorithms were used to compute an approximate solution from b. The
largest error in each computed solution vector was found, and these were averaged
over the 100 random vectors. The results are summarized in Table II.

TABLE I
Execution Times in Microseconds for Solution of a Cyclic Tridiagonal System of Order n

n Matrix factorization Cyclic reduction Ahlberg/Nilson/Walsh Algorithm 4

16 36 36 31 28
32 64 60 55 48
64 119 105 103 88
128 231 194 199 167

TABLE II
Mean Maximum Errors in the Solution of a Cyclic Tridiagonai System of Order n
(Unit: 1O--B)

n Matrix factorization Cyclic reduction Ahlberg/Nilson/Walsh Algorithm 4


(a) A = -3.0

16 7.7 14.7 10.1 10.3


32 8.3 16.8 12.3 12.3
64 9.6 19.5 13.9 13.9
128 9.9 20.6 14.5 14.6

(b) A = $4.0

16 4.4 8.1 6.8 6.7


32 5.0 9.4 7.6 7.5
64 5.5 11.1 8.0 8.0
128 5.7 12.1 8.5 8.6

It will be seen that matrix factorization gives the most accurate answers, and
cyclic reduction the least, with the other two algorithms intermediate and very
similar. However, all four algorithms are stable with respect to rounding errors,
and for practical purposes there is little to choose between them from this point
of view.
SOLUTION OF CYCLIC TRIDIAGONAL SYSTEMS 323

A careful analysis of the Ahlberg-Nilson-Walsh algorithm shows that the


number of multiplications could be reduced to 2.5n as in the case of Algorithm 4,
by noting that the elements of the vector h = E-lf are symmetric, i.e., hi = /I,-~ ,
1 < i < n - 1; hence half the multiplications in Eq. (7) are in fact redundant.
This improvement should make the Ahlberg-Nilson-Walsh algorithm competitive
with Algorithm 4, though the latter is conceptually a little simpler.
General cyclic tridiagonal systems in which the matrix A is neither symmetric
nor circulant arise in both spline and elliptic equation applications when a non-
uniform mesh is used. Neither matrix factorization nor cyclic reduction can easily
be generalized to these cases. For the Ahlberg-Nilson-Walsh algorithm the
generalized form is given in [l], and for Algorithm 4 the generalized form is
obvious, provided that the first row of A-l can be obtained in some way. Both
generalized algorithms require approximately 3n additions and 4n multiplications
per right-hand side, and 3n precomputed coefficients.
Finally, Algorithm 4 can easily be generalized to handle cyclic pentadiagonal
systemsof order n, either by computing two elements of the solution vector directly
and then solving the resulting strictly pentadiagonal system of order (n - 2), or
by factorizing the cyclic pentadiagonal matrix into the product of two cyclic
tridiagonal matrices.

REFERENCES

1. H. H. AHLBERG, E. N. NILMN, AND J. L. WALSH, “The Theory of Splines and Their Applica-
tions,” Academic Press, New York, 1967.
2. A. BENSON AND D. J. EVANS, J. Inst. Math. Its Appl. 9 (1972), 68.
3. D. J. EVANS, The Numerical Solution of Elliptic and Parabolic Equations Occurring in Com-
putational Physics, in “Computational Physics Conference Digest,” pp. 46-56, Institute of
Physics and the Physical Society, London, 1970.
4. D. J. EVANS AND L. V. ATKINSON, Comput. J. 13 (1970), 323.
5. R. W. HOCKNEY, J. Assoc. Comput. Mach. 12 (1965), 95.
6. R. W. HOCKNEY, The Potential Calculation and Some Applications, in “Methods in Com-
putational Physics,” Vol. 9, pp. 135-211, Academic Press, New York, 1970.
7. R. S. VARGA, “Matrix Iterative Analysis,” Prentice-Hall, Englewood Cliffs, NJ., 1962.
8. W. L. WOOD, SIAM J. Numer. Anal. 8 (1971). 439.

RECEIVED: March 17, 1975

CLIVE TEMPERT~N

Meteorological Ofice
Bracknell, Berkshire
England

You might also like