Gcd of multivariate polynomials via Newton polytopes

Gcd of multivariate polynomials via Newton polytopes

Applied Mathematics and Computation 217 (2011) 8377–8386 Contents lists available at ScienceDirect Applied Mathematics and Computation journal homep...

383KB Sizes 0 Downloads 139 Views

Applied Mathematics and Computation 217 (2011) 8377–8386

Contents lists available at ScienceDirect

Applied Mathematics and Computation journal homepage: www.elsevier.com/locate/amc

Gcd of multivariate polynomials via Newton polytopes q Luiz Emilio Allem, Vilmar Trevisan ⇑ Instituto de Matemática – UFRGS Porto Alegre, RS 91509-900, Brazil

a r t i c l e

i n f o

Keywords: Newton polytope Multivariate polynomial Greatest common divisor

a b s t r a c t We study geometric criteria to determine coprimality between multivariate polynomials. Our main contribution is the development of a polynomial-time algorithm (on the number of monomials) that detects coprimality of multivariate polynomials using Newton polytopes. We also show how to construct the gcd of two bivariate polynomials using their Newton polygons. Ó 2011 Elsevier Inc. All rights reserved.

1. Introduction It is well known that given randomly two multivariate polynomials (see, for example [5,7]), they are almost always relatively prime. Hence, it is a desirable feature of a gcd algorithm, the efficient detection of coprimality before engaging the computation of the actual gcd. In this paper, we present a geometric criterion that guarantees the coprimality between two multivariate polynomials. We also suggest a practical implementation of this criterion and verify that it is very efficient for sparse polynomials of large degrees and large coefficients. For bivariate polynomials we present an algorithm that uses the associated Newton polygons to actually compute the gcd. Many advances in Mathematics are made when results connect two distinct areas. One of the first results connecting geometric and algebraic properties of polynomials was done by Ostrowski [8] in 1921. He showed that if a polynomial is reducible then its associated Newton polytope is decomposable. More recently, S. Gao used the geometric properties of polytopes to construct families of absolutely irreducible polynomials in [3,4]. In [1], Gao and coworkers presented an algorithm for factoring bivariate polynomials via Newton polygons. In this paper we use geometric properties of Newton polytopes to obtain a criterion establishing that two multivariate polynomials are relatively prime. More precisely, we study the coprimality between multivariate polynomials verifying whether their associated Newton polytopes have no common factors. We show that Newton polytopes have no common factors if they have no common parallel edges. For determining the edges of a polytope, in order to transform the criterion into an algorithm, we compute its facial graph. In our implementation, we used the free mathematical software polymake [6]. Computing the facial graph of a polytope depends basically on the number of vertices of the polytope. Hence, we observe that our criterion can be used very efficiently for sparse multivariate polynomials with large degrees because this class of polynomials will have associated Newton polytopes with few vertices. The algorithm is suitable as a pretest in a gcd algorithm implementation and will be specially useful if the sparse multivariate polynomials have very large coefficients.

q

Work partially supported by CAPES Postdoctoral Fellowship (Luiz Emilio Allem) and CNPq (Vilmar Trevisan) - Grants 473815/2/10-9 and 309531/09-8.

⇑ Corresponding author.

E-mail addresses: [email protected] (L.E. Allem), [email protected] (V. Trevisan). 0096-3003/$ - see front matter Ó 2011 Elsevier Inc. All rights reserved. doi:10.1016/j.amc.2011.03.035

8378

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

