General definition
Let and be polynomials with coefficients in an integral domain , typically a field or the integers. A greatest common divisor of and is a polynomial that divides and , and such that every common divisor of and also divides . Every pair of polynomials (not both zero) has a GCD if and only if is a unique factorization domain. If is a field and and are not both zero, a polynomial is a greatest common divisor if and only if it divides both and , and it has the greatest degree among the polynomials having this property. If , the GCD is 0. However, some authors consider that it is not defined in this case. The greatest common divisor of and is usually denoted "". The greatest common divisor is not unique: if is a GCD of and , then the polynomial is another GCD if and only if there is an invertible element of such that : and :. In other words, the GCD is unique up to the multiplication by an invertible constant. In the case of the integers, this indetermination has been settled by choosing, as the GCD, the unique one which is positive (there is another one, which is its opposite). With this convention, the GCD of two integers is also the greatest (for the usual ordering) common divisor. However, since there is no natural total order for polynomials over an integral domain, one cannot proceed in the same way here. For univariate polynomials over a field, one can additionally require the GCD to be monic (that is to have 1 as its coefficient of the highest degree), but in more general cases there is no general convention. Therefore, equalities like or are common abuses of notation which should be read " is a GCD of and " and " and have the same set of GCDs as and ". In particular, means that the invertible constants are the only common divisors. In this case, by analogy with the integer case, one says that and are .Properties
*As stated above, the GCD of two polynomials exists if the coefficients belong either to a field, the ring of the integers, or more generally to a unique factorization domain. *If is any common divisor of and , then divides their GCD. * * for any polynomial . This property is at the basis of the proof of Euclidean algorithm. *For any invertible element of the ring of the coefficients, . *Hence for any scalars such that is invertible. *If , then . *If , then . *For two univariate polynomials and over a field, there exist polynomials and , such that and divides every such linear combination of and ( Bézout's identity). *The greatest common divisor of three or more polynomials may be defined similarly as for two polynomials. It may be computed recursively from GCD's of two polynomials by the identities: :: : and ::GCD by hand computation
There are several ways to find the greatest common divisor of two polynomials. Two of them are: #'' Factorization of polynomials'', in which one finds the factors of each expression, then selects the set of common factors held by all from within each set of factors. This method may be useful only in simple cases, as factoring is usually more difficult than computing the greatest common divisor. #The ''Factoring
To find the GCD of two polynomials using factoring, simply factor the two polynomials completely. Then, take the product of all common factors. At this stage, we do not necessarily have a monic polynomial, so finally multiply this by a constant to make it a monic polynomial. This will be the GCD of the two polynomials as it includes all common divisors and is monic. Example one: Find the GCD of and . : : Thus, their GCD is .Euclidean algorithm
Factoring polynomials can be difficult, especially if the polynomials have a large degree. TheUnivariate polynomials with coefficients in a field
The case of univariate polynomials over a field is especially important for several reasons. Firstly, it is the most elementary case and therefore appears in most first courses in algebra. Secondly, it is very similar to the case of the integers, and this analogy is the source of the notion ofEuclidean division
Euclidean division of polynomials, which is used in Euclid's algorithm for computing GCDs, is very similar to Euclidean division of integers. Its existence is based on the following theorem: Given two univariate polynomials ''a'' and ''b'' ≠ 0 defined over a field, there exist two polynomials ''q'' (the ''quotient'') and ''r'' (the ''remainder'') which satisfy : and : where "deg(...)" denotes the degree and the degree of the zero polynomial is defined as being negative. Moreover, ''q'' and ''r'' are uniquely defined by these relations. The difference from Euclidean division of the integers is that, for the integers, the degree is replaced by the absolute value, and that to have uniqueness one has to suppose that ''r'' is non-negative. The rings for which such a theorem exists are calledEuclid's algorithm
As for the integers, the Euclidean division allows us to define Euclid's algorithm for computing GCDs. Starting from two polynomials ''a'' and ''b'', Euclid's algorithm consists of recursively replacing the pair by (where "" denotes the remainder of the Euclidean division, computed by the algorithm of the preceding section), until ''b'' = 0. The GCD is the last non zero remainder. Euclid's algorithm may be formalized in the recursive programming style as: In the imperative programming style, the same algorithm becomes, giving a name to each intermediate remainder: The sequence of the degrees of the is strictly decreasing. Thus after, at most, steps, one get a null remainder, say . As and have the same divisors, the set of the common divisors is not changed by Euclid's algorithm and thus all pairs have the same set of common divisors. The common divisors of and are thus the common divisors of and 0. Thus is a GCD of and . This not only proves that Euclid's algorithm computes GCDs but also proves that GCDs exist.Bézout's identity and extended GCD algorithm
Bézout's identity is a GCD related theorem, initially proved for the integers, which is valid for everyArithmetic of algebraic extensions
An important application of the extended GCD algorithm is that it allows one to compute division in algebraic field extensions. Let an algebraic extension of a field , generated by an element whose minimal polynomial has degree . The elements of are usually represented by univariate polynomials over of degree less than . The addition in is simply the addition of polynomials: : The multiplication in is the multiplication of polynomials followed by the division by : : The inverse of a non zero element of is the coefficient in Bézout's identity , which may be computed by extended GCD algorithm. (the GCD is 1 because the minimal polynomial is irreducible). The degrees inequality in the specification of extended GCD algorithm shows that a further division by is not needed to get deg() < deg().Subresultants
In the case of univariate polynomials, there is a strong relationship between the greatest common divisors and resultants. More precisely, the resultant of two polynomials ''P'', ''Q'' is a polynomial function of the coefficients of ''P'' and ''Q'' which has the value zero if and only if the GCD of ''P'' and ''Q'' is not constant. The subresultants theory is a generalization of this property that allows characterizing generically the GCD of two polynomials, and the resultant is the 0-th subresultant polynomial. The ''i''-th ''subresultant polynomial'' ''Si''(''P'' ,''Q'') of two polynomials ''P'' and ''Q'' is a polynomial of degree at most ''i'' whose coefficients are polynomial functions of the coefficients of ''P'' and ''Q'', and the ''i''-th ''principal subresultant coefficient'' ''si''(''P'' ,''Q'') is the coefficient of degree ''i'' of ''Si''(''P'', ''Q''). They have the property that the GCD of ''P'' and ''Q'' has a degree ''d'' if and only if :. In this case, ''Sd''(''P'' ,''Q'') is a GCD of ''P'' and ''Q'' and : Every coefficient of the subresultant polynomials is defined as the determinant of a submatrix of the Sylvester matrix of ''P'' and ''Q''. This implies that subresultants "specialize" well. More precisely, subresultants are defined for polynomials over any commutative ring ''R'', and have the following property. Let ''φ'' be a ring homomorphism of ''R'' into another commutative ring ''S''. It extends to another homomorphism, denoted also ''φ'' between the polynomials rings over ''R'' and ''S''. Then, if ''P'' and ''Q'' are univariate polynomials with coefficients in ''R'' such that : and : then the subresultant polynomials and the principal subresultant coefficients of ''φ''(''P'') and ''φ''(''Q'') are the image by ''φ'' of those of ''P'' and ''Q''. The subresultants have two important properties which make them fundamental for the computation on computers of the GCD of two polynomials with integer coefficients. Firstly, their definition through determinants allows bounding, through Hadamard inequality, the size of the coefficients of the GCD. Secondly, this bound and the property of good specialization allow computing the GCD of two polynomials with integer coefficients through modular computation andTechnical definition
Let : be two univariate polynomials with coefficients in a field ''K''. Let us denote by the ''K'' vector space of dimension ''i'' of polynomials of degree less than ''i''. For non-negative integer ''i'' such that ''i'' ≤ ''m'' and ''i'' ≤ ''n'', let : be the linear map such that : The resultant of ''P'' and ''Q'' is the determinant of the Sylvester matrix, which is the (square) matrix of on the bases of the powers of ''X''. Similarly, the ''i''-subresultant polynomial is defined in term of determinants of submatrices of the matrix of Let us describe these matrices more precisely; Let ''p''''i'' = 0 for ''i'' < 0 or ''i'' > ''m'', and ''q''''i'' = 0 for ''i'' < 0 or ''i'' > ''n''. The Sylvester matrix is the (''m'' + ''n'') × (''m'' + ''n'')-matrix such that the coefficient of the ''i''-th row and the ''j''-th column is ''p''''m''+''j''−''i'' for ''j'' ≤ ''n'' and ''q''''j''−''i'' for ''j'' > ''n'': : The matrix ''Ti'' of is the (''m'' + ''n'' − ''i'') × (''m'' + ''n'' − 2''i'')-submatrix of ''S'' which is obtained by removing the last ''i'' rows of zeros in the submatrix of the columns 1 to ''n'' − ''i'' and ''n'' + 1 to ''m'' + ''n'' − ''i'' of ''S'' (that is removing ''i'' columns in each block and the ''i'' last rows of zeros). The ''principal subresultant coefficient'' ''si'' is the determinant of the ''m'' + ''n'' − 2''i'' first rows of ''Ti''. Let ''Vi'' be the (''m'' + ''n'' − 2''i'') × (''m'' + ''n'' − ''i'') matrix defined as follows. First we add (''i'' + 1) columns of zeros to the right of the (''m'' + ''n'' − 2''i'' − 1) × (''m'' + ''n'' − 2''i'' − 1)Sketch of the proof
It is not obvious that, as defined, the subresultants have the desired properties. Nevertheless, the proof is rather simple if the properties of linear algebra and those of polynomials are put together. As defined, the columns of the matrix ''Ti'' are the vectors of the coefficients of some polynomials belonging to the image of . The definition of the ''i''-th subresultant polynomial ''Si'' shows that the vector of its coefficients is a linear combination of these column vectors, and thus that ''Si'' belongs to the image of If the degree of the GCD is greater than ''i'', then Bézout's identity shows that every non zero polynomial in the image of has a degree larger than ''i''. This implies that ''Si''=0. If, on the other hand, the degree of the GCD is ''i'', then Bézout's identity again allows proving that the multiples of the GCD that have a degree lower than ''m'' + ''n'' − ''i'' are in the image of . The vector space of these multiples has the dimension ''m'' + ''n'' − 2''i'' and has a base of polynomials of pairwise different degrees, not smaller than ''i''. This implies that the submatrix of the ''m'' + ''n'' − 2''i'' first rows of the column echelon form of ''Ti'' is the identity matrix and thus that ''si'' is not 0. Thus ''Si'' is a polynomial in the image of , which is a multiple of the GCD and has the same degree. It is thus a greatest common divisor.GCD and root finding
Square-free factorization
Most root-finding algorithms behave badly with polynomials that haveSturm sequence
The ''Sturm sequence'' of a polynomial with real coefficients is the sequence of the remainders provided by a variant of Euclid's algorithm applied to the polynomial and its derivative. For getting the Sturm sequence, one simply replaces the instruction : of Euclid's algorithm by : Let ''V''(''a'') be the number of changes of signs in the sequence, when evaluated at a point ''a''. Sturm's theorem asserts that ''V''(''a'') − ''V''(''b'') is the number of real roots of the polynomial in the interval 'a'', ''b'' Thus the Sturm sequence allows computing the number of real roots in a given interval. By subdividing the interval until every subinterval contains at most one root, this provides an algorithm that locates the real roots in intervals of arbitrary small length.GCD over a ring and its field of fractions
In this section, we consider polynomials over a unique factorization domain ''R'', typically the ring of the integers, and over its field of fractions ''F'', typically the field of the rational numbers, and we denote ''R'' 'X''and ''F'' 'X''the rings of polynomials in a set of variables over these rings.Primitive part–content factorization
The ''content'' of a polynomial ''p'' ∈ ''R'' 'X'' denoted "cont(''p'')", is the GCD of its coefficients. A polynomial ''q'' ∈ ''F'' 'X''may be written : where ''p'' ∈ ''R'' 'X''and ''c'' ∈ ''R'': it suffices to take for ''c'' a multiple of all denominators of the coefficients of ''q'' (for example their product) and ''p'' = ''cq''. The ''content'' of ''q'' is defined as: : In both cases, the content is defined up to the multiplication by a unit of ''R''. The ''primitive part'' of a polynomial in ''R'' 'X''or ''F'' 'X''is defined by : In both cases, it is a polynomial in ''R'' 'X''that is ''primitive'', which means that 1 is a GCD of its coefficients. Thus every polynomial in ''R'' 'X''or ''F'' 'X''may be factorized as : and this factorization is unique up to the multiplication of the content by a unit of ''R'' and of the primitive part by the inverse of this unit. Gauss's lemma implies that the product of two primitive polynomials is primitive. It follows that : and :Relation between the GCD over ''R'' and over ''F''
The relations of the preceding section imply a strong relation between the GCD's in ''R'' 'X''and in ''F'' 'X'' To avoid ambiguities, the notation "''gcd''" will be indexed, in the following, by the ring in which the GCD is computed. If ''q''1 and ''q''2 belong to ''F'' 'X'' then : If ''p''1 and ''p''2 belong to ''R'' 'X'' then : and : Thus the computation of polynomial GCD's is essentially the same problem over ''F'' 'X''and over ''R'' 'X'' For univariate polynomials over the rational numbers, one may think that Euclid's algorithm is a convenient method for computing the GCD. However, it involves simplifying a large number of fractions of integers, and the resulting algorithm is not efficient. For this reason, methods have been designed to modify Euclid's algorithm for working only with polynomials over the integers. They consist of replacing the Euclidean division, which introduces fractions, by a so-called ''pseudo-division'', and replacing the remainder sequence of the Euclid's algorithm by so-called ''pseudo-remainder sequences'' (seeProof that GCD exists for multivariate polynomials
In the previous section we have seen that the GCD of polynomials in ''R'' 'X''may be deduced from GCDs in ''R'' and in ''F'' 'X'' A closer look on the proof shows that this allows us to prove the existence of GCDs in ''R'' 'X'' if they exist in ''R'' and in ''F'' 'X'' In particular, if GCDs exist in ''R'', and if ''X'' is reduced to one variable, this proves that GCDs exist in ''R'' 'X''(Euclid's algorithm proves the existence of GCDs in ''F'' 'X''. A polynomial in ''n'' variables may be considered as a univariate polynomial over the ring of polynomials in (''n'' − 1) variables. Thus a recursion on the number of variables shows that if GCDs exist and may be computed in ''R'', then they exist and may be computed in every multivariate polynomial ring over ''R''. In particular, if ''R'' is either the ring of the integers or a field, then GCDs exist in ''R'' 1,..., ''xn''">'x''1,..., ''xn'' and what precedes provides an algorithm to compute them. The proof that a polynomial ring over a unique factorization domain is also a unique factorization domain is similar, but it does not provide an algorithm, because there is no general algorithm to factor univariate polynomials over a field (there are examples of fields for which there does not exist any factorization algorithm for the univariate polynomials).Pseudo-remainder sequences
In this section, we consider an integral domain ''Z'' (typically the ring Z of the integers) and its field of fractions ''Q'' (typically the field Q of the rational numbers). Given two polynomials ''A'' and ''B'' in the univariate polynomial ring ''Z'' 'X'' the Euclidean division (over ''Q'') of ''A'' by ''B'' provides a quotient and a remainder which may not belong to ''Z'' 'X'' For, if one applies Euclid's algorithm to the following polynomials : and :