Abstract

We consider a few modifications of the Big prime modular algorithm for polynomials in . Our modifications are based on bounds of degrees of modular common divisors of polynomials, on estimates of the number of prime divisors of a resultant, and on finding preliminary bounds on degrees of common divisors using auxiliary primes. These modifications are used to suggest improved algorithms for calculation and for coprime polynomials detection. To illustrate the ideas we apply the constructed algorithms on certain polynomials, in particular on polynomials from Knuth’s example of intermediate expression swell.

1. Introduction

This work is one of the articles in which we would like to present parts from new introduction to computer algebra [1] that currently is under preparation. In [1] we try to give a “more algebraic” and detailed view on some of the areas of computer algebra, such as algorithms on the Euclidean rings, extensions of fields, operators in spaces on finite fields, and factorization in UFDs.

The Big prime modular algorithm is one of the first and most popular algorithms of computer algebra. In its classical form, it allows calculating the greatest common divisor for any nonzero polynomials . There are a few modifications of this algorithm for other UFDs, such as multivariate polynomial rings. Attention to the calculation is partially explained by the first examples that were built to explain importance of application of algebraic methods to computer science. In particular, Knuth’s well-known example of intermediate expression swell discusses the polynomialsand it shows that calculation of by traditional Euclidean algorithm on rational numbers generates very large integers to deal with, whereas consideration of these polynomials modulo , that is, consideration of their images under ring homomorphism (where is the polynomial ring over the residue ring ) very easily shows that (see [2] and also [36]). We are going to use polynomials (1) as examples below to apply the algorithms below (see Examples 16, 18, 22, 25, 27, and 29).

The main idea of the Big prime modular algorithm is that for the given polynomials one may first consider their images under . Unlike , the ring is an Euclidean domain, since it is a polynomial ring over a field, so can be computed in it by the well-known Euclidean algorithm. There remains “to lift” a certain fold of it to the ring to reconstruct the preimage . The “lifting” procedure consists of selecting the suitable value for prime , then finding in an appropriate preimage for , and then checking if that preimage divides both and . If yes, it is we are looking for. If not, then a new need be selected to repeat the process. Arguments based on resultants and on Landau-Mignotte bounds show that we can effectively choose such that the number of required repetitions is “small.”

The first aim of this work is to present in Sections 25 a slightly modified argumentation of the algorithm, based on comparison of the degrees of common divisors of and in and of and in (see Algorithm 2). This approach allows some simplification of a step of the algorithm: for some primes , we need not reconstruct the preimage of , but we immediately get an indication that this prime is not suitable, and we should proceed to a new (see Remark 15).

Then in Section 6 we discuss the problem if the Big prime modular algorithm could output the correct answer using just one prime or not. The answer is positive, but for some reasons it should not be used to improve the algorithm (to make it work with one ) because it evolves a very large prime (see Remark 19). Instead, we show that we can estimate the maximal number of (repetitions of steps) that may be used in traditional Big prime modular algorithm. For example, for polynomials (1) of Knuth’s example, this number is at most 31. Estimates of this type can be found in literature elsewhere. We just make the bound considerably smaller (see Remark 23).

The obtained bounds on the number of primes are especially effective when we are interested not in but just in detection if the polynomials are coprime or not. We consider this in Section 7 (see Algorithm 3).

In Section 8 we consider four other ideas to modify the Big prime modular algorithm. Two first ideas are based on checking the number of primes . The third idea is based on using an auxiliary prime to estimate the degree of by means of the degree of (see Algorithm 4). Example 27 shows how much better results we may get by this modification. The fourth idea combines both approaches: it uses a set of auxiliary primes to correctly find the degree of , and then we use a modified version of Landau-Mignotte bound to find a single big prime by which we can calculate the .

The arguments used here can be generalized for the case of polynomials on general UFDs. From the unique factorization in a UFD, it easily follows that always exists, and it is easy to detect if the given common divisor of maximal degree is or not. The less simple part is to find ways to compute (without having the prime-power factorization). That can be done for some classes of UFDs, such as multivariate polynomials on fields.

2. in Polynomial Rings and the Degrees of Common Divisors

The problem of finding the greatest common divisor of any nonzero elements , in a ring can be separated to two tasks:(1)Finding out if , in general, exists for .(2)Finding an effective way to calculate .