The computational time of our algorithm is a polynomial of degree 4 on the number of monomials of the polynomials involved. We also present computational experiments which confirm that our pretest is really efficient when used in these classes of polynomials. We would like to observe that our criterion is portable, in the sense that if the polytopes associated to two polynomials have no common parallel edges, then our coprimality criterion assures that they will be coprimes and will remain coprimes even if their coefficients are modified arbitrarily but with certain collection of them nonzero, i.e., if their associated Newton polytopes remain the same. Moreover, they will be relatively prime over any field. For bivariate polynomials which are not relatively prime we also present an algorithm that computes their gcd using Newton polygons. Our paper is organized as follows. In section 2 we present the terminology and the necessary geometric background. In section 3 we present our coprimality criterion and a theorem which is the key of our pre-test. In section 4 we propose a practical implementation of the criterion that is based on the facial graph of a polytope, and we use the software polymake to actually compute it. In section 5 we report some computational experiments which confirm that our pretest is really efficient when used in sparse multivariate polynomials with large degrees and large coefficients. In section 6 we present an algorithm to compute the gcd between two bivariate polynomials using Newton polygons and we give a detailed example. 2. Newton polytope In this section we develop the necessary background material on the theory of convex sets and the terminology used in the paper. We make the connection between a geometric property of polytopes and its relation with polynomials. For more properties of polytopes, we refer to [2,9]. A convex set in Rn is a set such that the points on the line segment joining any two points of the set lie in the set; the convex hull of a set of points is the smallest convex set which contains them; and the convex hull of a finite set of points is called a convex polytope. A point of a polytope is called a vertex if it does not belong to the interior of any line segment contained in the polytope. A polytope is always the convex hull of its vertices. Given any two integral polytopes A and B we define their Minkowski sum by

A þ B ¼ fa þ b : a 2 A; b 2 Bg: We call A and B the summands of A + B. Let f 2 F½x1 ; . . . ; xn , be a nonconstant polynomial over F, where F is an arbitrary field. The Newton polytope, denoted by Pf, associated to the polynomial

f ¼

X

fi1 ;...;in xi11    xinn

is the convex hull of the set of support vectors of f,

  Suppðf Þ ¼ ði1 ; . . . ; in Þ 2 Nn : fi1 ;...;in – 0 : An integral polytope is a polytope whose vertices have integer coordinates, and we say that an integral polytope is integrally decomposable, or simply decomposable, if it can be written as a Minkowski sum of two integral polytopes, each of which has more than one point. A summand in an integral decomposition is called an integral summand. We say an integral polytope is integrally indecomposable, or simply indecomposable, if it is not decomposable. In this paper we will work only with integral polytopes because they always will represent Newton polytopes associated to polynomials. Our starting point is the next theorem due to Ostrowski [8] which relates the geometry of the Newton polytope and the algebraic factorization of a polynomial f. Theorem 1 (Ostrowski). Let f, g and h 2 F½x1 ; . . . ; xn . If f = gh then Pf = Pg + Ph. Let f and g 2 F½x1 ; . . . ; xn  be two nonconstant polynomials over an arbitrary field F. The unique monic polynomial h satisfying (i) hjf and hjg, and (ii) if sjf and sjg then sjh, for all s 2 F½x1 ; . . . ; xn  is the greatest common divisor and denoted by h = gcd (f, g). Two polynomials f and g 2 F are said to be relatively prime or coprime if gcd (f, g) = 1. The following corollary establishes a geometric condition, sufficient to decide that two polynomials are coprime. Corollary 1 (Coprimality criterion). Let f and g 2 F½x1 ; . . . ; xn , both not divisible by any xi for 1 6 i 6 n. If Pf and Pg have no common integral summands then

gcdðf ; gÞ ¼ 1: Proof. Suppose by contradiction that gcd (f, g) = h, where deg(h) P 1 and h has not just one term because f and g are both not divisible by any xi. Then Ph has at least two integral points. Let f = h  s and g = h  t for some s, t 2 F½x1 ; . . . ; xn . Note that Ps and Pt have at least two integral points each, because f and g are both not divisible by any xi. By Theorem 1, Pf = Ph + Ps and Pg = Ph + Pt, hence Ph is a common integral summand of Pf and Pg, contradicting our assumption that Pf and Pg have no commons integral summands. h

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

8379

