JOURNALOF
ALGORJTHMS5,180-186(1984)
Finding the Number of Factors of a Polynomial P. J. WEINBERGER Bell hboratories,
Murray
Hill,
New Jersey 07974
Received September 15,198l TOTHEMEMORYOFGEORGECOOKE
Because computing modulo small primes is so cheap there is a common hope that global properties of polynomials might be easily deduced from such computations. The number of factors can be found, assuming suitable Riemann hypotheses, but in many interesting cases it is not possible to find the Galois group.
Quite effective algorithms are known for factoring polynomials in one variable with integer coefficients [6]. These algorithms are fast on most polynomials, but there are cases which require an amount of computation which is exponential in the size of the polynomial. (By the size of a polynomial I mean the product of the degree and the number of bits required to represent the largest absolute value of a coefficient.) Since the average polynomial is irreducible, it would be useful to have an algorithm which would decide irreducibility quickly. The usual technique for this, partially analyzed in [4], is to factor the given polynomial modulo p, for a fair number of primes. If there is no factorization in integers compatible with the set of mod p factorizations, then the polynomial must be irreducible. However, there are polynomials for which the method must fail (see Section 4). In the first part of this paper I discuss an analogous algorithm which determines the number of factors of the polynomial in polynomial time. This conclusion is theoretically stronger than Musser’s, in that polynomial time is guaranteed, but in fact the algorithm is not very efficient. Unfortunately, the proof that the algorithm works in polynomial time requires assuming the Riemann hypothesis for zeta functions of algebraic number fields. Fortunately, the rather messy analysis needed to use the Riemann hypotheses has already been done, and the applicable lemma is a simplification of one in a paper-by Cooke and the author [2]. 180 0196-6774/84 $3.00 Copyright All rights
Q 1984 by Academic Press, Inc of reproduction in any form reserved.
THE NUMBER OF FACTORS OF A POLYNOMIAL
181
1 Let f(x) = a,~” + a,~“-’ + ..a + a,, be a polynomial coefficients and no multiple roots. If
where the fi( x) are irreducible,
with integral
then
Each Ki = Q(cui), where (Y~is a root of the irreducible polynomial A(x). Now if f has r linear factors mod p, and each of the fi has r;: linear factors mod p, then Cr, = r. It is easy to calculate r [l]. Although calculating the I; would require having factored f, the behavior of the r;:, averaged over all primes, is understood. In particular, if p does not divide the discriminant of A, then ri is the number of primes of degree 1 of Ki which lie above p. The prime number theorem for number fields says that on average this number is one. Therefore, the average of t, over all primes, is the number of irreducible factors of f. The algorithm to find the number of irreducible factors of f is: factor f modulo 2,3,5,7,. . . , until the average numbers of linear factors off modulo primes can be determined. It is only a question of knowing when to stop
factoring, and this is the use of the Riemann hypotheses. Let K denote a number field of degree n, and let A denote the absolute value of its discriminant. Let rr(x, K) denote the number of prime ideals of K with norm no greater than x. As usual, let
LEMMA. If the Riemann hypothesis is true for the zeta function of K, then n(x,K)
= ii(x)
+ O(x’/*logAx”).
The constant implied in the 0 term is effective and absolute, and does not depend on the fieId. Proof:
This result is proved, in greater generality, in [5], and is used in
[l]. cl We are interested in counting only primes of degree one, while v counts all primes. Let n, count the number of primes of degree 1. Then those primes which are counted in v but not in ri all have degree greater than 1,
P. J. WEINBERGER
182
so that they must lie over rational primes which are no greater than x112. There can be no more than n such primes over any rational prime, so that T(X, K) = 771(x, K) + O(nx”2). LEMMA.
If the Riemann hypothesis holds for all K,, then
i=l
= r(l 4x,
+ O(xl/*log(]disc(f)]x”)/li(x))).
Q)
This lemma follows from the last in a trivial way. The last obstacle to proving the result is that q is not directly available from factoring f mod p. The difficulty is that if p divides the discriminant of f, some or all of the linear factors of f modulo p may not correspond to primes of degree one in some Ki. But there are no more than log]disc( f )I prime factors of the discriminant off, and changing 1~~by this amount only changes the implied constant in the 0 term of the above lemma. These observations imply the truth of the next theorem. THEOREM. Let N(x, f) denote the total number of linear factors of f modulo all the primes up through x. Then if the Riemann hypothesis is true for zeta functions of number fields,
( f{c:ii
- t-1 < Ax’/*log(Idisc(
f )Ix”)/li(x).
Here A represents some effective absolute constant. COROLLARY. With the above hypotheses, it is possible to determine the number of irreducible factors off in polynomial time. Proof Indeed, if x is chosen so large that the error term in the theorem is less than f, there can be no uncertainty as to which integer r is. Now ii(x) -K x/log(x), and log@isc( f )] is no more than a polynomial in the size of f, so the necessary x is no more than a polynomial in the size of f. Finally, determining the number of linear factors of f modulo p takes no more than polynomial time in p and the size off [l], and all the necessary p arelessthanx. Q.E.D.
Since the constant A has not been estimated, the above results give no guidance as to when to stop factoring f modulo p. A can be estimated without great difficulty, but the best estimates seem to be much too large to be useful.
THE NUMBER OF FACTORS OF A POLYNOMIAL
183
2 Instead of relying on the full strength of the result, and doing the work required to be certain that the true number of factors has been determined, one might gather factorizations off modulo several primes, and attempt to decide what sort of factorizations of f over Z are compatible with this information. The possibilities could be discussed in some generality, but I will content myself with some examples and some comments. Define p,(i, G) to be the probability that a rational prime has exactly i linear factors in a field of degree n whose normal closure has Galois group G. This probability is the natural density of the set of primes with the given property, and it exists by the Cebotarev density theorem. For any particular group G, the probabilities can be read directly from the representation of G as a subgroup of S,, the symmetric group on n symbols. In fact, p,(i, G) is the fraction of the permutations which leave i symbols fixed. The following table gives the probabilities for the transitive subgroups of S,: i
s4
0 1 2 3 4
s i a 0 ia
A4
a 5 0 0 ii
4 i 0 $ 0 +i
Abelian a 0 0 0 a
For instance, using this table one can easily calculate the probability that after j factorizations one incorrectly believes that f has more than 2 factors when it is the product of 2 irreducible quartics. (Well, not easily, but routinely.) Even at 10 primes, the probability of error is still appreciable. An alternative way of estimating the efficiency of the algorithm (on average), is to calculate the mean (necessarily 1) and the variance of the number of linear factors mod p. For the subgroups of S,, the variances are 1 for S, and A,, 2 for D8, and 3 for the two Abelian subgroups. The larger standard deviations make it harder to estimate the number of factors if some of them have the corresponding Galois groups. If one is actually interested in discovering the number of irreducible factors of a polynomial, or in proving it irreducible, he should look at the complete factorization mod p, not just at the number of linear factors. This is exactly what Musser does [4]. His analysis is predicated on the assumption that the various factorizations into distinct factors that f could have modulo a prime are equally probable. This assumption is equivalent, by the Cebotarev density theorem, with the hypothesis that the Galois group off is
184
P. J. WEINBERGER
the full symmetric group. This is quite a reasonable assumption to make, for all but a set of density zero of the polynomials do have the full symmetric group as Galois group [3]. Rather than reproduce the formal definition of the algorithm Musser is analyzing, consider a few examples. Consider an f whose group is S,. S, has 6 elements which are 4-cycles, 8 elements which are 3-cycles, 6 elements which are 2-cycles, 3 elements which are the product of two 2-cycles, and one identity. If in a set of factorizations modulo some primes, a 4-cycle occurs, or a 3-cycle and either a 2-cycle or the product of 2 2-cycles occurs, then one can conclude the polynomial is irreducible, otherwise not. Musser calculates the expected number of factorizations required to conclude the polynomial is irreducible (using a more sophisticated method) to be 2.969. If instead the polynomial has Galois group A,, the results are rather different. A, has 8 elements which are 3-cycles, 3 elements which are the product of two 2-cycles, and the identity. The polynomial is not proved to be irreducible until both a 3-cycle and a product of 2-cycles have occurred as factorizations modulo primes. The probability that this has not happened after k trials is 1/3k + 3/4k - 1/2k so that the expected number of trials is 2 k((l
- l/3)1/3+’
+(1 - 3/4)3/4k-’
k=l
-(l
- 1/12)1/12k-‘)
= 4.409.
Although this is still a small number, it is nearly 50% larger than the value for S,. It is even easier to do the other subgroups of S,. An equation with the noncyclic Abelian group can never be proved irreducible using modp techniques. The cyclic group has an expected time of 2 trials, and the dihedral group of order 8 has an expected time of 4 trials. Thus, even in the simple case of degree 4, there is a wide variation on polynomials with different Galois group.
3
With all this talk about Galois groups, one could ask if the Galois group can be determined by looking at factorizations modulo primes. Assume that the polynomial is known to be irreducible. All of the cases of low degree can be worked out explicitly, and it is possible to give the probability of mis-identifying a group on the basis of j trials. However, for large degrees
THE NUMBER
OF FACTORS
OF A POLYNOMIAL
185
there are groups which are known to occur but which cannot be distinguished. One example is in degree 27 (with thanks to Jack McLaughlin) where the elementary 3-group and a non-Abelian group, both of order 27, have regular representations in which 26 of the elements are the product of nine 3-cycles.
4
As a final point, I shall consider the question of when an irreducible polynomial cannot be proved irreducible using Musser’s algorithm. This will be the case if there an integer i, such that the factorizations of f modulo every prime are consistent with f having a factor of degree i. If the polynomial has degree n and Galois group G, then the question of whether the polynomial can be proved irreducible in this way reduces to questions about the cycle structure of the faithful representations of G as a transitive subgroup of S,. Here too a few examples will suffice. Consider the regular representation of S, in S,,,, where n > 3. If a group has order N, then in its regular representation an element of the group of order j will be the product of N/j j-cycles. If n > 3, the order of every element of S, will divide n!/2, so each factorization mod p will be consistent with an f of degree n! and Galois group S, having two factors of degree n!/2. As another example, reconsider the non-Abelian group, M, with 27 elements considered above. Let H be one of its non-normal subgroups of order 3, and consider the representation of M on the 9 cosets of H. The kernel of the representation must be a normal subgroup of M which is contained in H, and so must be the identity. Therefore the representation is faithful. There are still 26 elements of order 3, so that if f is a polynomial of degree 9 with Galois group M, every factorization mod p will be consistent with f having a factor of degree 3. A transitive permutation group G is cooperative if any polynomial whose degree is the degree of G and whose Galois group is G can be proved irreducible by the algorithm in [4]. Let G be a regular representation, so that G is a transitive group of permutations whose order is the same as its degree. The following theorem shows that if a normal f can be proved irreducible using the algorithm in [4], then its Galois group must have a special structure. THEOREM. If G is a regular permutation then G is metacyclic.
group and if G is cooperative,
(G is metacyclic if it has a normal cyclic subgroup H such that G/H cyclic.)
is also
186
P. J. WEINBERGER
Proof By a classical theorem of Burnside, if all the Sylow subgroups of G are cyclic, then G is metacyclic. The proof proceeds by showing that if a p-Sylow subgroup of G is not cyclic, then every permutation of G is consistent with f having a factor of degree n/p (n is the degree of G). Since G is regular, an element a of G of order j is the product of n/j j-cycles. Now j certainly divides n, and if j also divides n/p, the theorem is proved. But if j does not divide n/p, then the power of p dividing n, say pi, must also divide j. But then some power of a would have order pi, and so would generate a cyclic p-Sylow subgroup of G. This is impossible since all the Q.E.D. p-Sylow subgroups are conjugate. Nore added in proof. Several problems on polynomials are now known to have polynomial time solutions: factoring (A. K. Lenstra, H. W. Lenstra, and L. Lotasz, Math. Ann. 261 (1982), 514-534). and having a solvable Galois group (S. Landau and G. Miller, “Proceedings, 15th ACM Symposium on the Theory of Computing,” 1983). Another algorithm for testing irreducibility which depends on unproved hypotheses is that of L. M. Adleman and A. M. Odlyzko (Math. Comp. 41(1983), 699-709).
REFERENCES
1. E. BERLEKAMP, Factoring polynomials over large finite fields, Murh. Comp. 24 (1970), 713-735. 2. G. COOKE AND P. J. WEINBERGER, On the construction of division chains in algebraic number rings, with applications to SL,, Comm. Algebra 6 (3) (1975), 481-524. 3. P. X. GALLAGHER, Probabilistic Galois theory, in “Analytic Number Theory, Proceedings of the Symposium in Pure Mathematics,” pp. 91-102. Amer. Math. Sot. Providence, RI., (1972). 4. D. R. MUSSER,On the efficiency of a polynomial irreducibility test, J. Assoc. Compur. Mach. 25 (1978), 271-282. 5. P. J. WEINBERGER,On Euclidean rings of algebraic integers, in “Analytic Number Theory, Proceedings of the Symposium in Pure Mathematics,” pp. 321-332, Amer. Math. Sot., Providence, RI., (1972). 6. H. ZASSENHAUS,On Hensel factorization, I, J. Number of Theory 1 (1969), 291-311.