The Euclidean algorithm gives an easy answer to both of these tasks in any Euclidean domain, that is, an integrity domain possessing Euclidean norm  , such that hold for any nonzero elements ; and for any , where , there exist elements , such that , where either or and [4, 5, 710]. The Euclidean algorithm works for any polynomial ring over a field , such as , , , and because these rings can easily be turned to an Euclidean domain by defining for any nonzero .

The situation is less simple in non-Euclidean domains, even in such a widely used ring as the ring of polynomials with integer coefficients. That is not an Euclidean domain easy to show by elements . If were an Euclidean domain, it would contain elements , such that , which is not possible.

The first of two tasks mentioned above, namely, existence of , can be accomplished for by proving that is a UFD, that is, an integrity domain in which every nonzero element has a factorization , where is a unit (invertible) element in , the elements are prime for all , and the factorization above is unique in the sense that if has another factorization of that type , where and the elements are prime, then and (perhaps after some reordering of the prime factors) the respective prime elements are associated: for all . For briefness, in the sequel we will often omit the phrase “perhaps after some reordering of the prime factors” and this will cause no confusion.

After merging the associated prime elements together, we get a unique factorization into prime-power elements:(in some arguments below we may admit that some of the factors participate with degrees ; this makes some notations simpler). From this, it is easy to see that, in a UFD , exists for any nonzero elements . Assume has the factorization (we use the same primes in both factorizations because if, e.g., is not actually participating in one of those factorizations, we can add it as with ). Thenwhere . This follows from uniqueness of factorization in UFD. For, if is a common divisor of , and if is a prime divisor of , then it also is a prime divisor of and of . The elements cannot participate in factorization of by a power greater than , because then (or ) would have an alternative factorization in which occurs more than (or ) times.

The shortest way to see that is a UFD is to apply Gauss’s theorem: if the ring is a UFD, then the polynomial ring also is a UFD [4, 7, 8, 10, 11]. Since is a UFD (that fact is known as “the fundamental theorem of arithmetic”), also is a UFD.

Clearly, is defined up to a unit multiplier from . For integers from or for polynomials from , this unit multiplier can be just or . So to say, is defined “up to the sign ” because . And for polynomials from , is defined up to any nonzero multiplier . Taking this into account, we can use and as equivalent notations, since associated elements are defined up to a unit multiplier. Notice that in some sources they prefer to additionally introduce a normal form of to distinguish one fixed instance of . Instead of using that extra term, we will just in a few places refer to the “positive ,” meaning that we take, for example, and not .

Furthermore, since the content of a polynomial is for some elements (coefficients of the polynomials), the constant and the primitive part can also be considered up to a unit multiplier. For a nonzero polynomial , we can choose so that ; that is, the has the same sign as the leading coefficient of . Then the leading coefficient of the primitive part will be positive. We will use this below without special notification.

Now we would like to little restrict the algebraic background we use. Two main algebraic systems, used in the Big prime modular algorithm, are the Euclidean domains and the UFDs. However, their usage is “asymmetric” in the sense that the Euclidean domains and Euclidean algorithm are used in many parts of the Big prime modular algorithm, whereas the UFDs are used just to prove that does exist. Moreover, it is easy to understand that (2) and (4) may hardly be effective tools to calculate , since they are using factorization of elements to primes, while finding such a factorization is a more complicated task than finding just . Thus, it is reasonable to drop the UFDs from consideration and to obtain (2) directly using Gauss’s lemma on primitive polynomials in (a polynomial is primitive if , that is, ).

By Gauss’s lemma, a product of two primitive polynomials is primitive in [4, 7, 8, 10, 11]. So ifthen

The following is easy to deduce from Gauss’s lemma.

Lemma 1. If and is primitive, then if divides in the ring and then also divides in .

The unique factorization of any nonzero is easy to obtain from decompositions (6) above and from Lemma 1. Let us just outline it; the details can be found in [1, 4, 5, 7, 8]. By the fundamental theorem of arithmetic, can in a unique way be presented as a product of powers of primes: So, if , then we are done.

Assume . If is not prime, then, by repeatedly splitting it to products of factors of lower degree as many times as needed, we will eventually get a presentation of as a product of and of some finitely many primitive prime polynomials of degrees greater than . We do not yet have the uniqueness of this decomposition, but we can still group the associated elements together to get the presentationIf has another, alternative presentation of this sort and if is one of the primitive prime factors (of degree greater than ) of that presentation, then product (7) is divisible by . By Lemma 1, divides also in . Since is prime, it is associated with one of . Eliminate one instance of this in (7) and consider . If also is divisible by , we repeat the process. If not, we turn to other primitive prime polynomials (of degree greater than ) dividing what remains from (7) after elimination. After finitely many steps, (7) will become , and also from the other alternative presentation a constant should be left only. So we apply the fundamental theorem of arithmetic one more time to get that (7) is the unique factorization.