The main goal of this paper is to show how to decide efficiently when two Newton polytopes will share integral summands. We observe that the problem of testing whether a polytope is integrally indecomposable is NP-complete [4]. Finding all integral summands of a polytope seems a hard problem for polynomials of more than two variable1. Hence it is not clear that the criterion given in Corollary 1 can be transformed into an efficient algorithm. Suppose that we have two multivariate polynomials f and g such that their associated Newton polytopes Pf and Pg have no common integral summands. Then by the coprimality criterion we have that the gcd(f, g) = 1. The next three observations follow because a polytope is always the convex hull of its vertices, which depends only on the powers of the nonzero monomials of f and g. 1. The polynomials f and g will remain coprimes over any field, as long as that the coefficients of the monomials which correspond to the vertices of the polytopes do not vanish, i.e., the polytopes remain the same. 2. We can change the coefficients of the polynomials arbitrarily, as long as we keep non-zero the coefficients of all the monomials of the corresponding vertices of the Newton polytopes, and they will remain coprimes. 3. We can add monomials to f and g and they will remain coprimes, as long as their Newton polytopes remain the same. This means we can add monomials that correspond to interior points of their Newton polytopes. These are advantages that show portable characteristics of the criterion we are going develop in the next section. 3. Coprimality criterion Let P be a polytope in Rn . A face of P is the intersection of P with a supporting hyperplane to P. A vertex is a face of dimension 0. A face of dimension 1 is a line segment, called an edge of P. A face of dimension one less than that of P is called facet of P. The next lemma, which can be found in [2–4,9], describes how faces decompose as Minkowski sum of polytopes. Lemma 1. Let P = Q + R where Q and R are polytopes in Rn . Then each face of P is a Minkowski sum of unique faces of Q and R. From this fact we observe that the Minkowski sum u + v of two faces u and v, is an edge if either u and v are parallel edges or if u or v is an edge and the other is a single point. Notice that if u and v are not parallel or if u or v is a face of dimension greater than 1, then u + v has dimension greater than 1. Hence we proved the following. Lemma 2. Let P = Q + R where Q and R are polytopes in Rn . Then each edge of P is a Minkowski sum of unique parallel edges of Q and R or the Minkowski sum of one edge and one point. Consider conv(v0, v1) an edge of a polytope P joining the vertices v0 and v1. Let’s define

v etðv 0 ; v 1 Þ ¼ v 1  v 0 ; the vector derived from the edge conv(v0, v1). We define vet(P) the set composed by the vectors derived from all the edges of P. We say that a vector v in vet(P) is multiple of the vector u if there exists a real number k such that v = ku. Given any two polytopes P and Q we will write

v etðQ Þ,!v etðPÞ if each vector of vet(Q) is multiple of a vector of vet(P). Clearly we have that

v etðQ Þ,!v etðPÞ () v etðPÞ,!v etðQ Þ: And we say that

v etðQ Þ

v etðPÞ

if vet(Q) and vet(P) have no multiple vectors. Proposition 1. Let P and Q be polytopes in Rn . If Q is a summand of P then

v etðQ Þ,!v etðPÞ: Proof. We already observed that if P = Q + R then, each edge of P is a Minkowski sum of unique edges of Q and R or the Minkowski sum of one edge and one point, with all the edges being parallel. Then, each edge conv(q1, q2) of Q joining the vertices q1 and q2 of Q is parallel to some edge conv(p1, p2) of P. So, vet(q1, q2) = k  vet(p1, p2) to some k 2 R. h This proposition leads us to the next criterion to decide when two polytopes do not have common integral summands.

1 Gao and Lauder [4] developed an efficient algorithm for finding integral summands of Newton polygons, that is, for Newton polytopes associated twovariable polynomials.

8380

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

Corollary 2. Let P and Q be polytopes in Rn . If

v etðQ Þ

v etðPÞ

hen P and Q have no common integral summands.

v etðPÞ and that R is a common summand of P and Q. Let r 2 vet(R). By PropProof. Suppose, by contradiction, that v etðQ Þ osition 1, there exists u 2 v etðPÞ; v 2 v etðQ Þ; k1 ; k2 2 R such that r = k1u = k2v, meaning that u and v are multiple, contradicting the hypothesis. h Applying this takes us to the following theorem. Theorem 2. Consider f ; g 2 F½x1 ; . . . ; xn . If

v etðPg Þ

v etðPf Þ

then

gcdðf ; gÞ ¼ 1: Proof. By Corollary 2, Pf and Pg have no common integral summands. Then by the Coprimality Criterion, we have that gcd(f, g) = 1. h

4. Implementation issues If we were to use Theorem 2 for practical purposes, we still need to find an efficient procedure to compute edges of polytopes. 4.1. Facial Graph The facial graph of a polytope is an acyclic directed graph where the nodes are the faces of P and an arc connects faces F and G if only if G is a facet of F. In each node of the facial graph we have the vertices of P which belong to the face represented by the node. For further details about the facial graph of a polytope we refer to [10]. We can also use the free software polymake, available on the internet at http://www.math.tu-berlin.de/diskregeom/polymake/, which supports research in all areas of polytope theory. Particulary, polymake computes the facial graph of a polytope. For example, let’s consider the pyramid given in Fig. 1 which may be seen as the polytope

