Using an Efficient Sparse Minor Expansion Algorithm to Compute

advertisement
IEEE TRANSACTIONS ON COMPUTERS, VOL.
C-27, NO.
10,
OCTOBER
945
1978
Using an Efficient Sparse Minor Expansion
Algorithm to Compute Polynomial
Subresultants and the Greatest
Common Denominator
MARTIN L. GRISS,
Abstract-In this paper, the use of an efficient sparse minor
expansion method to directly compute the subresultants needed for
the greatest common denominator (GCD) of two polynomials is
described. The sparse minor expansion method (applied either to
Sylvester's or Bezout's matrix) naturally computes the coefficients of
the subresultants in the order corresponding to a polynomial remainder sequence (PRS), avoiding wasteful recomputation as much as
possible. It is suggested that this is an efficient method to compute
the resultant and GCD of sparse polynomials.
Index Terms-Inners, minor expansion, polynomial GCD,
subresultants, sparse matrices, sparse polynomials.
I. INTRODUCTION
mHE EMPIRICAL study of polynomial resultants by Ku
and Adler [1], the discussions of the subresultant
greatest common denominator (GCD) algorithm by Brown
[2], [3], and the use of "inners" (subresultants) [4] for a
multivariable polynomial greatest common factor (GCF) by
Bose [5] suggest that the direct application of minor expansion to either the Sylvester or Bezout matrices is an efficient
and interesting method of computing the GCD of two sparse
polynomials.
It will be shown in this paper that the process of comput-
ing the subminors required in an efficient sparse minor
algorithm [6], [7] quite easily and naturally yields the
requisite subresultants and GCD. The crux lies in an appropriate reordering of either Sylvester's or Bezout's matrix,
very similar to that studied in [7].
A number of authors have studied the problems of
computing determinants of matrices with polynomial elements. When the polynomials are sparse (many zero
coefficients in a full expansion), minor expansion is
significantly more efficient than elimination methods [8], [9].
A particularly effective iterative algorithm [8] processes the
rows of an N x N matrix in order, computing the minors of
all of the m x m submatrices consisting of the first m rows
and m of the N columns. This set of m x m minors is then
combined (with due attention to sign) with the elements of
them + 1st row to produce a new set of (m + 1) x (m + 1)
minors.
When the matrix itself is sparse (many zero elements), a
careful choice of the order in which the rows are processed
can have a significant effect on the total storage and time
Manuscript received June 3, 1977; revised February 2, 1978. This work
was supported in part by the National Science Foundation under Grant
MCS76-15035.
The author is with the Department of Computer Science, University of
Utah, Salt Lake City, UT 84112.
MEMBER, IEEE
required to compute the-determinant. An efficient sparse
minor expansion algorithm, using a sparse matrix representation and careful row ordering has been discussed by the
author [6], [7].
II. SUBRESULTANTS AND SYLVESTER'S MATRIX
The method will be described using the notation of Brown
and Traub [3], which we briefly review here. We are
interested in computing the resultant or GCD of two
multivariate polynomials, F and G. Expand F and G
(assumed to be primitive) with respect to a "main variable,"
X.
F(x)-=
0
i=O
Y
fix+-', G(x)= E gix
-
withV.>y. (1)
j
j=o
The coefficients {fi, gi} are polynomials in other variables,
and i = 0(F), y = @(G) are the degrees of the polynomials.
Brown and Traub define the subresultant, Sj(F, G) as
SJ(F, G)
fo fl ..
fo
=det
go
...
fy-j- 1
fy-2-2
* *t+7-2j-2
Xy-j- 'F
x2 -2F
0
-
q,-- I
91 .. - 9*-j- I
go0g
g2-j-2
go
gq,+y-2j- 2 Xt-j-2l
G
9'Y - j-
G
(2)
where fk= O if k > i, gk = 0 if k > y, and 0 <j <
min (i/, y) = y. (This matrix is the transpose of that given
in [3].)
Expanding the polynomials in the last column, it is shown
that
j
Sj(F, G) = E sjlxj- I for O < j < min (i, y) =y. (3)
1=0
The coefficients, Sji, are determinants
(i + y - 2j) * (/ + y - 2j) matrices, Sjl:
of
the
(i + y-2j) columns
fo ft
f2
fo
P
fOt
Sji=
g0
*--
fo
**
g1
g2
...
g0
g*1
.o.*.*.
0018-9340/78/1000-0945$00.75 (© 1978 IEEE
h±f
-2--2
***1
t+y-2j-3
f
,-i- I
+ 7y- 2j+1- 2
fql+
-
2j+ l- 2
flk-i+l
9V+y-2j-2
gt+y-2j-3
gq,+y-2j+i-
gtk- j- 1
gy-j+l
I
9P+ y- 2j+ 1- 2
(Y -j)
rows
I
rows
I(4)
946
EEE TRANSACTIONS ON COMPUTERS,
where g9 andfk are 0 if k is out of range, and 0 .< < min (/,
y) = y, 0 < I <j.
Now SOO is, of course, Sylvester's matrix, and det Soo = soo
is the resultant R(F, G). The matrices Sj, are submatrices of
Sylvester's matrix, Soo, hence the term subresultant for SJ(F,
G).
The fundamental theorem presented by Brown and Traub
[3] is the relation between a polynomial remainder sequence
(PRS) {Fi}, generated from a pair of polynomials F1 and F2,
and the subresultants Sj(Fl, F2), for 0 <j < (F2).
For each j, 0 < j < a(F2), either Sj(F,, F2) - Fi for some
Fi, or Sj(Fl, F2) =0. Hence, since GCD (F1, F2)- Fk for
the "last" polynomial Fk in the PRS, GCD (F1, F2)
Sj(Fl, F2) for some j. (Here "s" is similarity and j is determined such that Sk(F, G) 0 for k < j.) Further details,
and the exact similarity coefficients can be found in [3].
If we now reorder the rows of SOO as suggested in [7], we
obtain the matrix
90 91
go
fo fi
92
...
91
*-
g.
c-27, NO. 10, OCTOBER 1978
the sparse minor expansion algorithm. The matrix would be
even more sparse than indicated above, since certain of the
{]f} and {9g} coefficients can be zero as well.
III. USE OF THE SPARSE MINOR EXPANSION METHOD
As in [7] the matrix will be converted to a sparse form, a
list of sparse rows. Each column (c) will be identified by its
"key" 2c. The essence of the sparse minor expansion algorithm is as follows:
1) Each sparse row is represented as a list
.f) * . (2i' *f))
SROW =
where the {ffjj are the nonzero elements in this row and 2jiis
the associated key;
2) An m x m minor, consisting of the first m rows and
columns (Ii' j2, , Im)' is identified by a
key = 2il + 22 + ... + 2"m;
((2ji fjl)(2i2
go
I
flp
...
Soo =
VOL.
fA
...
( - Y)
base rows
(5)
I11
9n
...
y
pairs
I
9,
3) A set of m x m minors will also be represented as a list:
This is a "good" order for efficient computation using the
sparse minor expansion algorithm. We apply this algorithm
DLIST = ((KEY, D1)(KEY2 D2) ... (KEY, DJ))
first to the "base" set of rows of G coefficients (if * y), to
produce a set of (i/ y) * (/i y) minors. At each succes- (Thus, a sparse row can be thought of as a set of 1 x 1
sive step, k = 1, 2, , y, we merge in a "shifted" pair of FIG minors.)
4) Minor expansion is accomplished by "merging" an
rows,
"old"
set of m x m minors (DOLD) and the m + 1st row
ooo
fO
0
(sRow) to produce a new set (DNEW) of (m + 1) x (m + 1)
(6. gy
(000 0 go
minors, using a function DMRG1:
DNEW +- DMRG1 (DOLD, SROW);
to obtain a new set of (@ -y + 2k) * ( y-v + 2k) minors.
The subresultant coefficients, sj1, will be among the minors
DMRG1 simply collects contributions to an (m + 1) x
in the set fork = y-j,j = 0, * ,-1. If atanystepk + 1,
(m
D, with Key = 2il + 2i2 + . + 2jm+1, from
the new set of (nonzero) minors is empty, the coefficients of each+ m1) xminor
m minor Dk and row elementfg, such that Keyk +
the GCD (F, G) are among the kth set, and thus,
2C = Key; c is clearly one of the {jji. The sign of the
-
-
-
-
(6)
GCD
y-k
(F, G)~ E sy-,_lx
0=0
1
(7)
[in fact, GCD (F, G) = pp(Sj(F, G))].
The minor set at step k will also include additional minors,
required to compute the new k + 1st set. The most interesting point is that this method will compute all of the
subresultant coefficients required, sharing as much as possible the computation of common subminors, and generates
these coefficients in the order required to compute most
easily the GCD. As suggested by Brown [2] and Ku and
Adler [1], this minor expansion method should be very
effective for sparse polynomials and, of course, Sylvester's
matrix is rather sparse and structured, motivating the use of
contribution is obtained from the number of transpositions
of [.l,
JM+ 19 c] to obtain the order jl< i2 mik- 1 < C <
jk + 1 < .* < im + 1. The details of an efficient implementation
of DMRG1 are given in [7].
F and G will be written as ordered sparse rows:
F = ((20 fo)(21 fl) ... (2* * fo))
G-= ((2°_ go) (21 g-,))
(8)
representing polynomials with coefficients in other variables
(and the main variable x suppressed), lc(F) = fo, @(F) = 0.
As can be seen by examining (3) and (4), Sj1 is the minor of
a submatrix of S00, composed of the (VI + y - 2j - 1) columnsO0. i+y-2j- 2,andacolumnq= (1+l+y2j- 1), 1 = ... j selected from the remaining columns. We
..
..
...
-
947
GRISS: POLYNOMIAL SUBRESULTANTS AND GCD
identify sjl by the key
KEY (Sjl) = KEY (0, 1,",
minors always involve a joint shift of F and G:
NSET 4- DMRG1 (DMRG1 (SET, F), G));
(12)
F +- SHIFT (F, 2); G f-SHIFT (G, 2);
If we first make up a set of 2 x 2 minors,
FG +- DMRG1 (F, G), and generalize DMRG1 to accept 2
sets of minors (as suggested in [7]), we find a simpler form
+ y-2j-2,
1 + / + y -2j- 1)
= 20 + 21 + ..+ 2x-1 + 2x
= (2x
1) + 2x 21,
I= 0 j with x =
NSET 4- DMRG2
+ y-2j- 1. (9)
(SET, FG);
(13)
FG 4-SHIFr (FG, 2);
where the 2 x 2 minors in FG are therefore computed only
KEY (sj1) = (Bk- 1) + Bk * 21
once, saving repeated computation.
It is interesting to note that the elements of Bezout's
where
matrix (a i/ x matrix derived from Sylvester's matrix) are
Bk = 20+Y+2k-2y-1
simple sums of the 2 x 2 minors in FG. This suggests that
= 2q y+2k-1 = 4 * Bk-1
the
above method be directly applied to Bezout's matrix,
(10)
producing an even more efficient method, discussed in the
Now Bo _ 20-Y 1 and is computed while computing the next section.
"base" set:
IV. BEZOUT'S MATRIX
B 1/2;
The following 4' x 4l matrix B (known as Bezout's matrix)
SET := NIL;
has
been used by Ku and Adler [1] to compute the resultant,
FOR I = 1: (/-y) DO
G)= det (B):
S(F,
<<SET DMRG1 (SET, G);
G :=SHIFT (G, 2);
92
go g1
B =2 * B>»;
fr-y base
91
go
I
rows
where SHIFT (G, 2) simply "shifts" all keys of G by multiplygy
go g1
ing by 2. Now the main loop begins:
A I tk
A13
All A12
y rows
J:=y- 1;
Recall that j =y-k, k = 1
.
7 so that
...
...
STEP: NSET =DMRG1 (DMRG1 (SET, F), G));
IF NSET = NIL THEN GOTO DONE;
SET :=NSET; B =4 * B;
IF J = 0 THEN GOTO DONE;
F :=SHIFT (F, 2); G =SHIFT (G, 2);
J:=J- 1;
Ayl
(14)
The Aij are sums of 2 x 2 minors, Dij,
Dij = figj -fjgi
GOTO STEP;
Finally we compute the coefficients sjl:
DONE: Bi :=B - 1;
GCD := NIL;
FOR L:=O: J DO
<<GCD := LOOKUP
B =2 * B>>;
I
(Bi + B, SET) *GCD;
(15)
(wherefi or gi = 0 if i is out of range); and
w
Aij
=
E DkJ+k
k=0
(16)
with
w = min (i -j, /
-
i
-
1j - 1, X'-j - 1).
GCD :=REVERSE GCD;
The Aij are obtained from the coefficients of x in a
homogeneous system of equations [1], just as Sylvester's
which computes the GCD in a nonsparse form. The actual matrix is obtained from the system of equations
program is given in the Appendix, in MODE REDUCE [7], [10].
x*1- G(x) 0
(MODE REDUCE is a computer algebra system with a Pascallike type definition facility.)
x*-2G(x) 0
In order to find the GCD of nonprimitive polynomials,
the above algorithm will be applied recursively to the
coefficients, to obtain GCD (cont (F1), cont (F2)), as sug(17)
x°G(x)= 0
gested- in [5], so that finally,
=
=
GCD(F1, F2)
=
x-1- F(x) = 0
GCD(pp(Fj), pp(F2))*GCD(cont(F1), cont(F2)) (11)
Once the "base" set has been computed, subsequent sets of
x°F(x)= 0
948
IEEE TRANSACTIONS ON COMPUTERS, VOL.
We first define partial sums ("head" and "tail" polynomials)
of F(x) and G(x):
Fk(x)
k
=
Fk(X)
fixki
i=O
k
Gk(x) = Z giXy-i
10,
OCTOBER
1978
-
x°G(x)= 0
Fo(x)Go(x) - Go(x)Fo(x) = 0
Efix
i=k+l
y
Gk(x) =E
gix
i=O
NO.
x(-YG(x)=
=
*
=
c-27,
(21)
(18)
Fy_ l(x)Gy--(x)- G, I(x)F,- I(x) = 0.
given in [1].
that
50sothat
This derivation shows that if the columns of Sylvester's
matrix are labeled with.powers of x, [x* 1, x*+ -2, * *,
F(x) = F,(x) = F_ 1(x)
x°] [corresponding to the system of equations in (17)], the
transformation (19) corresponds to simple row operations
= Fk(x) x -k + Fk(X),
k 0 ...*
on (say) x'F(x), adding multiples of other rows. This can be
used to show the equivalence of det (S00) and det (B).
We can now show rather simply that the determinants of
G(x) = G7(x) = G_ l(x)
the matrices Sjl (selected from the first q/ - y + 2(y - j) rows
k + Gk(X),
= Gk(x) *
k = 0 ... Y. (19) of SOO) are identical to a similar process applied to the first
il - y + (y - j) rows of Bezout's matrix B. These are smaller
and the process will therefore be more efficient than
minors,
n cm e proqt0
We now combine y pairs of equationsWe xFx)
direct
to Sylvester's matrix as in Section III.
application
Y
XO'- +'G(x) 0 as i 0 y 1:
We permute the first -y + 2(y-j) rows of 300 to
correctly pair the xiF(x) and x'-Y+'G(x) rows:
*..
ggy
go g1
i=k+ 1
=
=
...
O
'
go
gy
gy
fy ..-f
...
Fo
Mj= Go
fo
g0
F,
fo fi
GI
fi
91
go
fo
Gy_
-go
I-Y
rows
I
(22)
2(y-j)
rows
fy
gy
91
excess columns
We now eliminate all {Fi} coefficients in the "excess columns" of the F rows, by performing the row operations
indicated in equation (19), using the Fi and Gi row "labels":
[x'F(x)]Gi(x) [x-Y +G(x)]Fi(x) 0
=
xzGi(x)[Fi(x)x-i + Fi(x)]
-
=
row
x*-Y+Fi[Gi(x)xy-' + Gi(x)]
x'F
-+
x'F
Gi(x)
Fi(x)
*x" "-G(x).
(23)
This multiplies each F row by go, and adds (or subtracts) a
of other rows. Thus, det (Mi) is increased by g97j.
multiple
= x'[Gi(x)Fi(x)
xYGi(x)Fi(x)] (20)
now
the principal segment of B, and additional
contains
which eliminates all powers of x greater than x*- y - 1. This Mj
rows of G:
leads to the q/ equations:
4-
I
..j
gY
.
o
go
0
go
0
g1
0
0
go
g1
Do,
91
D 12
D02 (Do3 + D12)
92
.
.
...
gy
gy
Doq,
Diq,
(24)
949
GRISS: POLYNOMIAL SUBRESULTANTS AND GCD
Each of the determinants s£l now corresponds to a determinant of Mj, with I selecting one of the last j columns. The
excess triangular portion of G rows can be replaced by 1
(after dividing by the gy0- factors) so that the determinants
sjl are obtained from the matrix
0
g
...
gy
...
0
9
Do,
D02 (Do3 + D12)
Doe,
Di,,
(25)
applying the stepwise method of Section III to Bezout's
matrix B. A program can be easily devised to compute the
Aij elements as the minors are generated in a stepwise
fashion.
IV. CONCLUSIONS
The application of the efficient sparse minor expansion
algorithm to the direct computation of the GCD via generation of all requisite subresultants is quite simple and
efficient.
I am grateful for many enjoyable discussions on this
subject with D. Yun, M. Rothstein, and S. Brown. The
method can be applied either to Sylvester's matrix or to
Bezout's reduced matrix, leading to an even more efficient
method. When the input polynomials are sparse, Sylvester's
matrix and even Bezout's matrix will be rather sparse,
clearly motivating the use of a sparse minor expansion
method.
APPENDIX
USE OF THE EFFICIENT SPARSE MINOR
ALGORITHM TO COMPUTE GCD
Load SPARSE MINOR package (ref. 7) to define sparse minor
data structures and procedures:
MODE
MODE
ELEM =POLYNOMIAL,
EROW=LISIOF ELEM;
DELEM=STRUCT(KEY:INTEGER,DETM:LLEM),
DROW =LISTOF DELEM;
Procedures:
DMRG1(drow,drow)->arow
SHIFT(drow,integer)->drow
Dense row
Sparse row
hinor expansion
Shift columns
ELEM PROCEDURE LOOKUP(K,D);
% Lookup K'th entry in minor list D;
DCL K:INTEGER, D:DROW;
IF NULL D THEN 0
ELSE IF KEY(HEAD D)=K ThEN DETM(hEAD D)
ELSE LOOKUP(K,TAIL D);
EROW PROCEDURE EGCD(E1,E2);
A Generate minors in "good-order" to obtain Subresultants or
BEGIN
DCL PHI,GAMMA,M,B1,B,J,L:INTEGER,
E,GCD:EROW,
F,G,SET,NSET:DROW;
A Ensure PhI>=GAMMA;
PHI:=LENGTH El -1; GAMMA:=LENGTh E2-1;
IF GAMMA > PHI THEN <<M:=PHI; PHl:=GAMMA; GAMMA:=M;
E: =El1; £1: =E2; E2: =E>>;
A Convert to sparse rows;
G:=DROW El; F:=DROW E2;
h:=PhI-GAMMA;
A Block of PHI-GAMMA "short" rows;
IF M>O THEN
<<SET:=F; h:=M-1; B:=1;
FOR l:=l:M DO <<F:=ShlFT(F,2);
B:=2*B;
SET:=DMfiGl(SEl,F)>>;
F:=ShIF'T(F,2) >>
ELSE <<SET:=DMRG1(F,G); GAMMA:=GAMMA-1; B:=2;
G:=ShIFT(G,2);
F:=ShlFI(F,2)>>;
STEP:
J:=GAMMA;
% Merge successive rows, until NSEI is empty;
NSET:=DMRG1(DMRGl(SET,F),G);
IF NULL NSET THEN GOTO DONE;
SET:=NSET;
IF J=O ThEN GOTO DONE;
X Shift columns by 1 place;
G:=SHIFT(G,2); F:=ShIFT(F,2);
B:=4*B; J:=J-1;
DONE:
GOTO STEP;
A Produce list of subresultants (or GCD);
Hi : 'B-i
GCD: =NIL;
FOR L:=O:J DO
<<GCD:=LOOKUP(b1B,SET)
B:=2*B>>;
ENE;
RETURN REVERSE GCD
. GCD;
GCD;
9IEEE TRANSACTIONS ON COMPuTERS, VOL. c-27, NO. 10, OCToBER 1978
950
REFERENCES
[11] M. L. Griss, "The definition and use of data-structures in REDUCE,"
[1] S. Y. Ku and.R. J. Adler, "Computing polynomial resultants:
Bezout's determinant vs. Collins' reduced PRS algorithm," Commun.
Ass. Comput. Mach., vol. 12, p. 23, 1969.
[2] W. S. Brown, "On the subresultant PRS algorithm," presented at
SYMSAC 76, Yorktown Heights, 1976. Bell Lab. Comput. Sci. Tech.
Rep. 56, 1976. (Submitted to Ass. Comput. Mach. TOMS.)
[3] W. S. Brown and J. F. Traub, "On Euclids algorithm and the theory
of subresultants," J. Ass. Comput. Mach., vol. 18, p. 505, 1971.
[4] E. I. Jury, "The theory and applications of the inners," Proc. IEEE,
vol. 63, pp. 1044-1068,
[5] N. K. Bose, "An algorithm for GCF extraction from two multivariable polynomials," Proc. IEEE (Letters), pp. 185-186, Jan. 1976.
[6] M. L Griss, "The algebraic solution of sparse linear systems via
minor expansion," Ass. Comput. Mach. TOMS, vol. 2, p. 39, 1976.
[7] -, "An efficient sparse minor expansion algorithm," Proc. Ass.
Comput. Mach. 76, p. 429, 1976.
[8] W. M. Gentleman and S. C. Johnson, "Analysis of algorithms, a case
study: Determinants of polynomials," Ass. Comput. Mach. TOMS,
vol. 2, p. 232, 1976.
[9] E. Horowitz and S. Sahni, "On computing the exact determinant of
matrices with polynomial entries," J. Ass. Comput. Mach., vol. 22, p.
38, 1975.
[10] A. C. Hearn, "A mode analyzing algebraic manipulation program,"
Proc. Ass. Comput. Mach. 74, p. 722, 1974.
Martin L Griss (M'76) was born in Capetown,
South Africa, on September 4, 1944. He received
the B.Sc. degree in mathematical physics at the
Technion, Haifa, IsraeL in 1967, and the Ph.D.
degree in theoretical physics at the University of
Illinois, Urbana, IL, in 1971.
He spent two years at the California Institute
of Technology, Pasadena, CA, as a Postdoctoral
Fellow in Theoretical Physics, and two years with
the Utah Computational Physics Group as a
Research Assistant Professor in the Department
of Physics. He is currently an Assistant Professor in the Department of
Computer Science, University of Utah, Salt Lake City, UT. He has been
involved with mathematical software and computational methods since
1963. Current research involves computer algebra and portable symbol
manipulation systems. Areas of interest include sparse matrices, general
computational methods, and portable programming language design and
implementation.
Dr. Griss is a member of the Association for Computing Machinery
(SIGPLAN, SIGNUM, SIGSAM, SIGSOFT, SIGMINI, and
SIGMICRO).
Proc. SYMSAC 76, Ass. Comput. Mach., p. 53, 1976.
Download