We see that (7) is a particular case of (2). The proof above avoided usage of Gauss’s theorem and the formal definitions of the UFDs. And we see that the prime elements of are of two types: prime numbers and primitive prime polynomials of degrees greater than .

Existence of for any two nonzero polynomials in can be deduced from (7) in analogy with (4). Ifthenwhere , , and (). However, like we admitted earlier, (4) and (9) are no effective tools to calculate . We will turn to calculation algorithm in the next sections (see Algorithms 4 and 5).

Equations (4) and (9) allow us to get some information that will be essential later. Observe that the following definition of , often used in elementary mathematics, is no longer true for general polynomial rings: is the greatest common divisor of and if it is their common divisor of maximal degree. For example, for and , the maximum of degree of their common divisors is . Nevertheless, is not , although , , and . For, is not divisible by the common divisor . We can detect the cases when the divisor of highest degree is .

Lemma 2. For polynomials , their common divisor of maximal degree is their if and only if .

The lemma easily follows from (7), (8), and (9). We see that in example above the condition was missing: but . In fact, .

Corollary 3. For primitive polynomials , their common divisor of maximal degree is their if and only if is primitive.

In the case if polynomials are over a field, the situation is simpler. For any field , the polynomial ring is a UFD (and even an Euclidean domain). Any nonzero has a factorizationwhich is unique in the sense mentioned above. Since all nonzero scalars in are units, what we, in (7) above, had as a product of some prime numbers actually “merges” in into a unit:

Comparing factorizations of type (10) for any nonzero polynomials , we easily get the following.

Lemma 4. For any nonzero polynomials over a field , their common divisor of maximal degree is their .

This, in particular, is true for rings mentioned above: , , , and . We will use this fact later to construct the Big prime modular algorithm and its modifications.

The analog of Lemma 4 was not true for because in factorization (9) we have the nonunit prime-power factors which do participate in factorization of but which add nothing to the degree of . This is why maximality of the degree is no longer the only criterion in to detect if the given is or not.

3. Some Notations for Modular Reductions

The following notations, adopted from [1], are to make our arguments shorter and more uniform when we deal with numerals, polynomials, and matrices. As above, let be the residue ring (finite Galois field ) and let be the rings homomorphism mapping each to the remainder after division of by . That is, , and .

We use the same symbol to denote the homomorphism where is the ring of polynomials over and is mapping each of the coefficients of to the remainder after division of by .

Similarly, we define the homomorphism of matrix rings which maps each of the elements of a matrix to the remainder after division of by .

Using the same symbol for numeric, polynomial, and matrix homomorphisms causes no misunderstanding below, and it is more comfortable for some reasons. These homomorphisms are called “modular reductions” or just “reductions. We can also specify these homomorphisms as “numeric modular reduction,” “polynomial modular reduction,” or “matrix modular reduction” where needed [1].

For , denote . For , denote . So ifthen And for a matrix denote . If , then .

4. Problems at Lifting the Modular to

Now we turn to the second task mentioned earlier: effective calculation of the actual for the given nonzero polynomials .

The ring is an Euclidean domain, unlike the ring . So we can use the Euclidean algorithm to calculate for any nonzero polynomials in , including the modular images and . Since the notation is going to be used repeatedly, for briefness denote by calculated by Euclidean algorithm for . Let us stress that is not determined uniquely, since for any nonzero the product also is for . We are denoting just one of these ’s (namely, that computed by the Euclidean algorithm) by . This is unique, since at each step of the Euclidean algorithm we have a unique action to take (to see this, just consider the steps of “long division” used to divide by on field ).

The main idea of the algorithm is to calculate for some suitable and to reconstruct by it. We separate the process to four main problems that may occur and show how to overcome each one to arrive to a correctly working algorithm.

4.1. Problem 1: Avoiding the Eliminating Coefficients

After reduction , some of the coefficients of and may change or even be eliminated. So their images and may keep very little information to reconstruct based on .

Example 5. If and , then for we get and . So these values contain no reliable information to reconstruct .