P ¼ conv ðð0; 0; 1Þ; ð1; 0; 0Þ; ð0; 0; 0Þ; ð0; 1; 0Þð1; 1; 0ÞÞ; where v0 = (0, 0, 1), v1 = (1, 0, 0), v2 = (0, 0, 0), v3 = (0, 1, 0) and v4 = (1, 1, 0) are the vertices of P. Using the software polymake we compute the facial graph of the polytope P, depicted in Fig. 2. In the graph of the Fig. 2, the node (0, 1, 4) represents a facet of P of dimension 3. This facet is the convex hull of the vertices v0, v1 and v4. The node (1, 4) represents an edge of P joining the vertices v1 and v4. Note that, the nodes (0, 1, 4) and (1, 4) are connected by an arc because the edge conv(v1, v4) is a face of the facet conv(v0, v1, v4). 4.2. Pretest for the gcd of multivariate polynomials Clearly it may happens that two polynomials are coprime in spite of the fact that their Newton polytopes share integral summands. On the other hand, Theorem 2 together with the observations made about the facial graph of a polytope, naturally lead to a test that decides when, for many multivariate polynomial families, two of these polynomials are relatively prime.

Fig. 1. A polytope with 5 vertices.

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

014

1234

14

04

4

034

34

01

1

012

12

23

0 3

03

8381

023

02

2

Fig. 2. Facial graph.

We see this criterion as a pretest for an implementation of a gcd algorithm. Our pretest works as follow. Given two multivariate polynomials, we compute the facial graph of the Newton polytopes associated to f and g. Then, we verify if the polytopes have parallel edges. If they have no parallel edges, then gcd(f, g) = 1, by Theorem 2. Algorithm 1. Pretest for gcd. Input: f and g 2 F½x1 ; . . . ; xn  nonzero polynomials both not divisible by any xi. Output: gcd (f, g) = 1 or ‘‘FAILURE’’. 1. Obtain Supp(f) and Supp(g). 2. Compute the facial graph of Pf = conv(Supp(f)) and Pg = conv(Supp(g)) using the software polymake. 3. If v etðPf Þ v etðPg Þ then return (gcd (f, g)=1) else return (’’FAILURE’’). Computational time: Let m and l be the number of monomials of the polynomials f and g, respectively. Step 1 of the algorithm can be executed in linear time of m and l. As for step 2, Seidel [10] computes, for a set S of s points in Rn , the facial graph of the convex hull of S in time O(s2 + Llogs), where L is the number of faces. If we consider m and l as the number of monomials of f and g as above and, without loss of generality m P l, then, in the worst case, step 2 can be executed in time

Oðm2 þ Lf logðmÞÞ; where the number of faces of Pf, Lf, may vary between X(1) and Oðmb2c Þ. n

8382

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

The time to verify the parallelism of edges in step 3 is dominated by above by the product of the number of edges of f and g. In turn, the number of edges of each polytope is dominated by the number of vertices which satisfies

]ðv etðPf ÞÞ 6



m 2

 ¼

m2  m : 2

Then, if we obtain success in our pretest, we verify whether v etðQ Þ

 2 2 ! m m O 2

v etðPÞ in time

and we conclude that our pretest works in time that is polynomial on the number of monomials. Remark 1 1. We would like to observe that the steps 2 and 3 of our algorithm depend on the number of vertices of the polytopes Pf and Pg. Then, we conclude that our algorithm works better with sparse polynomials with big degrees, because this class of polynomials have Newton polytopes associated with a small number of vertices and consequently a small number of faces. 2. Our pretest does not depend on the size the coefficients of the polynomials involved. 3. If our algorithm is successful, i.e., if the pretest returns gcd(f, g) = 1, then f and g remain coprimes under any field, provide the coefficients of the monomials which correspond to the vertices of Pf and Pg do not vanish. From these observations we may conclude that this algorithm is a good pretest for sparse multivariate polynomials with big degree and big coefficients. 5. Computational experiments In this section we confirm that our pretest is really effective when used in sparse polynomials with large degree and large coefficients. The importance of our algorithm hinges on the fact that the gcd of two polynomials is almost always 1. For the sake of completeness, we are going to present a well known probabilistic argument showing that given two random polynomials, the probability that they are coprimes is almost 1. Let’s consider f ; g 2 F½x1 ; . . . ; xn  with deg xi ðf Þ; deg xi ðgÞ 6 d for 1 6 i 6 n, then it well known that gcd (f, g) has positive degree in and only if res (f, g) = 0, where res (f, g) is the resultant of f and g. Now 2

