Gsolve: a faster algorithm for solving systems of algebraic equations
Manuel Bronstein
Computer Science Division
Dept. of Electrical Engineering and Computer Science
University of California, Berkeley
Berkeley, California 94720
Abstract
We apply the elimination property of Grdbner
bases with respect to pure lexicographic ordering
to solve systems of algebraic equations. We sug-
gest reasons for this approach to be faster than
the resultant technique, and give examples and
timings that show that it is indeed faster, and
more correct, than MACSYMA’s solve.
1. Introduction
Solving a system of algebraic equations in
several variables is a two step process: we first
need to reduce the system to one or several
univariate equations, which can then be solved.
That reduction can be done either by computing
resultants, or by computing a Gtibner basis for the
system. Since MACSYMA’s solve uses the resul-
tant approach, we have implemented gsolve which
uses Zacharias’ package ([81) to compute a Gtibner
basis. Our comparative timings indicate that the
latter is considerably faster than the former,
except for univariate equations or linear systems.
1.1. The resultant approach (solve)
This technique is based on the following two
properties:
(i) Xi does not appear in the resultant of f and g
with respect to Xi, and
(ii) the resultant of two polynomials f and g
belongs to the ideal (f,g).
Thus, the zeroes of our initial system will be
among those of the system of its resultants, which
has one equation and one variable less.
If the initial system has finitely many zeroes,
repeating this process will eventually give us one
or more univariate equations. While resultants
can be computed in polynomial time tL?l), the
degree of the univariate equation is Otd” I where
u is the initial number of variables. Solving
exactly such an equation can be very time-
consuming and often impossible. See 151.ch.1, for a
complete introduction to resultants and their use
in solving systems of algebraic equations
1.2. The Griibner basis approach (gsolve)
We assume that the reader is familiar with
the notion of a Gr8bner basis. See 151,ch.111, or 131
for an introduction to the topic. The algorithm is
based on the following “elimination” property of
Grijbner bases, proved in [71:
Let IT be a Griibner basis for an ideal I of
k[X,, . . . ,X,,,Y,, . . . ,Y,J with respect to some
ordering <. Zf < is such that any term involving
Yi’s is greater than any term involving only Xi’s,
then rn k[X,, . . ,Xnl] is a Grijbner basis fir
1 f-J k[X,, . . . ,X,,l.
The consequence of this result that is used in
gsolve is the following property, proved in [3],
problem 6.11, and mentioned in [5], ch.III.5:
Let Zck[X,, . . . ,X,1 be an ideal. Zf I has finitely
many zeroes in kn, then any Grabner basis for I
with respect to pure lexicographic ordering will
either be {1}, or will contain polynomials
h,, . . . ,h, such that for each i E [l..nl,
hick[Xl,. . . ,Xi] and the lead monomial of hi is a
non-zero power of Xi.
Conversely, if such polynomials exist in a Grobner
basis for each i E[l..n], then I has finitely many
zeroes in k”.
This work was supported in part by the Army Research Office
grant DAAG 29-85-K-0070
Permission to copy without fee ail or part of this material is granted
provided that the copies are not made or distributed for direct
commercialadvantage,the ACM copyright notice and the title of
thepublication andits dateappear,and noticeis giventhat copying
is by permission of the Association for Computing Machinery. To
copy otherwise, or to republish, requires a fee and/or specfic
permission.
0 1986 ACM O-89791-199-7/86/0700-0247 7% 247
Thus, the Grgbner basis of an ideal will have
exactly the same zeroes than the initial system
(since it is a basis for the same ideal), but it will
be a triangular system, which can be solved itera-
tively.
Although little is known about the complexity of
Buchberger’s algorithm ([1,2,6]) for computing
Gr%bner bases, it is much slower than computing
resultants. The size of a Gr’dbner basis can be as
large as doubly exponential in the number of vari-
ables, and most non-trivial examples are indeed of
exponential size. The point is, however, that the
degrees of the univariate equations that we obtain
cannot be larger, in the finite case, than the
number of solutions, while in the infinite case we
will have to solve an equation for Xi only if the
projection of the solution set on the Xi-axis is
finite, and the degree of that equation will be no
larger than the size of this projection. This often
gives equations of lower degrees than the resul-
tant technique, which could make this approach
faster overall.
2. Timings
We compared solve and gsolve on a VAX
8600 (vangogh.berkeley.edu), using actual equa-
tions from various users. Our results indicate 3
classes of systems:
(i) those that both techniques could solve,
(ii) those that gsolve could solve, but not solve,
and
(iii) those that neither technique could solve.
We now give examples from each class (the
numbers given are milliseconds of CPU time, gar-
bage collections excluded).
2.1. 1st case: both successful
We found that, except for linear systems, gsolve
was generally three times faster than solve. Most
sets of quadratic or cubic equations in (r,y) fall in
this case, as well as some systems of higher
degree.
To solve
x2+y2 = R2
Y = ax+b
for x and y, solve took 3816 msecs, while gsolve
took 1000 msecs.
To solve
1
axy2+b = c
dx2y+e = f
for z and y, solve took 9400 msecs, while gsolve
took 3633 msecs.
2.2. 2nd case: only gsolve successful
We found that most sets of quadratic or cubic
equations in (x,y,z) fall in this case, as well as
some complex sets of quadratic equations in (x,y).
Those include systems that arise from the study of
curves and surfaces in space. The time difference
was more significant, since gsolve was from eight
to twenty times faster than solve.
To solve
1
x2+y2+z2 = R2
z=x+y
xy+z2 = 1
for xy, and t, gsolve took 8150 msecs, while
solve returned the empty list after 68617 msecs
(the system has 4 zeroes in C3).
To 6nd the singularities of Durer’s conchoid, that
is to solve
2y2(y2+x2)+(b2-3a2)y2-2by2fy+x)
+2a2b(y+x)--a2r2+a2(a2-b2) = 0
* 4y3+4y(y2+x2)--by’-rlby(y+r)
+ 2(b2 -3a2)y+2a2b = 0
4Xy2- 2by2-2a2z+2a2b = 0

for x and y, gsolve took 12133 msecs, while solve
returned the empty list after 95017 msecs. The
system has 2 zeroes, which are:
3b-m
X= ,Y=
b+m
4 4
and
x= 36+- b-w
4
,y=
4 *
To solve
x2+y2 = R2
y = r2+r+l
for x and y, gsolve took 13750 msecs, while solve
ran out of memory space after 1399783 msecs.
There were also some systems where solve could
not find closed form formulas for the zeroes: to
solve
1
x2+y2 = 1
Y =x2+X+1
for x and y, gsolve took 4117 msecs, while solve
only found numerical approximations to the 4
zeroes in 1833 msecs.
248
2.3. 3rd case: none successful
Most systems in four or more variables, or with
high degrees, fall within this case. Both solve and
gsolve would run out of memory space, after a
similar time, with the exception that solve would
sometimes reject the system as too complex. A typ-
ical example is
I
x2+y2+z2 = R2
zy+2 = 1
xyz-x2-y2 = z-1
where gsolve returned an equivalent triangular
system in 430133 msecs, while solve rejected it
after 3717 msecs. However, the system returned by
gsolve contains a univariate equation of degree
12, while computing resultants will give a univari-
ate equation of degree 28.
2.4. Systems with infinitely many zeroes
None of the techniques proved significantly faster,
but solve showed several “bugs”. For instance,
when asked to solve
[ x2+y2+z2 = 1
I
z =x+y
for zj and z, solve returned the empty set [I after
1584 msecs, while gsolve returned the following
(correct) parameterization of the solution set (a cir-
cle) after 666 msecs:
[[x =x,y = -
d/2-3x2 -l-x
2
,z= -
42-3x2-x I
2 p
Ix= y d2-31c2-x d2-3x2+x
x, = 2 et=
2
11
3. Conclusion
We see that the GrZbner basis approach,
although slower in the triangulation stage, is
overall faster than the resultant approach on most
examples. Furthermore, we see that gsolve
increases the number of systems that can be solved
in MACSYMA. Although more extensive testing
is necessary, it appears that a Grcbner basis equa-
tion solver is a useful addition to an algebraic
manipulation system.
References
[ll Buchberger, B., A Theoretical Basis for the
Reduction of Polynomials to Canonical Forms,
ACM-SIGSAM Bulletin, 39, August 1976, pp.
19-29.
I21 Buchberger, B., A Note on the complexity of
computing Griibner bases, Proceedings of
EUROCAL ‘83, Lecture Notes in Computer
Science, vol. 162. Springer-Verlag, 1983, pp.
t37-145.
131Buchberger, B., Griibner bases: An Algorithmic
Method in Polynomial Ideal Theory, Recent
Trends in Multidimensional Systems Theory,
NE. Bose (ed.), D. Reidel Publ. Comp., 1985.
141Collii, G.E., The Calculation of Multivariate
Polynomial Resultants, J. ACM 18 (19711, pp.
515632.
151Davenport, J.H., Computer Algebra for CyZindr-
ical Algebraic Decomposition, Report TRITA-
NA-8511, NADA, Royal Institute of Tecbnol-
ogy, Stockholm.
t61
I71
181
Lauer, M., Canonical Representatives for Resi-
due Classes of a Polynomial Ideal, SYMSAC,
1976, pp. 339-345.
Trinks, W., Uber B. Buchbergers Verfahren,
Systeme algebraischer Gleichungen zu ltisen,
Journal of Number Theory 10, 1978, pp. 475-
488.
Zacharias, G., Generalized Grijbner Bases in
Commutative Polynomial Rings, Bachelor
Thesis, Lab. for Computer Science, MIT, 1978.
249

bronstein1986666666666666666666666666.pdf

  • 1.
    Gsolve: a fasteralgorithm for solving systems of algebraic equations Manuel Bronstein Computer Science Division Dept. of Electrical Engineering and Computer Science University of California, Berkeley Berkeley, California 94720 Abstract We apply the elimination property of Grdbner bases with respect to pure lexicographic ordering to solve systems of algebraic equations. We sug- gest reasons for this approach to be faster than the resultant technique, and give examples and timings that show that it is indeed faster, and more correct, than MACSYMA’s solve. 1. Introduction Solving a system of algebraic equations in several variables is a two step process: we first need to reduce the system to one or several univariate equations, which can then be solved. That reduction can be done either by computing resultants, or by computing a Gtibner basis for the system. Since MACSYMA’s solve uses the resul- tant approach, we have implemented gsolve which uses Zacharias’ package ([81) to compute a Gtibner basis. Our comparative timings indicate that the latter is considerably faster than the former, except for univariate equations or linear systems. 1.1. The resultant approach (solve) This technique is based on the following two properties: (i) Xi does not appear in the resultant of f and g with respect to Xi, and (ii) the resultant of two polynomials f and g belongs to the ideal (f,g). Thus, the zeroes of our initial system will be among those of the system of its resultants, which has one equation and one variable less. If the initial system has finitely many zeroes, repeating this process will eventually give us one or more univariate equations. While resultants can be computed in polynomial time tL?l), the degree of the univariate equation is Otd” I where u is the initial number of variables. Solving exactly such an equation can be very time- consuming and often impossible. See 151.ch.1, for a complete introduction to resultants and their use in solving systems of algebraic equations 1.2. The Griibner basis approach (gsolve) We assume that the reader is familiar with the notion of a Gr8bner basis. See 151,ch.111, or 131 for an introduction to the topic. The algorithm is based on the following “elimination” property of Grijbner bases, proved in [71: Let IT be a Griibner basis for an ideal I of k[X,, . . . ,X,,,Y,, . . . ,Y,J with respect to some ordering <. Zf < is such that any term involving Yi’s is greater than any term involving only Xi’s, then rn k[X,, . . ,Xnl] is a Grijbner basis fir 1 f-J k[X,, . . . ,X,,l. The consequence of this result that is used in gsolve is the following property, proved in [3], problem 6.11, and mentioned in [5], ch.III.5: Let Zck[X,, . . . ,X,1 be an ideal. Zf I has finitely many zeroes in kn, then any Grabner basis for I with respect to pure lexicographic ordering will either be {1}, or will contain polynomials h,, . . . ,h, such that for each i E [l..nl, hick[Xl,. . . ,Xi] and the lead monomial of hi is a non-zero power of Xi. Conversely, if such polynomials exist in a Grobner basis for each i E[l..n], then I has finitely many zeroes in k”. This work was supported in part by the Army Research Office grant DAAG 29-85-K-0070 Permission to copy without fee ail or part of this material is granted provided that the copies are not made or distributed for direct commercialadvantage,the ACM copyright notice and the title of thepublication andits dateappear,and noticeis giventhat copying is by permission of the Association for Computing Machinery. To copy otherwise, or to republish, requires a fee and/or specfic permission. 0 1986 ACM O-89791-199-7/86/0700-0247 7% 247
  • 2.
    Thus, the Grgbnerbasis of an ideal will have exactly the same zeroes than the initial system (since it is a basis for the same ideal), but it will be a triangular system, which can be solved itera- tively. Although little is known about the complexity of Buchberger’s algorithm ([1,2,6]) for computing Gr%bner bases, it is much slower than computing resultants. The size of a Gr’dbner basis can be as large as doubly exponential in the number of vari- ables, and most non-trivial examples are indeed of exponential size. The point is, however, that the degrees of the univariate equations that we obtain cannot be larger, in the finite case, than the number of solutions, while in the infinite case we will have to solve an equation for Xi only if the projection of the solution set on the Xi-axis is finite, and the degree of that equation will be no larger than the size of this projection. This often gives equations of lower degrees than the resul- tant technique, which could make this approach faster overall. 2. Timings We compared solve and gsolve on a VAX 8600 (vangogh.berkeley.edu), using actual equa- tions from various users. Our results indicate 3 classes of systems: (i) those that both techniques could solve, (ii) those that gsolve could solve, but not solve, and (iii) those that neither technique could solve. We now give examples from each class (the numbers given are milliseconds of CPU time, gar- bage collections excluded). 2.1. 1st case: both successful We found that, except for linear systems, gsolve was generally three times faster than solve. Most sets of quadratic or cubic equations in (r,y) fall in this case, as well as some systems of higher degree. To solve x2+y2 = R2 Y = ax+b for x and y, solve took 3816 msecs, while gsolve took 1000 msecs. To solve 1 axy2+b = c dx2y+e = f for z and y, solve took 9400 msecs, while gsolve took 3633 msecs. 2.2. 2nd case: only gsolve successful We found that most sets of quadratic or cubic equations in (x,y,z) fall in this case, as well as some complex sets of quadratic equations in (x,y). Those include systems that arise from the study of curves and surfaces in space. The time difference was more significant, since gsolve was from eight to twenty times faster than solve. To solve 1 x2+y2+z2 = R2 z=x+y xy+z2 = 1 for xy, and t, gsolve took 8150 msecs, while solve returned the empty list after 68617 msecs (the system has 4 zeroes in C3). To 6nd the singularities of Durer’s conchoid, that is to solve 2y2(y2+x2)+(b2-3a2)y2-2by2fy+x) +2a2b(y+x)--a2r2+a2(a2-b2) = 0 * 4y3+4y(y2+x2)--by’-rlby(y+r) + 2(b2 -3a2)y+2a2b = 0 4Xy2- 2by2-2a2z+2a2b = 0 for x and y, gsolve took 12133 msecs, while solve returned the empty list after 95017 msecs. The system has 2 zeroes, which are: 3b-m X= ,Y= b+m 4 4 and x= 36+- b-w 4 ,y= 4 * To solve x2+y2 = R2 y = r2+r+l for x and y, gsolve took 13750 msecs, while solve ran out of memory space after 1399783 msecs. There were also some systems where solve could not find closed form formulas for the zeroes: to solve 1 x2+y2 = 1 Y =x2+X+1 for x and y, gsolve took 4117 msecs, while solve only found numerical approximations to the 4 zeroes in 1833 msecs. 248
  • 3.
    2.3. 3rd case:none successful Most systems in four or more variables, or with high degrees, fall within this case. Both solve and gsolve would run out of memory space, after a similar time, with the exception that solve would sometimes reject the system as too complex. A typ- ical example is I x2+y2+z2 = R2 zy+2 = 1 xyz-x2-y2 = z-1 where gsolve returned an equivalent triangular system in 430133 msecs, while solve rejected it after 3717 msecs. However, the system returned by gsolve contains a univariate equation of degree 12, while computing resultants will give a univari- ate equation of degree 28. 2.4. Systems with infinitely many zeroes None of the techniques proved significantly faster, but solve showed several “bugs”. For instance, when asked to solve [ x2+y2+z2 = 1 I z =x+y for zj and z, solve returned the empty set [I after 1584 msecs, while gsolve returned the following (correct) parameterization of the solution set (a cir- cle) after 666 msecs: [[x =x,y = - d/2-3x2 -l-x 2 ,z= - 42-3x2-x I 2 p Ix= y d2-31c2-x d2-3x2+x x, = 2 et= 2 11 3. Conclusion We see that the GrZbner basis approach, although slower in the triangulation stage, is overall faster than the resultant approach on most examples. Furthermore, we see that gsolve increases the number of systems that can be solved in MACSYMA. Although more extensive testing is necessary, it appears that a Grcbner basis equa- tion solver is a useful addition to an algebraic manipulation system. References [ll Buchberger, B., A Theoretical Basis for the Reduction of Polynomials to Canonical Forms, ACM-SIGSAM Bulletin, 39, August 1976, pp. 19-29. I21 Buchberger, B., A Note on the complexity of computing Griibner bases, Proceedings of EUROCAL ‘83, Lecture Notes in Computer Science, vol. 162. Springer-Verlag, 1983, pp. t37-145. 131Buchberger, B., Griibner bases: An Algorithmic Method in Polynomial Ideal Theory, Recent Trends in Multidimensional Systems Theory, NE. Bose (ed.), D. Reidel Publ. Comp., 1985. 141Collii, G.E., The Calculation of Multivariate Polynomial Resultants, J. ACM 18 (19711, pp. 515632. 151Davenport, J.H., Computer Algebra for CyZindr- ical Algebraic Decomposition, Report TRITA- NA-8511, NADA, Royal Institute of Tecbnol- ogy, Stockholm. t61 I71 181 Lauer, M., Canonical Representatives for Resi- due Classes of a Polynomial Ideal, SYMSAC, 1976, pp. 339-345. Trinks, W., Uber B. Buchbergers Verfahren, Systeme algebraischer Gleichungen zu ltisen, Journal of Number Theory 10, 1978, pp. 475- 488. Zacharias, G., Generalized Grijbner Bases in Commutative Polynomial Rings, Bachelor Thesis, Lab. for Computer Science, MIT, 1978. 249