The first simple idea to avoid such elimination is to take larger than the absolute value of all coefficients of and . This, however, is not enough since a divisor of a polynomial may have coefficients, larger than those of . Moreover, using the cyclotomic polynomials for large enough , one can get divisors of which have a coefficient larger than any pregiven number [1, 4, 8]. Since we do not know the divisors of and , we cannot be sure if the abovementioned large will be large enough to prevent elimination of coefficients of . To overcome this, one can use the Landau-Mignotte bounds (in different sources, the bounds on coefficients of the divisors are called differently, associating them with names of L. Landau or M. Mignotte or with both of them; these authors have different roles in development of the formulas, which in turn are consequence of a formula by A. L. Cauchy), as done in [46]. For a polynomial given by (15), denote its norm by .

Theorem 6 (L. Landau, M. Mignotte). Let and be nonzero polynomials in . If is a divisor of , then

The proof is based on calculations on complex numbers, and it can be found, for example, in [1, 4]. We are going to use the Landau-Mignotte bounds in the following two shapes.

Corollary 7. In notations of Theorem 6, there is the following upper bound for the coefficients of :

Proof. To obtain this from (18), first notice that .
Next, if , then , where is a nonzero integer. Then .
Finally, if ( is unknown to us), then we can simply replace in (18) the value by .

Remark 8. In literature, they use the rather less accurate bound , but the second paragraph of our proof above allows replacing by . See also Remark 23.

Corollary 9. In notations of Theorem 6, if also is a divisor of the polynomial , then there is the following upper bound for the coefficients of :

Proof. To obtain this from (18), just notice that if is a common divisor for and , then its leading coefficient divides both and .

Formula (20) provides the hint to overcome Problem 1 about eliminating coefficients, mentioned at the start of this subsection. Although the divisors of and are yet unknown, we can compute and take . If we apply the reduction for this , we can be sure that none of the coefficients of has changed “much” under that homomorphism, for does not alter the nonnegative coefficients of , and it just adds to all negative coefficients of . The same holds true for .

4.2. Problem 2: Negative Coefficients and Reconstruction of the Preimage

The reduction is not a bijection, and has infinitely many preimages in . But the relatively uncomplicated relationship between coefficients of and , obtained in previous subsection, may allow us to reconstruct if we know . The condition puts a restriction on the preimage : the coefficients of either are equal to respective coefficients of (if they are nonnegative) or are the respective coefficients of minus (if they are negative). Reconstruction may cause problems connected with negative coefficients.

Example 10. If for some polynomials we have , we can take the prime, say . Assume we have somehow calculated ; we can be sure that is not the preimage because cannot have coefficients greater than by absolute value. But we still cannot be sure if the preimage is , or , or maybe .

It is easy to overcome this by just taking a larger value: If the coefficient of is nonnegative, then , and if it is negative, then . This provides us with the very simple method as shown in Algorithm 1 to reconstruct if we have already computed for sufficiently large prime .

Input: For an unknown polynomial we know
the upper bound of absolute values of its coefficients,
and for arbitrarily large prime number we have the
modular image   .
Reconstruct the polynomial .
(01) Choose any prime .
(02) Set .
(03) Set .
(04) While
(05)  if
(06)    set ;
(07)  else
(08)    set ;
(10)  set .
(11) Output .
Input: non-zero polynomials   .
Calculate their greatest common divisor  gcd.
(01) Calculate cont, cont in the Euclidean domain , choose their signs so that
    and .
(02) Set and .
(03) Calculate in the Euclidean domain by (25).
(04) Set and (they are positive by our selection of signs for and ).
(05) Calculate the positive in the Euclidean domain .
(06) Set .
(07) Compute the Landau-Mignotte bound by (20).
(08) Choose a new prime number .
(09) Apply the reduction to calculate the modular images .
(10) Calculate in the Euclidean domain .
(11) If
(12)  go to step (08);
(13) else
(14)  choose a such that the ;
(15)  call Algorithm 1 to calculate the preimage of ;
(16)  calculate in the Euclidean domain ;
(17)  set ;
(18)    if and
(19)      go to step (23);
(20)    else
(21)      set ;
(22)      go to step (08).
(23)  Output the result: .
Input: non-zero polynomials .
Detect if and are coprime.
(01) Calculate , in the Euclidean domain .
(02) Calculate in the Euclidean domain by (25).
(03) If
(04)  output the result: and are not coprime and stop.
(05) Set and .
(06) Calculate in the Euclidean domain .
(07) Set and .
(08) Compute the bound for polynomials by (32).
(09) Find the maximal for which .
(10)  Set .
(11)  While
(12)  choose a new prime ;
(13)  apply the reduction to calculate the modular images ;
(14)  calculate in the Euclidean domain ;
(15)    if
(16)      output the result: and are coprime and stop.
(17)  set .
(18)  If
(19)  go to step (12).
(20)  else
(21)  output the result: and are not coprime.
Input: non-zero polynomials .
Calculate their greatest common divisor  .
(01) Calculate , in the Euclidean domain , choose their signs
    so that and .