degðresðf ; gÞÞ 6 2ðn  1Þd : Let S  F be a finite set with s = ](S), then

  2ðn  1Þd2 prob resðf ; gÞðaÞ ¼ 0 : a 2 Sn 6 : s And, since gcd(f, g) – 1 if only if res(f, g) = 0, then 2

probfgcdðf ; gÞ – 1g 6

2ðn  1Þd : s

Since s is arbitrarily large, the conclusion follows. In the next tables we use multivariate polynomials with coefficients in Z, and they confirm that our pretest is worth using with sparse multivariate polynomials with big degree. In the tables (m, l) is the number of monomials of f and g, respectively, Maple is the time that the software Maple spent to determine the gcd and pretest is the time spent by our pre-test. Tables 1–4 deal with polynomials of large degree and random (small) coefficients. The next Tables 5–8 deal with sparse multivariate polynomials with large degree and large coefficients. The extra column (jfj, jgj) indicates that the coefficients of f and g are chosen randomly within the interval (jfj, jfj) and. (jgj, jgj), respectively. Our experiments were done inside Maple. Given f and g, we first compute the support (by collecting the exponent vectors), we then call polymake (outside Maple) to compute the facial graph, collect the edges and verify whether there are mulTable 1 Polynomials with 2 variables and small coefficients. (m, n)

(deg (f), deg (g))

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

0.009 0.659 71.871

0.006 0.013 0.003

1 1 1

8383

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386 Table 2 Polynomials with 3 variables and small coefficients. (m, n)

(deg (f), deg (g))

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

0.009 0.399 43.107

0.016 0.007 0.006

1 1 1

Table 3 Polynomials with 6 variables and small coefficients. (m, n)

(deg (f), deg (g))

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

0.006 0.079 21.698

0.017 0.023 0.033

1 1 1

Table 4 Polynomials with 10 variables and small coefficients. (m, l)

(deg (f), deg (g))

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

0.006 0.113 10.595

0.017 0.030 0.014

1 1 1

Table 5 Polynomials with 2 variables and large coefficients. (m, l)

(deg (f), deg (g))

(jfj, jgj)

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

(10000, 10000) (10000, 10000) (10000, 10000)

0.010 0.429 71.785

0.014 0.017 0.010

1 1 1

Table 6 Polynomials with 3 variables and large coefficients. (m, l)

(deg (f), deg (g))

(jfj, jgj)

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

(10000, 10000) (10000, 10000) (10000, 10000)

0.009 0.593 43.277

0.010 0.006 0.003

1 1 1

Table 7 Polynomials with 6 variables and large coefficients. (m, l)

(deg (f), deg (g))

(jfj, jgj)

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

(10000, 10000) (10000, 10000) (10000, 10000)

0.003 0.256 21.635

0.020 0.007 0.013

1 1 1

Table 8 Polynomials with 10 variables and large coefficients. (m, l)

(deg (f), deg (g))

(jfj, jgj)

Maple

Pretest

Gcd (f, g)

(6, 6) (6, 6) (6, 6)

(1000, 1000) (10000, 10000) (100000, 100000)

(10000, 10000) (10000, 10000) (10000, 10000)

0.003 0.123 10.875

0.007 0.020 0.017

1 1 1

8384

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