(02) Set and .
(03) Calculate in the Euclidean domain by (25).
(04) Set and (they are positive by our selection of signs
    for and ).
(05) Calculate the positive in the Euclidean domain .
(06) Set .
(07) Choose a prime number .
(08) Apply the reduction to calculate the modular images .
(09) Calculate in the Euclidean domain .
(10) Set .
(11) Calculate by (40) using the value of .
(12) Choose a new prime number .
(13) Apply the reduction to calculate the modular images .
(14) Calculate in the Euclidean domain .
(15) If
(16)  go to step (12).
(17) else
(18)  choose a such that the ;
(19)  call Algorithm 1 to calculate the preimage of ;
(20)  calculate in the Euclidean domain ;
(21)  set ;
(22)    if and
(23)      go to step (27);
(24)     else
(25)      set ;
(26)      go to step (12).
(27) Output the result: .
Input: non-zero polynomials .
Calculate their greatest common divisor  .
(01) Calculate , in the Euclidean domain , choose their signs
    so that and .
(02) Set and .
(03) Compute the bound for polynomials by (32).
(04) Find the maximal for which .
(05) Calculate in the Euclidean domain by (25).
(06) Set and (they are positive by our selection of signs
   for and ).
(07) Calculate the positive in the Euclidean domain .
(08) Set .
(09) Set .
(10) While
(11)  choose a new prime ;
(12)  apply the reduction to calculate the modular images ;
(13)  calculate in the Euclidean domain ;
(14)  if
(15)    set ;
(16)    if
(17)      set ;
(18)      go to step (32);
(19)  set .
(20) Calculate by (43) using the value of .
(21) Choose a new prime number .
(22) Apply the reduction to calculate the modular images .
(23) Calculate in the Euclidean domain .
(24) If
(25)  choose a such that the ;
(26)  call Algorithm 1 to calculate the preimage of ;
(27)  calculate in the Euclidean domain ;
(28)  set ;
(29)  go to step (32);
(30) else
(31)  go to step (21).
(32) Output the result: .
4.3. Problem 3: Finding the Correct Fold of the Modular of Right Degree

Now additionally assume the polynomials to be primitive. Since and are defined up to the sign , we can without loss of generality admit the leading coefficients of to be positive.

Below, in Problem 4, we will see that for some the polynomial , computed by the Euclidean algorithm in , may not be the image of and, moreover, its degree may be different from that of . This means that by applying Algorithm 1 to we may not obtain . Assume, however, we have , which meets the condition and for whichBy Corollary 3, a common divisor of is if and only if it is primitive and if its degree is the maximum of degrees of all common divisors. Since does not change the degree of , we get by Lemma 4 (applied for the field ) that is of in . This correspondence surely is not one-to-one, because in is calculated up to the unit element of , which is , whereas in is calculated up to the unit element of , which can be any nonzero number . So the polynomial calculated by the Euclidean algorithm may not be the image of .

Example 11. For and , whichever prime we take, we will get by the Euclidean algorithm But in we have . So regardless how large we choose, we will never get .

In other words, we are aware that the image is one of the folds of for some , but we are not aware which is that.

The leading coefficient of can also be assumed to be positive. Denote by the positive . Since both and are not altered by , their fraction also is not altered. Take such thatEven if is not the image , it is the image of , where divides . If we calculate the preimage of by Algorithm 1, we will get a polynomial, which is either or some fold of . Since are primitive, it remains to go to the primitive part .

The general case, when may not be primitive, can easily be reduced to the following: for arbitrary , take their decompositions by formula (5) and setThen assign , and do the steps above for these new polynomials. After is computed, we get the final answer as .

Notice that for Algorithm 1 we need to be greater than any coefficient of the polynomial we reconstruct. The bound assures that meets this condition for . We, however, reconstruct not but , which may have larger coefficients. One could overcome this point by taking , but this is not necessary because as we see later, while the Big prime modular algorithm works, the value of will grow and this issue will be covered.

4.4. Problem 4: Finding the Right Degree for the Modular

As we saw, one can reconstruct if we find such that condition (22) holds. Consider an example to see that (22) may actually not hold for some even if is not altering the coefficients of and !

Example 12. For and , we have . Taking we get and . In we have ; thus, . We get that . In particular, whatever we take, is not the image of under .

The idea to overcome this problem is to show that the number of primes , for which (22) falsifies, is “small.” So if the selected is not suitable, we take another and do the calculation again by the new prime. And we will not have to repeat these steps for many times (we will turn to this point in Section 6).

The proof of the following theorem and the definition of the resultant (i.e., of the determinant of the Sylvester matrix of polynomials ) can be found, for example, in [1, 4, 7, 10]. The resultant is a comfortable tool to detect if the given polynomials are coprime.

Theorem 13. Let be an integrity domain. The polynomials are coprime if and only if .

The following fact in a little different shape can be found in [4] or [5].

Corollary 14. If the prime does not divide at least one of the leading coefficients , of polynomials, respectively, , then . If also does not divide , where , then

Proof. Since divides , then by the choice of . Thus, .
Since , we can consider the fractions and in . From unique factorizations of and in UFD , it is very easy to deduce that In particular, . And the inequality may occur only if that is, when and are not coprime in or, by Theorem 13, when . The latter is the determinant of Sylvester matrix . Consider the matrix rings homomorphism (matrix modular reduction) where ; (as mentioned earlier we use the same symbol for numeric, polynomial, and matrix reductions). Since, and since the determinant of a matrix is a sum of products of its elements, we get So can be zero if and only if is divisible by . The polynomials and are coprime in and their resultant is not zero by Theorem 13. And cannot be a positive integer divisible by since that contradicts the condition of this corollary.

Corollary 14 shows that if for some equality (22) does not hold for polynomials , then either divides and or divides the resultant . We do not know , since we do not yet know to calculate the resultant . But since the number of such primes is just finite, we can arrive to the right after trying the process for a few primes. We will turn to this again in Section 6.

5. The Big Prime Modular Algorithm

Four steps of the previous section provide us with the following procedure. We keep all the notations from Section 4. Take the primitive polynomials . Without loss of generality, we may assume . Take any . Then , since . Calculate in by Euclidean algorithm. Then choose so that (24) holds. Construct applying Algorithm 1 to . If the primitive part divides both and , then for these primitive polynomials is found: . That follows from consideration about divisor degrees above: if had a common divisor of degree greater than , then, since the degree of is not altered by , we would get , which contradicts the maximality of by Lemma 4.

This means that if for we get or , we have the case when divides the resultant . Then we just ignore the calculated polynomial, choose another , and redo the steps for it. Repeating these steps for finitely many times, we will eventually arrive to the correct for the primitive polynomials .

The case of arbitrary nonzero polynomials can easily be reduced to this. By arguments mentioned earlier, we should calculate for primitive polynomials and and then output the final answer as , where is defined by (25). The process we described is the traditional form of the Big prime modular algorithm.

Remark 15. Since our approach in Section 4 evolved the maximality of degrees of the common divisors, we can shorten some of the steps of our algorithm. Let us store in a variable, say , the minimal value for which we already know it is not . As an initial , we may take, for example, . Each time we calculate , check if is equal to or larger than the current . If yes, we already know that we have an “inappropriate” . Then we no longer need to use Algorithm 1 to reconstruct and to get . We just skip these steps and proceed to the next . Reconstruct and check if and only when . Then, if does not divide or , we have discovered a new bound for . So set and proceed to the next . If in next step we get , we will again be aware that the steps of reconstruction of need be skipped.

We constructed Algorithm 2.

Turning back to Remark 15, notice that for some prime numbers we skip steps of Algorithm 2 and directly jump to step . In fact, Remark 15 has mainly theoretical purpose to display how usage of UFD properties and comparison of divisor degrees may reduce some of the steps of the Big prime modular algorithm. In practical examples, the set of primes we use contains few primes dividing , so we may not frequently get examples where steps are skipped.

Example 16. Let us apply Algorithm 2 to polynomials (1) mentioned in Knuth’s example above. Since and , And we can take the prime . It is not hard to compute that . So and are coprime. It is worth to compare with much smaller values and obtained below for the same polynomials in (1) in Example 27 using modified Algorithm 4.

In [1] we also apply Algorithm 2 to other polynomials with cases when the polynomials are not coprime.

6. Estimating the Prime Divisors of the Resultant