tiple ones. We then compare the time used by Maple for this procedure to the time used by Maple to compute the gcd of f and g. We are aware that this is a very rough implementation and a naive comparison since Maple has its own pretests, preventing computing the actual gcd if f and g are coprime. Nevertheless it is illustrative to verify that even in these rough conditions, the algorithm was competitive, specially for very sparse polynomials. We would like to observe that during our extensive simulations we never found two random polynomials with gcd – 1. 6. Computing the gcd of bivariate polynomials via Newton polygons In this section we describe how to compute all common integral summands between two polygons in R2 and then use it to compute the gcd between two bivariate polynomials. Given a polygon P in R2 , let’s consider v0, v1, . . . , vm1 the vertices of P ordered cyclically in a clockwise direction. Then, we define the set of edges of P vet(P) = {E1, . . . , En}, with Ei = vi  vi1=(ai, bi) for 1 6 i 6 m, where ai ; bi 2 Z and vm = v0. A vector v ¼ ða; bÞ 2 Z2 is called a primitive vector if gcd (a, b) = 1. Let ni = gcd (ai, bi), then define ei ¼ naii ; nbii . Then Ei = niei where ei is a primitive vector for 1 6 i 6 m. The sequence of vectors {niei}16i6m, which we call the edge sequence, uniquely identifies the polygon P up to translation determined by v0. Define vetprim(P) = {e1, . . . , em}. As the boundary of the polygon is a closed path, we have that Pm i¼1 ni ei ¼ ð0; 0Þ. The next lemma shows how to find the common integral polygons between two given polygons. Lemma 3. Let P and Q be two integral polygons with edge sequences {niei}16i6p and fn0i e0i g16i6q ; respectively. Then, P and Q have a common integral summand R if only if the edge sequence of R is of the form fn00k e00k g16k6r with e00k 2 v etprimðPÞ \ v etprimðQ Þ, where e00k ¼ ei ¼ e0j with ei 2 vetprim(P) and e0j 2 v etprimðQ Þ, and 0 6 n00k 6 minfni ; n0j g for 1 6 k 6 r. Proof. Let R be a common integral summand of P and Q. We consider that the edge sequence of R is fE00k g16k6r . We know that each E00k is summand of some edge of P and Q. Then E00k is summand of niei for some 1 6 i 6 p and n0j e0j for some 1 6 j 6 q, with e00k ¼ ei ¼ e0j . Then E00k ¼ n00k e00k with 0 6 n00k 6 minfni ; n0j g for 1 6 k 6 r. Now, if the edge sequence of R is of the form fn00k e00k g16k6r then each edge n00k e00k is summand of any edge of P and Q. Then, R is a common summand to P and Q. h Notice that, in accordance to Lemma 2, if two polygons P and Q are such that vetprim(P) \ vetprim(Q) = ; then these polygons have no common integral summands. Let f and g 2 F½x; y and consider {niei}16i6p and fn0i e0i g16i6q the edge sequences of the polygons Pf and Pg, respectively. Observe that vetprim(Pf) = {e1, . . . , ep} and v etprimðP g Þ ¼ fe01 ; . . . ; e0q g. By the Theorem 2, if vetprim(Pf) \ vetprim(Pg) = ; then gcd (f, g) = 1. We are interested when

v etprimðPf Þ \ v etprimðPg Þ – ;; and possibly gcd(f, g) – 1. Particularly we want to compute the gcd (f, g) from the common summands of the polytopes Pf and Pg. Define the set v etprimðPh Þ ¼ v etprimðP f Þ \ v etprimðPg Þ ¼ fe001 ; . . . ; e00r g. Now, define the set Ph with edge sequence fn001 e001 ; . . . ; n00r e00r g with n00i ¼ minfni ; n0j g. Note that each n00i e00i for 1 6 i 6 r is summand of some edge from Pf and Pg. First suppose that the edge sequence fn00i e00i g16i6r has the property that r X

n00i e00i ¼ ð0; 0Þ:

i¼1

Then Ph defines a polygon which is summand of Pf and Pg. Let’s associate to the polygon Ph the generic polynomial P h¼ hij xi yj where each (i, j) corresponds to an integral point in Ph. Notice that if we solve the system then we can find out that whether h divides or not f and g. An efficient way to find the polynomial h, that is, to solve the system is presented by Abu Salem et al. [1] and may be seen as a modified Hensel lifting method. Proposition 2. Let h 2 F½x; y be the generic polynomial associated to the polygon Ph and suppose that h divides f and g. Then