Although at the start of the Big prime modular algorithm we cannot compute the resultant for the given (we do not know ), we can nevertheless estimate the value of and the number of its prime divisors. Denote

Lemma 17. For any polynomials and for any of their common divisors , the following holds:

Proof. By Corollary 7, the coefficients of fractions and are bounded, respectively, by and , where ; . Since the numbers of summands in these fractions are at most and , respectively, we get Applying Hadamard’s maximal determinant bound [4] to the Sylvester matrix , we get that

The bound of (32) is very rough. To see this, apply it to polynomials (1) of Knuth’s example.

Example 18. For polynomials (1), we have and . So we can estimate , , and . Thus which is a too large number to comfortably operate with.

Remark 19. If in Algorithm 2 we use a primethen we will get that whatever the greatest common divisor is. And, clearly, holds for . So, in this case, Algorithm 2 will output the correct using just one , and we will not have to take another after step . However, Example 18 shows why it is not reasonable to choose by rule (37) to have in Algorithm 2 one cycle only: it is easier to go via a few cycles for smaller rather than to operate with a huge , which is two times larger than the bound obtained in Example 18.

Nevertheless, the bound may be useful if we remember that the process in Algorithm 2 concerned not the value of but the number of its distinct prime divisors. Let us denote by the product of the first primes: (where , , etc.). They sometimes call theth primorial.” The following is essential.

Lemma 20. The number of pairwise distinct prime divisors of a positive integer is less than or equal to .

From Lemmas 17 and 20, we easily get the following.

Corollary 21. For any polynomials and for any of their common divisors , the number of pairwise distinct prime divisors of is at most , where is the largest number for which .

Primorial (as a function on ) grows very rapidly. Say, for , it is more than six billions: . This observation allows using the bound in the following way: although the value of as a function on and and on the coefficients of and grows rapidly, the number of its distinct prime divisors may not be “very large” thanks to the fact that also grows rapidly. Consider this on polynomials and values from Example 18.

Example 22. It is easy to compute that where is the large number from Example 18. This means that the number of prime divisors of , whatever the divisor is, is not greater than . And, whichever distinct primes we take, at least one of them will not be a divisor of . That is, Algorithm 2 for the polynomials of Knuth’s example will output the correct answer in not more than cycles. We cannot find primes so that Algorithm 2 arrives to a wrong on step for all of them.

Remark 23. Let us stress that estimates on the number of prime divisors of the resultant and the analog of Algorithm 3 can be found elsewhere, for example, in [4]. So the only news we have is that here we use a slightly better value for and to get times smaller bound for . Namely, in Corollary 7 we estimate not by but by (see (19) and Remark 8). This makes the bound in formula (32) times lower, since and appear and times, respectively.

7. An Algorithm to Check Coprime Polynomials

The first application of the bounds found in previous section is an algorithm checking if the given polynomials are coprime. Present the polynomials as and . If , then are not coprime, and we do not have to check the primitive parts, at all.

If , then switch to the polynomials and . By Corollary 21, the number of distinct prime divisors of is less than or equal to , where is the largest number for which .

Consider any primes , each not dividing , where and . If for at least one , then and are coprime because and .

And if for all , then and are not coprime for at least one , which is not dividing . This means that and are not coprime. We got Algorithm 3.

Two important advantages of this algorithm are that here we use much smaller primes (we just require , not ), and in Algorithm 3, unlike in Algorithm 2, we never need to find , to compute the preimage of and the primitive part .

Remark 24. As is mentioned by Knuth in [2], in a probabilistic sense, the polynomials are much more likely to be coprime than the integer numbers. So it is reasonable to first test by Algorithm 3 if the given polynomials are coprime, and only after that apply Algorithm 2 to find their in case if they are not coprime. See also Algorithm 5, where we combine both of these approaches with a better bound for prime .

Example 25. Apply Algorithm 3 to polynomials (1) from Knuth’s example. As we saw in Example 22, . For , we get ,, which are not coprime, since . And for we get , , which are coprime. So .

Example 26. If and . Then , and . Since , we get that , and if for any four primes (not dividing ). It is easy to check that for .

8. Other Modifications of Algorithms

The bounds mentioned in Section 6 can be applied to obtain modifications of Algorithm 2. Let us outline four ideas, of which only the last two will be written down as algorithms.

For the nonzero polynomials , let us again start by computing and switching to the primitive parts and , assuming that their leading coefficients and are positive. Calculate , by Corollary 7, by Corollary 9, and by (32). Find the maximal for which . Then take any primes , each greater than . We do not know , but we are aware that the number of prime divisors of is less than or equal to . So at least one of the primes is not dividing . To find it, compute the degrees of for all . Take any , for which is the minimal (in case there is more than one with this property, take one of them, preferably the smallest of all).

By our construction, holds. So we can proceed to the next steps: choose , such that ; then find by Algorithm 1 the preimage of ; then proceed to its primitive part ; and then output the final answer as .

The advantage of this approach is that we do not have to go via steps of Algorithm 2 for more than one prime . Also, we do not have to take care of the variable . But the disadvantage is that we have to compute for large primes for times (whereas in Algorithm 2 the correct answer could be discovered after consideration of fewer primes). Clearly, the disadvantage is a serious obstacle, since repetitions for large primes consume more labour than steps of Algorithm 2. So this is just a theoretical idea, not an approach for an effective algorithm.

The disadvantage can be reduced in the following way: in previous arguments, after we find and , select the prime numbers each satisfying the condition . This is a much weaker condition than the condition used above, so we will surely get smaller primes. Take to be the minimum of all degrees for all . Since none of the primes divides , for any , we have . On the other hand, since at least one of the primes does not divide , we know that, for that , the degree of is equal to . Combining these, we get that . Since we know , we can take a prime and compute and check its degree: if , then we have a wrong (we no longer need go to steps of Algorithm 2 to discover that). Then choose a new value for and repeat the step. And if , then we have the right . We calculate , the preimage of , and then , and output the answer (see Algorithm 5 for a better version of this idea).

The third modification, not depending on , can be constructed by estimating by means of an auxiliary prime number . By Landau-Mignotte Theorem 6, if is any divisor of the polynomials and , then and . Since is bounded by and is bounded by , we get the following analog of (20):

Now assume is a prime not dividing , and denote . By Corollary 14, . We get for the coefficients of the following bound: , where is a better bound for the coefficients of because may be considerably less than .

We can improve Algorithm 2, if we preliminarily find by calculating for an “auxiliary” prime and then choose the “main” prime by the rule (instead of ). Observe that if then also because . Additionally, we can introduce the variable to store the values that we know are greater than . We get Algorithm 4.

Example 27. Let us apply Algorithm 4 to polynomials (1) from Knuth’s example. Since , take . We have already computed in Example 25 that . Then and Take . It is easy to calculate that . Compare this with Example 16, where we had to use much larger prime . Moreover, if we take as an auxiliary , say , then and So we can take an even smaller prime .

The ideas of Algorithms 3 and 4 can be combined to work with more than one auxiliary prime . Like we mentioned in Remark 24, Knuth in [2] recommends checking first if the polynomials are coprime and proceeding to their calculation only after we get that they are not coprime (this is motivated by probabilistic arguments). Compute by formula (32) and find like we did in step of Algorithm 3: is the maximal number for which . Then choose any primes not dividing , and start computing the modular ’s ( times). If at some step we find , then we are done: the polynomials are coprime if , or their is the nontrivial scalar . And if for all , then we know that(1)these polynomials are not coprime,(2)the positive degree of is the minimumThis exact value of is a better result than the estimate obtained earlier by just one .

Like above, we can assume to be primitive (if not, we can again denote and switch to the primitive parts and ). Applying the Landau-Mignotte Theorem 6 for the coefficients of , we get that , where

Now we can take and by the Euclidean algorithm calculate in . If , we drop this and choose another prime . And if , then we proceed to the final steps: we choose , then get the preimage of , then go to the primitive part , and output the final answer as .

Remark 28. This approach has the following advantages: Firstly, the bound on primes is better than formula (40) since here we have not but . Secondly, we no longer need to calculate the number , the preimage , and the primitive part for more than one prime . This is because, if the selected is not appropriate, we already have an indicator of that: .

We built Algorithm 5.

Example 29. Let us apply Algorithm 5 again on polynomials of Knuth’s example (1). As we saw in Example 22, . So we may have to consider at most auxiliary primes . But we in fact need just two of them, because and (see Example 25). So in Algorithm 5 we jump from step to step directly.

Competing Interests

The author declares that there is no conflict of interests regarding the publication of this paper.

Acknowledgments

The author was supported in part by joint grant 15RF-054 of RFBR and SCS MES RA (in frames of joint research projects SCS and RFBR) and by 15T-1A258 grant of SCS MES RA.