gcdðf ; gÞ ¼ h: Proof. Suppose gcd (f, g) = h0 with h0 – h. Then, by Theorem 1, P h0 is an integral summand of Pf and Pg. Hence P Ph0 ¼ fki ei ; . . . ; kr er g with ri¼1 ki ei ¼ ð0; 0Þ and 0 6 ki 6 n00i . Notice that Lemma 3 implies that P h0 is summand of Ph. But, h divides f and g. Then h divides h0 = gcd (f, g). And, therefore, Ph is summand of P h0 , contradiction. In this way, h0 = h and gcd (f, g) = h. h Pr 00 00 00 Now we are going to study the case i¼1 ni ei – ð0; 0Þ. The idea is to look for an edge sequence fkji ei g16i6r such that Pr 00 00 0 6 kji 6 ni and i¼1 kji ei ¼ ð0; 0Þ. We would like to observe that this problem is NP  complete and for details about an algorithm to solve this we refer to [4].

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

8385

P Notice that if there is no edge sequence {kjiei}16i6r with 0 6 kji 6 ni and ri¼1 kji ei ¼ ð0; 0Þ. Then gcd (f, g) = 1. We consider P1, . . . , Pl the polygons whose edges sequence have the property {kjiei}16i6r with 0 6 kji 6 ni and Pr i¼1 kji ei ¼ ð0; 0Þ for 1 6 j 6 l. Then, each Pj leads to a generic polynomial hj, which is a candidate factor of f and g. Proposition 3. Let M = gcd (f, g). Then there is i 2 {1, . . . , l} such that

hi ¼ M: Proof. Let M = gcd (f, g). Then PM is summand of Pf and Pg, and the edge sequence which represents PM has the form {kiei}16i6r P with 0 6 ki 6 ni and ri¼1 ki ei ¼ ð0; 0Þ. Then PM = Pj to some j 2 {1, . . . , l}. Hence M = hj. h We finish this section presenting the algorithm to compute the gcd between two bivariate polynomials. Algorithm 2. Input: f and g 2 F½x; y. Output: gcd(f, g). 1. Compute the common integral summands Ph of Pf and Pg using [4]. 2. If Pf and Pg have no common integral summand, then RETURN (gcd (f, g) = 1). 3. For each common integral summand Ph do: – Using [1], verify if Ph leads to a divisor h of f and g. 4. If no common integral summand lead to a divisor of f and g, then RETURN (gcd (f, g) = 1). 5. Among all divisors of f and g: RETURN (gcd (f, g) = divisor with highest total degree). Computational time: We measure the complexity of Algorithm 2 by the number of operations performed. In [4] all the integral summands of an integral polygon P can be computed in OðtP m2P N P Þ operations, ignoring logarithmic factors, where tP is the number of integral points in P, mP the number of edges and Np the maximum number of integral points on an edge. Following [1], for a given a bivariate polynomial f and an integral summand Ph of the integral polygon associated to f, Pf, we can find a factor h of f using Ph or show that Ph does not lead to a factor h of f using Oðt uPf Þ operations, where t is the number of integral points in Pf and u is a natural number. Hence, step 1 of the algorithm computes the common integral summands of Pf and Pg using O(tm2N), where t ¼ maxftPf ; tPg g; m ¼ maxfmPf ; mPg g and N ¼ maxfN Pf ; N Pg g. In step 3, we consider that Pf and Pg have r common integral summands and using [1] we can find whether the summands lead or not to common factors of f and g using O(rtu) operations. This shows that the Algorithm 2 works in time O(tm2N + rtu). Since the complexity of Algorithm 2 depends on the number of integral points of the polygons, our algorithm is more efficient when the inputs are sparse polynomials. To illustrate our point, we notice that (for example) the algorithm of von zur Gathen [5, pg. 161] computes gcd (f, g) in 12n2d2 + O(nd(n + d)), where degx(f) = n P degx(g) P 1 and degy(f), degy(g) 6 d, a time depending on the degrees involved. Hence, the algorithm will be less efficient for high degree polynomials, regardless its sparsity. 6.1. An Example In this section we present an example explaining how to find the gcd of two bivariate polynomials using Newton polygons. Example 1. Let f = 1 + 2x2 + 2x2y2 + y2 + x4 + x4y2 + xy2 + x3y2 + x3y4 + xy4 and g ¼ x þ 2x2 y þ xy2 þ y þ x3 þ x4 y þ x3 y2 þ x2 y2 þ x3 y3 þ x2 y4 þ xy3 2 R ,whose Newton polygons are given in Fig. 3. The edge sequence of Pf is given by {niei}16i66 where n1 = 4, n2 = 2, n3 = 1, n4 = 2, n5 = 1, n6 = 2 and e1 = (1, 0), e2 = (0, 1), e3 = (1, 2), e4 = (1, 0), e5 = (1,  2), e6 = (0,  1). And the edge sequence of Pg is given by fn0i e0i g16i67 where n01 ¼ 2; n02 ¼ 1; n03 ¼ 1; n04 ¼ 1; n05 ¼ 1; n06 ¼ 1; n07 ¼ 1 and e01 ¼ ð1; 0Þ; e02 ¼ ð1; 1Þ; e03 ¼ ð1; 2Þ; e04 ¼ ð1; 1Þ; e05 ¼ ð1; 1Þ; e06 ¼ ð1; 2Þ; e07 ¼ ð1; 1Þ.

Fig. 3. Newton polygons associated to the bivariate polynomials f and g.

8386

L.E. Allem, V. Trevisan / Applied Mathematics and Computation 217 (2011) 8377–8386

Fig. 4. Common summand of Pf and Pg.

We have

v etprimðPf Þ ¼ fð1; 0Þ; ð0; 1Þ; ð1; 2Þ; ð1; 0Þ; ð1; 2Þ; ð0; 1Þg and

v etprimðPg Þ ¼ fð1; 0Þ; ð1; 1Þ; ð1; 2Þ; ð1; 1Þ; ð1; 1Þ; ð1; 2Þ; ð1; 1Þg: Then

v etprimðPh Þ ¼ v etprimðPf Þ \ v etprimðPg Þ ¼ fð1; 0Þ; ð1; 2Þ; ð1; 2Þg with n001 ¼ minimumf4; 2g ¼ 2; n002 ¼ minimumf1; 1g ¼ 1 and n003 ¼ minimumf1; 1g ¼ 1. Note that 3 X

n00i e00i ¼ 2ð1; 0Þ þ 1ð1; 2Þ þ 1ð1; 2Þ ¼ ð0; 0Þ:

i¼1

Then h = h00 + h10x + h20x2 + h11xy + h12xy2 is the generic polynomial associated to the polygon Ph like in Fig. 4. After applying the modified Hensel lifting presented in [1], we found h = 1 + x2 + xy2. Which divides f and g. Hence, by Proposition 2 h = gcd (f, g).

7. Conclusion In this paper we presented an efficient algorithm, based on Newton polytopes, that can determine relative primality between two multivariate polynomials. It is suitable to work as a pretest on an implementation of a gcd algorithm, since it is specially effective for sparse multivariate polynomials with large degrees and large coefficients. We also showed that we can compute the gcd of bivariate polynomials using Newton polygons. References [1] [2] [3] [4] [5] [6] [7] [8] [9]

F. Abu Salem, S. Gao, A.G.B. Lauder, Factoring polynomials via polytopes, in: Proceeding of ISSAC 2004, 2004, pp. 4–11. G. Ewald, Combinatorial Convexity and Algebraic Geometry, GTM 168, Springer, 1996. S. Gao, Absolute irreducibility of polynomials via Newton Polytopes, Journal of Algebra 237 (2001) 501–520. S. Gao, A.G.B. Lauder, Decomposition of polytopes and polynomials, Discrete and Computational Geometry 26 (2001) 89–104. J. von zur Gathen, J. Gërhard, Modern computer algebra, Cambridge University Press, 1999. Ewgenij Gawrilow, Michael Joswig, Geometric reasoning with polymake, url: , 2005. D.E. Knuth, The Art of Computer programing, Seminumerical Algorithms, vol. 2, Addison-Wesley, 1973. A.M. Ostrowski, Ber die Bedeutung der theorie der konvexen polyeder fr die formale algebra, Jahresberichte Deutsche Math, Verein 30 (1921) 98–99. R. Schneider, Convex bodies: the Brunn-Minkowski theory, Encycopledia of Mathematics and its Applications, vol. 44, Cambridge University Press, Cambridge, 1993. [10] R. Seidel, Constructing higher-dimensional convex hulls at logarithmic cost per Face, in: Proceedings of the eighteenth annual ACM symposium on Theory of computing, Berkeley, California, United States, 1986, pp. 404–413.